babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/webRequest" {
  410. /**
  411. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  412. */
  413. export class WebRequest {
  414. private _xhr;
  415. /**
  416. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  417. * i.e. when loading files, where the server/service expects an Authorization header
  418. */
  419. static CustomRequestHeaders: {
  420. [key: string]: string;
  421. };
  422. /**
  423. * Add callback functions in this array to update all the requests before they get sent to the network
  424. */
  425. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  426. private _injectCustomRequestHeaders;
  427. /**
  428. * Gets or sets a function to be called when loading progress changes
  429. */
  430. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  431. /**
  432. * Returns client's state
  433. */
  434. readonly readyState: number;
  435. /**
  436. * Returns client's status
  437. */
  438. readonly status: number;
  439. /**
  440. * Returns client's status as a text
  441. */
  442. readonly statusText: string;
  443. /**
  444. * Returns client's response
  445. */
  446. readonly response: any;
  447. /**
  448. * Returns client's response url
  449. */
  450. readonly responseURL: string;
  451. /**
  452. * Returns client's response as text
  453. */
  454. readonly responseText: string;
  455. /**
  456. * Gets or sets the expected response type
  457. */
  458. responseType: XMLHttpRequestResponseType;
  459. /** @hidden */
  460. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  461. /** @hidden */
  462. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  463. /**
  464. * Cancels any network activity
  465. */
  466. abort(): void;
  467. /**
  468. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  469. * @param body defines an optional request body
  470. */
  471. send(body?: Document | BodyInit | null): void;
  472. /**
  473. * Sets the request method, request URL
  474. * @param method defines the method to use (GET, POST, etc..)
  475. * @param url defines the url to connect with
  476. */
  477. open(method: string, url: string): void;
  478. }
  479. }
  480. declare module "babylonjs/Misc/fileRequest" {
  481. import { Observable } from "babylonjs/Misc/observable";
  482. /**
  483. * File request interface
  484. */
  485. export interface IFileRequest {
  486. /**
  487. * Raised when the request is complete (success or error).
  488. */
  489. onCompleteObservable: Observable<IFileRequest>;
  490. /**
  491. * Aborts the request for a file.
  492. */
  493. abort: () => void;
  494. }
  495. }
  496. declare module "babylonjs/Maths/math.scalar" {
  497. /**
  498. * Scalar computation library
  499. */
  500. export class Scalar {
  501. /**
  502. * Two pi constants convenient for computation.
  503. */
  504. static TwoPi: number;
  505. /**
  506. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  507. * @param a number
  508. * @param b number
  509. * @param epsilon (default = 1.401298E-45)
  510. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  511. */
  512. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  513. /**
  514. * Returns a string : the upper case translation of the number i to hexadecimal.
  515. * @param i number
  516. * @returns the upper case translation of the number i to hexadecimal.
  517. */
  518. static ToHex(i: number): string;
  519. /**
  520. * Returns -1 if value is negative and +1 is value is positive.
  521. * @param value the value
  522. * @returns the value itself if it's equal to zero.
  523. */
  524. static Sign(value: number): number;
  525. /**
  526. * Returns the value itself if it's between min and max.
  527. * Returns min if the value is lower than min.
  528. * Returns max if the value is greater than max.
  529. * @param value the value to clmap
  530. * @param min the min value to clamp to (default: 0)
  531. * @param max the max value to clamp to (default: 1)
  532. * @returns the clamped value
  533. */
  534. static Clamp(value: number, min?: number, max?: number): number;
  535. /**
  536. * the log2 of value.
  537. * @param value the value to compute log2 of
  538. * @returns the log2 of value.
  539. */
  540. static Log2(value: number): number;
  541. /**
  542. * Loops the value, so that it is never larger than length and never smaller than 0.
  543. *
  544. * This is similar to the modulo operator but it works with floating point numbers.
  545. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  546. * With t = 5 and length = 2.5, the result would be 0.0.
  547. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  548. * @param value the value
  549. * @param length the length
  550. * @returns the looped value
  551. */
  552. static Repeat(value: number, length: number): number;
  553. /**
  554. * Normalize the value between 0.0 and 1.0 using min and max values
  555. * @param value value to normalize
  556. * @param min max to normalize between
  557. * @param max min to normalize between
  558. * @returns the normalized value
  559. */
  560. static Normalize(value: number, min: number, max: number): number;
  561. /**
  562. * Denormalize the value from 0.0 and 1.0 using min and max values
  563. * @param normalized value to denormalize
  564. * @param min max to denormalize between
  565. * @param max min to denormalize between
  566. * @returns the denormalized value
  567. */
  568. static Denormalize(normalized: number, min: number, max: number): number;
  569. /**
  570. * Calculates the shortest difference between two given angles given in degrees.
  571. * @param current current angle in degrees
  572. * @param target target angle in degrees
  573. * @returns the delta
  574. */
  575. static DeltaAngle(current: number, target: number): number;
  576. /**
  577. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  578. * @param tx value
  579. * @param length length
  580. * @returns The returned value will move back and forth between 0 and length
  581. */
  582. static PingPong(tx: number, length: number): number;
  583. /**
  584. * Interpolates between min and max with smoothing at the limits.
  585. *
  586. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  587. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  588. * @param from from
  589. * @param to to
  590. * @param tx value
  591. * @returns the smooth stepped value
  592. */
  593. static SmoothStep(from: number, to: number, tx: number): number;
  594. /**
  595. * Moves a value current towards target.
  596. *
  597. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  598. * Negative values of maxDelta pushes the value away from target.
  599. * @param current current value
  600. * @param target target value
  601. * @param maxDelta max distance to move
  602. * @returns resulting value
  603. */
  604. static MoveTowards(current: number, target: number, maxDelta: number): number;
  605. /**
  606. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  607. *
  608. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  609. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  610. * @param current current value
  611. * @param target target value
  612. * @param maxDelta max distance to move
  613. * @returns resulting angle
  614. */
  615. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  616. /**
  617. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  618. * @param start start value
  619. * @param end target value
  620. * @param amount amount to lerp between
  621. * @returns the lerped value
  622. */
  623. static Lerp(start: number, end: number, amount: number): number;
  624. /**
  625. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  626. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  627. * @param start start value
  628. * @param end target value
  629. * @param amount amount to lerp between
  630. * @returns the lerped value
  631. */
  632. static LerpAngle(start: number, end: number, amount: number): number;
  633. /**
  634. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  635. * @param a start value
  636. * @param b target value
  637. * @param value value between a and b
  638. * @returns the inverseLerp value
  639. */
  640. static InverseLerp(a: number, b: number, value: number): number;
  641. /**
  642. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  643. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  644. * @param value1 spline value
  645. * @param tangent1 spline value
  646. * @param value2 spline value
  647. * @param tangent2 spline value
  648. * @param amount input value
  649. * @returns hermite result
  650. */
  651. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  652. /**
  653. * Returns a random float number between and min and max values
  654. * @param min min value of random
  655. * @param max max value of random
  656. * @returns random value
  657. */
  658. static RandomRange(min: number, max: number): number;
  659. /**
  660. * This function returns percentage of a number in a given range.
  661. *
  662. * RangeToPercent(40,20,60) will return 0.5 (50%)
  663. * RangeToPercent(34,0,100) will return 0.34 (34%)
  664. * @param number to convert to percentage
  665. * @param min min range
  666. * @param max max range
  667. * @returns the percentage
  668. */
  669. static RangeToPercent(number: number, min: number, max: number): number;
  670. /**
  671. * This function returns number that corresponds to the percentage in a given range.
  672. *
  673. * PercentToRange(0.34,0,100) will return 34.
  674. * @param percent to convert to number
  675. * @param min min range
  676. * @param max max range
  677. * @returns the number
  678. */
  679. static PercentToRange(percent: number, min: number, max: number): number;
  680. /**
  681. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  682. * @param angle The angle to normalize in radian.
  683. * @return The converted angle.
  684. */
  685. static NormalizeRadians(angle: number): number;
  686. }
  687. }
  688. declare module "babylonjs/Maths/math.constants" {
  689. /**
  690. * Constant used to convert a value to gamma space
  691. * @ignorenaming
  692. */
  693. export const ToGammaSpace: number;
  694. /**
  695. * Constant used to convert a value to linear space
  696. * @ignorenaming
  697. */
  698. export const ToLinearSpace = 2.2;
  699. /**
  700. * Constant used to define the minimal number value in Babylon.js
  701. * @ignorenaming
  702. */
  703. let Epsilon: number;
  704. export { Epsilon };
  705. }
  706. declare module "babylonjs/Maths/math.viewport" {
  707. /**
  708. * Class used to represent a viewport on screen
  709. */
  710. export class Viewport {
  711. /** viewport left coordinate */
  712. x: number;
  713. /** viewport top coordinate */
  714. y: number;
  715. /**viewport width */
  716. width: number;
  717. /** viewport height */
  718. height: number;
  719. /**
  720. * Creates a Viewport object located at (x, y) and sized (width, height)
  721. * @param x defines viewport left coordinate
  722. * @param y defines viewport top coordinate
  723. * @param width defines the viewport width
  724. * @param height defines the viewport height
  725. */
  726. constructor(
  727. /** viewport left coordinate */
  728. x: number,
  729. /** viewport top coordinate */
  730. y: number,
  731. /**viewport width */
  732. width: number,
  733. /** viewport height */
  734. height: number);
  735. /**
  736. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  737. * @param renderWidth defines the rendering width
  738. * @param renderHeight defines the rendering height
  739. * @returns a new Viewport
  740. */
  741. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  742. /**
  743. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  744. * @param renderWidth defines the rendering width
  745. * @param renderHeight defines the rendering height
  746. * @param ref defines the target viewport
  747. * @returns the current viewport
  748. */
  749. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  750. /**
  751. * Returns a new Viewport copied from the current one
  752. * @returns a new Viewport
  753. */
  754. clone(): Viewport;
  755. }
  756. }
  757. declare module "babylonjs/Misc/arrayTools" {
  758. /**
  759. * Class containing a set of static utilities functions for arrays.
  760. */
  761. export class ArrayTools {
  762. /**
  763. * Returns an array of the given size filled with element built from the given constructor and the paramters
  764. * @param size the number of element to construct and put in the array
  765. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  766. * @returns a new array filled with new objects
  767. */
  768. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  769. }
  770. }
  771. declare module "babylonjs/Maths/math.like" {
  772. import { float, int, DeepImmutable } from "babylonjs/types";
  773. /**
  774. * @hidden
  775. */
  776. export interface IColor4Like {
  777. r: float;
  778. g: float;
  779. b: float;
  780. a: float;
  781. }
  782. /**
  783. * @hidden
  784. */
  785. export interface IColor3Like {
  786. r: float;
  787. g: float;
  788. b: float;
  789. }
  790. /**
  791. * @hidden
  792. */
  793. export interface IVector4Like {
  794. x: float;
  795. y: float;
  796. z: float;
  797. w: float;
  798. }
  799. /**
  800. * @hidden
  801. */
  802. export interface IVector3Like {
  803. x: float;
  804. y: float;
  805. z: float;
  806. }
  807. /**
  808. * @hidden
  809. */
  810. export interface IVector2Like {
  811. x: float;
  812. y: float;
  813. }
  814. /**
  815. * @hidden
  816. */
  817. export interface IMatrixLike {
  818. toArray(): DeepImmutable<Float32Array>;
  819. updateFlag: int;
  820. }
  821. /**
  822. * @hidden
  823. */
  824. export interface IViewportLike {
  825. x: float;
  826. y: float;
  827. width: float;
  828. height: float;
  829. }
  830. /**
  831. * @hidden
  832. */
  833. export interface IPlaneLike {
  834. normal: IVector3Like;
  835. d: float;
  836. normalize(): void;
  837. }
  838. }
  839. declare module "babylonjs/Maths/math.vector" {
  840. import { Viewport } from "babylonjs/Maths/math.viewport";
  841. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  842. import { IPlaneLike } from "babylonjs/Maths/math.like";
  843. /**
  844. * Class representing a vector containing 2 coordinates
  845. */
  846. export class Vector2 {
  847. /** defines the first coordinate */
  848. x: number;
  849. /** defines the second coordinate */
  850. y: number;
  851. /**
  852. * Creates a new Vector2 from the given x and y coordinates
  853. * @param x defines the first coordinate
  854. * @param y defines the second coordinate
  855. */
  856. constructor(
  857. /** defines the first coordinate */
  858. x?: number,
  859. /** defines the second coordinate */
  860. y?: number);
  861. /**
  862. * Gets a string with the Vector2 coordinates
  863. * @returns a string with the Vector2 coordinates
  864. */
  865. toString(): string;
  866. /**
  867. * Gets class name
  868. * @returns the string "Vector2"
  869. */
  870. getClassName(): string;
  871. /**
  872. * Gets current vector hash code
  873. * @returns the Vector2 hash code as a number
  874. */
  875. getHashCode(): number;
  876. /**
  877. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  878. * @param array defines the source array
  879. * @param index defines the offset in source array
  880. * @returns the current Vector2
  881. */
  882. toArray(array: FloatArray, index?: number): Vector2;
  883. /**
  884. * Copy the current vector to an array
  885. * @returns a new array with 2 elements: the Vector2 coordinates.
  886. */
  887. asArray(): number[];
  888. /**
  889. * Sets the Vector2 coordinates with the given Vector2 coordinates
  890. * @param source defines the source Vector2
  891. * @returns the current updated Vector2
  892. */
  893. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  894. /**
  895. * Sets the Vector2 coordinates with the given floats
  896. * @param x defines the first coordinate
  897. * @param y defines the second coordinate
  898. * @returns the current updated Vector2
  899. */
  900. copyFromFloats(x: number, y: number): Vector2;
  901. /**
  902. * Sets the Vector2 coordinates with the given floats
  903. * @param x defines the first coordinate
  904. * @param y defines the second coordinate
  905. * @returns the current updated Vector2
  906. */
  907. set(x: number, y: number): Vector2;
  908. /**
  909. * Add another vector with the current one
  910. * @param otherVector defines the other vector
  911. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  912. */
  913. add(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  916. * @param otherVector defines the other vector
  917. * @param result defines the target vector
  918. * @returns the unmodified current Vector2
  919. */
  920. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  921. /**
  922. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  923. * @param otherVector defines the other vector
  924. * @returns the current updated Vector2
  925. */
  926. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  927. /**
  928. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  929. * @param otherVector defines the other vector
  930. * @returns a new Vector2
  931. */
  932. addVector3(otherVector: Vector3): Vector2;
  933. /**
  934. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  935. * @param otherVector defines the other vector
  936. * @returns a new Vector2
  937. */
  938. subtract(otherVector: Vector2): Vector2;
  939. /**
  940. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  941. * @param otherVector defines the other vector
  942. * @param result defines the target vector
  943. * @returns the unmodified current Vector2
  944. */
  945. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  946. /**
  947. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  948. * @param otherVector defines the other vector
  949. * @returns the current updated Vector2
  950. */
  951. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  952. /**
  953. * Multiplies in place the current Vector2 coordinates by the given ones
  954. * @param otherVector defines the other vector
  955. * @returns the current updated Vector2
  956. */
  957. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  958. /**
  959. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  960. * @param otherVector defines the other vector
  961. * @returns a new Vector2
  962. */
  963. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  964. /**
  965. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  966. * @param otherVector defines the other vector
  967. * @param result defines the target vector
  968. * @returns the unmodified current Vector2
  969. */
  970. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  971. /**
  972. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  973. * @param x defines the first coordinate
  974. * @param y defines the second coordinate
  975. * @returns a new Vector2
  976. */
  977. multiplyByFloats(x: number, y: number): Vector2;
  978. /**
  979. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  980. * @param otherVector defines the other vector
  981. * @returns a new Vector2
  982. */
  983. divide(otherVector: Vector2): Vector2;
  984. /**
  985. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  986. * @param otherVector defines the other vector
  987. * @param result defines the target vector
  988. * @returns the unmodified current Vector2
  989. */
  990. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  991. /**
  992. * Divides the current Vector2 coordinates by the given ones
  993. * @param otherVector defines the other vector
  994. * @returns the current updated Vector2
  995. */
  996. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  997. /**
  998. * Gets a new Vector2 with current Vector2 negated coordinates
  999. * @returns a new Vector2
  1000. */
  1001. negate(): Vector2;
  1002. /**
  1003. * Multiply the Vector2 coordinates by scale
  1004. * @param scale defines the scaling factor
  1005. * @returns the current updated Vector2
  1006. */
  1007. scaleInPlace(scale: number): Vector2;
  1008. /**
  1009. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1010. * @param scale defines the scaling factor
  1011. * @returns a new Vector2
  1012. */
  1013. scale(scale: number): Vector2;
  1014. /**
  1015. * Scale the current Vector2 values by a factor to a given Vector2
  1016. * @param scale defines the scale factor
  1017. * @param result defines the Vector2 object where to store the result
  1018. * @returns the unmodified current Vector2
  1019. */
  1020. scaleToRef(scale: number, result: Vector2): Vector2;
  1021. /**
  1022. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1023. * @param scale defines the scale factor
  1024. * @param result defines the Vector2 object where to store the result
  1025. * @returns the unmodified current Vector2
  1026. */
  1027. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1028. /**
  1029. * Gets a boolean if two vectors are equals
  1030. * @param otherVector defines the other vector
  1031. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1032. */
  1033. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1034. /**
  1035. * Gets a boolean if two vectors are equals (using an epsilon value)
  1036. * @param otherVector defines the other vector
  1037. * @param epsilon defines the minimal distance to consider equality
  1038. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1039. */
  1040. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1041. /**
  1042. * Gets a new Vector2 from current Vector2 floored values
  1043. * @returns a new Vector2
  1044. */
  1045. floor(): Vector2;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. fract(): Vector2;
  1051. /**
  1052. * Gets the length of the vector
  1053. * @returns the vector length (float)
  1054. */
  1055. length(): number;
  1056. /**
  1057. * Gets the vector squared length
  1058. * @returns the vector squared length (float)
  1059. */
  1060. lengthSquared(): number;
  1061. /**
  1062. * Normalize the vector
  1063. * @returns the current updated Vector2
  1064. */
  1065. normalize(): Vector2;
  1066. /**
  1067. * Gets a new Vector2 copied from the Vector2
  1068. * @returns a new Vector2
  1069. */
  1070. clone(): Vector2;
  1071. /**
  1072. * Gets a new Vector2(0, 0)
  1073. * @returns a new Vector2
  1074. */
  1075. static Zero(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(1, 1)
  1078. * @returns a new Vector2
  1079. */
  1080. static One(): Vector2;
  1081. /**
  1082. * Gets a new Vector2 set from the given index element of the given array
  1083. * @param array defines the data source
  1084. * @param offset defines the offset in the data source
  1085. * @returns a new Vector2
  1086. */
  1087. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1088. /**
  1089. * Sets "result" from the given index element of the given array
  1090. * @param array defines the data source
  1091. * @param offset defines the offset in the data source
  1092. * @param result defines the target vector
  1093. */
  1094. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1095. /**
  1096. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1097. * @param value1 defines 1st point of control
  1098. * @param value2 defines 2nd point of control
  1099. * @param value3 defines 3rd point of control
  1100. * @param value4 defines 4th point of control
  1101. * @param amount defines the interpolation factor
  1102. * @returns a new Vector2
  1103. */
  1104. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1105. /**
  1106. * 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".
  1107. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1108. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1109. * @param value defines the value to clamp
  1110. * @param min defines the lower limit
  1111. * @param max defines the upper limit
  1112. * @returns a new Vector2
  1113. */
  1114. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1115. /**
  1116. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1117. * @param value1 defines the 1st control point
  1118. * @param tangent1 defines the outgoing tangent
  1119. * @param value2 defines the 2nd control point
  1120. * @param tangent2 defines the incoming tangent
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1127. * @param start defines the start vector
  1128. * @param end defines the end vector
  1129. * @param amount defines the interpolation factor
  1130. * @returns a new Vector2
  1131. */
  1132. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1133. /**
  1134. * Gets the dot product of the vector "left" and the vector "right"
  1135. * @param left defines first vector
  1136. * @param right defines second vector
  1137. * @returns the dot product (float)
  1138. */
  1139. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1140. /**
  1141. * Returns a new Vector2 equal to the normalized given vector
  1142. * @param vector defines the vector to normalize
  1143. * @returns a new Vector2
  1144. */
  1145. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1146. /**
  1147. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1148. * @param left defines 1st vector
  1149. * @param right defines 2nd vector
  1150. * @returns a new Vector2
  1151. */
  1152. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1153. /**
  1154. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1155. * @param left defines 1st vector
  1156. * @param right defines 2nd vector
  1157. * @returns a new Vector2
  1158. */
  1159. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1160. /**
  1161. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1162. * @param vector defines the vector to transform
  1163. * @param transformation defines the matrix to apply
  1164. * @returns a new Vector2
  1165. */
  1166. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1167. /**
  1168. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1169. * @param vector defines the vector to transform
  1170. * @param transformation defines the matrix to apply
  1171. * @param result defines the target vector
  1172. */
  1173. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1174. /**
  1175. * Determines if a given vector is included in a triangle
  1176. * @param p defines the vector to test
  1177. * @param p0 defines 1st triangle point
  1178. * @param p1 defines 2nd triangle point
  1179. * @param p2 defines 3rd triangle point
  1180. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1181. */
  1182. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1183. /**
  1184. * Gets the distance between the vectors "value1" and "value2"
  1185. * @param value1 defines first vector
  1186. * @param value2 defines second vector
  1187. * @returns the distance between vectors
  1188. */
  1189. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1190. /**
  1191. * Returns the squared distance between the vectors "value1" and "value2"
  1192. * @param value1 defines first vector
  1193. * @param value2 defines second vector
  1194. * @returns the squared distance between vectors
  1195. */
  1196. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1197. /**
  1198. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1199. * @param value1 defines first vector
  1200. * @param value2 defines second vector
  1201. * @returns a new Vector2
  1202. */
  1203. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1204. /**
  1205. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1206. * @param p defines the middle point
  1207. * @param segA defines one point of the segment
  1208. * @param segB defines the other point of the segment
  1209. * @returns the shortest distance
  1210. */
  1211. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1212. }
  1213. /**
  1214. * Classed used to store (x,y,z) vector representation
  1215. * A Vector3 is the main object used in 3D geometry
  1216. * It can represent etiher the coordinates of a point the space, either a direction
  1217. * Reminder: js uses a left handed forward facing system
  1218. */
  1219. export class Vector3 {
  1220. /**
  1221. * Defines the first coordinates (on X axis)
  1222. */
  1223. x: number;
  1224. /**
  1225. * Defines the second coordinates (on Y axis)
  1226. */
  1227. y: number;
  1228. /**
  1229. * Defines the third coordinates (on Z axis)
  1230. */
  1231. z: number;
  1232. private static _UpReadOnly;
  1233. private static _ZeroReadOnly;
  1234. /**
  1235. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1236. * @param x defines the first coordinates (on X axis)
  1237. * @param y defines the second coordinates (on Y axis)
  1238. * @param z defines the third coordinates (on Z axis)
  1239. */
  1240. constructor(
  1241. /**
  1242. * Defines the first coordinates (on X axis)
  1243. */
  1244. x?: number,
  1245. /**
  1246. * Defines the second coordinates (on Y axis)
  1247. */
  1248. y?: number,
  1249. /**
  1250. * Defines the third coordinates (on Z axis)
  1251. */
  1252. z?: number);
  1253. /**
  1254. * Creates a string representation of the Vector3
  1255. * @returns a string with the Vector3 coordinates.
  1256. */
  1257. toString(): string;
  1258. /**
  1259. * Gets the class name
  1260. * @returns the string "Vector3"
  1261. */
  1262. getClassName(): string;
  1263. /**
  1264. * Creates the Vector3 hash code
  1265. * @returns a number which tends to be unique between Vector3 instances
  1266. */
  1267. getHashCode(): number;
  1268. /**
  1269. * Creates an array containing three elements : the coordinates of the Vector3
  1270. * @returns a new array of numbers
  1271. */
  1272. asArray(): number[];
  1273. /**
  1274. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1275. * @param array defines the destination array
  1276. * @param index defines the offset in the destination array
  1277. * @returns the current Vector3
  1278. */
  1279. toArray(array: FloatArray, index?: number): Vector3;
  1280. /**
  1281. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1282. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1283. */
  1284. toQuaternion(): Quaternion;
  1285. /**
  1286. * Adds the given vector to the current Vector3
  1287. * @param otherVector defines the second operand
  1288. * @returns the current updated Vector3
  1289. */
  1290. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the given coordinates to the current Vector3
  1293. * @param x defines the x coordinate of the operand
  1294. * @param y defines the y coordinate of the operand
  1295. * @param z defines the z coordinate of the operand
  1296. * @returns the current updated Vector3
  1297. */
  1298. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1299. /**
  1300. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1301. * @param otherVector defines the second operand
  1302. * @returns the resulting Vector3
  1303. */
  1304. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1305. /**
  1306. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1307. * @param otherVector defines the second operand
  1308. * @param result defines the Vector3 object where to store the result
  1309. * @returns the current Vector3
  1310. */
  1311. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1312. /**
  1313. * Subtract the given vector from the current Vector3
  1314. * @param otherVector defines the second operand
  1315. * @returns the current updated Vector3
  1316. */
  1317. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1318. /**
  1319. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1320. * @param otherVector defines the second operand
  1321. * @returns the resulting Vector3
  1322. */
  1323. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1324. /**
  1325. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1326. * @param otherVector defines the second operand
  1327. * @param result defines the Vector3 object where to store the result
  1328. * @returns the current Vector3
  1329. */
  1330. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1331. /**
  1332. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1333. * @param x defines the x coordinate of the operand
  1334. * @param y defines the y coordinate of the operand
  1335. * @param z defines the z coordinate of the operand
  1336. * @returns the resulting Vector3
  1337. */
  1338. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1339. /**
  1340. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1341. * @param x defines the x coordinate of the operand
  1342. * @param y defines the y coordinate of the operand
  1343. * @param z defines the z coordinate of the operand
  1344. * @param result defines the Vector3 object where to store the result
  1345. * @returns the current Vector3
  1346. */
  1347. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1348. /**
  1349. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1350. * @returns a new Vector3
  1351. */
  1352. negate(): Vector3;
  1353. /**
  1354. * Multiplies the Vector3 coordinates by the float "scale"
  1355. * @param scale defines the multiplier factor
  1356. * @returns the current updated Vector3
  1357. */
  1358. scaleInPlace(scale: number): Vector3;
  1359. /**
  1360. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1361. * @param scale defines the multiplier factor
  1362. * @returns a new Vector3
  1363. */
  1364. scale(scale: number): Vector3;
  1365. /**
  1366. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1367. * @param scale defines the multiplier factor
  1368. * @param result defines the Vector3 object where to store the result
  1369. * @returns the current Vector3
  1370. */
  1371. scaleToRef(scale: number, result: Vector3): Vector3;
  1372. /**
  1373. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1374. * @param scale defines the scale factor
  1375. * @param result defines the Vector3 object where to store the result
  1376. * @returns the unmodified current Vector3
  1377. */
  1378. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1379. /**
  1380. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1381. * @param otherVector defines the second operand
  1382. * @returns true if both vectors are equals
  1383. */
  1384. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1385. /**
  1386. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1387. * @param otherVector defines the second operand
  1388. * @param epsilon defines the minimal distance to define values as equals
  1389. * @returns true if both vectors are distant less than epsilon
  1390. */
  1391. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1392. /**
  1393. * Returns true if the current Vector3 coordinates equals the given floats
  1394. * @param x defines the x coordinate of the operand
  1395. * @param y defines the y coordinate of the operand
  1396. * @param z defines the z coordinate of the operand
  1397. * @returns true if both vectors are equals
  1398. */
  1399. equalsToFloats(x: number, y: number, z: number): boolean;
  1400. /**
  1401. * Multiplies the current Vector3 coordinates by the given ones
  1402. * @param otherVector defines the second operand
  1403. * @returns the current updated Vector3
  1404. */
  1405. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1406. /**
  1407. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1408. * @param otherVector defines the second operand
  1409. * @returns the new Vector3
  1410. */
  1411. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1412. /**
  1413. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1414. * @param otherVector defines the second operand
  1415. * @param result defines the Vector3 object where to store the result
  1416. * @returns the current Vector3
  1417. */
  1418. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1419. /**
  1420. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1421. * @param x defines the x coordinate of the operand
  1422. * @param y defines the y coordinate of the operand
  1423. * @param z defines the z coordinate of the operand
  1424. * @returns the new Vector3
  1425. */
  1426. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1427. /**
  1428. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1429. * @param otherVector defines the second operand
  1430. * @returns the new Vector3
  1431. */
  1432. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1433. /**
  1434. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1435. * @param otherVector defines the second operand
  1436. * @param result defines the Vector3 object where to store the result
  1437. * @returns the current Vector3
  1438. */
  1439. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1440. /**
  1441. * Divides the current Vector3 coordinates by the given ones.
  1442. * @param otherVector defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. divideInPlace(otherVector: Vector3): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1448. * @param other defines the second operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1454. * @param other defines the second operand
  1455. * @returns the current updated Vector3
  1456. */
  1457. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1458. /**
  1459. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1460. * @param x defines the x coordinate of the operand
  1461. * @param y defines the y coordinate of the operand
  1462. * @param z defines the z coordinate of the operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1466. /**
  1467. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1468. * @param x defines the x coordinate of the operand
  1469. * @param y defines the y coordinate of the operand
  1470. * @param z defines the z coordinate of the operand
  1471. * @returns the current updated Vector3
  1472. */
  1473. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1474. /**
  1475. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1476. * Check if is non uniform within a certain amount of decimal places to account for this
  1477. * @param epsilon the amount the values can differ
  1478. * @returns if the the vector is non uniform to a certain number of decimal places
  1479. */
  1480. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1481. /**
  1482. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1483. */
  1484. readonly isNonUniform: boolean;
  1485. /**
  1486. * Gets a new Vector3 from current Vector3 floored values
  1487. * @returns a new Vector3
  1488. */
  1489. floor(): Vector3;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. fract(): Vector3;
  1495. /**
  1496. * Gets the length of the Vector3
  1497. * @returns the length of the Vector3
  1498. */
  1499. length(): number;
  1500. /**
  1501. * Gets the squared length of the Vector3
  1502. * @returns squared length of the Vector3
  1503. */
  1504. lengthSquared(): number;
  1505. /**
  1506. * Normalize the current Vector3.
  1507. * Please note that this is an in place operation.
  1508. * @returns the current updated Vector3
  1509. */
  1510. normalize(): Vector3;
  1511. /**
  1512. * Reorders the x y z properties of the vector in place
  1513. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1514. * @returns the current updated vector
  1515. */
  1516. reorderInPlace(order: string): this;
  1517. /**
  1518. * Rotates the vector around 0,0,0 by a quaternion
  1519. * @param quaternion the rotation quaternion
  1520. * @param result vector to store the result
  1521. * @returns the resulting vector
  1522. */
  1523. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1524. /**
  1525. * Rotates a vector around a given point
  1526. * @param quaternion the rotation quaternion
  1527. * @param point the point to rotate around
  1528. * @param result vector to store the result
  1529. * @returns the resulting vector
  1530. */
  1531. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1532. /**
  1533. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1534. * The cross product is then orthogonal to both current and "other"
  1535. * @param other defines the right operand
  1536. * @returns the cross product
  1537. */
  1538. cross(other: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Checks if a given vector is inside a specific range
  1777. * @param v defines the vector to test
  1778. * @param min defines the minimum range
  1779. * @param max defines the maximum range
  1780. */
  1781. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1782. /**
  1783. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1784. * @param value1 defines the first control point
  1785. * @param tangent1 defines the first tangent vector
  1786. * @param value2 defines the second control point
  1787. * @param tangent2 defines the second tangent vector
  1788. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1789. * @returns the new Vector3
  1790. */
  1791. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1792. /**
  1793. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1794. * @param start defines the start value
  1795. * @param end defines the end value
  1796. * @param amount max defines amount between both (between 0 and 1)
  1797. * @returns the new Vector3
  1798. */
  1799. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1800. /**
  1801. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1802. * @param start defines the start value
  1803. * @param end defines the end value
  1804. * @param amount max defines amount between both (between 0 and 1)
  1805. * @param result defines the Vector3 where to store the result
  1806. */
  1807. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1808. /**
  1809. * Returns the dot product (float) between the vectors "left" and "right"
  1810. * @param left defines the left operand
  1811. * @param right defines the right operand
  1812. * @returns the dot product
  1813. */
  1814. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1815. /**
  1816. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1817. * The cross product is then orthogonal to both "left" and "right"
  1818. * @param left defines the left operand
  1819. * @param right defines the right operand
  1820. * @returns the cross product
  1821. */
  1822. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1823. /**
  1824. * Sets the given vector "result" with the cross product of "left" and "right"
  1825. * The cross product is then orthogonal to both "left" and "right"
  1826. * @param left defines the left operand
  1827. * @param right defines the right operand
  1828. * @param result defines the Vector3 where to store the result
  1829. */
  1830. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1831. /**
  1832. * Returns a new Vector3 as the normalization of the given vector
  1833. * @param vector defines the Vector3 to normalize
  1834. * @returns the new Vector3
  1835. */
  1836. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1837. /**
  1838. * Sets the given vector "result" with the normalization of the given first vector
  1839. * @param vector defines the Vector3 to normalize
  1840. * @param result defines the Vector3 where to store the result
  1841. */
  1842. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1843. /**
  1844. * Project a Vector3 onto screen space
  1845. * @param vector defines the Vector3 to project
  1846. * @param world defines the world matrix to use
  1847. * @param transform defines the transform (view x projection) matrix to use
  1848. * @param viewport defines the screen viewport to use
  1849. * @returns the new Vector3
  1850. */
  1851. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1852. /** @hidden */
  1853. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param transform defines the transform (view x projection) matrix to use
  1861. * @returns the new Vector3
  1862. */
  1863. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1864. /**
  1865. * Unproject from screen space to object space
  1866. * @param source defines the screen space Vector3 to use
  1867. * @param viewportWidth defines the current width of the viewport
  1868. * @param viewportHeight defines the current height of the viewport
  1869. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1870. * @param view defines the view matrix to use
  1871. * @param projection defines the projection matrix to use
  1872. * @returns the new Vector3
  1873. */
  1874. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1875. /**
  1876. * Unproject from screen space to object space
  1877. * @param source defines the screen space Vector3 to use
  1878. * @param viewportWidth defines the current width of the viewport
  1879. * @param viewportHeight defines the current height of the viewport
  1880. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1881. * @param view defines the view matrix to use
  1882. * @param projection defines the projection matrix to use
  1883. * @param result defines the Vector3 where to store the result
  1884. */
  1885. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1886. /**
  1887. * Unproject from screen space to object space
  1888. * @param sourceX defines the screen space x coordinate to use
  1889. * @param sourceY defines the screen space y coordinate to use
  1890. * @param sourceZ defines the screen space z coordinate to use
  1891. * @param viewportWidth defines the current width of the viewport
  1892. * @param viewportHeight defines the current height of the viewport
  1893. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1894. * @param view defines the view matrix to use
  1895. * @param projection defines the projection matrix to use
  1896. * @param result defines the Vector3 where to store the result
  1897. */
  1898. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1899. /**
  1900. * Gets the minimal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Gets the maximal coordinate values between two Vector3
  1908. * @param left defines the first operand
  1909. * @param right defines the second operand
  1910. * @returns the new Vector3
  1911. */
  1912. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * Returns the distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the distance
  1918. */
  1919. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns the squared distance between the vectors "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the squared distance
  1925. */
  1926. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1927. /**
  1928. * Returns a new Vector3 located at the center between "value1" and "value2"
  1929. * @param value1 defines the first operand
  1930. * @param value2 defines the second operand
  1931. * @returns the new Vector3
  1932. */
  1933. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1934. /**
  1935. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1936. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1937. * to something in order to rotate it from its local system to the given target system
  1938. * Note: axis1, axis2 and axis3 are normalized during this operation
  1939. * @param axis1 defines the first axis
  1940. * @param axis2 defines the second axis
  1941. * @param axis3 defines the third axis
  1942. * @returns a new Vector3
  1943. */
  1944. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1945. /**
  1946. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1947. * @param axis1 defines the first axis
  1948. * @param axis2 defines the second axis
  1949. * @param axis3 defines the third axis
  1950. * @param ref defines the Vector3 where to store the result
  1951. */
  1952. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1953. }
  1954. /**
  1955. * Vector4 class created for EulerAngle class conversion to Quaternion
  1956. */
  1957. export class Vector4 {
  1958. /** x value of the vector */
  1959. x: number;
  1960. /** y value of the vector */
  1961. y: number;
  1962. /** z value of the vector */
  1963. z: number;
  1964. /** w value of the vector */
  1965. w: number;
  1966. /**
  1967. * Creates a Vector4 object from the given floats.
  1968. * @param x x value of the vector
  1969. * @param y y value of the vector
  1970. * @param z z value of the vector
  1971. * @param w w value of the vector
  1972. */
  1973. constructor(
  1974. /** x value of the vector */
  1975. x: number,
  1976. /** y value of the vector */
  1977. y: number,
  1978. /** z value of the vector */
  1979. z: number,
  1980. /** w value of the vector */
  1981. w: number);
  1982. /**
  1983. * Returns the string with the Vector4 coordinates.
  1984. * @returns a string containing all the vector values
  1985. */
  1986. toString(): string;
  1987. /**
  1988. * Returns the string "Vector4".
  1989. * @returns "Vector4"
  1990. */
  1991. getClassName(): string;
  1992. /**
  1993. * Returns the Vector4 hash code.
  1994. * @returns a unique hash code
  1995. */
  1996. getHashCode(): number;
  1997. /**
  1998. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1999. * @returns the resulting array
  2000. */
  2001. asArray(): number[];
  2002. /**
  2003. * Populates the given array from the given index with the Vector4 coordinates.
  2004. * @param array array to populate
  2005. * @param index index of the array to start at (default: 0)
  2006. * @returns the Vector4.
  2007. */
  2008. toArray(array: FloatArray, index?: number): Vector4;
  2009. /**
  2010. * Adds the given vector to the current Vector4.
  2011. * @param otherVector the vector to add
  2012. * @returns the updated Vector4.
  2013. */
  2014. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2015. /**
  2016. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2017. * @param otherVector the vector to add
  2018. * @returns the resulting vector
  2019. */
  2020. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2021. /**
  2022. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2023. * @param otherVector the vector to add
  2024. * @param result the vector to store the result
  2025. * @returns the current Vector4.
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2028. /**
  2029. * Subtract in place the given vector from the current Vector4.
  2030. * @param otherVector the vector to subtract
  2031. * @returns the updated Vector4.
  2032. */
  2033. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2034. /**
  2035. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2036. * @param otherVector the vector to add
  2037. * @returns the new vector with the result
  2038. */
  2039. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2040. /**
  2041. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2042. * @param otherVector the vector to subtract
  2043. * @param result the vector to store the result
  2044. * @returns the current Vector4.
  2045. */
  2046. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2049. */
  2050. /**
  2051. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2052. * @param x value to subtract
  2053. * @param y value to subtract
  2054. * @param z value to subtract
  2055. * @param w value to subtract
  2056. * @returns new vector containing the result
  2057. */
  2058. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2059. /**
  2060. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2061. * @param x value to subtract
  2062. * @param y value to subtract
  2063. * @param z value to subtract
  2064. * @param w value to subtract
  2065. * @param result the vector to store the result in
  2066. * @returns the current Vector4.
  2067. */
  2068. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2069. /**
  2070. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2071. * @returns a new vector with the negated values
  2072. */
  2073. negate(): Vector4;
  2074. /**
  2075. * Multiplies the current Vector4 coordinates by scale (float).
  2076. * @param scale the number to scale with
  2077. * @returns the updated Vector4.
  2078. */
  2079. scaleInPlace(scale: number): Vector4;
  2080. /**
  2081. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2082. * @param scale the number to scale with
  2083. * @returns a new vector with the result
  2084. */
  2085. scale(scale: number): Vector4;
  2086. /**
  2087. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2088. * @param scale the number to scale with
  2089. * @param result a vector to store the result in
  2090. * @returns the current Vector4.
  2091. */
  2092. scaleToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2095. * @param scale defines the scale factor
  2096. * @param result defines the Vector4 object where to store the result
  2097. * @returns the unmodified current Vector4
  2098. */
  2099. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2100. /**
  2101. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2102. * @param otherVector the vector to compare against
  2103. * @returns true if they are equal
  2104. */
  2105. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2106. /**
  2107. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2108. * @param otherVector vector to compare against
  2109. * @param epsilon (Default: very small number)
  2110. * @returns true if they are equal
  2111. */
  2112. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2113. /**
  2114. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2115. * @param x x value to compare against
  2116. * @param y y value to compare against
  2117. * @param z z value to compare against
  2118. * @param w w value to compare against
  2119. * @returns true if equal
  2120. */
  2121. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2122. /**
  2123. * Multiplies in place the current Vector4 by the given one.
  2124. * @param otherVector vector to multiple with
  2125. * @returns the updated Vector4.
  2126. */
  2127. multiplyInPlace(otherVector: Vector4): Vector4;
  2128. /**
  2129. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2130. * @param otherVector vector to multiple with
  2131. * @returns resulting new vector
  2132. */
  2133. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2134. /**
  2135. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2136. * @param otherVector vector to multiple with
  2137. * @param result vector to store the result
  2138. * @returns the current Vector4.
  2139. */
  2140. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2141. /**
  2142. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2143. * @param x x value multiply with
  2144. * @param y y value multiply with
  2145. * @param z z value multiply with
  2146. * @param w w value multiply with
  2147. * @returns resulting new vector
  2148. */
  2149. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2150. /**
  2151. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2152. * @param otherVector vector to devide with
  2153. * @returns resulting new vector
  2154. */
  2155. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2156. /**
  2157. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2158. * @param otherVector vector to devide with
  2159. * @param result vector to store the result
  2160. * @returns the current Vector4.
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2163. /**
  2164. * Divides the current Vector3 coordinates by the given ones.
  2165. * @param otherVector vector to devide with
  2166. * @returns the updated Vector3.
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2169. /**
  2170. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2171. * @param other defines the second operand
  2172. * @returns the current updated Vector4
  2173. */
  2174. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2175. /**
  2176. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2177. * @param other defines the second operand
  2178. * @returns the current updated Vector4
  2179. */
  2180. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2181. /**
  2182. * Gets a new Vector4 from current Vector4 floored values
  2183. * @returns a new Vector4
  2184. */
  2185. floor(): Vector4;
  2186. /**
  2187. * Gets a new Vector4 from current Vector3 floored values
  2188. * @returns a new Vector4
  2189. */
  2190. fract(): Vector4;
  2191. /**
  2192. * Returns the Vector4 length (float).
  2193. * @returns the length
  2194. */
  2195. length(): number;
  2196. /**
  2197. * Returns the Vector4 squared length (float).
  2198. * @returns the length squared
  2199. */
  2200. lengthSquared(): number;
  2201. /**
  2202. * Normalizes in place the Vector4.
  2203. * @returns the updated Vector4.
  2204. */
  2205. normalize(): Vector4;
  2206. /**
  2207. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2208. * @returns this converted to a new vector3
  2209. */
  2210. toVector3(): Vector3;
  2211. /**
  2212. * Returns a new Vector4 copied from the current one.
  2213. * @returns the new cloned vector
  2214. */
  2215. clone(): Vector4;
  2216. /**
  2217. * Updates the current Vector4 with the given one coordinates.
  2218. * @param source the source vector to copy from
  2219. * @returns the updated Vector4.
  2220. */
  2221. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2222. /**
  2223. * Updates the current Vector4 coordinates with the given floats.
  2224. * @param x float to copy from
  2225. * @param y float to copy from
  2226. * @param z float to copy from
  2227. * @param w float to copy from
  2228. * @returns the updated Vector4.
  2229. */
  2230. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2231. /**
  2232. * Updates the current Vector4 coordinates with the given floats.
  2233. * @param x float to set from
  2234. * @param y float to set from
  2235. * @param z float to set from
  2236. * @param w float to set from
  2237. * @returns the updated Vector4.
  2238. */
  2239. set(x: number, y: number, z: number, w: number): Vector4;
  2240. /**
  2241. * Copies the given float to the current Vector3 coordinates
  2242. * @param v defines the x, y, z and w coordinates of the operand
  2243. * @returns the current updated Vector3
  2244. */
  2245. setAll(v: number): Vector4;
  2246. /**
  2247. * Returns a new Vector4 set from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @returns the new vector
  2251. */
  2252. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" from the starting index of the given Float32Array.
  2262. * @param array the array to pull values from
  2263. * @param offset the offset into the array to start at
  2264. * @param result the vector to store the result in
  2265. */
  2266. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2267. /**
  2268. * Updates the given vector "result" coordinates from the given floats.
  2269. * @param x float to set from
  2270. * @param y float to set from
  2271. * @param z float to set from
  2272. * @param w float to set from
  2273. * @param result the vector to the floats in
  2274. */
  2275. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2276. /**
  2277. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2278. * @returns the new vector
  2279. */
  2280. static Zero(): Vector4;
  2281. /**
  2282. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2283. * @returns the new vector
  2284. */
  2285. static One(): Vector4;
  2286. /**
  2287. * Returns a new normalized Vector4 from the given one.
  2288. * @param vector the vector to normalize
  2289. * @returns the vector
  2290. */
  2291. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2292. /**
  2293. * Updates the given vector "result" from the normalization of the given one.
  2294. * @param vector the vector to normalize
  2295. * @param result the vector to store the result in
  2296. */
  2297. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2298. /**
  2299. * Returns a vector with the minimum values from the left and right vectors
  2300. * @param left left vector to minimize
  2301. * @param right right vector to minimize
  2302. * @returns a new vector with the minimum of the left and right vector values
  2303. */
  2304. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns a vector with the maximum values from the left and right vectors
  2307. * @param left left vector to maximize
  2308. * @param right right vector to maximize
  2309. * @returns a new vector with the maximum of the left and right vector values
  2310. */
  2311. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2312. /**
  2313. * Returns the distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors
  2317. */
  2318. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the distance between
  2322. * @param value2 value to calulate the distance between
  2323. * @return the distance between the two vectors squared
  2324. */
  2325. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2326. /**
  2327. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2328. * @param value1 value to calulate the center between
  2329. * @param value2 value to calulate the center between
  2330. * @return the center between the two vectors
  2331. */
  2332. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2333. /**
  2334. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2335. * This methods computes transformed normalized direction vectors only.
  2336. * @param vector the vector to transform
  2337. * @param transformation the transformation matrix to apply
  2338. * @returns the new vector
  2339. */
  2340. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2341. /**
  2342. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2343. * This methods computes transformed normalized direction vectors only.
  2344. * @param vector the vector to transform
  2345. * @param transformation the transformation matrix to apply
  2346. * @param result the vector to store the result in
  2347. */
  2348. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2349. /**
  2350. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2351. * This methods computes transformed normalized direction vectors only.
  2352. * @param x value to transform
  2353. * @param y value to transform
  2354. * @param z value to transform
  2355. * @param w value to transform
  2356. * @param transformation the transformation matrix to apply
  2357. * @param result the vector to store the results in
  2358. */
  2359. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2360. /**
  2361. * Creates a new Vector4 from a Vector3
  2362. * @param source defines the source data
  2363. * @param w defines the 4th component (default is 0)
  2364. * @returns a new Vector4
  2365. */
  2366. static FromVector3(source: Vector3, w?: number): Vector4;
  2367. }
  2368. /**
  2369. * Class used to store quaternion data
  2370. * @see https://en.wikipedia.org/wiki/Quaternion
  2371. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2372. */
  2373. export class Quaternion {
  2374. /** defines the first component (0 by default) */
  2375. x: number;
  2376. /** defines the second component (0 by default) */
  2377. y: number;
  2378. /** defines the third component (0 by default) */
  2379. z: number;
  2380. /** defines the fourth component (1.0 by default) */
  2381. w: number;
  2382. /**
  2383. * Creates a new Quaternion from the given floats
  2384. * @param x defines the first component (0 by default)
  2385. * @param y defines the second component (0 by default)
  2386. * @param z defines the third component (0 by default)
  2387. * @param w defines the fourth component (1.0 by default)
  2388. */
  2389. constructor(
  2390. /** defines the first component (0 by default) */
  2391. x?: number,
  2392. /** defines the second component (0 by default) */
  2393. y?: number,
  2394. /** defines the third component (0 by default) */
  2395. z?: number,
  2396. /** defines the fourth component (1.0 by default) */
  2397. w?: number);
  2398. /**
  2399. * Gets a string representation for the current quaternion
  2400. * @returns a string with the Quaternion coordinates
  2401. */
  2402. toString(): string;
  2403. /**
  2404. * Gets the class name of the quaternion
  2405. * @returns the string "Quaternion"
  2406. */
  2407. getClassName(): string;
  2408. /**
  2409. * Gets a hash code for this quaternion
  2410. * @returns the quaternion hash code
  2411. */
  2412. getHashCode(): number;
  2413. /**
  2414. * Copy the quaternion to an array
  2415. * @returns a new array populated with 4 elements from the quaternion coordinates
  2416. */
  2417. asArray(): number[];
  2418. /**
  2419. * Check if two quaternions are equals
  2420. * @param otherQuaternion defines the second operand
  2421. * @return true if the current quaternion and the given one coordinates are strictly equals
  2422. */
  2423. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2424. /**
  2425. * Clone the current quaternion
  2426. * @returns a new quaternion copied from the current one
  2427. */
  2428. clone(): Quaternion;
  2429. /**
  2430. * Copy a quaternion to the current one
  2431. * @param other defines the other quaternion
  2432. * @returns the updated current quaternion
  2433. */
  2434. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2435. /**
  2436. * Updates the current quaternion with the given float coordinates
  2437. * @param x defines the x coordinate
  2438. * @param y defines the y coordinate
  2439. * @param z defines the z coordinate
  2440. * @param w defines the w coordinate
  2441. * @returns the updated current quaternion
  2442. */
  2443. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2444. /**
  2445. * Updates the current quaternion from the given float coordinates
  2446. * @param x defines the x coordinate
  2447. * @param y defines the y coordinate
  2448. * @param z defines the z coordinate
  2449. * @param w defines the w coordinate
  2450. * @returns the updated current quaternion
  2451. */
  2452. set(x: number, y: number, z: number, w: number): Quaternion;
  2453. /**
  2454. * Adds two quaternions
  2455. * @param other defines the second operand
  2456. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2457. */
  2458. add(other: DeepImmutable<Quaternion>): Quaternion;
  2459. /**
  2460. * Add a quaternion to the current one
  2461. * @param other defines the quaternion to add
  2462. * @returns the current quaternion
  2463. */
  2464. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2465. /**
  2466. * Subtract two quaternions
  2467. * @param other defines the second operand
  2468. * @returns a new quaternion as the subtraction result of the given one from the current one
  2469. */
  2470. subtract(other: Quaternion): Quaternion;
  2471. /**
  2472. * Multiplies the current quaternion by a scale factor
  2473. * @param value defines the scale factor
  2474. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2475. */
  2476. scale(value: number): Quaternion;
  2477. /**
  2478. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2479. * @param scale defines the scale factor
  2480. * @param result defines the Quaternion object where to store the result
  2481. * @returns the unmodified current quaternion
  2482. */
  2483. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2484. /**
  2485. * Multiplies in place the current quaternion by a scale factor
  2486. * @param value defines the scale factor
  2487. * @returns the current modified quaternion
  2488. */
  2489. scaleInPlace(value: number): Quaternion;
  2490. /**
  2491. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2492. * @param scale defines the scale factor
  2493. * @param result defines the Quaternion object where to store the result
  2494. * @returns the unmodified current quaternion
  2495. */
  2496. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2497. /**
  2498. * Multiplies two quaternions
  2499. * @param q1 defines the second operand
  2500. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2501. */
  2502. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2503. /**
  2504. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2505. * @param q1 defines the second operand
  2506. * @param result defines the target quaternion
  2507. * @returns the current quaternion
  2508. */
  2509. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2510. /**
  2511. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2512. * @param q1 defines the second operand
  2513. * @returns the currentupdated quaternion
  2514. */
  2515. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2518. * @param ref defines the target quaternion
  2519. * @returns the current quaternion
  2520. */
  2521. conjugateToRef(ref: Quaternion): Quaternion;
  2522. /**
  2523. * Conjugates in place (1-q) the current quaternion
  2524. * @returns the current updated quaternion
  2525. */
  2526. conjugateInPlace(): Quaternion;
  2527. /**
  2528. * Conjugates in place (1-q) the current quaternion
  2529. * @returns a new quaternion
  2530. */
  2531. conjugate(): Quaternion;
  2532. /**
  2533. * Gets length of current quaternion
  2534. * @returns the quaternion length (float)
  2535. */
  2536. length(): number;
  2537. /**
  2538. * Normalize in place the current quaternion
  2539. * @returns the current updated quaternion
  2540. */
  2541. normalize(): Quaternion;
  2542. /**
  2543. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2544. * @param order is a reserved parameter and is ignore for now
  2545. * @returns a new Vector3 containing the Euler angles
  2546. */
  2547. toEulerAngles(order?: string): Vector3;
  2548. /**
  2549. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2550. * @param result defines the vector which will be filled with the Euler angles
  2551. * @param order is a reserved parameter and is ignore for now
  2552. * @returns the current unchanged quaternion
  2553. */
  2554. toEulerAnglesToRef(result: Vector3): Quaternion;
  2555. /**
  2556. * Updates the given rotation matrix with the current quaternion values
  2557. * @param result defines the target matrix
  2558. * @returns the current unchanged quaternion
  2559. */
  2560. toRotationMatrix(result: Matrix): Quaternion;
  2561. /**
  2562. * Updates the current quaternion from the given rotation matrix values
  2563. * @param matrix defines the source matrix
  2564. * @returns the current updated quaternion
  2565. */
  2566. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2567. /**
  2568. * Creates a new quaternion from a rotation matrix
  2569. * @param matrix defines the source matrix
  2570. * @returns a new quaternion created from the given rotation matrix values
  2571. */
  2572. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2573. /**
  2574. * Updates the given quaternion with the given rotation matrix values
  2575. * @param matrix defines the source matrix
  2576. * @param result defines the target quaternion
  2577. */
  2578. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2579. /**
  2580. * Returns the dot product (float) between the quaternions "left" and "right"
  2581. * @param left defines the left operand
  2582. * @param right defines the right operand
  2583. * @returns the dot product
  2584. */
  2585. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2586. /**
  2587. * Checks if the two quaternions are close to each other
  2588. * @param quat0 defines the first quaternion to check
  2589. * @param quat1 defines the second quaternion to check
  2590. * @returns true if the two quaternions are close to each other
  2591. */
  2592. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2593. /**
  2594. * Creates an empty quaternion
  2595. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2596. */
  2597. static Zero(): Quaternion;
  2598. /**
  2599. * Inverse a given quaternion
  2600. * @param q defines the source quaternion
  2601. * @returns a new quaternion as the inverted current quaternion
  2602. */
  2603. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2604. /**
  2605. * Inverse a given quaternion
  2606. * @param q defines the source quaternion
  2607. * @param result the quaternion the result will be stored in
  2608. * @returns the result quaternion
  2609. */
  2610. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2611. /**
  2612. * Creates an identity quaternion
  2613. * @returns the identity quaternion
  2614. */
  2615. static Identity(): Quaternion;
  2616. /**
  2617. * Gets a boolean indicating if the given quaternion is identity
  2618. * @param quaternion defines the quaternion to check
  2619. * @returns true if the quaternion is identity
  2620. */
  2621. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2622. /**
  2623. * Creates a quaternion from a rotation around an axis
  2624. * @param axis defines the axis to use
  2625. * @param angle defines the angle to use
  2626. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2627. */
  2628. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2629. /**
  2630. * Creates a rotation around an axis and stores it into the given quaternion
  2631. * @param axis defines the axis to use
  2632. * @param angle defines the angle to use
  2633. * @param result defines the target quaternion
  2634. * @returns the target quaternion
  2635. */
  2636. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2637. /**
  2638. * Creates a new quaternion from data stored into an array
  2639. * @param array defines the data source
  2640. * @param offset defines the offset in the source array where the data starts
  2641. * @returns a new quaternion
  2642. */
  2643. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2644. /**
  2645. * Create a quaternion from Euler rotation angles
  2646. * @param x Pitch
  2647. * @param y Yaw
  2648. * @param z Roll
  2649. * @returns the new Quaternion
  2650. */
  2651. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2652. /**
  2653. * Updates a quaternion from Euler rotation angles
  2654. * @param x Pitch
  2655. * @param y Yaw
  2656. * @param z Roll
  2657. * @param result the quaternion to store the result
  2658. * @returns the updated quaternion
  2659. */
  2660. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2661. /**
  2662. * Create a quaternion from Euler rotation vector
  2663. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2664. * @returns the new Quaternion
  2665. */
  2666. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2667. /**
  2668. * Updates a quaternion from Euler rotation vector
  2669. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2670. * @param result the quaternion to store the result
  2671. * @returns the updated quaternion
  2672. */
  2673. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2674. /**
  2675. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2676. * @param yaw defines the rotation around Y axis
  2677. * @param pitch defines the rotation around X axis
  2678. * @param roll defines the rotation around Z axis
  2679. * @returns the new quaternion
  2680. */
  2681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2682. /**
  2683. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2684. * @param yaw defines the rotation around Y axis
  2685. * @param pitch defines the rotation around X axis
  2686. * @param roll defines the rotation around Z axis
  2687. * @param result defines the target quaternion
  2688. */
  2689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2690. /**
  2691. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2692. * @param alpha defines the rotation around first axis
  2693. * @param beta defines the rotation around second axis
  2694. * @param gamma defines the rotation around third axis
  2695. * @returns the new quaternion
  2696. */
  2697. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2698. /**
  2699. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2700. * @param alpha defines the rotation around first axis
  2701. * @param beta defines the rotation around second axis
  2702. * @param gamma defines the rotation around third axis
  2703. * @param result defines the target quaternion
  2704. */
  2705. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2706. /**
  2707. * 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)
  2708. * @param axis1 defines the first axis
  2709. * @param axis2 defines the second axis
  2710. * @param axis3 defines the third axis
  2711. * @returns the new quaternion
  2712. */
  2713. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2714. /**
  2715. * 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
  2716. * @param axis1 defines the first axis
  2717. * @param axis2 defines the second axis
  2718. * @param axis3 defines the third axis
  2719. * @param ref defines the target quaternion
  2720. */
  2721. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2722. /**
  2723. * Interpolates between two quaternions
  2724. * @param left defines first quaternion
  2725. * @param right defines second quaternion
  2726. * @param amount defines the gradient to use
  2727. * @returns the new interpolated quaternion
  2728. */
  2729. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2730. /**
  2731. * Interpolates between two quaternions and stores it into a target quaternion
  2732. * @param left defines first quaternion
  2733. * @param right defines second quaternion
  2734. * @param amount defines the gradient to use
  2735. * @param result defines the target quaternion
  2736. */
  2737. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2738. /**
  2739. * Interpolate between two quaternions using Hermite interpolation
  2740. * @param value1 defines first quaternion
  2741. * @param tangent1 defines the incoming tangent
  2742. * @param value2 defines second quaternion
  2743. * @param tangent2 defines the outgoing tangent
  2744. * @param amount defines the target quaternion
  2745. * @returns the new interpolated quaternion
  2746. */
  2747. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2748. }
  2749. /**
  2750. * Class used to store matrix data (4x4)
  2751. */
  2752. export class Matrix {
  2753. private static _updateFlagSeed;
  2754. private static _identityReadOnly;
  2755. private _isIdentity;
  2756. private _isIdentityDirty;
  2757. private _isIdentity3x2;
  2758. private _isIdentity3x2Dirty;
  2759. /**
  2760. * Gets the update flag of the matrix which is an unique number for the matrix.
  2761. * It will be incremented every time the matrix data change.
  2762. * You can use it to speed the comparison between two versions of the same matrix.
  2763. */
  2764. updateFlag: number;
  2765. private readonly _m;
  2766. /**
  2767. * Gets the internal data of the matrix
  2768. */
  2769. readonly m: DeepImmutable<Float32Array>;
  2770. /** @hidden */
  2771. _markAsUpdated(): void;
  2772. /** @hidden */
  2773. private _updateIdentityStatus;
  2774. /**
  2775. * Creates an empty matrix (filled with zeros)
  2776. */
  2777. constructor();
  2778. /**
  2779. * Check if the current matrix is identity
  2780. * @returns true is the matrix is the identity matrix
  2781. */
  2782. isIdentity(): boolean;
  2783. /**
  2784. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2785. * @returns true is the matrix is the identity matrix
  2786. */
  2787. isIdentityAs3x2(): boolean;
  2788. /**
  2789. * Gets the determinant of the matrix
  2790. * @returns the matrix determinant
  2791. */
  2792. determinant(): number;
  2793. /**
  2794. * Returns the matrix as a Float32Array
  2795. * @returns the matrix underlying array
  2796. */
  2797. toArray(): DeepImmutable<Float32Array>;
  2798. /**
  2799. * Returns the matrix as a Float32Array
  2800. * @returns the matrix underlying array.
  2801. */
  2802. asArray(): DeepImmutable<Float32Array>;
  2803. /**
  2804. * Inverts the current matrix in place
  2805. * @returns the current inverted matrix
  2806. */
  2807. invert(): Matrix;
  2808. /**
  2809. * Sets all the matrix elements to zero
  2810. * @returns the current matrix
  2811. */
  2812. reset(): Matrix;
  2813. /**
  2814. * Adds the current matrix with a second one
  2815. * @param other defines the matrix to add
  2816. * @returns a new matrix as the addition of the current matrix and the given one
  2817. */
  2818. add(other: DeepImmutable<Matrix>): Matrix;
  2819. /**
  2820. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2821. * @param other defines the matrix to add
  2822. * @param result defines the target matrix
  2823. * @returns the current matrix
  2824. */
  2825. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2826. /**
  2827. * Adds in place the given matrix to the current matrix
  2828. * @param other defines the second operand
  2829. * @returns the current updated matrix
  2830. */
  2831. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2832. /**
  2833. * Sets the given matrix to the current inverted Matrix
  2834. * @param other defines the target matrix
  2835. * @returns the unmodified current matrix
  2836. */
  2837. invertToRef(other: Matrix): Matrix;
  2838. /**
  2839. * add a value at the specified position in the current Matrix
  2840. * @param index the index of the value within the matrix. between 0 and 15.
  2841. * @param value the value to be added
  2842. * @returns the current updated matrix
  2843. */
  2844. addAtIndex(index: number, value: number): Matrix;
  2845. /**
  2846. * mutiply the specified position in the current Matrix by a value
  2847. * @param index the index of the value within the matrix. between 0 and 15.
  2848. * @param value the value to be added
  2849. * @returns the current updated matrix
  2850. */
  2851. multiplyAtIndex(index: number, value: number): Matrix;
  2852. /**
  2853. * Inserts the translation vector (using 3 floats) in the current matrix
  2854. * @param x defines the 1st component of the translation
  2855. * @param y defines the 2nd component of the translation
  2856. * @param z defines the 3rd component of the translation
  2857. * @returns the current updated matrix
  2858. */
  2859. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2860. /**
  2861. * Adds the translation vector (using 3 floats) in the current matrix
  2862. * @param x defines the 1st component of the translation
  2863. * @param y defines the 2nd component of the translation
  2864. * @param z defines the 3rd component of the translation
  2865. * @returns the current updated matrix
  2866. */
  2867. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2868. /**
  2869. * Inserts the translation vector in the current matrix
  2870. * @param vector3 defines the translation to insert
  2871. * @returns the current updated matrix
  2872. */
  2873. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2874. /**
  2875. * Gets the translation value of the current matrix
  2876. * @returns a new Vector3 as the extracted translation from the matrix
  2877. */
  2878. getTranslation(): Vector3;
  2879. /**
  2880. * Fill a Vector3 with the extracted translation from the matrix
  2881. * @param result defines the Vector3 where to store the translation
  2882. * @returns the current matrix
  2883. */
  2884. getTranslationToRef(result: Vector3): Matrix;
  2885. /**
  2886. * Remove rotation and scaling part from the matrix
  2887. * @returns the updated matrix
  2888. */
  2889. removeRotationAndScaling(): Matrix;
  2890. /**
  2891. * Multiply two matrices
  2892. * @param other defines the second operand
  2893. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2894. */
  2895. multiply(other: DeepImmutable<Matrix>): Matrix;
  2896. /**
  2897. * Copy the current matrix from the given one
  2898. * @param other defines the source matrix
  2899. * @returns the current updated matrix
  2900. */
  2901. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Populates the given array from the starting index with the current matrix values
  2904. * @param array defines the target array
  2905. * @param offset defines the offset in the target array where to start storing values
  2906. * @returns the current matrix
  2907. */
  2908. copyToArray(array: Float32Array, offset?: number): Matrix;
  2909. /**
  2910. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2911. * @param other defines the second operand
  2912. * @param result defines the matrix where to store the multiplication
  2913. * @returns the current matrix
  2914. */
  2915. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2916. /**
  2917. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2918. * @param other defines the second operand
  2919. * @param result defines the array where to store the multiplication
  2920. * @param offset defines the offset in the target array where to start storing values
  2921. * @returns the current matrix
  2922. */
  2923. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2924. /**
  2925. * Check equality between this matrix and a second one
  2926. * @param value defines the second matrix to compare
  2927. * @returns true is the current matrix and the given one values are strictly equal
  2928. */
  2929. equals(value: DeepImmutable<Matrix>): boolean;
  2930. /**
  2931. * Clone the current matrix
  2932. * @returns a new matrix from the current matrix
  2933. */
  2934. clone(): Matrix;
  2935. /**
  2936. * Returns the name of the current matrix class
  2937. * @returns the string "Matrix"
  2938. */
  2939. getClassName(): string;
  2940. /**
  2941. * Gets the hash code of the current matrix
  2942. * @returns the hash code
  2943. */
  2944. getHashCode(): number;
  2945. /**
  2946. * Decomposes the current Matrix into a translation, rotation and scaling components
  2947. * @param scale defines the scale vector3 given as a reference to update
  2948. * @param rotation defines the rotation quaternion given as a reference to update
  2949. * @param translation defines the translation vector3 given as a reference to update
  2950. * @returns true if operation was successful
  2951. */
  2952. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2953. /**
  2954. * Gets specific row of the matrix
  2955. * @param index defines the number of the row to get
  2956. * @returns the index-th row of the current matrix as a new Vector4
  2957. */
  2958. getRow(index: number): Nullable<Vector4>;
  2959. /**
  2960. * Sets the index-th row of the current matrix to the vector4 values
  2961. * @param index defines the number of the row to set
  2962. * @param row defines the target vector4
  2963. * @returns the updated current matrix
  2964. */
  2965. setRow(index: number, row: Vector4): Matrix;
  2966. /**
  2967. * Compute the transpose of the matrix
  2968. * @returns the new transposed matrix
  2969. */
  2970. transpose(): Matrix;
  2971. /**
  2972. * Compute the transpose of the matrix and store it in a given matrix
  2973. * @param result defines the target matrix
  2974. * @returns the current matrix
  2975. */
  2976. transposeToRef(result: Matrix): Matrix;
  2977. /**
  2978. * Sets the index-th row of the current matrix with the given 4 x float values
  2979. * @param index defines the row index
  2980. * @param x defines the x component to set
  2981. * @param y defines the y component to set
  2982. * @param z defines the z component to set
  2983. * @param w defines the w component to set
  2984. * @returns the updated current matrix
  2985. */
  2986. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  2987. /**
  2988. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  2989. * @param scale defines the scale factor
  2990. * @returns a new matrix
  2991. */
  2992. scale(scale: number): Matrix;
  2993. /**
  2994. * Scale the current matrix values by a factor to a given result matrix
  2995. * @param scale defines the scale factor
  2996. * @param result defines the matrix to store the result
  2997. * @returns the current matrix
  2998. */
  2999. scaleToRef(scale: number, result: Matrix): Matrix;
  3000. /**
  3001. * Scale the current matrix values by a factor and add the result to a given matrix
  3002. * @param scale defines the scale factor
  3003. * @param result defines the Matrix to store the result
  3004. * @returns the current matrix
  3005. */
  3006. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3007. /**
  3008. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3009. * @param ref matrix to store the result
  3010. */
  3011. toNormalMatrix(ref: Matrix): void;
  3012. /**
  3013. * Gets only rotation part of the current matrix
  3014. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3015. */
  3016. getRotationMatrix(): Matrix;
  3017. /**
  3018. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3019. * @param result defines the target matrix to store data to
  3020. * @returns the current matrix
  3021. */
  3022. getRotationMatrixToRef(result: Matrix): Matrix;
  3023. /**
  3024. * Toggles model matrix from being right handed to left handed in place and vice versa
  3025. */
  3026. toggleModelMatrixHandInPlace(): void;
  3027. /**
  3028. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3029. */
  3030. toggleProjectionMatrixHandInPlace(): void;
  3031. /**
  3032. * Creates a matrix from an array
  3033. * @param array defines the source array
  3034. * @param offset defines an offset in the source array
  3035. * @returns a new Matrix set from the starting index of the given array
  3036. */
  3037. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3038. /**
  3039. * Copy the content of an array into a given matrix
  3040. * @param array defines the source array
  3041. * @param offset defines an offset in the source array
  3042. * @param result defines the target matrix
  3043. */
  3044. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3045. /**
  3046. * Stores an array into a matrix after having multiplied each component by a given factor
  3047. * @param array defines the source array
  3048. * @param offset defines the offset in the source array
  3049. * @param scale defines the scaling factor
  3050. * @param result defines the target matrix
  3051. */
  3052. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3053. /**
  3054. * Gets an identity matrix that must not be updated
  3055. */
  3056. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3057. /**
  3058. * Stores a list of values (16) inside a given matrix
  3059. * @param initialM11 defines 1st value of 1st row
  3060. * @param initialM12 defines 2nd value of 1st row
  3061. * @param initialM13 defines 3rd value of 1st row
  3062. * @param initialM14 defines 4th value of 1st row
  3063. * @param initialM21 defines 1st value of 2nd row
  3064. * @param initialM22 defines 2nd value of 2nd row
  3065. * @param initialM23 defines 3rd value of 2nd row
  3066. * @param initialM24 defines 4th value of 2nd row
  3067. * @param initialM31 defines 1st value of 3rd row
  3068. * @param initialM32 defines 2nd value of 3rd row
  3069. * @param initialM33 defines 3rd value of 3rd row
  3070. * @param initialM34 defines 4th value of 3rd row
  3071. * @param initialM41 defines 1st value of 4th row
  3072. * @param initialM42 defines 2nd value of 4th row
  3073. * @param initialM43 defines 3rd value of 4th row
  3074. * @param initialM44 defines 4th value of 4th row
  3075. * @param result defines the target matrix
  3076. */
  3077. 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;
  3078. /**
  3079. * Creates new matrix from a list of values (16)
  3080. * @param initialM11 defines 1st value of 1st row
  3081. * @param initialM12 defines 2nd value of 1st row
  3082. * @param initialM13 defines 3rd value of 1st row
  3083. * @param initialM14 defines 4th value of 1st row
  3084. * @param initialM21 defines 1st value of 2nd row
  3085. * @param initialM22 defines 2nd value of 2nd row
  3086. * @param initialM23 defines 3rd value of 2nd row
  3087. * @param initialM24 defines 4th value of 2nd row
  3088. * @param initialM31 defines 1st value of 3rd row
  3089. * @param initialM32 defines 2nd value of 3rd row
  3090. * @param initialM33 defines 3rd value of 3rd row
  3091. * @param initialM34 defines 4th value of 3rd row
  3092. * @param initialM41 defines 1st value of 4th row
  3093. * @param initialM42 defines 2nd value of 4th row
  3094. * @param initialM43 defines 3rd value of 4th row
  3095. * @param initialM44 defines 4th value of 4th row
  3096. * @returns the new matrix
  3097. */
  3098. 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;
  3099. /**
  3100. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3101. * @param scale defines the scale vector3
  3102. * @param rotation defines the rotation quaternion
  3103. * @param translation defines the translation vector3
  3104. * @returns a new matrix
  3105. */
  3106. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3107. /**
  3108. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3109. * @param scale defines the scale vector3
  3110. * @param rotation defines the rotation quaternion
  3111. * @param translation defines the translation vector3
  3112. * @param result defines the target matrix
  3113. */
  3114. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3115. /**
  3116. * Creates a new identity matrix
  3117. * @returns a new identity matrix
  3118. */
  3119. static Identity(): Matrix;
  3120. /**
  3121. * Creates a new identity matrix and stores the result in a given matrix
  3122. * @param result defines the target matrix
  3123. */
  3124. static IdentityToRef(result: Matrix): void;
  3125. /**
  3126. * Creates a new zero matrix
  3127. * @returns a new zero matrix
  3128. */
  3129. static Zero(): Matrix;
  3130. /**
  3131. * Creates a new rotation matrix for "angle" radians around the X axis
  3132. * @param angle defines the angle (in radians) to use
  3133. * @return the new matrix
  3134. */
  3135. static RotationX(angle: number): Matrix;
  3136. /**
  3137. * Creates a new matrix as the invert of a given matrix
  3138. * @param source defines the source matrix
  3139. * @returns the new matrix
  3140. */
  3141. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3142. /**
  3143. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3144. * @param angle defines the angle (in radians) to use
  3145. * @param result defines the target matrix
  3146. */
  3147. static RotationXToRef(angle: number, result: Matrix): void;
  3148. /**
  3149. * Creates a new rotation matrix for "angle" radians around the Y axis
  3150. * @param angle defines the angle (in radians) to use
  3151. * @return the new matrix
  3152. */
  3153. static RotationY(angle: number): Matrix;
  3154. /**
  3155. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3156. * @param angle defines the angle (in radians) to use
  3157. * @param result defines the target matrix
  3158. */
  3159. static RotationYToRef(angle: number, result: Matrix): void;
  3160. /**
  3161. * Creates a new rotation matrix for "angle" radians around the Z axis
  3162. * @param angle defines the angle (in radians) to use
  3163. * @return the new matrix
  3164. */
  3165. static RotationZ(angle: number): Matrix;
  3166. /**
  3167. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3168. * @param angle defines the angle (in radians) to use
  3169. * @param result defines the target matrix
  3170. */
  3171. static RotationZToRef(angle: number, result: Matrix): void;
  3172. /**
  3173. * Creates a new rotation matrix for "angle" radians around the given axis
  3174. * @param axis defines the axis to use
  3175. * @param angle defines the angle (in radians) to use
  3176. * @return the new matrix
  3177. */
  3178. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3179. /**
  3180. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3181. * @param axis defines the axis to use
  3182. * @param angle defines the angle (in radians) to use
  3183. * @param result defines the target matrix
  3184. */
  3185. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3186. /**
  3187. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3188. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3189. * @param from defines the vector to align
  3190. * @param to defines the vector to align to
  3191. * @param result defines the target matrix
  3192. */
  3193. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a rotation matrix
  3196. * @param yaw defines the yaw angle in radians (Y axis)
  3197. * @param pitch defines the pitch angle in radians (X axis)
  3198. * @param roll defines the roll angle in radians (X axis)
  3199. * @returns the new rotation matrix
  3200. */
  3201. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3202. /**
  3203. * Creates a rotation matrix and stores it in a given matrix
  3204. * @param yaw defines the yaw angle in radians (Y axis)
  3205. * @param pitch defines the pitch angle in radians (X axis)
  3206. * @param roll defines the roll angle in radians (X axis)
  3207. * @param result defines the target matrix
  3208. */
  3209. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3210. /**
  3211. * Creates a scaling matrix
  3212. * @param x defines the scale factor on X axis
  3213. * @param y defines the scale factor on Y axis
  3214. * @param z defines the scale factor on Z axis
  3215. * @returns the new matrix
  3216. */
  3217. static Scaling(x: number, y: number, z: number): Matrix;
  3218. /**
  3219. * Creates a scaling matrix and stores it in a given matrix
  3220. * @param x defines the scale factor on X axis
  3221. * @param y defines the scale factor on Y axis
  3222. * @param z defines the scale factor on Z axis
  3223. * @param result defines the target matrix
  3224. */
  3225. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3226. /**
  3227. * Creates a translation matrix
  3228. * @param x defines the translation on X axis
  3229. * @param y defines the translation on Y axis
  3230. * @param z defines the translationon Z axis
  3231. * @returns the new matrix
  3232. */
  3233. static Translation(x: number, y: number, z: number): Matrix;
  3234. /**
  3235. * Creates a translation matrix and stores it in a given matrix
  3236. * @param x defines the translation on X axis
  3237. * @param y defines the translation on Y axis
  3238. * @param z defines the translationon Z axis
  3239. * @param result defines the target matrix
  3240. */
  3241. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3242. /**
  3243. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3244. * @param startValue defines the start value
  3245. * @param endValue defines the end value
  3246. * @param gradient defines the gradient factor
  3247. * @returns the new matrix
  3248. */
  3249. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3250. /**
  3251. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3252. * @param startValue defines the start value
  3253. * @param endValue defines the end value
  3254. * @param gradient defines the gradient factor
  3255. * @param result defines the Matrix object where to store data
  3256. */
  3257. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3258. /**
  3259. * Builds a new matrix whose values are computed by:
  3260. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3261. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3262. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3263. * @param startValue defines the first matrix
  3264. * @param endValue defines the second matrix
  3265. * @param gradient defines the gradient between the two matrices
  3266. * @returns the new matrix
  3267. */
  3268. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3269. /**
  3270. * Update a matrix to values which are computed by:
  3271. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3272. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3273. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3274. * @param startValue defines the first matrix
  3275. * @param endValue defines the second matrix
  3276. * @param gradient defines the gradient between the two matrices
  3277. * @param result defines the target matrix
  3278. */
  3279. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3280. /**
  3281. * 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"
  3282. * This function works in left handed mode
  3283. * @param eye defines the final position of the entity
  3284. * @param target defines where the entity should look at
  3285. * @param up defines the up vector for the entity
  3286. * @returns the new matrix
  3287. */
  3288. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3289. /**
  3290. * 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".
  3291. * This function works in left handed mode
  3292. * @param eye defines the final position of the entity
  3293. * @param target defines where the entity should look at
  3294. * @param up defines the up vector for the entity
  3295. * @param result defines the target matrix
  3296. */
  3297. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3298. /**
  3299. * 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"
  3300. * This function works in right handed mode
  3301. * @param eye defines the final position of the entity
  3302. * @param target defines where the entity should look at
  3303. * @param up defines the up vector for the entity
  3304. * @returns the new matrix
  3305. */
  3306. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3307. /**
  3308. * 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".
  3309. * This function works in right handed mode
  3310. * @param eye defines the final position of the entity
  3311. * @param target defines where the entity should look at
  3312. * @param up defines the up vector for the entity
  3313. * @param result defines the target matrix
  3314. */
  3315. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3316. /**
  3317. * Create a left-handed orthographic projection matrix
  3318. * @param width defines the viewport width
  3319. * @param height defines the viewport height
  3320. * @param znear defines the near clip plane
  3321. * @param zfar defines the far clip plane
  3322. * @returns a new matrix as a left-handed orthographic projection matrix
  3323. */
  3324. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3325. /**
  3326. * Store a left-handed orthographic projection to a given matrix
  3327. * @param width defines the viewport width
  3328. * @param height defines the viewport height
  3329. * @param znear defines the near clip plane
  3330. * @param zfar defines the far clip plane
  3331. * @param result defines the target matrix
  3332. */
  3333. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3334. /**
  3335. * Create a left-handed orthographic projection matrix
  3336. * @param left defines the viewport left coordinate
  3337. * @param right defines the viewport right coordinate
  3338. * @param bottom defines the viewport bottom coordinate
  3339. * @param top defines the viewport top coordinate
  3340. * @param znear defines the near clip plane
  3341. * @param zfar defines the far clip plane
  3342. * @returns a new matrix as a left-handed orthographic projection matrix
  3343. */
  3344. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3345. /**
  3346. * Stores a left-handed orthographic projection into a given matrix
  3347. * @param left defines the viewport left coordinate
  3348. * @param right defines the viewport right coordinate
  3349. * @param bottom defines the viewport bottom coordinate
  3350. * @param top defines the viewport top coordinate
  3351. * @param znear defines the near clip plane
  3352. * @param zfar defines the far clip plane
  3353. * @param result defines the target matrix
  3354. */
  3355. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3356. /**
  3357. * Creates a right-handed orthographic projection matrix
  3358. * @param left defines the viewport left coordinate
  3359. * @param right defines the viewport right coordinate
  3360. * @param bottom defines the viewport bottom coordinate
  3361. * @param top defines the viewport top coordinate
  3362. * @param znear defines the near clip plane
  3363. * @param zfar defines the far clip plane
  3364. * @returns a new matrix as a right-handed orthographic projection matrix
  3365. */
  3366. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3367. /**
  3368. * Stores a right-handed orthographic projection into a given matrix
  3369. * @param left defines the viewport left coordinate
  3370. * @param right defines the viewport right coordinate
  3371. * @param bottom defines the viewport bottom coordinate
  3372. * @param top defines the viewport top coordinate
  3373. * @param znear defines the near clip plane
  3374. * @param zfar defines the far clip plane
  3375. * @param result defines the target matrix
  3376. */
  3377. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3378. /**
  3379. * Creates a left-handed perspective projection matrix
  3380. * @param width defines the viewport width
  3381. * @param height defines the viewport height
  3382. * @param znear defines the near clip plane
  3383. * @param zfar defines the far clip plane
  3384. * @returns a new matrix as a left-handed perspective projection matrix
  3385. */
  3386. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3387. /**
  3388. * Creates a left-handed perspective projection matrix
  3389. * @param fov defines the horizontal field of view
  3390. * @param aspect defines the aspect ratio
  3391. * @param znear defines the near clip plane
  3392. * @param zfar defines the far clip plane
  3393. * @returns a new matrix as a left-handed perspective projection matrix
  3394. */
  3395. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3396. /**
  3397. * Stores a left-handed perspective projection into a given matrix
  3398. * @param fov defines the horizontal field of view
  3399. * @param aspect defines the aspect ratio
  3400. * @param znear defines the near clip plane
  3401. * @param zfar defines the far clip plane
  3402. * @param result defines the target matrix
  3403. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3404. */
  3405. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3406. /**
  3407. * Creates a right-handed perspective projection matrix
  3408. * @param fov defines the horizontal field of view
  3409. * @param aspect defines the aspect ratio
  3410. * @param znear defines the near clip plane
  3411. * @param zfar defines the far clip plane
  3412. * @returns a new matrix as a right-handed perspective projection matrix
  3413. */
  3414. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3415. /**
  3416. * Stores a right-handed perspective projection into a given matrix
  3417. * @param fov defines the horizontal field of view
  3418. * @param aspect defines the aspect ratio
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @param result defines the target matrix
  3422. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3423. */
  3424. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3425. /**
  3426. * Stores a perspective projection for WebVR info a given matrix
  3427. * @param fov defines the field of view
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @param result defines the target matrix
  3431. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3432. */
  3433. static PerspectiveFovWebVRToRef(fov: {
  3434. upDegrees: number;
  3435. downDegrees: number;
  3436. leftDegrees: number;
  3437. rightDegrees: number;
  3438. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3439. /**
  3440. * Computes a complete transformation matrix
  3441. * @param viewport defines the viewport to use
  3442. * @param world defines the world matrix
  3443. * @param view defines the view matrix
  3444. * @param projection defines the projection matrix
  3445. * @param zmin defines the near clip plane
  3446. * @param zmax defines the far clip plane
  3447. * @returns the transformation matrix
  3448. */
  3449. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3450. /**
  3451. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3452. * @param matrix defines the matrix to use
  3453. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3454. */
  3455. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3456. /**
  3457. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3458. * @param matrix defines the matrix to use
  3459. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3460. */
  3461. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3462. /**
  3463. * Compute the transpose of a given matrix
  3464. * @param matrix defines the matrix to transpose
  3465. * @returns the new matrix
  3466. */
  3467. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3468. /**
  3469. * Compute the transpose of a matrix and store it in a target matrix
  3470. * @param matrix defines the matrix to transpose
  3471. * @param result defines the target matrix
  3472. */
  3473. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3474. /**
  3475. * Computes a reflection matrix from a plane
  3476. * @param plane defines the reflection plane
  3477. * @returns a new matrix
  3478. */
  3479. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3480. /**
  3481. * Computes a reflection matrix from a plane
  3482. * @param plane defines the reflection plane
  3483. * @param result defines the target matrix
  3484. */
  3485. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3486. /**
  3487. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3488. * @param xaxis defines the value of the 1st axis
  3489. * @param yaxis defines the value of the 2nd axis
  3490. * @param zaxis defines the value of the 3rd axis
  3491. * @param result defines the target matrix
  3492. */
  3493. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3494. /**
  3495. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3496. * @param quat defines the quaternion to use
  3497. * @param result defines the target matrix
  3498. */
  3499. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3500. }
  3501. /**
  3502. * @hidden
  3503. */
  3504. export class TmpVectors {
  3505. static Vector2: Vector2[];
  3506. static Vector3: Vector3[];
  3507. static Vector4: Vector4[];
  3508. static Quaternion: Quaternion[];
  3509. static Matrix: Matrix[];
  3510. }
  3511. }
  3512. declare module "babylonjs/Maths/math.color" {
  3513. import { DeepImmutable, FloatArray } from "babylonjs/types";
  3514. /**
  3515. * Class used to hold a RBG color
  3516. */
  3517. export class Color3 {
  3518. /**
  3519. * Defines the red component (between 0 and 1, default is 0)
  3520. */
  3521. r: number;
  3522. /**
  3523. * Defines the green component (between 0 and 1, default is 0)
  3524. */
  3525. g: number;
  3526. /**
  3527. * Defines the blue component (between 0 and 1, default is 0)
  3528. */
  3529. b: number;
  3530. /**
  3531. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3532. * @param r defines the red component (between 0 and 1, default is 0)
  3533. * @param g defines the green component (between 0 and 1, default is 0)
  3534. * @param b defines the blue component (between 0 and 1, default is 0)
  3535. */
  3536. constructor(
  3537. /**
  3538. * Defines the red component (between 0 and 1, default is 0)
  3539. */
  3540. r?: number,
  3541. /**
  3542. * Defines the green component (between 0 and 1, default is 0)
  3543. */
  3544. g?: number,
  3545. /**
  3546. * Defines the blue component (between 0 and 1, default is 0)
  3547. */
  3548. b?: number);
  3549. /**
  3550. * Creates a string with the Color3 current values
  3551. * @returns the string representation of the Color3 object
  3552. */
  3553. toString(): string;
  3554. /**
  3555. * Returns the string "Color3"
  3556. * @returns "Color3"
  3557. */
  3558. getClassName(): string;
  3559. /**
  3560. * Compute the Color3 hash code
  3561. * @returns an unique number that can be used to hash Color3 objects
  3562. */
  3563. getHashCode(): number;
  3564. /**
  3565. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3566. * @param array defines the array where to store the r,g,b components
  3567. * @param index defines an optional index in the target array to define where to start storing values
  3568. * @returns the current Color3 object
  3569. */
  3570. toArray(array: FloatArray, index?: number): Color3;
  3571. /**
  3572. * Returns a new Color4 object from the current Color3 and the given alpha
  3573. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3574. * @returns a new Color4 object
  3575. */
  3576. toColor4(alpha?: number): Color4;
  3577. /**
  3578. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3579. * @returns the new array
  3580. */
  3581. asArray(): number[];
  3582. /**
  3583. * Returns the luminance value
  3584. * @returns a float value
  3585. */
  3586. toLuminance(): number;
  3587. /**
  3588. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3589. * @param otherColor defines the second operand
  3590. * @returns the new Color3 object
  3591. */
  3592. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3593. /**
  3594. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3595. * @param otherColor defines the second operand
  3596. * @param result defines the Color3 object where to store the result
  3597. * @returns the current Color3
  3598. */
  3599. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3600. /**
  3601. * Determines equality between Color3 objects
  3602. * @param otherColor defines the second operand
  3603. * @returns true if the rgb values are equal to the given ones
  3604. */
  3605. equals(otherColor: DeepImmutable<Color3>): boolean;
  3606. /**
  3607. * Determines equality between the current Color3 object and a set of r,b,g values
  3608. * @param r defines the red component to check
  3609. * @param g defines the green component to check
  3610. * @param b defines the blue component to check
  3611. * @returns true if the rgb values are equal to the given ones
  3612. */
  3613. equalsFloats(r: number, g: number, b: number): boolean;
  3614. /**
  3615. * Multiplies in place each rgb value by scale
  3616. * @param scale defines the scaling factor
  3617. * @returns the updated Color3
  3618. */
  3619. scale(scale: number): Color3;
  3620. /**
  3621. * Multiplies the rgb values by scale and stores the result into "result"
  3622. * @param scale defines the scaling factor
  3623. * @param result defines the Color3 object where to store the result
  3624. * @returns the unmodified current Color3
  3625. */
  3626. scaleToRef(scale: number, result: Color3): Color3;
  3627. /**
  3628. * Scale the current Color3 values by a factor and add the result to a given Color3
  3629. * @param scale defines the scale factor
  3630. * @param result defines color to store the result into
  3631. * @returns the unmodified current Color3
  3632. */
  3633. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3634. /**
  3635. * Clamps the rgb values by the min and max values and stores the result into "result"
  3636. * @param min defines minimum clamping value (default is 0)
  3637. * @param max defines maximum clamping value (default is 1)
  3638. * @param result defines color to store the result into
  3639. * @returns the original Color3
  3640. */
  3641. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3642. /**
  3643. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3644. * @param otherColor defines the second operand
  3645. * @returns the new Color3
  3646. */
  3647. add(otherColor: DeepImmutable<Color3>): Color3;
  3648. /**
  3649. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3650. * @param otherColor defines the second operand
  3651. * @param result defines Color3 object to store the result into
  3652. * @returns the unmodified current Color3
  3653. */
  3654. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3655. /**
  3656. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3657. * @param otherColor defines the second operand
  3658. * @returns the new Color3
  3659. */
  3660. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3661. /**
  3662. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3663. * @param otherColor defines the second operand
  3664. * @param result defines Color3 object to store the result into
  3665. * @returns the unmodified current Color3
  3666. */
  3667. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3668. /**
  3669. * Copy the current object
  3670. * @returns a new Color3 copied the current one
  3671. */
  3672. clone(): Color3;
  3673. /**
  3674. * Copies the rgb values from the source in the current Color3
  3675. * @param source defines the source Color3 object
  3676. * @returns the updated Color3 object
  3677. */
  3678. copyFrom(source: DeepImmutable<Color3>): Color3;
  3679. /**
  3680. * Updates the Color3 rgb values from the given floats
  3681. * @param r defines the red component to read from
  3682. * @param g defines the green component to read from
  3683. * @param b defines the blue component to read from
  3684. * @returns the current Color3 object
  3685. */
  3686. copyFromFloats(r: number, g: number, b: number): Color3;
  3687. /**
  3688. * Updates the Color3 rgb values from the given floats
  3689. * @param r defines the red component to read from
  3690. * @param g defines the green component to read from
  3691. * @param b defines the blue component to read from
  3692. * @returns the current Color3 object
  3693. */
  3694. set(r: number, g: number, b: number): Color3;
  3695. /**
  3696. * Compute the Color3 hexadecimal code as a string
  3697. * @returns a string containing the hexadecimal representation of the Color3 object
  3698. */
  3699. toHexString(): string;
  3700. /**
  3701. * Computes a new Color3 converted from the current one to linear space
  3702. * @returns a new Color3 object
  3703. */
  3704. toLinearSpace(): Color3;
  3705. /**
  3706. * Converts current color in rgb space to HSV values
  3707. * @returns a new color3 representing the HSV values
  3708. */
  3709. toHSV(): Color3;
  3710. /**
  3711. * Converts current color in rgb space to HSV values
  3712. * @param result defines the Color3 where to store the HSV values
  3713. */
  3714. toHSVToRef(result: Color3): void;
  3715. /**
  3716. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3717. * @param convertedColor defines the Color3 object where to store the linear space version
  3718. * @returns the unmodified Color3
  3719. */
  3720. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3721. /**
  3722. * Computes a new Color3 converted from the current one to gamma space
  3723. * @returns a new Color3 object
  3724. */
  3725. toGammaSpace(): Color3;
  3726. /**
  3727. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3728. * @param convertedColor defines the Color3 object where to store the gamma space version
  3729. * @returns the unmodified Color3
  3730. */
  3731. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3732. private static _BlackReadOnly;
  3733. /**
  3734. * Convert Hue, saturation and value to a Color3 (RGB)
  3735. * @param hue defines the hue
  3736. * @param saturation defines the saturation
  3737. * @param value defines the value
  3738. * @param result defines the Color3 where to store the RGB values
  3739. */
  3740. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3741. /**
  3742. * Creates a new Color3 from the string containing valid hexadecimal values
  3743. * @param hex defines a string containing valid hexadecimal values
  3744. * @returns a new Color3 object
  3745. */
  3746. static FromHexString(hex: string): Color3;
  3747. /**
  3748. * Creates a new Color3 from the starting index of the given array
  3749. * @param array defines the source array
  3750. * @param offset defines an offset in the source array
  3751. * @returns a new Color3 object
  3752. */
  3753. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3754. /**
  3755. * Creates a new Color3 from integer values (< 256)
  3756. * @param r defines the red component to read from (value between 0 and 255)
  3757. * @param g defines the green component to read from (value between 0 and 255)
  3758. * @param b defines the blue component to read from (value between 0 and 255)
  3759. * @returns a new Color3 object
  3760. */
  3761. static FromInts(r: number, g: number, b: number): Color3;
  3762. /**
  3763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3764. * @param start defines the start Color3 value
  3765. * @param end defines the end Color3 value
  3766. * @param amount defines the gradient value between start and end
  3767. * @returns a new Color3 object
  3768. */
  3769. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3770. /**
  3771. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3772. * @param left defines the start value
  3773. * @param right defines the end value
  3774. * @param amount defines the gradient factor
  3775. * @param result defines the Color3 object where to store the result
  3776. */
  3777. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3778. /**
  3779. * Returns a Color3 value containing a red color
  3780. * @returns a new Color3 object
  3781. */
  3782. static Red(): Color3;
  3783. /**
  3784. * Returns a Color3 value containing a green color
  3785. * @returns a new Color3 object
  3786. */
  3787. static Green(): Color3;
  3788. /**
  3789. * Returns a Color3 value containing a blue color
  3790. * @returns a new Color3 object
  3791. */
  3792. static Blue(): Color3;
  3793. /**
  3794. * Returns a Color3 value containing a black color
  3795. * @returns a new Color3 object
  3796. */
  3797. static Black(): Color3;
  3798. /**
  3799. * Gets a Color3 value containing a black color that must not be updated
  3800. */
  3801. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3802. /**
  3803. * Returns a Color3 value containing a white color
  3804. * @returns a new Color3 object
  3805. */
  3806. static White(): Color3;
  3807. /**
  3808. * Returns a Color3 value containing a purple color
  3809. * @returns a new Color3 object
  3810. */
  3811. static Purple(): Color3;
  3812. /**
  3813. * Returns a Color3 value containing a magenta color
  3814. * @returns a new Color3 object
  3815. */
  3816. static Magenta(): Color3;
  3817. /**
  3818. * Returns a Color3 value containing a yellow color
  3819. * @returns a new Color3 object
  3820. */
  3821. static Yellow(): Color3;
  3822. /**
  3823. * Returns a Color3 value containing a gray color
  3824. * @returns a new Color3 object
  3825. */
  3826. static Gray(): Color3;
  3827. /**
  3828. * Returns a Color3 value containing a teal color
  3829. * @returns a new Color3 object
  3830. */
  3831. static Teal(): Color3;
  3832. /**
  3833. * Returns a Color3 value containing a random color
  3834. * @returns a new Color3 object
  3835. */
  3836. static Random(): Color3;
  3837. }
  3838. /**
  3839. * Class used to hold a RBGA color
  3840. */
  3841. export class Color4 {
  3842. /**
  3843. * Defines the red component (between 0 and 1, default is 0)
  3844. */
  3845. r: number;
  3846. /**
  3847. * Defines the green component (between 0 and 1, default is 0)
  3848. */
  3849. g: number;
  3850. /**
  3851. * Defines the blue component (between 0 and 1, default is 0)
  3852. */
  3853. b: number;
  3854. /**
  3855. * Defines the alpha component (between 0 and 1, default is 1)
  3856. */
  3857. a: number;
  3858. /**
  3859. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3860. * @param r defines the red component (between 0 and 1, default is 0)
  3861. * @param g defines the green component (between 0 and 1, default is 0)
  3862. * @param b defines the blue component (between 0 and 1, default is 0)
  3863. * @param a defines the alpha component (between 0 and 1, default is 1)
  3864. */
  3865. constructor(
  3866. /**
  3867. * Defines the red component (between 0 and 1, default is 0)
  3868. */
  3869. r?: number,
  3870. /**
  3871. * Defines the green component (between 0 and 1, default is 0)
  3872. */
  3873. g?: number,
  3874. /**
  3875. * Defines the blue component (between 0 and 1, default is 0)
  3876. */
  3877. b?: number,
  3878. /**
  3879. * Defines the alpha component (between 0 and 1, default is 1)
  3880. */
  3881. a?: number);
  3882. /**
  3883. * Adds in place the given Color4 values to the current Color4 object
  3884. * @param right defines the second operand
  3885. * @returns the current updated Color4 object
  3886. */
  3887. addInPlace(right: DeepImmutable<Color4>): Color4;
  3888. /**
  3889. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3890. * @returns the new array
  3891. */
  3892. asArray(): number[];
  3893. /**
  3894. * Stores from the starting index in the given array the Color4 successive values
  3895. * @param array defines the array where to store the r,g,b components
  3896. * @param index defines an optional index in the target array to define where to start storing values
  3897. * @returns the current Color4 object
  3898. */
  3899. toArray(array: number[], index?: number): Color4;
  3900. /**
  3901. * Determines equality between Color4 objects
  3902. * @param otherColor defines the second operand
  3903. * @returns true if the rgba values are equal to the given ones
  3904. */
  3905. equals(otherColor: DeepImmutable<Color4>): boolean;
  3906. /**
  3907. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3908. * @param right defines the second operand
  3909. * @returns a new Color4 object
  3910. */
  3911. add(right: DeepImmutable<Color4>): Color4;
  3912. /**
  3913. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3914. * @param right defines the second operand
  3915. * @returns a new Color4 object
  3916. */
  3917. subtract(right: DeepImmutable<Color4>): Color4;
  3918. /**
  3919. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3920. * @param right defines the second operand
  3921. * @param result defines the Color4 object where to store the result
  3922. * @returns the current Color4 object
  3923. */
  3924. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3925. /**
  3926. * Creates a new Color4 with the current Color4 values multiplied by scale
  3927. * @param scale defines the scaling factor to apply
  3928. * @returns a new Color4 object
  3929. */
  3930. scale(scale: number): Color4;
  3931. /**
  3932. * Multiplies the current Color4 values by scale and stores the result in "result"
  3933. * @param scale defines the scaling factor to apply
  3934. * @param result defines the Color4 object where to store the result
  3935. * @returns the current unmodified Color4
  3936. */
  3937. scaleToRef(scale: number, result: Color4): Color4;
  3938. /**
  3939. * Scale the current Color4 values by a factor and add the result to a given Color4
  3940. * @param scale defines the scale factor
  3941. * @param result defines the Color4 object where to store the result
  3942. * @returns the unmodified current Color4
  3943. */
  3944. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3945. /**
  3946. * Clamps the rgb values by the min and max values and stores the result into "result"
  3947. * @param min defines minimum clamping value (default is 0)
  3948. * @param max defines maximum clamping value (default is 1)
  3949. * @param result defines color to store the result into.
  3950. * @returns the cuurent Color4
  3951. */
  3952. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3953. /**
  3954. * Multipy an Color4 value by another and return a new Color4 object
  3955. * @param color defines the Color4 value to multiply by
  3956. * @returns a new Color4 object
  3957. */
  3958. multiply(color: Color4): Color4;
  3959. /**
  3960. * Multipy a Color4 value by another and push the result in a reference value
  3961. * @param color defines the Color4 value to multiply by
  3962. * @param result defines the Color4 to fill the result in
  3963. * @returns the result Color4
  3964. */
  3965. multiplyToRef(color: Color4, result: Color4): Color4;
  3966. /**
  3967. * Creates a string with the Color4 current values
  3968. * @returns the string representation of the Color4 object
  3969. */
  3970. toString(): string;
  3971. /**
  3972. * Returns the string "Color4"
  3973. * @returns "Color4"
  3974. */
  3975. getClassName(): string;
  3976. /**
  3977. * Compute the Color4 hash code
  3978. * @returns an unique number that can be used to hash Color4 objects
  3979. */
  3980. getHashCode(): number;
  3981. /**
  3982. * Creates a new Color4 copied from the current one
  3983. * @returns a new Color4 object
  3984. */
  3985. clone(): Color4;
  3986. /**
  3987. * Copies the given Color4 values into the current one
  3988. * @param source defines the source Color4 object
  3989. * @returns the current updated Color4 object
  3990. */
  3991. copyFrom(source: Color4): Color4;
  3992. /**
  3993. * Copies the given float values into the current one
  3994. * @param r defines the red component to read from
  3995. * @param g defines the green component to read from
  3996. * @param b defines the blue component to read from
  3997. * @param a defines the alpha component to read from
  3998. * @returns the current updated Color4 object
  3999. */
  4000. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4001. /**
  4002. * Copies the given float values into the current one
  4003. * @param r defines the red component to read from
  4004. * @param g defines the green component to read from
  4005. * @param b defines the blue component to read from
  4006. * @param a defines the alpha component to read from
  4007. * @returns the current updated Color4 object
  4008. */
  4009. set(r: number, g: number, b: number, a: number): Color4;
  4010. /**
  4011. * Compute the Color4 hexadecimal code as a string
  4012. * @returns a string containing the hexadecimal representation of the Color4 object
  4013. */
  4014. toHexString(): string;
  4015. /**
  4016. * Computes a new Color4 converted from the current one to linear space
  4017. * @returns a new Color4 object
  4018. */
  4019. toLinearSpace(): Color4;
  4020. /**
  4021. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4022. * @param convertedColor defines the Color4 object where to store the linear space version
  4023. * @returns the unmodified Color4
  4024. */
  4025. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4026. /**
  4027. * Computes a new Color4 converted from the current one to gamma space
  4028. * @returns a new Color4 object
  4029. */
  4030. toGammaSpace(): Color4;
  4031. /**
  4032. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4033. * @param convertedColor defines the Color4 object where to store the gamma space version
  4034. * @returns the unmodified Color4
  4035. */
  4036. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4037. /**
  4038. * Creates a new Color4 from the string containing valid hexadecimal values
  4039. * @param hex defines a string containing valid hexadecimal values
  4040. * @returns a new Color4 object
  4041. */
  4042. static FromHexString(hex: string): Color4;
  4043. /**
  4044. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4045. * @param left defines the start value
  4046. * @param right defines the end value
  4047. * @param amount defines the gradient factor
  4048. * @returns a new Color4 object
  4049. */
  4050. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4051. /**
  4052. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4053. * @param left defines the start value
  4054. * @param right defines the end value
  4055. * @param amount defines the gradient factor
  4056. * @param result defines the Color4 object where to store data
  4057. */
  4058. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4059. /**
  4060. * Creates a new Color4 from a Color3 and an alpha value
  4061. * @param color3 defines the source Color3 to read from
  4062. * @param alpha defines the alpha component (1.0 by default)
  4063. * @returns a new Color4 object
  4064. */
  4065. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4066. /**
  4067. * Creates a new Color4 from the starting index element of the given array
  4068. * @param array defines the source array to read from
  4069. * @param offset defines the offset in the source array
  4070. * @returns a new Color4 object
  4071. */
  4072. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4073. /**
  4074. * Creates a new Color3 from integer values (< 256)
  4075. * @param r defines the red component to read from (value between 0 and 255)
  4076. * @param g defines the green component to read from (value between 0 and 255)
  4077. * @param b defines the blue component to read from (value between 0 and 255)
  4078. * @param a defines the alpha component to read from (value between 0 and 255)
  4079. * @returns a new Color3 object
  4080. */
  4081. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4082. /**
  4083. * Check the content of a given array and convert it to an array containing RGBA data
  4084. * If the original array was already containing count * 4 values then it is returned directly
  4085. * @param colors defines the array to check
  4086. * @param count defines the number of RGBA data to expect
  4087. * @returns an array containing count * 4 values (RGBA)
  4088. */
  4089. static CheckColors4(colors: number[], count: number): number[];
  4090. }
  4091. /**
  4092. * @hidden
  4093. */
  4094. export class TmpColors {
  4095. static Color3: Color3[];
  4096. static Color4: Color4[];
  4097. }
  4098. }
  4099. declare module "babylonjs/Maths/sphericalPolynomial" {
  4100. import { Vector3 } from "babylonjs/Maths/math.vector";
  4101. import { Color3 } from "babylonjs/Maths/math.color";
  4102. /**
  4103. * Class representing spherical harmonics coefficients to the 3rd degree
  4104. */
  4105. export class SphericalHarmonics {
  4106. /**
  4107. * Defines whether or not the harmonics have been prescaled for rendering.
  4108. */
  4109. preScaled: boolean;
  4110. /**
  4111. * The l0,0 coefficients of the spherical harmonics
  4112. */
  4113. l00: Vector3;
  4114. /**
  4115. * The l1,-1 coefficients of the spherical harmonics
  4116. */
  4117. l1_1: Vector3;
  4118. /**
  4119. * The l1,0 coefficients of the spherical harmonics
  4120. */
  4121. l10: Vector3;
  4122. /**
  4123. * The l1,1 coefficients of the spherical harmonics
  4124. */
  4125. l11: Vector3;
  4126. /**
  4127. * The l2,-2 coefficients of the spherical harmonics
  4128. */
  4129. l2_2: Vector3;
  4130. /**
  4131. * The l2,-1 coefficients of the spherical harmonics
  4132. */
  4133. l2_1: Vector3;
  4134. /**
  4135. * The l2,0 coefficients of the spherical harmonics
  4136. */
  4137. l20: Vector3;
  4138. /**
  4139. * The l2,1 coefficients of the spherical harmonics
  4140. */
  4141. l21: Vector3;
  4142. /**
  4143. * The l2,2 coefficients of the spherical harmonics
  4144. */
  4145. l22: Vector3;
  4146. /**
  4147. * Adds a light to the spherical harmonics
  4148. * @param direction the direction of the light
  4149. * @param color the color of the light
  4150. * @param deltaSolidAngle the delta solid angle of the light
  4151. */
  4152. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4153. /**
  4154. * Scales the spherical harmonics by the given amount
  4155. * @param scale the amount to scale
  4156. */
  4157. scaleInPlace(scale: number): void;
  4158. /**
  4159. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4160. *
  4161. * ```
  4162. * E_lm = A_l * L_lm
  4163. * ```
  4164. *
  4165. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4166. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4167. * the scaling factors are given in equation 9.
  4168. */
  4169. convertIncidentRadianceToIrradiance(): void;
  4170. /**
  4171. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4172. *
  4173. * ```
  4174. * L = (1/pi) * E * rho
  4175. * ```
  4176. *
  4177. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4178. */
  4179. convertIrradianceToLambertianRadiance(): void;
  4180. /**
  4181. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4182. * required operations at run time.
  4183. *
  4184. * This is simply done by scaling back the SH with Ylm constants parameter.
  4185. * The trigonometric part being applied by the shader at run time.
  4186. */
  4187. preScaleForRendering(): void;
  4188. /**
  4189. * Constructs a spherical harmonics from an array.
  4190. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4191. * @returns the spherical harmonics
  4192. */
  4193. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4194. /**
  4195. * Gets the spherical harmonics from polynomial
  4196. * @param polynomial the spherical polynomial
  4197. * @returns the spherical harmonics
  4198. */
  4199. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4200. }
  4201. /**
  4202. * Class representing spherical polynomial coefficients to the 3rd degree
  4203. */
  4204. export class SphericalPolynomial {
  4205. private _harmonics;
  4206. /**
  4207. * The spherical harmonics used to create the polynomials.
  4208. */
  4209. readonly preScaledHarmonics: SphericalHarmonics;
  4210. /**
  4211. * The x coefficients of the spherical polynomial
  4212. */
  4213. x: Vector3;
  4214. /**
  4215. * The y coefficients of the spherical polynomial
  4216. */
  4217. y: Vector3;
  4218. /**
  4219. * The z coefficients of the spherical polynomial
  4220. */
  4221. z: Vector3;
  4222. /**
  4223. * The xx coefficients of the spherical polynomial
  4224. */
  4225. xx: Vector3;
  4226. /**
  4227. * The yy coefficients of the spherical polynomial
  4228. */
  4229. yy: Vector3;
  4230. /**
  4231. * The zz coefficients of the spherical polynomial
  4232. */
  4233. zz: Vector3;
  4234. /**
  4235. * The xy coefficients of the spherical polynomial
  4236. */
  4237. xy: Vector3;
  4238. /**
  4239. * The yz coefficients of the spherical polynomial
  4240. */
  4241. yz: Vector3;
  4242. /**
  4243. * The zx coefficients of the spherical polynomial
  4244. */
  4245. zx: Vector3;
  4246. /**
  4247. * Adds an ambient color to the spherical polynomial
  4248. * @param color the color to add
  4249. */
  4250. addAmbient(color: Color3): void;
  4251. /**
  4252. * Scales the spherical polynomial by the given amount
  4253. * @param scale the amount to scale
  4254. */
  4255. scaleInPlace(scale: number): void;
  4256. /**
  4257. * Gets the spherical polynomial from harmonics
  4258. * @param harmonics the spherical harmonics
  4259. * @returns the spherical polynomial
  4260. */
  4261. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4262. /**
  4263. * Constructs a spherical polynomial from an array.
  4264. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4265. * @returns the spherical polynomial
  4266. */
  4267. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4268. }
  4269. }
  4270. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  4271. /**
  4272. * Define options used to create a render target texture
  4273. */
  4274. export class RenderTargetCreationOptions {
  4275. /**
  4276. * Specifies is mipmaps must be generated
  4277. */
  4278. generateMipMaps?: boolean;
  4279. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4280. generateDepthBuffer?: boolean;
  4281. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4282. generateStencilBuffer?: boolean;
  4283. /** Defines texture type (int by default) */
  4284. type?: number;
  4285. /** Defines sampling mode (trilinear by default) */
  4286. samplingMode?: number;
  4287. /** Defines format (RGBA by default) */
  4288. format?: number;
  4289. }
  4290. }
  4291. declare module "babylonjs/Instrumentation/timeToken" {
  4292. import { Nullable } from "babylonjs/types";
  4293. /**
  4294. * @hidden
  4295. **/
  4296. export class _TimeToken {
  4297. _startTimeQuery: Nullable<WebGLQuery>;
  4298. _endTimeQuery: Nullable<WebGLQuery>;
  4299. _timeElapsedQuery: Nullable<WebGLQuery>;
  4300. _timeElapsedQueryEnded: boolean;
  4301. }
  4302. }
  4303. declare module "babylonjs/Engines/constants" {
  4304. /** Defines the cross module used constants to avoid circular dependncies */
  4305. export class Constants {
  4306. /** Defines that alpha blending is disabled */
  4307. static readonly ALPHA_DISABLE: number;
  4308. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4309. static readonly ALPHA_ADD: number;
  4310. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4311. static readonly ALPHA_COMBINE: number;
  4312. /** Defines that alpha blending to DEST - SRC * DEST */
  4313. static readonly ALPHA_SUBTRACT: number;
  4314. /** Defines that alpha blending to SRC * DEST */
  4315. static readonly ALPHA_MULTIPLY: number;
  4316. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4317. static readonly ALPHA_MAXIMIZED: number;
  4318. /** Defines that alpha blending to SRC + DEST */
  4319. static readonly ALPHA_ONEONE: number;
  4320. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4321. static readonly ALPHA_PREMULTIPLIED: number;
  4322. /**
  4323. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4324. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4325. */
  4326. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4327. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4328. static readonly ALPHA_INTERPOLATE: number;
  4329. /**
  4330. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4331. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4332. */
  4333. static readonly ALPHA_SCREENMODE: number;
  4334. /**
  4335. * Defines that alpha blending to SRC + DST
  4336. * Alpha will be set to SRC ALPHA + DST ALPHA
  4337. */
  4338. static readonly ALPHA_ONEONE_ONEONE: number;
  4339. /**
  4340. * Defines that alpha blending to SRC * DST ALPHA + DST
  4341. * Alpha will be set to 0
  4342. */
  4343. static readonly ALPHA_ALPHATOCOLOR: number;
  4344. /**
  4345. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4346. */
  4347. static readonly ALPHA_REVERSEONEMINUS: number;
  4348. /**
  4349. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4350. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4351. */
  4352. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4353. /**
  4354. * Defines that alpha blending to SRC + DST
  4355. * Alpha will be set to SRC ALPHA
  4356. */
  4357. static readonly ALPHA_ONEONE_ONEZERO: number;
  4358. /** Defines that alpha blending equation a SUM */
  4359. static readonly ALPHA_EQUATION_ADD: number;
  4360. /** Defines that alpha blending equation a SUBSTRACTION */
  4361. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4362. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4363. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4364. /** Defines that alpha blending equation a MAX operation */
  4365. static readonly ALPHA_EQUATION_MAX: number;
  4366. /** Defines that alpha blending equation a MIN operation */
  4367. static readonly ALPHA_EQUATION_MIN: number;
  4368. /**
  4369. * Defines that alpha blending equation a DARKEN operation:
  4370. * It takes the min of the src and sums the alpha channels.
  4371. */
  4372. static readonly ALPHA_EQUATION_DARKEN: number;
  4373. /** Defines that the ressource is not delayed*/
  4374. static readonly DELAYLOADSTATE_NONE: number;
  4375. /** Defines that the ressource was successfully delay loaded */
  4376. static readonly DELAYLOADSTATE_LOADED: number;
  4377. /** Defines that the ressource is currently delay loading */
  4378. static readonly DELAYLOADSTATE_LOADING: number;
  4379. /** Defines that the ressource is delayed and has not started loading */
  4380. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4381. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4382. static readonly NEVER: number;
  4383. /** 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 */
  4384. static readonly ALWAYS: number;
  4385. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4386. static readonly LESS: number;
  4387. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4388. static readonly EQUAL: number;
  4389. /** 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 */
  4390. static readonly LEQUAL: number;
  4391. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4392. static readonly GREATER: number;
  4393. /** 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 */
  4394. static readonly GEQUAL: number;
  4395. /** 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 */
  4396. static readonly NOTEQUAL: number;
  4397. /** Passed to stencilOperation to specify that stencil value must be kept */
  4398. static readonly KEEP: number;
  4399. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4400. static readonly REPLACE: number;
  4401. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4402. static readonly INCR: number;
  4403. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4404. static readonly DECR: number;
  4405. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4406. static readonly INVERT: number;
  4407. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4408. static readonly INCR_WRAP: number;
  4409. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4410. static readonly DECR_WRAP: number;
  4411. /** Texture is not repeating outside of 0..1 UVs */
  4412. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4413. /** Texture is repeating outside of 0..1 UVs */
  4414. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4415. /** Texture is repeating and mirrored */
  4416. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4417. /** ALPHA */
  4418. static readonly TEXTUREFORMAT_ALPHA: number;
  4419. /** LUMINANCE */
  4420. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4421. /** LUMINANCE_ALPHA */
  4422. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4423. /** RGB */
  4424. static readonly TEXTUREFORMAT_RGB: number;
  4425. /** RGBA */
  4426. static readonly TEXTUREFORMAT_RGBA: number;
  4427. /** RED */
  4428. static readonly TEXTUREFORMAT_RED: number;
  4429. /** RED (2nd reference) */
  4430. static readonly TEXTUREFORMAT_R: number;
  4431. /** RG */
  4432. static readonly TEXTUREFORMAT_RG: number;
  4433. /** RED_INTEGER */
  4434. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4435. /** RED_INTEGER (2nd reference) */
  4436. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4437. /** RG_INTEGER */
  4438. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4439. /** RGB_INTEGER */
  4440. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4441. /** RGBA_INTEGER */
  4442. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4443. /** UNSIGNED_BYTE */
  4444. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4445. /** UNSIGNED_BYTE (2nd reference) */
  4446. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4447. /** FLOAT */
  4448. static readonly TEXTURETYPE_FLOAT: number;
  4449. /** HALF_FLOAT */
  4450. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4451. /** BYTE */
  4452. static readonly TEXTURETYPE_BYTE: number;
  4453. /** SHORT */
  4454. static readonly TEXTURETYPE_SHORT: number;
  4455. /** UNSIGNED_SHORT */
  4456. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4457. /** INT */
  4458. static readonly TEXTURETYPE_INT: number;
  4459. /** UNSIGNED_INT */
  4460. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4461. /** UNSIGNED_SHORT_4_4_4_4 */
  4462. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4463. /** UNSIGNED_SHORT_5_5_5_1 */
  4464. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4465. /** UNSIGNED_SHORT_5_6_5 */
  4466. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4467. /** UNSIGNED_INT_2_10_10_10_REV */
  4468. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4469. /** UNSIGNED_INT_24_8 */
  4470. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4471. /** UNSIGNED_INT_10F_11F_11F_REV */
  4472. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4473. /** UNSIGNED_INT_5_9_9_9_REV */
  4474. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4475. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4476. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4477. /** nearest is mag = nearest and min = nearest and mip = linear */
  4478. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4479. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4480. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4481. /** Trilinear is mag = linear and min = linear and mip = linear */
  4482. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4483. /** nearest is mag = nearest and min = nearest and mip = linear */
  4484. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4485. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4486. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4487. /** Trilinear is mag = linear and min = linear and mip = linear */
  4488. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4489. /** mag = nearest and min = nearest and mip = nearest */
  4490. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4491. /** mag = nearest and min = linear and mip = nearest */
  4492. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4493. /** mag = nearest and min = linear and mip = linear */
  4494. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4495. /** mag = nearest and min = linear and mip = none */
  4496. static readonly TEXTURE_NEAREST_LINEAR: number;
  4497. /** mag = nearest and min = nearest and mip = none */
  4498. static readonly TEXTURE_NEAREST_NEAREST: number;
  4499. /** mag = linear and min = nearest and mip = nearest */
  4500. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4501. /** mag = linear and min = nearest and mip = linear */
  4502. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4503. /** mag = linear and min = linear and mip = none */
  4504. static readonly TEXTURE_LINEAR_LINEAR: number;
  4505. /** mag = linear and min = nearest and mip = none */
  4506. static readonly TEXTURE_LINEAR_NEAREST: number;
  4507. /** Explicit coordinates mode */
  4508. static readonly TEXTURE_EXPLICIT_MODE: number;
  4509. /** Spherical coordinates mode */
  4510. static readonly TEXTURE_SPHERICAL_MODE: number;
  4511. /** Planar coordinates mode */
  4512. static readonly TEXTURE_PLANAR_MODE: number;
  4513. /** Cubic coordinates mode */
  4514. static readonly TEXTURE_CUBIC_MODE: number;
  4515. /** Projection coordinates mode */
  4516. static readonly TEXTURE_PROJECTION_MODE: number;
  4517. /** Skybox coordinates mode */
  4518. static readonly TEXTURE_SKYBOX_MODE: number;
  4519. /** Inverse Cubic coordinates mode */
  4520. static readonly TEXTURE_INVCUBIC_MODE: number;
  4521. /** Equirectangular coordinates mode */
  4522. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4523. /** Equirectangular Fixed coordinates mode */
  4524. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4525. /** Equirectangular Fixed Mirrored coordinates mode */
  4526. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4527. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4528. static readonly SCALEMODE_FLOOR: number;
  4529. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4530. static readonly SCALEMODE_NEAREST: number;
  4531. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4532. static readonly SCALEMODE_CEILING: number;
  4533. /**
  4534. * The dirty texture flag value
  4535. */
  4536. static readonly MATERIAL_TextureDirtyFlag: number;
  4537. /**
  4538. * The dirty light flag value
  4539. */
  4540. static readonly MATERIAL_LightDirtyFlag: number;
  4541. /**
  4542. * The dirty fresnel flag value
  4543. */
  4544. static readonly MATERIAL_FresnelDirtyFlag: number;
  4545. /**
  4546. * The dirty attribute flag value
  4547. */
  4548. static readonly MATERIAL_AttributesDirtyFlag: number;
  4549. /**
  4550. * The dirty misc flag value
  4551. */
  4552. static readonly MATERIAL_MiscDirtyFlag: number;
  4553. /**
  4554. * The all dirty flag value
  4555. */
  4556. static readonly MATERIAL_AllDirtyFlag: number;
  4557. /**
  4558. * Returns the triangle fill mode
  4559. */
  4560. static readonly MATERIAL_TriangleFillMode: number;
  4561. /**
  4562. * Returns the wireframe mode
  4563. */
  4564. static readonly MATERIAL_WireFrameFillMode: number;
  4565. /**
  4566. * Returns the point fill mode
  4567. */
  4568. static readonly MATERIAL_PointFillMode: number;
  4569. /**
  4570. * Returns the point list draw mode
  4571. */
  4572. static readonly MATERIAL_PointListDrawMode: number;
  4573. /**
  4574. * Returns the line list draw mode
  4575. */
  4576. static readonly MATERIAL_LineListDrawMode: number;
  4577. /**
  4578. * Returns the line loop draw mode
  4579. */
  4580. static readonly MATERIAL_LineLoopDrawMode: number;
  4581. /**
  4582. * Returns the line strip draw mode
  4583. */
  4584. static readonly MATERIAL_LineStripDrawMode: number;
  4585. /**
  4586. * Returns the triangle strip draw mode
  4587. */
  4588. static readonly MATERIAL_TriangleStripDrawMode: number;
  4589. /**
  4590. * Returns the triangle fan draw mode
  4591. */
  4592. static readonly MATERIAL_TriangleFanDrawMode: number;
  4593. /**
  4594. * Stores the clock-wise side orientation
  4595. */
  4596. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4597. /**
  4598. * Stores the counter clock-wise side orientation
  4599. */
  4600. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4601. /**
  4602. * Nothing
  4603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4604. */
  4605. static readonly ACTION_NothingTrigger: number;
  4606. /**
  4607. * On pick
  4608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4609. */
  4610. static readonly ACTION_OnPickTrigger: number;
  4611. /**
  4612. * On left pick
  4613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4614. */
  4615. static readonly ACTION_OnLeftPickTrigger: number;
  4616. /**
  4617. * On right pick
  4618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4619. */
  4620. static readonly ACTION_OnRightPickTrigger: number;
  4621. /**
  4622. * On center pick
  4623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4624. */
  4625. static readonly ACTION_OnCenterPickTrigger: number;
  4626. /**
  4627. * On pick down
  4628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4629. */
  4630. static readonly ACTION_OnPickDownTrigger: number;
  4631. /**
  4632. * On double pick
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnDoublePickTrigger: number;
  4636. /**
  4637. * On pick up
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnPickUpTrigger: number;
  4641. /**
  4642. * On pick out.
  4643. * This trigger will only be raised if you also declared a OnPickDown
  4644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4645. */
  4646. static readonly ACTION_OnPickOutTrigger: number;
  4647. /**
  4648. * On long press
  4649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4650. */
  4651. static readonly ACTION_OnLongPressTrigger: number;
  4652. /**
  4653. * On pointer over
  4654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4655. */
  4656. static readonly ACTION_OnPointerOverTrigger: number;
  4657. /**
  4658. * On pointer out
  4659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4660. */
  4661. static readonly ACTION_OnPointerOutTrigger: number;
  4662. /**
  4663. * On every frame
  4664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4665. */
  4666. static readonly ACTION_OnEveryFrameTrigger: number;
  4667. /**
  4668. * On intersection enter
  4669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4670. */
  4671. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4672. /**
  4673. * On intersection exit
  4674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4675. */
  4676. static readonly ACTION_OnIntersectionExitTrigger: number;
  4677. /**
  4678. * On key down
  4679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4680. */
  4681. static readonly ACTION_OnKeyDownTrigger: number;
  4682. /**
  4683. * On key up
  4684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4685. */
  4686. static readonly ACTION_OnKeyUpTrigger: number;
  4687. /**
  4688. * Billboard mode will only apply to Y axis
  4689. */
  4690. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4691. /**
  4692. * Billboard mode will apply to all axes
  4693. */
  4694. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4695. /**
  4696. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4697. */
  4698. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4699. /**
  4700. * Gets or sets base Assets URL
  4701. */
  4702. static PARTICLES_BaseAssetsUrl: string;
  4703. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4704. * Test order :
  4705. * Is the bounding sphere outside the frustum ?
  4706. * If not, are the bounding box vertices outside the frustum ?
  4707. * It not, then the cullable object is in the frustum.
  4708. */
  4709. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4710. /** Culling strategy : Bounding Sphere Only.
  4711. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4712. * It's also less accurate than the standard because some not visible objects can still be selected.
  4713. * Test : is the bounding sphere outside the frustum ?
  4714. * If not, then the cullable object is in the frustum.
  4715. */
  4716. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4717. /** Culling strategy : Optimistic Inclusion.
  4718. * This in an inclusion test first, then the standard exclusion test.
  4719. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4720. * 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.
  4721. * Anyway, it's as accurate as the standard strategy.
  4722. * Test :
  4723. * Is the cullable object bounding sphere center in the frustum ?
  4724. * If not, apply the default culling strategy.
  4725. */
  4726. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4727. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4728. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4729. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4730. * 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.
  4731. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4732. * Test :
  4733. * Is the cullable object bounding sphere center in the frustum ?
  4734. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4735. */
  4736. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4737. /**
  4738. * No logging while loading
  4739. */
  4740. static readonly SCENELOADER_NO_LOGGING: number;
  4741. /**
  4742. * Minimal logging while loading
  4743. */
  4744. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4745. /**
  4746. * Summary logging while loading
  4747. */
  4748. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4749. /**
  4750. * Detailled logging while loading
  4751. */
  4752. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4753. }
  4754. }
  4755. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  4756. import { Nullable } from "babylonjs/types";
  4757. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  4758. /**
  4759. * This represents the required contract to create a new type of texture loader.
  4760. */
  4761. export interface IInternalTextureLoader {
  4762. /**
  4763. * Defines wether the loader supports cascade loading the different faces.
  4764. */
  4765. supportCascades: boolean;
  4766. /**
  4767. * This returns if the loader support the current file information.
  4768. * @param extension defines the file extension of the file being loaded
  4769. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4770. * @param fallback defines the fallback internal texture if any
  4771. * @param isBase64 defines whether the texture is encoded as a base64
  4772. * @param isBuffer defines whether the texture data are stored as a buffer
  4773. * @returns true if the loader can load the specified file
  4774. */
  4775. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4776. /**
  4777. * Transform the url before loading if required.
  4778. * @param rootUrl the url of the texture
  4779. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4780. * @returns the transformed texture
  4781. */
  4782. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4783. /**
  4784. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4785. * @param rootUrl the url of the texture
  4786. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4787. * @returns the fallback texture
  4788. */
  4789. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4790. /**
  4791. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4792. * @param data contains the texture data
  4793. * @param texture defines the BabylonJS internal texture
  4794. * @param createPolynomials will be true if polynomials have been requested
  4795. * @param onLoad defines the callback to trigger once the texture is ready
  4796. * @param onError defines the callback to trigger in case of error
  4797. */
  4798. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4799. /**
  4800. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4801. * @param data contains the texture data
  4802. * @param texture defines the BabylonJS internal texture
  4803. * @param callback defines the method to call once ready to upload
  4804. */
  4805. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4806. }
  4807. }
  4808. declare module "babylonjs/Engines/IPipelineContext" {
  4809. /**
  4810. * Class used to store and describe the pipeline context associated with an effect
  4811. */
  4812. export interface IPipelineContext {
  4813. /**
  4814. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4815. */
  4816. isAsync: boolean;
  4817. /**
  4818. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4819. */
  4820. isReady: boolean;
  4821. /** @hidden */
  4822. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4823. }
  4824. }
  4825. declare module "babylonjs/Meshes/dataBuffer" {
  4826. /**
  4827. * Class used to store gfx data (like WebGLBuffer)
  4828. */
  4829. export class DataBuffer {
  4830. /**
  4831. * Gets or sets the number of objects referencing this buffer
  4832. */
  4833. references: number;
  4834. /** Gets or sets the size of the underlying buffer */
  4835. capacity: number;
  4836. /**
  4837. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4838. */
  4839. is32Bits: boolean;
  4840. /**
  4841. * Gets the underlying buffer
  4842. */
  4843. readonly underlyingResource: any;
  4844. }
  4845. }
  4846. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4847. /** @hidden */
  4848. export interface IShaderProcessor {
  4849. attributeProcessor?: (attribute: string) => string;
  4850. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4851. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4852. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4853. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4854. lineProcessor?: (line: string, isFragment: boolean) => string;
  4855. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4856. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4857. }
  4858. }
  4859. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4860. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4861. /** @hidden */
  4862. export interface ProcessingOptions {
  4863. defines: string[];
  4864. indexParameters: any;
  4865. isFragment: boolean;
  4866. shouldUseHighPrecisionShader: boolean;
  4867. supportsUniformBuffers: boolean;
  4868. shadersRepository: string;
  4869. includesShadersStore: {
  4870. [key: string]: string;
  4871. };
  4872. processor?: IShaderProcessor;
  4873. version: string;
  4874. platformName: string;
  4875. lookForClosingBracketForUniformBuffer?: boolean;
  4876. }
  4877. }
  4878. declare module "babylonjs/Misc/stringTools" {
  4879. /**
  4880. * Helper to manipulate strings
  4881. */
  4882. export class StringTools {
  4883. /**
  4884. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4885. * @param str Source string
  4886. * @param suffix Suffix to search for in the source string
  4887. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4888. */
  4889. static EndsWith(str: string, suffix: string): boolean;
  4890. /**
  4891. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4892. * @param str Source string
  4893. * @param suffix Suffix to search for in the source string
  4894. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4895. */
  4896. static StartsWith(str: string, suffix: string): boolean;
  4897. }
  4898. }
  4899. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4900. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4901. /** @hidden */
  4902. export class ShaderCodeNode {
  4903. line: string;
  4904. children: ShaderCodeNode[];
  4905. additionalDefineKey?: string;
  4906. additionalDefineValue?: string;
  4907. isValid(preprocessors: {
  4908. [key: string]: string;
  4909. }): boolean;
  4910. process(preprocessors: {
  4911. [key: string]: string;
  4912. }, options: ProcessingOptions): string;
  4913. }
  4914. }
  4915. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4916. /** @hidden */
  4917. export class ShaderCodeCursor {
  4918. private _lines;
  4919. lineIndex: number;
  4920. readonly currentLine: string;
  4921. readonly canRead: boolean;
  4922. lines: string[];
  4923. }
  4924. }
  4925. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4926. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4927. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4928. /** @hidden */
  4929. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4930. process(preprocessors: {
  4931. [key: string]: string;
  4932. }, options: ProcessingOptions): string;
  4933. }
  4934. }
  4935. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4936. /** @hidden */
  4937. export class ShaderDefineExpression {
  4938. isTrue(preprocessors: {
  4939. [key: string]: string;
  4940. }): boolean;
  4941. }
  4942. }
  4943. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4944. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4945. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4946. /** @hidden */
  4947. export class ShaderCodeTestNode extends ShaderCodeNode {
  4948. testExpression: ShaderDefineExpression;
  4949. isValid(preprocessors: {
  4950. [key: string]: string;
  4951. }): boolean;
  4952. }
  4953. }
  4954. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4955. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4956. /** @hidden */
  4957. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4958. define: string;
  4959. not: boolean;
  4960. constructor(define: string, not?: boolean);
  4961. isTrue(preprocessors: {
  4962. [key: string]: string;
  4963. }): boolean;
  4964. }
  4965. }
  4966. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4967. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4968. /** @hidden */
  4969. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4970. leftOperand: ShaderDefineExpression;
  4971. rightOperand: ShaderDefineExpression;
  4972. isTrue(preprocessors: {
  4973. [key: string]: string;
  4974. }): boolean;
  4975. }
  4976. }
  4977. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4978. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4979. /** @hidden */
  4980. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4981. leftOperand: ShaderDefineExpression;
  4982. rightOperand: ShaderDefineExpression;
  4983. isTrue(preprocessors: {
  4984. [key: string]: string;
  4985. }): boolean;
  4986. }
  4987. }
  4988. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4989. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4990. /** @hidden */
  4991. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4992. define: string;
  4993. operand: string;
  4994. testValue: string;
  4995. constructor(define: string, operand: string, testValue: string);
  4996. isTrue(preprocessors: {
  4997. [key: string]: string;
  4998. }): boolean;
  4999. }
  5000. }
  5001. declare module "babylonjs/Misc/loadFileError" {
  5002. import { WebRequest } from "babylonjs/Misc/webRequest";
  5003. /**
  5004. * @ignore
  5005. * Application error to support additional information when loading a file
  5006. */
  5007. export class LoadFileError extends Error {
  5008. /** defines the optional web request */
  5009. request?: WebRequest | undefined;
  5010. private static _setPrototypeOf;
  5011. /**
  5012. * Creates a new LoadFileError
  5013. * @param message defines the message of the error
  5014. * @param request defines the optional web request
  5015. */
  5016. constructor(message: string,
  5017. /** defines the optional web request */
  5018. request?: WebRequest | undefined);
  5019. }
  5020. }
  5021. declare module "babylonjs/Offline/IOfflineProvider" {
  5022. /**
  5023. * Class used to enable access to offline support
  5024. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5025. */
  5026. export interface IOfflineProvider {
  5027. /**
  5028. * Gets a boolean indicating if scene must be saved in the database
  5029. */
  5030. enableSceneOffline: boolean;
  5031. /**
  5032. * Gets a boolean indicating if textures must be saved in the database
  5033. */
  5034. enableTexturesOffline: boolean;
  5035. /**
  5036. * Open the offline support and make it available
  5037. * @param successCallback defines the callback to call on success
  5038. * @param errorCallback defines the callback to call on error
  5039. */
  5040. open(successCallback: () => void, errorCallback: () => void): void;
  5041. /**
  5042. * Loads an image from the offline support
  5043. * @param url defines the url to load from
  5044. * @param image defines the target DOM image
  5045. */
  5046. loadImage(url: string, image: HTMLImageElement): void;
  5047. /**
  5048. * Loads a file from offline support
  5049. * @param url defines the URL to load from
  5050. * @param sceneLoaded defines a callback to call on success
  5051. * @param progressCallBack defines a callback to call when progress changed
  5052. * @param errorCallback defines a callback to call on error
  5053. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5054. */
  5055. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5056. }
  5057. }
  5058. declare module "babylonjs/Misc/filesInputStore" {
  5059. /**
  5060. * Class used to help managing file picking and drag'n'drop
  5061. * File Storage
  5062. */
  5063. export class FilesInputStore {
  5064. /**
  5065. * List of files ready to be loaded
  5066. */
  5067. static FilesToLoad: {
  5068. [key: string]: File;
  5069. };
  5070. }
  5071. }
  5072. declare module "babylonjs/Misc/retryStrategy" {
  5073. import { WebRequest } from "babylonjs/Misc/webRequest";
  5074. /**
  5075. * Class used to define a retry strategy when error happens while loading assets
  5076. */
  5077. export class RetryStrategy {
  5078. /**
  5079. * Function used to defines an exponential back off strategy
  5080. * @param maxRetries defines the maximum number of retries (3 by default)
  5081. * @param baseInterval defines the interval between retries
  5082. * @returns the strategy function to use
  5083. */
  5084. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/fileTools" {
  5088. import { WebRequest } from "babylonjs/Misc/webRequest";
  5089. import { Nullable } from "babylonjs/types";
  5090. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  5091. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  5092. /**
  5093. * @hidden
  5094. */
  5095. export class FileTools {
  5096. /**
  5097. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5098. */
  5099. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5100. /**
  5101. * Gets or sets the base URL to use to load assets
  5102. */
  5103. static BaseUrl: string;
  5104. /**
  5105. * Default behaviour for cors in the application.
  5106. * It can be a string if the expected behavior is identical in the entire app.
  5107. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5108. */
  5109. static CorsBehavior: string | ((url: string | string[]) => string);
  5110. /**
  5111. * Gets or sets a function used to pre-process url before using them to load assets
  5112. */
  5113. static PreprocessUrl: (url: string) => string;
  5114. /**
  5115. * Removes unwanted characters from an url
  5116. * @param url defines the url to clean
  5117. * @returns the cleaned url
  5118. */
  5119. private static _CleanUrl;
  5120. /**
  5121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5122. * @param url define the url we are trying
  5123. * @param element define the dom element where to configure the cors policy
  5124. */
  5125. static SetCorsBehavior(url: string | string[], element: {
  5126. crossOrigin: string | null;
  5127. }): void;
  5128. /**
  5129. * Loads an image as an HTMLImageElement.
  5130. * @param input url string, ArrayBuffer, or Blob to load
  5131. * @param onLoad callback called when the image successfully loads
  5132. * @param onError callback called when the image fails to load
  5133. * @param offlineProvider offline provider for caching
  5134. * @returns the HTMLImageElement of the loaded image
  5135. */
  5136. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5137. /**
  5138. * Loads a file
  5139. * @param fileToLoad defines the file to load
  5140. * @param callback defines the callback to call when data is loaded
  5141. * @param progressCallBack defines the callback to call during loading process
  5142. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5143. * @returns a file request object
  5144. */
  5145. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5146. /**
  5147. * Loads a file
  5148. * @param url url string, ArrayBuffer, or Blob to load
  5149. * @param onSuccess callback called when the file successfully loads
  5150. * @param onProgress callback called while file is loading (if the server supports this mode)
  5151. * @param offlineProvider defines the offline provider for caching
  5152. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5153. * @param onError callback called when the file fails to load
  5154. * @returns a file request object
  5155. */
  5156. 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;
  5157. /**
  5158. * Checks if the loaded document was accessed via `file:`-Protocol.
  5159. * @returns boolean
  5160. */
  5161. static IsFileURL(): boolean;
  5162. }
  5163. }
  5164. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5165. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5166. /** @hidden */
  5167. export class ShaderProcessor {
  5168. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5169. private static _ProcessPrecision;
  5170. private static _ExtractOperation;
  5171. private static _BuildSubExpression;
  5172. private static _BuildExpression;
  5173. private static _MoveCursorWithinIf;
  5174. private static _MoveCursor;
  5175. private static _EvaluatePreProcessors;
  5176. private static _PreparePreProcessors;
  5177. private static _ProcessShaderConversion;
  5178. private static _ProcessIncludes;
  5179. }
  5180. }
  5181. declare module "babylonjs/Materials/iEffectFallbacks" {
  5182. import { Effect } from "babylonjs/Materials/effect";
  5183. /**
  5184. * Interface used to define common properties for effect fallbacks
  5185. */
  5186. export interface IEffectFallbacks {
  5187. /**
  5188. * Removes the defines that should be removed when falling back.
  5189. * @param currentDefines defines the current define statements for the shader.
  5190. * @param effect defines the current effect we try to compile
  5191. * @returns The resulting defines with defines of the current rank removed.
  5192. */
  5193. reduce(currentDefines: string, effect: Effect): string;
  5194. /**
  5195. * Removes the fallback from the bound mesh.
  5196. */
  5197. unBindMesh(): void;
  5198. /**
  5199. * Checks to see if more fallbacks are still availible.
  5200. */
  5201. hasMoreFallbacks: boolean;
  5202. }
  5203. }
  5204. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5205. /**
  5206. * Class used to evalaute queries containing `and` and `or` operators
  5207. */
  5208. export class AndOrNotEvaluator {
  5209. /**
  5210. * Evaluate a query
  5211. * @param query defines the query to evaluate
  5212. * @param evaluateCallback defines the callback used to filter result
  5213. * @returns true if the query matches
  5214. */
  5215. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5216. private static _HandleParenthesisContent;
  5217. private static _SimplifyNegation;
  5218. }
  5219. }
  5220. declare module "babylonjs/Misc/tags" {
  5221. /**
  5222. * Class used to store custom tags
  5223. */
  5224. export class Tags {
  5225. /**
  5226. * Adds support for tags on the given object
  5227. * @param obj defines the object to use
  5228. */
  5229. static EnableFor(obj: any): void;
  5230. /**
  5231. * Removes tags support
  5232. * @param obj defines the object to use
  5233. */
  5234. static DisableFor(obj: any): void;
  5235. /**
  5236. * Gets a boolean indicating if the given object has tags
  5237. * @param obj defines the object to use
  5238. * @returns a boolean
  5239. */
  5240. static HasTags(obj: any): boolean;
  5241. /**
  5242. * Gets the tags available on a given object
  5243. * @param obj defines the object to use
  5244. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5245. * @returns the tags
  5246. */
  5247. static GetTags(obj: any, asString?: boolean): any;
  5248. /**
  5249. * Adds tags to an object
  5250. * @param obj defines the object to use
  5251. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5252. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5253. */
  5254. static AddTagsTo(obj: any, tagsString: string): void;
  5255. /**
  5256. * @hidden
  5257. */
  5258. static _AddTagTo(obj: any, tag: string): void;
  5259. /**
  5260. * Removes specific tags from a specific object
  5261. * @param obj defines the object to use
  5262. * @param tagsString defines the tags to remove
  5263. */
  5264. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5265. /**
  5266. * @hidden
  5267. */
  5268. static _RemoveTagFrom(obj: any, tag: string): void;
  5269. /**
  5270. * Defines if tags hosted on an object match a given query
  5271. * @param obj defines the object to use
  5272. * @param tagsQuery defines the tag query
  5273. * @returns a boolean
  5274. */
  5275. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5276. }
  5277. }
  5278. declare module "babylonjs/Maths/math.path" {
  5279. import { DeepImmutable, Nullable } from "babylonjs/types";
  5280. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5281. /**
  5282. * Defines potential orientation for back face culling
  5283. */
  5284. export enum Orientation {
  5285. /**
  5286. * Clockwise
  5287. */
  5288. CW = 0,
  5289. /** Counter clockwise */
  5290. CCW = 1
  5291. }
  5292. /** Class used to represent a Bezier curve */
  5293. export class BezierCurve {
  5294. /**
  5295. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5296. * @param t defines the time
  5297. * @param x1 defines the left coordinate on X axis
  5298. * @param y1 defines the left coordinate on Y axis
  5299. * @param x2 defines the right coordinate on X axis
  5300. * @param y2 defines the right coordinate on Y axis
  5301. * @returns the interpolated value
  5302. */
  5303. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5304. }
  5305. /**
  5306. * Defines angle representation
  5307. */
  5308. export class Angle {
  5309. private _radians;
  5310. /**
  5311. * Creates an Angle object of "radians" radians (float).
  5312. * @param radians the angle in radians
  5313. */
  5314. constructor(radians: number);
  5315. /**
  5316. * Get value in degrees
  5317. * @returns the Angle value in degrees (float)
  5318. */
  5319. degrees(): number;
  5320. /**
  5321. * Get value in radians
  5322. * @returns the Angle value in radians (float)
  5323. */
  5324. radians(): number;
  5325. /**
  5326. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5327. * @param a defines first vector
  5328. * @param b defines second vector
  5329. * @returns a new Angle
  5330. */
  5331. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5332. /**
  5333. * Gets a new Angle object from the given float in radians
  5334. * @param radians defines the angle value in radians
  5335. * @returns a new Angle
  5336. */
  5337. static FromRadians(radians: number): Angle;
  5338. /**
  5339. * Gets a new Angle object from the given float in degrees
  5340. * @param degrees defines the angle value in degrees
  5341. * @returns a new Angle
  5342. */
  5343. static FromDegrees(degrees: number): Angle;
  5344. }
  5345. /**
  5346. * This represents an arc in a 2d space.
  5347. */
  5348. export class Arc2 {
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2;
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2;
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2;
  5355. /**
  5356. * Defines the center point of the arc.
  5357. */
  5358. centerPoint: Vector2;
  5359. /**
  5360. * Defines the radius of the arc.
  5361. */
  5362. radius: number;
  5363. /**
  5364. * Defines the angle of the arc (from mid point to end point).
  5365. */
  5366. angle: Angle;
  5367. /**
  5368. * Defines the start angle of the arc (from start point to middle point).
  5369. */
  5370. startAngle: Angle;
  5371. /**
  5372. * Defines the orientation of the arc (clock wise/counter clock wise).
  5373. */
  5374. orientation: Orientation;
  5375. /**
  5376. * Creates an Arc object from the three given points : start, middle and end.
  5377. * @param startPoint Defines the start point of the arc
  5378. * @param midPoint Defines the midlle point of the arc
  5379. * @param endPoint Defines the end point of the arc
  5380. */
  5381. constructor(
  5382. /** Defines the start point of the arc */
  5383. startPoint: Vector2,
  5384. /** Defines the mid point of the arc */
  5385. midPoint: Vector2,
  5386. /** Defines the end point of the arc */
  5387. endPoint: Vector2);
  5388. }
  5389. /**
  5390. * Represents a 2D path made up of multiple 2D points
  5391. */
  5392. export class Path2 {
  5393. private _points;
  5394. private _length;
  5395. /**
  5396. * If the path start and end point are the same
  5397. */
  5398. closed: boolean;
  5399. /**
  5400. * Creates a Path2 object from the starting 2D coordinates x and y.
  5401. * @param x the starting points x value
  5402. * @param y the starting points y value
  5403. */
  5404. constructor(x: number, y: number);
  5405. /**
  5406. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5407. * @param x the added points x value
  5408. * @param y the added points y value
  5409. * @returns the updated Path2.
  5410. */
  5411. addLineTo(x: number, y: number): Path2;
  5412. /**
  5413. * 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.
  5414. * @param midX middle point x value
  5415. * @param midY middle point y value
  5416. * @param endX end point x value
  5417. * @param endY end point y value
  5418. * @param numberOfSegments (default: 36)
  5419. * @returns the updated Path2.
  5420. */
  5421. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5422. /**
  5423. * Closes the Path2.
  5424. * @returns the Path2.
  5425. */
  5426. close(): Path2;
  5427. /**
  5428. * Gets the sum of the distance between each sequential point in the path
  5429. * @returns the Path2 total length (float).
  5430. */
  5431. length(): number;
  5432. /**
  5433. * Gets the points which construct the path
  5434. * @returns the Path2 internal array of points.
  5435. */
  5436. getPoints(): Vector2[];
  5437. /**
  5438. * Retreives the point at the distance aways from the starting point
  5439. * @param normalizedLengthPosition the length along the path to retreive the point from
  5440. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5441. */
  5442. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5443. /**
  5444. * Creates a new path starting from an x and y position
  5445. * @param x starting x value
  5446. * @param y starting y value
  5447. * @returns a new Path2 starting at the coordinates (x, y).
  5448. */
  5449. static StartingAt(x: number, y: number): Path2;
  5450. }
  5451. /**
  5452. * Represents a 3D path made up of multiple 3D points
  5453. */
  5454. export class Path3D {
  5455. /**
  5456. * an array of Vector3, the curve axis of the Path3D
  5457. */
  5458. path: Vector3[];
  5459. private _curve;
  5460. private _distances;
  5461. private _tangents;
  5462. private _normals;
  5463. private _binormals;
  5464. private _raw;
  5465. /**
  5466. * new Path3D(path, normal, raw)
  5467. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5468. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5469. * @param path an array of Vector3, the curve axis of the Path3D
  5470. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5471. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5472. */
  5473. constructor(
  5474. /**
  5475. * an array of Vector3, the curve axis of the Path3D
  5476. */
  5477. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5478. /**
  5479. * Returns the Path3D array of successive Vector3 designing its curve.
  5480. * @returns the Path3D array of successive Vector3 designing its curve.
  5481. */
  5482. getCurve(): Vector3[];
  5483. /**
  5484. * Returns an array populated with tangent vectors on each Path3D curve point.
  5485. * @returns an array populated with tangent vectors on each Path3D curve point.
  5486. */
  5487. getTangents(): Vector3[];
  5488. /**
  5489. * Returns an array populated with normal vectors on each Path3D curve point.
  5490. * @returns an array populated with normal vectors on each Path3D curve point.
  5491. */
  5492. getNormals(): Vector3[];
  5493. /**
  5494. * Returns an array populated with binormal vectors on each Path3D curve point.
  5495. * @returns an array populated with binormal vectors on each Path3D curve point.
  5496. */
  5497. getBinormals(): Vector3[];
  5498. /**
  5499. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5500. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5501. */
  5502. getDistances(): number[];
  5503. /**
  5504. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5505. * @param path path which all values are copied into the curves points
  5506. * @param firstNormal which should be projected onto the curve
  5507. * @returns the same object updated.
  5508. */
  5509. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5510. private _compute;
  5511. private _getFirstNonNullVector;
  5512. private _getLastNonNullVector;
  5513. private _normalVector;
  5514. }
  5515. /**
  5516. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5517. * A Curve3 is designed from a series of successive Vector3.
  5518. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5519. */
  5520. export class Curve3 {
  5521. private _points;
  5522. private _length;
  5523. /**
  5524. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5525. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5526. * @param v1 (Vector3) the control point
  5527. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5528. * @param nbPoints (integer) the wanted number of points in the curve
  5529. * @returns the created Curve3
  5530. */
  5531. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5532. /**
  5533. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5534. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5535. * @param v1 (Vector3) the first control point
  5536. * @param v2 (Vector3) the second control point
  5537. * @param v3 (Vector3) the end point of the Cubic Bezier
  5538. * @param nbPoints (integer) the wanted number of points in the curve
  5539. * @returns the created Curve3
  5540. */
  5541. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5542. /**
  5543. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5544. * @param p1 (Vector3) the origin point of the Hermite Spline
  5545. * @param t1 (Vector3) the tangent vector at the origin point
  5546. * @param p2 (Vector3) the end point of the Hermite Spline
  5547. * @param t2 (Vector3) the tangent vector at the end point
  5548. * @param nbPoints (integer) the wanted number of points in the curve
  5549. * @returns the created Curve3
  5550. */
  5551. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5552. /**
  5553. * Returns a Curve3 object along a CatmullRom Spline curve :
  5554. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5555. * @param nbPoints (integer) the wanted number of points between each curve control points
  5556. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5557. * @returns the created Curve3
  5558. */
  5559. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5560. /**
  5561. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5562. * A Curve3 is designed from a series of successive Vector3.
  5563. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5564. * @param points points which make up the curve
  5565. */
  5566. constructor(points: Vector3[]);
  5567. /**
  5568. * @returns the Curve3 stored array of successive Vector3
  5569. */
  5570. getPoints(): Vector3[];
  5571. /**
  5572. * @returns the computed length (float) of the curve.
  5573. */
  5574. length(): number;
  5575. /**
  5576. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5577. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5578. * curveA and curveB keep unchanged.
  5579. * @param curve the curve to continue from this curve
  5580. * @returns the newly constructed curve
  5581. */
  5582. continue(curve: DeepImmutable<Curve3>): Curve3;
  5583. private _computeLength;
  5584. }
  5585. }
  5586. declare module "babylonjs/Animations/easing" {
  5587. /**
  5588. * This represents the main contract an easing function should follow.
  5589. * Easing functions are used throughout the animation system.
  5590. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5591. */
  5592. export interface IEasingFunction {
  5593. /**
  5594. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5595. * of the easing function.
  5596. * The link below provides some of the most common examples of easing functions.
  5597. * @see https://easings.net/
  5598. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5599. * @returns the corresponding value on the curve defined by the easing function
  5600. */
  5601. ease(gradient: number): number;
  5602. }
  5603. /**
  5604. * Base class used for every default easing function.
  5605. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5606. */
  5607. export class EasingFunction implements IEasingFunction {
  5608. /**
  5609. * Interpolation follows the mathematical formula associated with the easing function.
  5610. */
  5611. static readonly EASINGMODE_EASEIN: number;
  5612. /**
  5613. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5614. */
  5615. static readonly EASINGMODE_EASEOUT: number;
  5616. /**
  5617. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5618. */
  5619. static readonly EASINGMODE_EASEINOUT: number;
  5620. private _easingMode;
  5621. /**
  5622. * Sets the easing mode of the current function.
  5623. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5624. */
  5625. setEasingMode(easingMode: number): void;
  5626. /**
  5627. * Gets the current easing mode.
  5628. * @returns the easing mode
  5629. */
  5630. getEasingMode(): number;
  5631. /**
  5632. * @hidden
  5633. */
  5634. easeInCore(gradient: number): number;
  5635. /**
  5636. * Given an input gradient between 0 and 1, this returns the corresponding value
  5637. * of the easing function.
  5638. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5639. * @returns the corresponding value on the curve defined by the easing function
  5640. */
  5641. ease(gradient: number): number;
  5642. }
  5643. /**
  5644. * Easing function with a circle shape (see link below).
  5645. * @see https://easings.net/#easeInCirc
  5646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5647. */
  5648. export class CircleEase extends EasingFunction implements IEasingFunction {
  5649. /** @hidden */
  5650. easeInCore(gradient: number): number;
  5651. }
  5652. /**
  5653. * Easing function with a ease back shape (see link below).
  5654. * @see https://easings.net/#easeInBack
  5655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5656. */
  5657. export class BackEase extends EasingFunction implements IEasingFunction {
  5658. /** Defines the amplitude of the function */
  5659. amplitude: number;
  5660. /**
  5661. * Instantiates a back ease easing
  5662. * @see https://easings.net/#easeInBack
  5663. * @param amplitude Defines the amplitude of the function
  5664. */
  5665. constructor(
  5666. /** Defines the amplitude of the function */
  5667. amplitude?: number);
  5668. /** @hidden */
  5669. easeInCore(gradient: number): number;
  5670. }
  5671. /**
  5672. * Easing function with a bouncing shape (see link below).
  5673. * @see https://easings.net/#easeInBounce
  5674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5675. */
  5676. export class BounceEase extends EasingFunction implements IEasingFunction {
  5677. /** Defines the number of bounces */
  5678. bounces: number;
  5679. /** Defines the amplitude of the bounce */
  5680. bounciness: number;
  5681. /**
  5682. * Instantiates a bounce easing
  5683. * @see https://easings.net/#easeInBounce
  5684. * @param bounces Defines the number of bounces
  5685. * @param bounciness Defines the amplitude of the bounce
  5686. */
  5687. constructor(
  5688. /** Defines the number of bounces */
  5689. bounces?: number,
  5690. /** Defines the amplitude of the bounce */
  5691. bounciness?: number);
  5692. /** @hidden */
  5693. easeInCore(gradient: number): number;
  5694. }
  5695. /**
  5696. * Easing function with a power of 3 shape (see link below).
  5697. * @see https://easings.net/#easeInCubic
  5698. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5699. */
  5700. export class CubicEase extends EasingFunction implements IEasingFunction {
  5701. /** @hidden */
  5702. easeInCore(gradient: number): number;
  5703. }
  5704. /**
  5705. * Easing function with an elastic shape (see link below).
  5706. * @see https://easings.net/#easeInElastic
  5707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5708. */
  5709. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5710. /** Defines the number of oscillations*/
  5711. oscillations: number;
  5712. /** Defines the amplitude of the oscillations*/
  5713. springiness: number;
  5714. /**
  5715. * Instantiates an elastic easing function
  5716. * @see https://easings.net/#easeInElastic
  5717. * @param oscillations Defines the number of oscillations
  5718. * @param springiness Defines the amplitude of the oscillations
  5719. */
  5720. constructor(
  5721. /** Defines the number of oscillations*/
  5722. oscillations?: number,
  5723. /** Defines the amplitude of the oscillations*/
  5724. springiness?: number);
  5725. /** @hidden */
  5726. easeInCore(gradient: number): number;
  5727. }
  5728. /**
  5729. * Easing function with an exponential shape (see link below).
  5730. * @see https://easings.net/#easeInExpo
  5731. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5732. */
  5733. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5734. /** Defines the exponent of the function */
  5735. exponent: number;
  5736. /**
  5737. * Instantiates an exponential easing function
  5738. * @see https://easings.net/#easeInExpo
  5739. * @param exponent Defines the exponent of the function
  5740. */
  5741. constructor(
  5742. /** Defines the exponent of the function */
  5743. exponent?: number);
  5744. /** @hidden */
  5745. easeInCore(gradient: number): number;
  5746. }
  5747. /**
  5748. * Easing function with a power shape (see link below).
  5749. * @see https://easings.net/#easeInQuad
  5750. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5751. */
  5752. export class PowerEase extends EasingFunction implements IEasingFunction {
  5753. /** Defines the power of the function */
  5754. power: number;
  5755. /**
  5756. * Instantiates an power base easing function
  5757. * @see https://easings.net/#easeInQuad
  5758. * @param power Defines the power of the function
  5759. */
  5760. constructor(
  5761. /** Defines the power of the function */
  5762. power?: number);
  5763. /** @hidden */
  5764. easeInCore(gradient: number): number;
  5765. }
  5766. /**
  5767. * Easing function with a power of 2 shape (see link below).
  5768. * @see https://easings.net/#easeInQuad
  5769. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5770. */
  5771. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5772. /** @hidden */
  5773. easeInCore(gradient: number): number;
  5774. }
  5775. /**
  5776. * Easing function with a power of 4 shape (see link below).
  5777. * @see https://easings.net/#easeInQuart
  5778. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5779. */
  5780. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with a power of 5 shape (see link below).
  5786. * @see https://easings.net/#easeInQuint
  5787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5790. /** @hidden */
  5791. easeInCore(gradient: number): number;
  5792. }
  5793. /**
  5794. * Easing function with a sin shape (see link below).
  5795. * @see https://easings.net/#easeInSine
  5796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5797. */
  5798. export class SineEase extends EasingFunction implements IEasingFunction {
  5799. /** @hidden */
  5800. easeInCore(gradient: number): number;
  5801. }
  5802. /**
  5803. * Easing function with a bezier shape (see link below).
  5804. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5806. */
  5807. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5808. /** Defines the x component of the start tangent in the bezier curve */
  5809. x1: number;
  5810. /** Defines the y component of the start tangent in the bezier curve */
  5811. y1: number;
  5812. /** Defines the x component of the end tangent in the bezier curve */
  5813. x2: number;
  5814. /** Defines the y component of the end tangent in the bezier curve */
  5815. y2: number;
  5816. /**
  5817. * Instantiates a bezier function
  5818. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5819. * @param x1 Defines the x component of the start tangent in the bezier curve
  5820. * @param y1 Defines the y component of the start tangent in the bezier curve
  5821. * @param x2 Defines the x component of the end tangent in the bezier curve
  5822. * @param y2 Defines the y component of the end tangent in the bezier curve
  5823. */
  5824. constructor(
  5825. /** Defines the x component of the start tangent in the bezier curve */
  5826. x1?: number,
  5827. /** Defines the y component of the start tangent in the bezier curve */
  5828. y1?: number,
  5829. /** Defines the x component of the end tangent in the bezier curve */
  5830. x2?: number,
  5831. /** Defines the y component of the end tangent in the bezier curve */
  5832. y2?: number);
  5833. /** @hidden */
  5834. easeInCore(gradient: number): number;
  5835. }
  5836. }
  5837. declare module "babylonjs/Animations/animationKey" {
  5838. /**
  5839. * Defines an interface which represents an animation key frame
  5840. */
  5841. export interface IAnimationKey {
  5842. /**
  5843. * Frame of the key frame
  5844. */
  5845. frame: number;
  5846. /**
  5847. * Value at the specifies key frame
  5848. */
  5849. value: any;
  5850. /**
  5851. * The input tangent for the cubic hermite spline
  5852. */
  5853. inTangent?: any;
  5854. /**
  5855. * The output tangent for the cubic hermite spline
  5856. */
  5857. outTangent?: any;
  5858. /**
  5859. * The animation interpolation type
  5860. */
  5861. interpolation?: AnimationKeyInterpolation;
  5862. }
  5863. /**
  5864. * Enum for the animation key frame interpolation type
  5865. */
  5866. export enum AnimationKeyInterpolation {
  5867. /**
  5868. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5869. */
  5870. STEP = 1
  5871. }
  5872. }
  5873. declare module "babylonjs/Animations/animationRange" {
  5874. /**
  5875. * Represents the range of an animation
  5876. */
  5877. export class AnimationRange {
  5878. /**The name of the animation range**/
  5879. name: string;
  5880. /**The starting frame of the animation */
  5881. from: number;
  5882. /**The ending frame of the animation*/
  5883. to: number;
  5884. /**
  5885. * Initializes the range of an animation
  5886. * @param name The name of the animation range
  5887. * @param from The starting frame of the animation
  5888. * @param to The ending frame of the animation
  5889. */
  5890. constructor(
  5891. /**The name of the animation range**/
  5892. name: string,
  5893. /**The starting frame of the animation */
  5894. from: number,
  5895. /**The ending frame of the animation*/
  5896. to: number);
  5897. /**
  5898. * Makes a copy of the animation range
  5899. * @returns A copy of the animation range
  5900. */
  5901. clone(): AnimationRange;
  5902. }
  5903. }
  5904. declare module "babylonjs/Animations/animationEvent" {
  5905. /**
  5906. * Composed of a frame, and an action function
  5907. */
  5908. export class AnimationEvent {
  5909. /** The frame for which the event is triggered **/
  5910. frame: number;
  5911. /** The event to perform when triggered **/
  5912. action: (currentFrame: number) => void;
  5913. /** Specifies if the event should be triggered only once**/
  5914. onlyOnce?: boolean | undefined;
  5915. /**
  5916. * Specifies if the animation event is done
  5917. */
  5918. isDone: boolean;
  5919. /**
  5920. * Initializes the animation event
  5921. * @param frame The frame for which the event is triggered
  5922. * @param action The event to perform when triggered
  5923. * @param onlyOnce Specifies if the event should be triggered only once
  5924. */
  5925. constructor(
  5926. /** The frame for which the event is triggered **/
  5927. frame: number,
  5928. /** The event to perform when triggered **/
  5929. action: (currentFrame: number) => void,
  5930. /** Specifies if the event should be triggered only once**/
  5931. onlyOnce?: boolean | undefined);
  5932. /** @hidden */
  5933. _clone(): AnimationEvent;
  5934. }
  5935. }
  5936. declare module "babylonjs/Behaviors/behavior" {
  5937. import { Nullable } from "babylonjs/types";
  5938. /**
  5939. * Interface used to define a behavior
  5940. */
  5941. export interface Behavior<T> {
  5942. /** gets or sets behavior's name */
  5943. name: string;
  5944. /**
  5945. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5946. */
  5947. init(): void;
  5948. /**
  5949. * Called when the behavior is attached to a target
  5950. * @param target defines the target where the behavior is attached to
  5951. */
  5952. attach(target: T): void;
  5953. /**
  5954. * Called when the behavior is detached from its target
  5955. */
  5956. detach(): void;
  5957. }
  5958. /**
  5959. * Interface implemented by classes supporting behaviors
  5960. */
  5961. export interface IBehaviorAware<T> {
  5962. /**
  5963. * Attach a behavior
  5964. * @param behavior defines the behavior to attach
  5965. * @returns the current host
  5966. */
  5967. addBehavior(behavior: Behavior<T>): T;
  5968. /**
  5969. * Remove a behavior from the current object
  5970. * @param behavior defines the behavior to detach
  5971. * @returns the current host
  5972. */
  5973. removeBehavior(behavior: Behavior<T>): T;
  5974. /**
  5975. * Gets a behavior using its name to search
  5976. * @param name defines the name to search
  5977. * @returns the behavior or null if not found
  5978. */
  5979. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5980. }
  5981. }
  5982. declare module "babylonjs/Misc/smartArray" {
  5983. /**
  5984. * Defines an array and its length.
  5985. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5986. */
  5987. export interface ISmartArrayLike<T> {
  5988. /**
  5989. * The data of the array.
  5990. */
  5991. data: Array<T>;
  5992. /**
  5993. * The active length of the array.
  5994. */
  5995. length: number;
  5996. }
  5997. /**
  5998. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5999. */
  6000. export class SmartArray<T> implements ISmartArrayLike<T> {
  6001. /**
  6002. * The full set of data from the array.
  6003. */
  6004. data: Array<T>;
  6005. /**
  6006. * The active length of the array.
  6007. */
  6008. length: number;
  6009. protected _id: number;
  6010. /**
  6011. * Instantiates a Smart Array.
  6012. * @param capacity defines the default capacity of the array.
  6013. */
  6014. constructor(capacity: number);
  6015. /**
  6016. * Pushes a value at the end of the active data.
  6017. * @param value defines the object to push in the array.
  6018. */
  6019. push(value: T): void;
  6020. /**
  6021. * Iterates over the active data and apply the lambda to them.
  6022. * @param func defines the action to apply on each value.
  6023. */
  6024. forEach(func: (content: T) => void): void;
  6025. /**
  6026. * Sorts the full sets of data.
  6027. * @param compareFn defines the comparison function to apply.
  6028. */
  6029. sort(compareFn: (a: T, b: T) => number): void;
  6030. /**
  6031. * Resets the active data to an empty array.
  6032. */
  6033. reset(): void;
  6034. /**
  6035. * Releases all the data from the array as well as the array.
  6036. */
  6037. dispose(): void;
  6038. /**
  6039. * Concats the active data with a given array.
  6040. * @param array defines the data to concatenate with.
  6041. */
  6042. concat(array: any): void;
  6043. /**
  6044. * Returns the position of a value in the active data.
  6045. * @param value defines the value to find the index for
  6046. * @returns the index if found in the active data otherwise -1
  6047. */
  6048. indexOf(value: T): number;
  6049. /**
  6050. * Returns whether an element is part of the active data.
  6051. * @param value defines the value to look for
  6052. * @returns true if found in the active data otherwise false
  6053. */
  6054. contains(value: T): boolean;
  6055. private static _GlobalId;
  6056. }
  6057. /**
  6058. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6059. * The data in this array can only be present once
  6060. */
  6061. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6062. private _duplicateId;
  6063. /**
  6064. * Pushes a value at the end of the active data.
  6065. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Pushes a value at the end of the active data.
  6071. * If the data is already present, it won t be added again
  6072. * @param value defines the object to push in the array.
  6073. * @returns true if added false if it was already present
  6074. */
  6075. pushNoDuplicate(value: T): boolean;
  6076. /**
  6077. * Resets the active data to an empty array.
  6078. */
  6079. reset(): void;
  6080. /**
  6081. * Concats the active data with a given array.
  6082. * This ensures no dupplicate will be present in the result.
  6083. * @param array defines the data to concatenate with.
  6084. */
  6085. concatWithNoDuplicate(array: any): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/Cameras/cameraInputsManager" {
  6089. import { Nullable } from "babylonjs/types";
  6090. import { Camera } from "babylonjs/Cameras/camera";
  6091. /**
  6092. * @ignore
  6093. * This is a list of all the different input types that are available in the application.
  6094. * Fo instance: ArcRotateCameraGamepadInput...
  6095. */
  6096. export var CameraInputTypes: {};
  6097. /**
  6098. * This is the contract to implement in order to create a new input class.
  6099. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6100. */
  6101. export interface ICameraInput<TCamera extends Camera> {
  6102. /**
  6103. * Defines the camera the input is attached to.
  6104. */
  6105. camera: Nullable<TCamera>;
  6106. /**
  6107. * Gets the class name of the current intput.
  6108. * @returns the class name
  6109. */
  6110. getClassName(): string;
  6111. /**
  6112. * Get the friendly name associated with the input class.
  6113. * @returns the input friendly name
  6114. */
  6115. getSimpleName(): string;
  6116. /**
  6117. * Attach the input controls to a specific dom element to get the input from.
  6118. * @param element Defines the element the controls should be listened from
  6119. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6120. */
  6121. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6122. /**
  6123. * Detach the current controls from the specified dom element.
  6124. * @param element Defines the element to stop listening the inputs from
  6125. */
  6126. detachControl(element: Nullable<HTMLElement>): void;
  6127. /**
  6128. * Update the current camera state depending on the inputs that have been used this frame.
  6129. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6130. */
  6131. checkInputs?: () => void;
  6132. }
  6133. /**
  6134. * Represents a map of input types to input instance or input index to input instance.
  6135. */
  6136. export interface CameraInputsMap<TCamera extends Camera> {
  6137. /**
  6138. * Accessor to the input by input type.
  6139. */
  6140. [name: string]: ICameraInput<TCamera>;
  6141. /**
  6142. * Accessor to the input by input index.
  6143. */
  6144. [idx: number]: ICameraInput<TCamera>;
  6145. }
  6146. /**
  6147. * This represents the input manager used within a camera.
  6148. * It helps dealing with all the different kind of input attached to a camera.
  6149. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6150. */
  6151. export class CameraInputsManager<TCamera extends Camera> {
  6152. /**
  6153. * Defines the list of inputs attahed to the camera.
  6154. */
  6155. attached: CameraInputsMap<TCamera>;
  6156. /**
  6157. * Defines the dom element the camera is collecting inputs from.
  6158. * This is null if the controls have not been attached.
  6159. */
  6160. attachedElement: Nullable<HTMLElement>;
  6161. /**
  6162. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6163. */
  6164. noPreventDefault: boolean;
  6165. /**
  6166. * Defined the camera the input manager belongs to.
  6167. */
  6168. camera: TCamera;
  6169. /**
  6170. * Update the current camera state depending on the inputs that have been used this frame.
  6171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6172. */
  6173. checkInputs: () => void;
  6174. /**
  6175. * Instantiate a new Camera Input Manager.
  6176. * @param camera Defines the camera the input manager blongs to
  6177. */
  6178. constructor(camera: TCamera);
  6179. /**
  6180. * Add an input method to a camera
  6181. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6182. * @param input camera input method
  6183. */
  6184. add(input: ICameraInput<TCamera>): void;
  6185. /**
  6186. * Remove a specific input method from a camera
  6187. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6188. * @param inputToRemove camera input method
  6189. */
  6190. remove(inputToRemove: ICameraInput<TCamera>): void;
  6191. /**
  6192. * Remove a specific input type from a camera
  6193. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6194. * @param inputType the type of the input to remove
  6195. */
  6196. removeByType(inputType: string): void;
  6197. private _addCheckInputs;
  6198. /**
  6199. * Attach the input controls to the currently attached dom element to listen the events from.
  6200. * @param input Defines the input to attach
  6201. */
  6202. attachInput(input: ICameraInput<TCamera>): void;
  6203. /**
  6204. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6205. * @param element Defines the dom element to collect the events from
  6206. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6207. */
  6208. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6209. /**
  6210. * Detach the current manager inputs controls from a specific dom element.
  6211. * @param element Defines the dom element to collect the events from
  6212. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6213. */
  6214. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6215. /**
  6216. * Rebuild the dynamic inputCheck function from the current list of
  6217. * defined inputs in the manager.
  6218. */
  6219. rebuildInputCheck(): void;
  6220. /**
  6221. * Remove all attached input methods from a camera
  6222. */
  6223. clear(): void;
  6224. /**
  6225. * Serialize the current input manager attached to a camera.
  6226. * This ensures than once parsed,
  6227. * the input associated to the camera will be identical to the current ones
  6228. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6229. */
  6230. serialize(serializedCamera: any): void;
  6231. /**
  6232. * Parses an input manager serialized JSON to restore the previous list of inputs
  6233. * and states associated to a camera.
  6234. * @param parsedCamera Defines the JSON to parse
  6235. */
  6236. parse(parsedCamera: any): void;
  6237. }
  6238. }
  6239. declare module "babylonjs/Meshes/buffer" {
  6240. import { Nullable, DataArray } from "babylonjs/types";
  6241. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6242. /**
  6243. * Class used to store data that will be store in GPU memory
  6244. */
  6245. export class Buffer {
  6246. private _engine;
  6247. private _buffer;
  6248. /** @hidden */
  6249. _data: Nullable<DataArray>;
  6250. private _updatable;
  6251. private _instanced;
  6252. /**
  6253. * Gets the byte stride.
  6254. */
  6255. readonly byteStride: number;
  6256. /**
  6257. * Constructor
  6258. * @param engine the engine
  6259. * @param data the data to use for this buffer
  6260. * @param updatable whether the data is updatable
  6261. * @param stride the stride (optional)
  6262. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6263. * @param instanced whether the buffer is instanced (optional)
  6264. * @param useBytes set to true if the stride in in bytes (optional)
  6265. */
  6266. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6267. /**
  6268. * Create a new VertexBuffer based on the current buffer
  6269. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6270. * @param offset defines offset in the buffer (0 by default)
  6271. * @param size defines the size in floats of attributes (position is 3 for instance)
  6272. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6273. * @param instanced defines if the vertex buffer contains indexed data
  6274. * @param useBytes defines if the offset and stride are in bytes
  6275. * @returns the new vertex buffer
  6276. */
  6277. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6278. /**
  6279. * Gets a boolean indicating if the Buffer is updatable?
  6280. * @returns true if the buffer is updatable
  6281. */
  6282. isUpdatable(): boolean;
  6283. /**
  6284. * Gets current buffer's data
  6285. * @returns a DataArray or null
  6286. */
  6287. getData(): Nullable<DataArray>;
  6288. /**
  6289. * Gets underlying native buffer
  6290. * @returns underlying native buffer
  6291. */
  6292. getBuffer(): Nullable<DataBuffer>;
  6293. /**
  6294. * Gets the stride in float32 units (i.e. byte stride / 4).
  6295. * May not be an integer if the byte stride is not divisible by 4.
  6296. * DEPRECATED. Use byteStride instead.
  6297. * @returns the stride in float32 units
  6298. */
  6299. getStrideSize(): number;
  6300. /**
  6301. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6302. * @param data defines the data to store
  6303. */
  6304. create(data?: Nullable<DataArray>): void;
  6305. /** @hidden */
  6306. _rebuild(): void;
  6307. /**
  6308. * Update current buffer data
  6309. * @param data defines the data to store
  6310. */
  6311. update(data: DataArray): void;
  6312. /**
  6313. * Updates the data directly.
  6314. * @param data the new data
  6315. * @param offset the new offset
  6316. * @param vertexCount the vertex count (optional)
  6317. * @param useBytes set to true if the offset is in bytes
  6318. */
  6319. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6320. /**
  6321. * Release all resources
  6322. */
  6323. dispose(): void;
  6324. }
  6325. /**
  6326. * Specialized buffer used to store vertex data
  6327. */
  6328. export class VertexBuffer {
  6329. /** @hidden */
  6330. _buffer: Buffer;
  6331. private _kind;
  6332. private _size;
  6333. private _ownsBuffer;
  6334. private _instanced;
  6335. private _instanceDivisor;
  6336. /**
  6337. * The byte type.
  6338. */
  6339. static readonly BYTE: number;
  6340. /**
  6341. * The unsigned byte type.
  6342. */
  6343. static readonly UNSIGNED_BYTE: number;
  6344. /**
  6345. * The short type.
  6346. */
  6347. static readonly SHORT: number;
  6348. /**
  6349. * The unsigned short type.
  6350. */
  6351. static readonly UNSIGNED_SHORT: number;
  6352. /**
  6353. * The integer type.
  6354. */
  6355. static readonly INT: number;
  6356. /**
  6357. * The unsigned integer type.
  6358. */
  6359. static readonly UNSIGNED_INT: number;
  6360. /**
  6361. * The float type.
  6362. */
  6363. static readonly FLOAT: number;
  6364. /**
  6365. * Gets or sets the instance divisor when in instanced mode
  6366. */
  6367. instanceDivisor: number;
  6368. /**
  6369. * Gets the byte stride.
  6370. */
  6371. readonly byteStride: number;
  6372. /**
  6373. * Gets the byte offset.
  6374. */
  6375. readonly byteOffset: number;
  6376. /**
  6377. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6378. */
  6379. readonly normalized: boolean;
  6380. /**
  6381. * Gets the data type of each component in the array.
  6382. */
  6383. readonly type: number;
  6384. /**
  6385. * Constructor
  6386. * @param engine the engine
  6387. * @param data the data to use for this vertex buffer
  6388. * @param kind the vertex buffer kind
  6389. * @param updatable whether the data is updatable
  6390. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6391. * @param stride the stride (optional)
  6392. * @param instanced whether the buffer is instanced (optional)
  6393. * @param offset the offset of the data (optional)
  6394. * @param size the number of components (optional)
  6395. * @param type the type of the component (optional)
  6396. * @param normalized whether the data contains normalized data (optional)
  6397. * @param useBytes set to true if stride and offset are in bytes (optional)
  6398. */
  6399. 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);
  6400. /** @hidden */
  6401. _rebuild(): void;
  6402. /**
  6403. * Returns the kind of the VertexBuffer (string)
  6404. * @returns a string
  6405. */
  6406. getKind(): string;
  6407. /**
  6408. * Gets a boolean indicating if the VertexBuffer is updatable?
  6409. * @returns true if the buffer is updatable
  6410. */
  6411. isUpdatable(): boolean;
  6412. /**
  6413. * Gets current buffer's data
  6414. * @returns a DataArray or null
  6415. */
  6416. getData(): Nullable<DataArray>;
  6417. /**
  6418. * Gets underlying native buffer
  6419. * @returns underlying native buffer
  6420. */
  6421. getBuffer(): Nullable<DataBuffer>;
  6422. /**
  6423. * Gets the stride in float32 units (i.e. byte stride / 4).
  6424. * May not be an integer if the byte stride is not divisible by 4.
  6425. * DEPRECATED. Use byteStride instead.
  6426. * @returns the stride in float32 units
  6427. */
  6428. getStrideSize(): number;
  6429. /**
  6430. * Returns the offset as a multiple of the type byte length.
  6431. * DEPRECATED. Use byteOffset instead.
  6432. * @returns the offset in bytes
  6433. */
  6434. getOffset(): number;
  6435. /**
  6436. * Returns the number of components per vertex attribute (integer)
  6437. * @returns the size in float
  6438. */
  6439. getSize(): number;
  6440. /**
  6441. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6442. * @returns true if this buffer is instanced
  6443. */
  6444. getIsInstanced(): boolean;
  6445. /**
  6446. * Returns the instancing divisor, zero for non-instanced (integer).
  6447. * @returns a number
  6448. */
  6449. getInstanceDivisor(): number;
  6450. /**
  6451. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6452. * @param data defines the data to store
  6453. */
  6454. create(data?: DataArray): void;
  6455. /**
  6456. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6457. * This function will create a new buffer if the current one is not updatable
  6458. * @param data defines the data to store
  6459. */
  6460. update(data: DataArray): void;
  6461. /**
  6462. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6463. * Returns the directly updated WebGLBuffer.
  6464. * @param data the new data
  6465. * @param offset the new offset
  6466. * @param useBytes set to true if the offset is in bytes
  6467. */
  6468. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6469. /**
  6470. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6471. */
  6472. dispose(): void;
  6473. /**
  6474. * Enumerates each value of this vertex buffer as numbers.
  6475. * @param count the number of values to enumerate
  6476. * @param callback the callback function called for each value
  6477. */
  6478. forEach(count: number, callback: (value: number, index: number) => void): void;
  6479. /**
  6480. * Positions
  6481. */
  6482. static readonly PositionKind: string;
  6483. /**
  6484. * Normals
  6485. */
  6486. static readonly NormalKind: string;
  6487. /**
  6488. * Tangents
  6489. */
  6490. static readonly TangentKind: string;
  6491. /**
  6492. * Texture coordinates
  6493. */
  6494. static readonly UVKind: string;
  6495. /**
  6496. * Texture coordinates 2
  6497. */
  6498. static readonly UV2Kind: string;
  6499. /**
  6500. * Texture coordinates 3
  6501. */
  6502. static readonly UV3Kind: string;
  6503. /**
  6504. * Texture coordinates 4
  6505. */
  6506. static readonly UV4Kind: string;
  6507. /**
  6508. * Texture coordinates 5
  6509. */
  6510. static readonly UV5Kind: string;
  6511. /**
  6512. * Texture coordinates 6
  6513. */
  6514. static readonly UV6Kind: string;
  6515. /**
  6516. * Colors
  6517. */
  6518. static readonly ColorKind: string;
  6519. /**
  6520. * Matrix indices (for bones)
  6521. */
  6522. static readonly MatricesIndicesKind: string;
  6523. /**
  6524. * Matrix weights (for bones)
  6525. */
  6526. static readonly MatricesWeightsKind: string;
  6527. /**
  6528. * Additional matrix indices (for bones)
  6529. */
  6530. static readonly MatricesIndicesExtraKind: string;
  6531. /**
  6532. * Additional matrix weights (for bones)
  6533. */
  6534. static readonly MatricesWeightsExtraKind: string;
  6535. /**
  6536. * Deduces the stride given a kind.
  6537. * @param kind The kind string to deduce
  6538. * @returns The deduced stride
  6539. */
  6540. static DeduceStride(kind: string): number;
  6541. /**
  6542. * Gets the byte length of the given type.
  6543. * @param type the type
  6544. * @returns the number of bytes
  6545. */
  6546. static GetTypeByteLength(type: number): number;
  6547. /**
  6548. * Enumerates each value of the given parameters as numbers.
  6549. * @param data the data to enumerate
  6550. * @param byteOffset the byte offset of the data
  6551. * @param byteStride the byte stride of the data
  6552. * @param componentCount the number of components per element
  6553. * @param componentType the type of the component
  6554. * @param count the number of values to enumerate
  6555. * @param normalized whether the data is normalized
  6556. * @param callback the callback function called for each value
  6557. */
  6558. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6559. private static _GetFloatValue;
  6560. }
  6561. }
  6562. declare module "babylonjs/Collisions/intersectionInfo" {
  6563. import { Nullable } from "babylonjs/types";
  6564. /**
  6565. * @hidden
  6566. */
  6567. export class IntersectionInfo {
  6568. bu: Nullable<number>;
  6569. bv: Nullable<number>;
  6570. distance: number;
  6571. faceId: number;
  6572. subMeshId: number;
  6573. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6574. }
  6575. }
  6576. declare module "babylonjs/Maths/math.plane" {
  6577. import { DeepImmutable } from "babylonjs/types";
  6578. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6579. /**
  6580. * Represens a plane by the equation ax + by + cz + d = 0
  6581. */
  6582. export class Plane {
  6583. private static _TmpMatrix;
  6584. /**
  6585. * Normal of the plane (a,b,c)
  6586. */
  6587. normal: Vector3;
  6588. /**
  6589. * d component of the plane
  6590. */
  6591. d: number;
  6592. /**
  6593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6594. * @param a a component of the plane
  6595. * @param b b component of the plane
  6596. * @param c c component of the plane
  6597. * @param d d component of the plane
  6598. */
  6599. constructor(a: number, b: number, c: number, d: number);
  6600. /**
  6601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6602. */
  6603. asArray(): number[];
  6604. /**
  6605. * @returns a new plane copied from the current Plane.
  6606. */
  6607. clone(): Plane;
  6608. /**
  6609. * @returns the string "Plane".
  6610. */
  6611. getClassName(): string;
  6612. /**
  6613. * @returns the Plane hash code.
  6614. */
  6615. getHashCode(): number;
  6616. /**
  6617. * Normalize the current Plane in place.
  6618. * @returns the updated Plane.
  6619. */
  6620. normalize(): Plane;
  6621. /**
  6622. * Applies a transformation the plane and returns the result
  6623. * @param transformation the transformation matrix to be applied to the plane
  6624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6625. */
  6626. transform(transformation: DeepImmutable<Matrix>): Plane;
  6627. /**
  6628. * Calcualtte the dot product between the point and the plane normal
  6629. * @param point point to calculate the dot product with
  6630. * @returns the dot product (float) of the point coordinates and the plane normal.
  6631. */
  6632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6633. /**
  6634. * Updates the current Plane from the plane defined by the three given points.
  6635. * @param point1 one of the points used to contruct the plane
  6636. * @param point2 one of the points used to contruct the plane
  6637. * @param point3 one of the points used to contruct the plane
  6638. * @returns the updated Plane.
  6639. */
  6640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6641. /**
  6642. * Checks if the plane is facing a given direction
  6643. * @param direction the direction to check if the plane is facing
  6644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6645. * @returns True is the vector "direction" is the same side than the plane normal.
  6646. */
  6647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6648. /**
  6649. * Calculates the distance to a point
  6650. * @param point point to calculate distance to
  6651. * @returns the signed distance (float) from the given point to the Plane.
  6652. */
  6653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6654. /**
  6655. * Creates a plane from an array
  6656. * @param array the array to create a plane from
  6657. * @returns a new Plane from the given array.
  6658. */
  6659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6660. /**
  6661. * Creates a plane from three points
  6662. * @param point1 point used to create the plane
  6663. * @param point2 point used to create the plane
  6664. * @param point3 point used to create the plane
  6665. * @returns a new Plane defined by the three given points.
  6666. */
  6667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6668. /**
  6669. * Creates a plane from an origin point and a normal
  6670. * @param origin origin of the plane to be constructed
  6671. * @param normal normal of the plane to be constructed
  6672. * @returns a new Plane the normal vector to this plane at the given origin point.
  6673. * Note : the vector "normal" is updated because normalized.
  6674. */
  6675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6676. /**
  6677. * Calculates the distance from a plane and a point
  6678. * @param origin origin of the plane to be constructed
  6679. * @param normal normal of the plane to be constructed
  6680. * @param point point to calculate distance to
  6681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6682. */
  6683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6684. }
  6685. }
  6686. declare module "babylonjs/Culling/boundingSphere" {
  6687. import { DeepImmutable } from "babylonjs/types";
  6688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6689. import { Plane } from "babylonjs/Maths/math.plane";
  6690. /**
  6691. * Class used to store bounding sphere information
  6692. */
  6693. export class BoundingSphere {
  6694. /**
  6695. * Gets the center of the bounding sphere in local space
  6696. */
  6697. readonly center: Vector3;
  6698. /**
  6699. * Radius of the bounding sphere in local space
  6700. */
  6701. radius: number;
  6702. /**
  6703. * Gets the center of the bounding sphere in world space
  6704. */
  6705. readonly centerWorld: Vector3;
  6706. /**
  6707. * Radius of the bounding sphere in world space
  6708. */
  6709. radiusWorld: number;
  6710. /**
  6711. * Gets the minimum vector in local space
  6712. */
  6713. readonly minimum: Vector3;
  6714. /**
  6715. * Gets the maximum vector in local space
  6716. */
  6717. readonly maximum: Vector3;
  6718. private _worldMatrix;
  6719. private static readonly TmpVector3;
  6720. /**
  6721. * Creates a new bounding sphere
  6722. * @param min defines the minimum vector (in local space)
  6723. * @param max defines the maximum vector (in local space)
  6724. * @param worldMatrix defines the new world matrix
  6725. */
  6726. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6727. /**
  6728. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6729. * @param min defines the new minimum vector (in local space)
  6730. * @param max defines the new maximum vector (in local space)
  6731. * @param worldMatrix defines the new world matrix
  6732. */
  6733. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6734. /**
  6735. * Scale the current bounding sphere by applying a scale factor
  6736. * @param factor defines the scale factor to apply
  6737. * @returns the current bounding box
  6738. */
  6739. scale(factor: number): BoundingSphere;
  6740. /**
  6741. * Gets the world matrix of the bounding box
  6742. * @returns a matrix
  6743. */
  6744. getWorldMatrix(): DeepImmutable<Matrix>;
  6745. /** @hidden */
  6746. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6747. /**
  6748. * Tests if the bounding sphere is intersecting the frustum planes
  6749. * @param frustumPlanes defines the frustum planes to test
  6750. * @returns true if there is an intersection
  6751. */
  6752. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6753. /**
  6754. * Tests if the bounding sphere center is in between the frustum planes.
  6755. * Used for optimistic fast inclusion.
  6756. * @param frustumPlanes defines the frustum planes to test
  6757. * @returns true if the sphere center is in between the frustum planes
  6758. */
  6759. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6760. /**
  6761. * Tests if a point is inside the bounding sphere
  6762. * @param point defines the point to test
  6763. * @returns true if the point is inside the bounding sphere
  6764. */
  6765. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6766. /**
  6767. * Checks if two sphere intersct
  6768. * @param sphere0 sphere 0
  6769. * @param sphere1 sphere 1
  6770. * @returns true if the speres intersect
  6771. */
  6772. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6773. }
  6774. }
  6775. declare module "babylonjs/Culling/boundingBox" {
  6776. import { DeepImmutable } from "babylonjs/types";
  6777. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6778. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6779. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6780. import { Plane } from "babylonjs/Maths/math.plane";
  6781. /**
  6782. * Class used to store bounding box information
  6783. */
  6784. export class BoundingBox implements ICullable {
  6785. /**
  6786. * Gets the 8 vectors representing the bounding box in local space
  6787. */
  6788. readonly vectors: Vector3[];
  6789. /**
  6790. * Gets the center of the bounding box in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Gets the center of the bounding box in world space
  6795. */
  6796. readonly centerWorld: Vector3;
  6797. /**
  6798. * Gets the extend size in local space
  6799. */
  6800. readonly extendSize: Vector3;
  6801. /**
  6802. * Gets the extend size in world space
  6803. */
  6804. readonly extendSizeWorld: Vector3;
  6805. /**
  6806. * Gets the OBB (object bounding box) directions
  6807. */
  6808. readonly directions: Vector3[];
  6809. /**
  6810. * Gets the 8 vectors representing the bounding box in world space
  6811. */
  6812. readonly vectorsWorld: Vector3[];
  6813. /**
  6814. * Gets the minimum vector in world space
  6815. */
  6816. readonly minimumWorld: Vector3;
  6817. /**
  6818. * Gets the maximum vector in world space
  6819. */
  6820. readonly maximumWorld: Vector3;
  6821. /**
  6822. * Gets the minimum vector in local space
  6823. */
  6824. readonly minimum: Vector3;
  6825. /**
  6826. * Gets the maximum vector in local space
  6827. */
  6828. readonly maximum: Vector3;
  6829. private _worldMatrix;
  6830. private static readonly TmpVector3;
  6831. /**
  6832. * @hidden
  6833. */
  6834. _tag: number;
  6835. /**
  6836. * Creates a new bounding box
  6837. * @param min defines the minimum vector (in local space)
  6838. * @param max defines the maximum vector (in local space)
  6839. * @param worldMatrix defines the new world matrix
  6840. */
  6841. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6842. /**
  6843. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6844. * @param min defines the new minimum vector (in local space)
  6845. * @param max defines the new maximum vector (in local space)
  6846. * @param worldMatrix defines the new world matrix
  6847. */
  6848. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6849. /**
  6850. * Scale the current bounding box by applying a scale factor
  6851. * @param factor defines the scale factor to apply
  6852. * @returns the current bounding box
  6853. */
  6854. scale(factor: number): BoundingBox;
  6855. /**
  6856. * Gets the world matrix of the bounding box
  6857. * @returns a matrix
  6858. */
  6859. getWorldMatrix(): DeepImmutable<Matrix>;
  6860. /** @hidden */
  6861. _update(world: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Tests if the bounding box is intersecting the frustum planes
  6864. * @param frustumPlanes defines the frustum planes to test
  6865. * @returns true if there is an intersection
  6866. */
  6867. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6868. /**
  6869. * Tests if the bounding box is entirely inside the frustum planes
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @returns true if there is an inclusion
  6872. */
  6873. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. /**
  6875. * Tests if a point is inside the bounding box
  6876. * @param point defines the point to test
  6877. * @returns true if the point is inside the bounding box
  6878. */
  6879. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6880. /**
  6881. * Tests if the bounding box intersects with a bounding sphere
  6882. * @param sphere defines the sphere to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6886. /**
  6887. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6888. * @param min defines the min vector to use
  6889. * @param max defines the max vector to use
  6890. * @returns true if there is an intersection
  6891. */
  6892. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Tests if two bounding boxes are intersections
  6895. * @param box0 defines the first box to test
  6896. * @param box1 defines the second box to test
  6897. * @returns true if there is an intersection
  6898. */
  6899. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6900. /**
  6901. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6902. * @param minPoint defines the minimum vector of the bounding box
  6903. * @param maxPoint defines the maximum vector of the bounding box
  6904. * @param sphereCenter defines the sphere center
  6905. * @param sphereRadius defines the sphere radius
  6906. * @returns true if there is an intersection
  6907. */
  6908. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6909. /**
  6910. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6911. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6912. * @param frustumPlanes defines the frustum planes to test
  6913. * @return true if there is an inclusion
  6914. */
  6915. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6916. /**
  6917. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6918. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6919. * @param frustumPlanes defines the frustum planes to test
  6920. * @return true if there is an intersection
  6921. */
  6922. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/collider" {
  6926. import { Nullable, IndicesArray } from "babylonjs/types";
  6927. import { Vector3 } from "babylonjs/Maths/math.vector";
  6928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6929. import { Plane } from "babylonjs/Maths/math.plane";
  6930. /** @hidden */
  6931. export class Collider {
  6932. /** Define if a collision was found */
  6933. collisionFound: boolean;
  6934. /**
  6935. * Define last intersection point in local space
  6936. */
  6937. intersectionPoint: Vector3;
  6938. /**
  6939. * Define last collided mesh
  6940. */
  6941. collidedMesh: Nullable<AbstractMesh>;
  6942. private _collisionPoint;
  6943. private _planeIntersectionPoint;
  6944. private _tempVector;
  6945. private _tempVector2;
  6946. private _tempVector3;
  6947. private _tempVector4;
  6948. private _edge;
  6949. private _baseToVertex;
  6950. private _destinationPoint;
  6951. private _slidePlaneNormal;
  6952. private _displacementVector;
  6953. /** @hidden */
  6954. _radius: Vector3;
  6955. /** @hidden */
  6956. _retry: number;
  6957. private _velocity;
  6958. private _basePoint;
  6959. private _epsilon;
  6960. /** @hidden */
  6961. _velocityWorldLength: number;
  6962. /** @hidden */
  6963. _basePointWorld: Vector3;
  6964. private _velocityWorld;
  6965. private _normalizedVelocity;
  6966. /** @hidden */
  6967. _initialVelocity: Vector3;
  6968. /** @hidden */
  6969. _initialPosition: Vector3;
  6970. private _nearestDistance;
  6971. private _collisionMask;
  6972. collisionMask: number;
  6973. /**
  6974. * Gets the plane normal used to compute the sliding response (in local space)
  6975. */
  6976. readonly slidePlaneNormal: Vector3;
  6977. /** @hidden */
  6978. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6979. /** @hidden */
  6980. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6981. /** @hidden */
  6982. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6983. /** @hidden */
  6984. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6985. /** @hidden */
  6986. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6987. /** @hidden */
  6988. _getResponse(pos: Vector3, vel: Vector3): void;
  6989. }
  6990. }
  6991. declare module "babylonjs/Culling/boundingInfo" {
  6992. import { DeepImmutable } from "babylonjs/types";
  6993. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6994. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6995. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6996. import { Plane } from "babylonjs/Maths/math.plane";
  6997. import { Collider } from "babylonjs/Collisions/collider";
  6998. /**
  6999. * Interface for cullable objects
  7000. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7001. */
  7002. export interface ICullable {
  7003. /**
  7004. * Checks if the object or part of the object is in the frustum
  7005. * @param frustumPlanes Camera near/planes
  7006. * @returns true if the object is in frustum otherwise false
  7007. */
  7008. isInFrustum(frustumPlanes: Plane[]): boolean;
  7009. /**
  7010. * Checks if a cullable object (mesh...) is in the camera frustum
  7011. * Unlike isInFrustum this cheks the full bounding box
  7012. * @param frustumPlanes Camera near/planes
  7013. * @returns true if the object is in frustum otherwise false
  7014. */
  7015. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7016. }
  7017. /**
  7018. * Info for a bounding data of a mesh
  7019. */
  7020. export class BoundingInfo implements ICullable {
  7021. /**
  7022. * Bounding box for the mesh
  7023. */
  7024. readonly boundingBox: BoundingBox;
  7025. /**
  7026. * Bounding sphere for the mesh
  7027. */
  7028. readonly boundingSphere: BoundingSphere;
  7029. private _isLocked;
  7030. private static readonly TmpVector3;
  7031. /**
  7032. * Constructs bounding info
  7033. * @param minimum min vector of the bounding box/sphere
  7034. * @param maximum max vector of the bounding box/sphere
  7035. * @param worldMatrix defines the new world matrix
  7036. */
  7037. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7038. /**
  7039. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7040. * @param min defines the new minimum vector (in local space)
  7041. * @param max defines the new maximum vector (in local space)
  7042. * @param worldMatrix defines the new world matrix
  7043. */
  7044. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7045. /**
  7046. * min vector of the bounding box/sphere
  7047. */
  7048. readonly minimum: Vector3;
  7049. /**
  7050. * max vector of the bounding box/sphere
  7051. */
  7052. readonly maximum: Vector3;
  7053. /**
  7054. * If the info is locked and won't be updated to avoid perf overhead
  7055. */
  7056. isLocked: boolean;
  7057. /**
  7058. * Updates the bounding sphere and box
  7059. * @param world world matrix to be used to update
  7060. */
  7061. update(world: DeepImmutable<Matrix>): void;
  7062. /**
  7063. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7064. * @param center New center of the bounding info
  7065. * @param extend New extend of the bounding info
  7066. * @returns the current bounding info
  7067. */
  7068. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7069. /**
  7070. * Scale the current bounding info by applying a scale factor
  7071. * @param factor defines the scale factor to apply
  7072. * @returns the current bounding info
  7073. */
  7074. scale(factor: number): BoundingInfo;
  7075. /**
  7076. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7077. * @param frustumPlanes defines the frustum to test
  7078. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7079. * @returns true if the bounding info is in the frustum planes
  7080. */
  7081. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7082. /**
  7083. * Gets the world distance between the min and max points of the bounding box
  7084. */
  7085. readonly diagonalLength: number;
  7086. /**
  7087. * Checks if a cullable object (mesh...) is in the camera frustum
  7088. * Unlike isInFrustum this cheks the full bounding box
  7089. * @param frustumPlanes Camera near/planes
  7090. * @returns true if the object is in frustum otherwise false
  7091. */
  7092. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7093. /** @hidden */
  7094. _checkCollision(collider: Collider): boolean;
  7095. /**
  7096. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7097. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7098. * @param point the point to check intersection with
  7099. * @returns if the point intersects
  7100. */
  7101. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7102. /**
  7103. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7104. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7105. * @param boundingInfo the bounding info to check intersection with
  7106. * @param precise if the intersection should be done using OBB
  7107. * @returns if the bounding info intersects
  7108. */
  7109. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7110. }
  7111. }
  7112. declare module "babylonjs/Maths/math.functions" {
  7113. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7114. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7115. /**
  7116. * Extracts minimum and maximum values from a list of indexed positions
  7117. * @param positions defines the positions to use
  7118. * @param indices defines the indices to the positions
  7119. * @param indexStart defines the start index
  7120. * @param indexCount defines the end index
  7121. * @param bias defines bias value to add to the result
  7122. * @return minimum and maximum values
  7123. */
  7124. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7125. minimum: Vector3;
  7126. maximum: Vector3;
  7127. };
  7128. /**
  7129. * Extracts minimum and maximum values from a list of positions
  7130. * @param positions defines the positions to use
  7131. * @param start defines the start index in the positions array
  7132. * @param count defines the number of positions to handle
  7133. * @param bias defines bias value to add to the result
  7134. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7135. * @return minimum and maximum values
  7136. */
  7137. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7138. minimum: Vector3;
  7139. maximum: Vector3;
  7140. };
  7141. }
  7142. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7143. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7144. /** @hidden */
  7145. export class WebGLDataBuffer extends DataBuffer {
  7146. private _buffer;
  7147. constructor(resource: WebGLBuffer);
  7148. readonly underlyingResource: any;
  7149. }
  7150. }
  7151. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7152. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7153. import { Nullable } from "babylonjs/types";
  7154. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7155. /** @hidden */
  7156. export class WebGLPipelineContext implements IPipelineContext {
  7157. engine: ThinEngine;
  7158. program: Nullable<WebGLProgram>;
  7159. context?: WebGLRenderingContext;
  7160. vertexShader?: WebGLShader;
  7161. fragmentShader?: WebGLShader;
  7162. isParallelCompiled: boolean;
  7163. onCompiled?: () => void;
  7164. transformFeedback?: WebGLTransformFeedback | null;
  7165. readonly isAsync: boolean;
  7166. readonly isReady: boolean;
  7167. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7168. }
  7169. }
  7170. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7171. import { FloatArray, Nullable } from "babylonjs/types";
  7172. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7173. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7174. module "babylonjs/Engines/thinEngine" {
  7175. interface ThinEngine {
  7176. /**
  7177. * Create an uniform buffer
  7178. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7179. * @param elements defines the content of the uniform buffer
  7180. * @returns the webGL uniform buffer
  7181. */
  7182. createUniformBuffer(elements: FloatArray): DataBuffer;
  7183. /**
  7184. * Create a dynamic uniform buffer
  7185. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7186. * @param elements defines the content of the uniform buffer
  7187. * @returns the webGL uniform buffer
  7188. */
  7189. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7190. /**
  7191. * Update an existing uniform buffer
  7192. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7193. * @param uniformBuffer defines the target uniform buffer
  7194. * @param elements defines the content to update
  7195. * @param offset defines the offset in the uniform buffer where update should start
  7196. * @param count defines the size of the data to update
  7197. */
  7198. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7199. /**
  7200. * Bind an uniform buffer to the current webGL context
  7201. * @param buffer defines the buffer to bind
  7202. */
  7203. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7204. /**
  7205. * Bind a buffer to the current webGL context at a given location
  7206. * @param buffer defines the buffer to bind
  7207. * @param location defines the index where to bind the buffer
  7208. */
  7209. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7210. /**
  7211. * Bind a specific block at a given index in a specific shader program
  7212. * @param pipelineContext defines the pipeline context to use
  7213. * @param blockName defines the block name
  7214. * @param index defines the index where to bind the block
  7215. */
  7216. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7217. }
  7218. }
  7219. }
  7220. declare module "babylonjs/Materials/uniformBuffer" {
  7221. import { Nullable, FloatArray } from "babylonjs/types";
  7222. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7223. import { Engine } from "babylonjs/Engines/engine";
  7224. import { Effect } from "babylonjs/Materials/effect";
  7225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7226. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7227. import { Color3 } from "babylonjs/Maths/math.color";
  7228. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7229. /**
  7230. * Uniform buffer objects.
  7231. *
  7232. * Handles blocks of uniform on the GPU.
  7233. *
  7234. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7235. *
  7236. * For more information, please refer to :
  7237. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7238. */
  7239. export class UniformBuffer {
  7240. private _engine;
  7241. private _buffer;
  7242. private _data;
  7243. private _bufferData;
  7244. private _dynamic?;
  7245. private _uniformLocations;
  7246. private _uniformSizes;
  7247. private _uniformLocationPointer;
  7248. private _needSync;
  7249. private _noUBO;
  7250. private _currentEffect;
  7251. private static _MAX_UNIFORM_SIZE;
  7252. private static _tempBuffer;
  7253. /**
  7254. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7255. * This is dynamic to allow compat with webgl 1 and 2.
  7256. * You will need to pass the name of the uniform as well as the value.
  7257. */
  7258. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7259. /**
  7260. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7261. * This is dynamic to allow compat with webgl 1 and 2.
  7262. * You will need to pass the name of the uniform as well as the value.
  7263. */
  7264. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7265. /**
  7266. * Lambda to Update a single float in a uniform buffer.
  7267. * This is dynamic to allow compat with webgl 1 and 2.
  7268. * You will need to pass the name of the uniform as well as the value.
  7269. */
  7270. updateFloat: (name: string, x: number) => void;
  7271. /**
  7272. * Lambda to Update a vec2 of float in a uniform buffer.
  7273. * This is dynamic to allow compat with webgl 1 and 2.
  7274. * You will need to pass the name of the uniform as well as the value.
  7275. */
  7276. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7277. /**
  7278. * Lambda to Update a vec3 of float in a uniform buffer.
  7279. * This is dynamic to allow compat with webgl 1 and 2.
  7280. * You will need to pass the name of the uniform as well as the value.
  7281. */
  7282. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7283. /**
  7284. * Lambda to Update a vec4 of float in a uniform buffer.
  7285. * This is dynamic to allow compat with webgl 1 and 2.
  7286. * You will need to pass the name of the uniform as well as the value.
  7287. */
  7288. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7289. /**
  7290. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7291. * This is dynamic to allow compat with webgl 1 and 2.
  7292. * You will need to pass the name of the uniform as well as the value.
  7293. */
  7294. updateMatrix: (name: string, mat: Matrix) => void;
  7295. /**
  7296. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7297. * This is dynamic to allow compat with webgl 1 and 2.
  7298. * You will need to pass the name of the uniform as well as the value.
  7299. */
  7300. updateVector3: (name: string, vector: Vector3) => void;
  7301. /**
  7302. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7303. * This is dynamic to allow compat with webgl 1 and 2.
  7304. * You will need to pass the name of the uniform as well as the value.
  7305. */
  7306. updateVector4: (name: string, vector: Vector4) => void;
  7307. /**
  7308. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7309. * This is dynamic to allow compat with webgl 1 and 2.
  7310. * You will need to pass the name of the uniform as well as the value.
  7311. */
  7312. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7313. /**
  7314. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7319. /**
  7320. * Instantiates a new Uniform buffer objects.
  7321. *
  7322. * Handles blocks of uniform on the GPU.
  7323. *
  7324. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7325. *
  7326. * For more information, please refer to :
  7327. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7328. * @param engine Define the engine the buffer is associated with
  7329. * @param data Define the data contained in the buffer
  7330. * @param dynamic Define if the buffer is updatable
  7331. */
  7332. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7333. /**
  7334. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7335. * or just falling back on setUniformXXX calls.
  7336. */
  7337. readonly useUbo: boolean;
  7338. /**
  7339. * Indicates if the WebGL underlying uniform buffer is in sync
  7340. * with the javascript cache data.
  7341. */
  7342. readonly isSync: boolean;
  7343. /**
  7344. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7345. * Also, a dynamic UniformBuffer will disable cache verification and always
  7346. * update the underlying WebGL uniform buffer to the GPU.
  7347. * @returns if Dynamic, otherwise false
  7348. */
  7349. isDynamic(): boolean;
  7350. /**
  7351. * The data cache on JS side.
  7352. * @returns the underlying data as a float array
  7353. */
  7354. getData(): Float32Array;
  7355. /**
  7356. * The underlying WebGL Uniform buffer.
  7357. * @returns the webgl buffer
  7358. */
  7359. getBuffer(): Nullable<DataBuffer>;
  7360. /**
  7361. * std140 layout specifies how to align data within an UBO structure.
  7362. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7363. * for specs.
  7364. */
  7365. private _fillAlignment;
  7366. /**
  7367. * Adds an uniform in the buffer.
  7368. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7369. * for the layout to be correct !
  7370. * @param name Name of the uniform, as used in the uniform block in the shader.
  7371. * @param size Data size, or data directly.
  7372. */
  7373. addUniform(name: string, size: number | number[]): void;
  7374. /**
  7375. * Adds a Matrix 4x4 to the uniform buffer.
  7376. * @param name Name of the uniform, as used in the uniform block in the shader.
  7377. * @param mat A 4x4 matrix.
  7378. */
  7379. addMatrix(name: string, mat: Matrix): void;
  7380. /**
  7381. * Adds a vec2 to the uniform buffer.
  7382. * @param name Name of the uniform, as used in the uniform block in the shader.
  7383. * @param x Define the x component value of the vec2
  7384. * @param y Define the y component value of the vec2
  7385. */
  7386. addFloat2(name: string, x: number, y: number): void;
  7387. /**
  7388. * Adds a vec3 to the uniform buffer.
  7389. * @param name Name of the uniform, as used in the uniform block in the shader.
  7390. * @param x Define the x component value of the vec3
  7391. * @param y Define the y component value of the vec3
  7392. * @param z Define the z component value of the vec3
  7393. */
  7394. addFloat3(name: string, x: number, y: number, z: number): void;
  7395. /**
  7396. * Adds a vec3 to the uniform buffer.
  7397. * @param name Name of the uniform, as used in the uniform block in the shader.
  7398. * @param color Define the vec3 from a Color
  7399. */
  7400. addColor3(name: string, color: Color3): void;
  7401. /**
  7402. * Adds a vec4 to the uniform buffer.
  7403. * @param name Name of the uniform, as used in the uniform block in the shader.
  7404. * @param color Define the rgb components from a Color
  7405. * @param alpha Define the a component of the vec4
  7406. */
  7407. addColor4(name: string, color: Color3, alpha: number): void;
  7408. /**
  7409. * Adds a vec3 to the uniform buffer.
  7410. * @param name Name of the uniform, as used in the uniform block in the shader.
  7411. * @param vector Define the vec3 components from a Vector
  7412. */
  7413. addVector3(name: string, vector: Vector3): void;
  7414. /**
  7415. * Adds a Matrix 3x3 to the uniform buffer.
  7416. * @param name Name of the uniform, as used in the uniform block in the shader.
  7417. */
  7418. addMatrix3x3(name: string): void;
  7419. /**
  7420. * Adds a Matrix 2x2 to the uniform buffer.
  7421. * @param name Name of the uniform, as used in the uniform block in the shader.
  7422. */
  7423. addMatrix2x2(name: string): void;
  7424. /**
  7425. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7426. */
  7427. create(): void;
  7428. /** @hidden */
  7429. _rebuild(): void;
  7430. /**
  7431. * Updates the WebGL Uniform Buffer on the GPU.
  7432. * If the `dynamic` flag is set to true, no cache comparison is done.
  7433. * Otherwise, the buffer will be updated only if the cache differs.
  7434. */
  7435. update(): void;
  7436. /**
  7437. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7438. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7439. * @param data Define the flattened data
  7440. * @param size Define the size of the data.
  7441. */
  7442. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7443. private _valueCache;
  7444. private _cacheMatrix;
  7445. private _updateMatrix3x3ForUniform;
  7446. private _updateMatrix3x3ForEffect;
  7447. private _updateMatrix2x2ForEffect;
  7448. private _updateMatrix2x2ForUniform;
  7449. private _updateFloatForEffect;
  7450. private _updateFloatForUniform;
  7451. private _updateFloat2ForEffect;
  7452. private _updateFloat2ForUniform;
  7453. private _updateFloat3ForEffect;
  7454. private _updateFloat3ForUniform;
  7455. private _updateFloat4ForEffect;
  7456. private _updateFloat4ForUniform;
  7457. private _updateMatrixForEffect;
  7458. private _updateMatrixForUniform;
  7459. private _updateVector3ForEffect;
  7460. private _updateVector3ForUniform;
  7461. private _updateVector4ForEffect;
  7462. private _updateVector4ForUniform;
  7463. private _updateColor3ForEffect;
  7464. private _updateColor3ForUniform;
  7465. private _updateColor4ForEffect;
  7466. private _updateColor4ForUniform;
  7467. /**
  7468. * Sets a sampler uniform on the effect.
  7469. * @param name Define the name of the sampler.
  7470. * @param texture Define the texture to set in the sampler
  7471. */
  7472. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7473. /**
  7474. * Directly updates the value of the uniform in the cache AND on the GPU.
  7475. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7476. * @param data Define the flattened data
  7477. */
  7478. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7479. /**
  7480. * Binds this uniform buffer to an effect.
  7481. * @param effect Define the effect to bind the buffer to
  7482. * @param name Name of the uniform block in the shader.
  7483. */
  7484. bindToEffect(effect: Effect, name: string): void;
  7485. /**
  7486. * Disposes the uniform buffer.
  7487. */
  7488. dispose(): void;
  7489. }
  7490. }
  7491. declare module "babylonjs/Misc/iInspectable" {
  7492. /**
  7493. * Enum that determines the text-wrapping mode to use.
  7494. */
  7495. export enum InspectableType {
  7496. /**
  7497. * Checkbox for booleans
  7498. */
  7499. Checkbox = 0,
  7500. /**
  7501. * Sliders for numbers
  7502. */
  7503. Slider = 1,
  7504. /**
  7505. * Vector3
  7506. */
  7507. Vector3 = 2,
  7508. /**
  7509. * Quaternions
  7510. */
  7511. Quaternion = 3,
  7512. /**
  7513. * Color3
  7514. */
  7515. Color3 = 4,
  7516. /**
  7517. * String
  7518. */
  7519. String = 5
  7520. }
  7521. /**
  7522. * Interface used to define custom inspectable properties.
  7523. * This interface is used by the inspector to display custom property grids
  7524. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7525. */
  7526. export interface IInspectable {
  7527. /**
  7528. * Gets the label to display
  7529. */
  7530. label: string;
  7531. /**
  7532. * Gets the name of the property to edit
  7533. */
  7534. propertyName: string;
  7535. /**
  7536. * Gets the type of the editor to use
  7537. */
  7538. type: InspectableType;
  7539. /**
  7540. * Gets the minimum value of the property when using in "slider" mode
  7541. */
  7542. min?: number;
  7543. /**
  7544. * Gets the maximum value of the property when using in "slider" mode
  7545. */
  7546. max?: number;
  7547. /**
  7548. * Gets the setp to use when using in "slider" mode
  7549. */
  7550. step?: number;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/timingTools" {
  7554. /**
  7555. * Class used to provide helper for timing
  7556. */
  7557. export class TimingTools {
  7558. /**
  7559. * Polyfill for setImmediate
  7560. * @param action defines the action to execute after the current execution block
  7561. */
  7562. static SetImmediate(action: () => void): void;
  7563. }
  7564. }
  7565. declare module "babylonjs/Misc/instantiationTools" {
  7566. /**
  7567. * Class used to enable instatition of objects by class name
  7568. */
  7569. export class InstantiationTools {
  7570. /**
  7571. * Use this object to register external classes like custom textures or material
  7572. * to allow the laoders to instantiate them
  7573. */
  7574. static RegisteredExternalClasses: {
  7575. [key: string]: Object;
  7576. };
  7577. /**
  7578. * Tries to instantiate a new object from a given class name
  7579. * @param className defines the class name to instantiate
  7580. * @returns the new object or null if the system was not able to do the instantiation
  7581. */
  7582. static Instantiate(className: string): any;
  7583. }
  7584. }
  7585. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7586. /**
  7587. * Define options used to create a depth texture
  7588. */
  7589. export class DepthTextureCreationOptions {
  7590. /** Specifies whether or not a stencil should be allocated in the texture */
  7591. generateStencil?: boolean;
  7592. /** Specifies whether or not bilinear filtering is enable on the texture */
  7593. bilinearFiltering?: boolean;
  7594. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7595. comparisonFunction?: number;
  7596. /** Specifies if the created texture is a cube texture */
  7597. isCube?: boolean;
  7598. }
  7599. }
  7600. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7602. import { Nullable } from "babylonjs/types";
  7603. import { Scene } from "babylonjs/scene";
  7604. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7605. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7606. module "babylonjs/Engines/thinEngine" {
  7607. interface ThinEngine {
  7608. /**
  7609. * Creates a depth stencil cube texture.
  7610. * This is only available in WebGL 2.
  7611. * @param size The size of face edge in the cube texture.
  7612. * @param options The options defining the cube texture.
  7613. * @returns The cube texture
  7614. */
  7615. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7616. /**
  7617. * Creates a cube texture
  7618. * @param rootUrl defines the url where the files to load is located
  7619. * @param scene defines the current scene
  7620. * @param files defines the list of files to load (1 per face)
  7621. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7622. * @param onLoad defines an optional callback raised when the texture is loaded
  7623. * @param onError defines an optional callback raised if there is an issue to load the texture
  7624. * @param format defines the format of the data
  7625. * @param forcedExtension defines the extension to use to pick the right loader
  7626. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7627. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7628. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7629. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7630. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7631. * @returns the cube texture as an InternalTexture
  7632. */
  7633. 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;
  7634. /**
  7635. * Creates a cube texture
  7636. * @param rootUrl defines the url where the files to load is located
  7637. * @param scene defines the current scene
  7638. * @param files defines the list of files to load (1 per face)
  7639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7640. * @param onLoad defines an optional callback raised when the texture is loaded
  7641. * @param onError defines an optional callback raised if there is an issue to load the texture
  7642. * @param format defines the format of the data
  7643. * @param forcedExtension defines the extension to use to pick the right loader
  7644. * @returns the cube texture as an InternalTexture
  7645. */
  7646. 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;
  7647. /**
  7648. * Creates a cube texture
  7649. * @param rootUrl defines the url where the files to load is located
  7650. * @param scene defines the current scene
  7651. * @param files defines the list of files to load (1 per face)
  7652. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7653. * @param onLoad defines an optional callback raised when the texture is loaded
  7654. * @param onError defines an optional callback raised if there is an issue to load the texture
  7655. * @param format defines the format of the data
  7656. * @param forcedExtension defines the extension to use to pick the right loader
  7657. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7658. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7659. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7660. * @returns the cube texture as an InternalTexture
  7661. */
  7662. 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;
  7663. /** @hidden */
  7664. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7665. /** @hidden */
  7666. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7671. }
  7672. }
  7673. }
  7674. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7675. import { Nullable } from "babylonjs/types";
  7676. import { Scene } from "babylonjs/scene";
  7677. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7678. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7679. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * The url of the texture
  7687. */
  7688. url: string;
  7689. /**
  7690. * Gets or sets the center of the bounding box associated with the cube texture.
  7691. * It must define where the camera used to render the texture was set
  7692. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7693. */
  7694. boundingBoxPosition: Vector3;
  7695. private _boundingBoxSize;
  7696. /**
  7697. * Gets or sets the size of the bounding box associated with the cube texture
  7698. * When defined, the cubemap will switch to local mode
  7699. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7700. * @example https://www.babylonjs-playground.com/#RNASML
  7701. */
  7702. /**
  7703. * Returns the bounding box size
  7704. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7705. */
  7706. boundingBoxSize: Vector3;
  7707. protected _rotationY: number;
  7708. /**
  7709. * Sets texture matrix rotation angle around Y axis in radians.
  7710. */
  7711. /**
  7712. * Gets texture matrix rotation angle around Y axis radians.
  7713. */
  7714. rotationY: number;
  7715. /**
  7716. * Are mip maps generated for this texture or not.
  7717. */
  7718. readonly noMipmap: boolean;
  7719. private _noMipmap;
  7720. private _files;
  7721. protected _forcedExtension: Nullable<string>;
  7722. private _extensions;
  7723. private _textureMatrix;
  7724. private _format;
  7725. private _createPolynomials;
  7726. /** @hidden */
  7727. _prefiltered: boolean;
  7728. /**
  7729. * Creates a cube texture from an array of image urls
  7730. * @param files defines an array of image urls
  7731. * @param scene defines the hosting scene
  7732. * @param noMipmap specifies if mip maps are not used
  7733. * @returns a cube texture
  7734. */
  7735. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7736. /**
  7737. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7738. * @param url defines the url of the prefiltered texture
  7739. * @param scene defines the scene the texture is attached to
  7740. * @param forcedExtension defines the extension of the file if different from the url
  7741. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7742. * @return the prefiltered texture
  7743. */
  7744. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7745. /**
  7746. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7747. * as prefiltered data.
  7748. * @param rootUrl defines the url of the texture or the root name of the six images
  7749. * @param scene defines the scene the texture is attached to
  7750. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7751. * @param noMipmap defines if mipmaps should be created or not
  7752. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7753. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7754. * @param onError defines a callback triggered in case of error during load
  7755. * @param format defines the internal format to use for the texture once loaded
  7756. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7757. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7758. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7759. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7760. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7761. * @return the cube texture
  7762. */
  7763. 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);
  7764. /**
  7765. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7766. */
  7767. readonly isPrefiltered: boolean;
  7768. /**
  7769. * Get the current class name of the texture useful for serialization or dynamic coding.
  7770. * @returns "CubeTexture"
  7771. */
  7772. getClassName(): string;
  7773. /**
  7774. * Update the url (and optional buffer) of this texture if url was null during construction.
  7775. * @param url the url of the texture
  7776. * @param forcedExtension defines the extension to use
  7777. * @param onLoad callback called when the texture is loaded (defaults to null)
  7778. */
  7779. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7780. /**
  7781. * Delays loading of the cube texture
  7782. * @param forcedExtension defines the extension to use
  7783. */
  7784. delayLoad(forcedExtension?: string): void;
  7785. /**
  7786. * Returns the reflection texture matrix
  7787. * @returns the reflection texture matrix
  7788. */
  7789. getReflectionTextureMatrix(): Matrix;
  7790. /**
  7791. * Sets the reflection texture matrix
  7792. * @param value Reflection texture matrix
  7793. */
  7794. setReflectionTextureMatrix(value: Matrix): void;
  7795. /**
  7796. * Parses text to create a cube texture
  7797. * @param parsedTexture define the serialized text to read from
  7798. * @param scene defines the hosting scene
  7799. * @param rootUrl defines the root url of the cube texture
  7800. * @returns a cube texture
  7801. */
  7802. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7803. /**
  7804. * Makes a clone, or deep copy, of the cube texture
  7805. * @returns a new cube texture
  7806. */
  7807. clone(): CubeTexture;
  7808. }
  7809. }
  7810. declare module "babylonjs/Materials/materialDefines" {
  7811. /**
  7812. * Manages the defines for the Material
  7813. */
  7814. export class MaterialDefines {
  7815. /** @hidden */
  7816. protected _keys: string[];
  7817. private _isDirty;
  7818. /** @hidden */
  7819. _renderId: number;
  7820. /** @hidden */
  7821. _areLightsDirty: boolean;
  7822. /** @hidden */
  7823. _areLightsDisposed: boolean;
  7824. /** @hidden */
  7825. _areAttributesDirty: boolean;
  7826. /** @hidden */
  7827. _areTexturesDirty: boolean;
  7828. /** @hidden */
  7829. _areFresnelDirty: boolean;
  7830. /** @hidden */
  7831. _areMiscDirty: boolean;
  7832. /** @hidden */
  7833. _areImageProcessingDirty: boolean;
  7834. /** @hidden */
  7835. _normals: boolean;
  7836. /** @hidden */
  7837. _uvs: boolean;
  7838. /** @hidden */
  7839. _needNormals: boolean;
  7840. /** @hidden */
  7841. _needUVs: boolean;
  7842. [id: string]: any;
  7843. /**
  7844. * Specifies if the material needs to be re-calculated
  7845. */
  7846. readonly isDirty: boolean;
  7847. /**
  7848. * Marks the material to indicate that it has been re-calculated
  7849. */
  7850. markAsProcessed(): void;
  7851. /**
  7852. * Marks the material to indicate that it needs to be re-calculated
  7853. */
  7854. markAsUnprocessed(): void;
  7855. /**
  7856. * Marks the material to indicate all of its defines need to be re-calculated
  7857. */
  7858. markAllAsDirty(): void;
  7859. /**
  7860. * Marks the material to indicate that image processing needs to be re-calculated
  7861. */
  7862. markAsImageProcessingDirty(): void;
  7863. /**
  7864. * Marks the material to indicate the lights need to be re-calculated
  7865. * @param disposed Defines whether the light is dirty due to dispose or not
  7866. */
  7867. markAsLightDirty(disposed?: boolean): void;
  7868. /**
  7869. * Marks the attribute state as changed
  7870. */
  7871. markAsAttributesDirty(): void;
  7872. /**
  7873. * Marks the texture state as changed
  7874. */
  7875. markAsTexturesDirty(): void;
  7876. /**
  7877. * Marks the fresnel state as changed
  7878. */
  7879. markAsFresnelDirty(): void;
  7880. /**
  7881. * Marks the misc state as changed
  7882. */
  7883. markAsMiscDirty(): void;
  7884. /**
  7885. * Rebuilds the material defines
  7886. */
  7887. rebuild(): void;
  7888. /**
  7889. * Specifies if two material defines are equal
  7890. * @param other - A material define instance to compare to
  7891. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7892. */
  7893. isEqual(other: MaterialDefines): boolean;
  7894. /**
  7895. * Clones this instance's defines to another instance
  7896. * @param other - material defines to clone values to
  7897. */
  7898. cloneTo(other: MaterialDefines): void;
  7899. /**
  7900. * Resets the material define values
  7901. */
  7902. reset(): void;
  7903. /**
  7904. * Converts the material define values to a string
  7905. * @returns - String of material define information
  7906. */
  7907. toString(): string;
  7908. }
  7909. }
  7910. declare module "babylonjs/Materials/colorCurves" {
  7911. import { Effect } from "babylonjs/Materials/effect";
  7912. /**
  7913. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7914. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7915. * 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;
  7916. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7917. */
  7918. export class ColorCurves {
  7919. private _dirty;
  7920. private _tempColor;
  7921. private _globalCurve;
  7922. private _highlightsCurve;
  7923. private _midtonesCurve;
  7924. private _shadowsCurve;
  7925. private _positiveCurve;
  7926. private _negativeCurve;
  7927. private _globalHue;
  7928. private _globalDensity;
  7929. private _globalSaturation;
  7930. private _globalExposure;
  7931. /**
  7932. * Gets the global Hue value.
  7933. * 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).
  7934. */
  7935. /**
  7936. * Sets the global Hue value.
  7937. * 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).
  7938. */
  7939. globalHue: number;
  7940. /**
  7941. * Gets the global Density value.
  7942. * 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.
  7943. * Values less than zero provide a filter of opposite hue.
  7944. */
  7945. /**
  7946. * Sets the global Density value.
  7947. * 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.
  7948. * Values less than zero provide a filter of opposite hue.
  7949. */
  7950. globalDensity: number;
  7951. /**
  7952. * Gets the global Saturation value.
  7953. * 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.
  7954. */
  7955. /**
  7956. * Sets the global Saturation value.
  7957. * 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.
  7958. */
  7959. globalSaturation: number;
  7960. /**
  7961. * Gets the global Exposure value.
  7962. * 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.
  7963. */
  7964. /**
  7965. * Sets the global Exposure value.
  7966. * 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.
  7967. */
  7968. globalExposure: number;
  7969. private _highlightsHue;
  7970. private _highlightsDensity;
  7971. private _highlightsSaturation;
  7972. private _highlightsExposure;
  7973. /**
  7974. * Gets the highlights Hue value.
  7975. * 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).
  7976. */
  7977. /**
  7978. * Sets the highlights Hue value.
  7979. * 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).
  7980. */
  7981. highlightsHue: number;
  7982. /**
  7983. * Gets the highlights Density value.
  7984. * 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.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. /**
  7988. * Sets the highlights 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. highlightsDensity: number;
  7993. /**
  7994. * Gets the highlights 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. /**
  7998. * Sets the highlights Saturation value.
  7999. * 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.
  8000. */
  8001. highlightsSaturation: number;
  8002. /**
  8003. * Gets the highlights Exposure value.
  8004. * 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.
  8005. */
  8006. /**
  8007. * Sets the highlights Exposure value.
  8008. * 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.
  8009. */
  8010. highlightsExposure: number;
  8011. private _midtonesHue;
  8012. private _midtonesDensity;
  8013. private _midtonesSaturation;
  8014. private _midtonesExposure;
  8015. /**
  8016. * Gets the midtones Hue value.
  8017. * 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).
  8018. */
  8019. /**
  8020. * Sets the midtones Hue value.
  8021. * 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).
  8022. */
  8023. midtonesHue: number;
  8024. /**
  8025. * Gets the midtones Density value.
  8026. * 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.
  8027. * Values less than zero provide a filter of opposite hue.
  8028. */
  8029. /**
  8030. * Sets the midtones Density value.
  8031. * 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.
  8032. * Values less than zero provide a filter of opposite hue.
  8033. */
  8034. midtonesDensity: number;
  8035. /**
  8036. * Gets the midtones Saturation value.
  8037. * 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.
  8038. */
  8039. /**
  8040. * Sets the midtones 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. midtonesSaturation: number;
  8044. /**
  8045. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  8047. */
  8048. /**
  8049. * Sets the midtones Exposure value.
  8050. * 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.
  8051. */
  8052. midtonesExposure: number;
  8053. private _shadowsHue;
  8054. private _shadowsDensity;
  8055. private _shadowsSaturation;
  8056. private _shadowsExposure;
  8057. /**
  8058. * Gets the shadows Hue value.
  8059. * 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).
  8060. */
  8061. /**
  8062. * Sets the shadows Hue value.
  8063. * 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).
  8064. */
  8065. shadowsHue: number;
  8066. /**
  8067. * Gets the shadows Density value.
  8068. * 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.
  8069. * Values less than zero provide a filter of opposite hue.
  8070. */
  8071. /**
  8072. * Sets the shadows Density value.
  8073. * 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.
  8074. * Values less than zero provide a filter of opposite hue.
  8075. */
  8076. shadowsDensity: number;
  8077. /**
  8078. * Gets the shadows Saturation value.
  8079. * 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.
  8080. */
  8081. /**
  8082. * Sets the shadows Saturation value.
  8083. * 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.
  8084. */
  8085. shadowsSaturation: number;
  8086. /**
  8087. * Gets the shadows Exposure value.
  8088. * 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.
  8089. */
  8090. /**
  8091. * Sets the shadows Exposure 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 exposure and negative values decrease exposure.
  8093. */
  8094. shadowsExposure: number;
  8095. /**
  8096. * Returns the class name
  8097. * @returns The class name
  8098. */
  8099. getClassName(): string;
  8100. /**
  8101. * Binds the color curves to the shader.
  8102. * @param colorCurves The color curve to bind
  8103. * @param effect The effect to bind to
  8104. * @param positiveUniform The positive uniform shader parameter
  8105. * @param neutralUniform The neutral uniform shader parameter
  8106. * @param negativeUniform The negative uniform shader parameter
  8107. */
  8108. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8109. /**
  8110. * Prepare the list of uniforms associated with the ColorCurves effects.
  8111. * @param uniformsList The list of uniforms used in the effect
  8112. */
  8113. static PrepareUniforms(uniformsList: string[]): void;
  8114. /**
  8115. * Returns color grading data based on a hue, density, saturation and exposure value.
  8116. * @param filterHue The hue of the color filter.
  8117. * @param filterDensity The density of the color filter.
  8118. * @param saturation The saturation.
  8119. * @param exposure The exposure.
  8120. * @param result The result data container.
  8121. */
  8122. private getColorGradingDataToRef;
  8123. /**
  8124. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8125. * @param value The input slider value in range [-100,100].
  8126. * @returns Adjusted value.
  8127. */
  8128. private static applyColorGradingSliderNonlinear;
  8129. /**
  8130. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8131. * @param hue The hue (H) input.
  8132. * @param saturation The saturation (S) input.
  8133. * @param brightness The brightness (B) input.
  8134. * @result An RGBA color represented as Vector4.
  8135. */
  8136. private static fromHSBToRef;
  8137. /**
  8138. * Returns a value clamped between min and max
  8139. * @param value The value to clamp
  8140. * @param min The minimum of value
  8141. * @param max The maximum of value
  8142. * @returns The clamped value.
  8143. */
  8144. private static clamp;
  8145. /**
  8146. * Clones the current color curve instance.
  8147. * @return The cloned curves
  8148. */
  8149. clone(): ColorCurves;
  8150. /**
  8151. * Serializes the current color curve instance to a json representation.
  8152. * @return a JSON representation
  8153. */
  8154. serialize(): any;
  8155. /**
  8156. * Parses the color curve from a json representation.
  8157. * @param source the JSON source to parse
  8158. * @return The parsed curves
  8159. */
  8160. static Parse(source: any): ColorCurves;
  8161. }
  8162. }
  8163. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8164. import { Observable } from "babylonjs/Misc/observable";
  8165. import { Nullable } from "babylonjs/types";
  8166. import { Color4 } from "babylonjs/Maths/math.color";
  8167. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8168. import { Effect } from "babylonjs/Materials/effect";
  8169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8170. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8171. /**
  8172. * Interface to follow in your material defines to integrate easily the
  8173. * Image proccessing functions.
  8174. * @hidden
  8175. */
  8176. export interface IImageProcessingConfigurationDefines {
  8177. IMAGEPROCESSING: boolean;
  8178. VIGNETTE: boolean;
  8179. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8180. VIGNETTEBLENDMODEOPAQUE: boolean;
  8181. TONEMAPPING: boolean;
  8182. TONEMAPPING_ACES: boolean;
  8183. CONTRAST: boolean;
  8184. EXPOSURE: boolean;
  8185. COLORCURVES: boolean;
  8186. COLORGRADING: boolean;
  8187. COLORGRADING3D: boolean;
  8188. SAMPLER3DGREENDEPTH: boolean;
  8189. SAMPLER3DBGRMAP: boolean;
  8190. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8191. }
  8192. /**
  8193. * @hidden
  8194. */
  8195. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8196. IMAGEPROCESSING: boolean;
  8197. VIGNETTE: boolean;
  8198. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8199. VIGNETTEBLENDMODEOPAQUE: boolean;
  8200. TONEMAPPING: boolean;
  8201. TONEMAPPING_ACES: boolean;
  8202. CONTRAST: boolean;
  8203. COLORCURVES: boolean;
  8204. COLORGRADING: boolean;
  8205. COLORGRADING3D: boolean;
  8206. SAMPLER3DGREENDEPTH: boolean;
  8207. SAMPLER3DBGRMAP: boolean;
  8208. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8209. EXPOSURE: boolean;
  8210. constructor();
  8211. }
  8212. /**
  8213. * This groups together the common properties used for image processing either in direct forward pass
  8214. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8215. * or not.
  8216. */
  8217. export class ImageProcessingConfiguration {
  8218. /**
  8219. * Default tone mapping applied in BabylonJS.
  8220. */
  8221. static readonly TONEMAPPING_STANDARD: number;
  8222. /**
  8223. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8224. * to other engines rendering to increase portability.
  8225. */
  8226. static readonly TONEMAPPING_ACES: number;
  8227. /**
  8228. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8229. */
  8230. colorCurves: Nullable<ColorCurves>;
  8231. private _colorCurvesEnabled;
  8232. /**
  8233. * Gets wether the color curves effect is enabled.
  8234. */
  8235. /**
  8236. * Sets wether the color curves effect is enabled.
  8237. */
  8238. colorCurvesEnabled: boolean;
  8239. private _colorGradingTexture;
  8240. /**
  8241. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8242. */
  8243. /**
  8244. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8245. */
  8246. colorGradingTexture: Nullable<BaseTexture>;
  8247. private _colorGradingEnabled;
  8248. /**
  8249. * Gets wether the color grading effect is enabled.
  8250. */
  8251. /**
  8252. * Sets wether the color grading effect is enabled.
  8253. */
  8254. colorGradingEnabled: boolean;
  8255. private _colorGradingWithGreenDepth;
  8256. /**
  8257. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8258. */
  8259. /**
  8260. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8261. */
  8262. colorGradingWithGreenDepth: boolean;
  8263. private _colorGradingBGR;
  8264. /**
  8265. * Gets wether the color grading texture contains BGR values.
  8266. */
  8267. /**
  8268. * Sets wether the color grading texture contains BGR values.
  8269. */
  8270. colorGradingBGR: boolean;
  8271. /** @hidden */
  8272. _exposure: number;
  8273. /**
  8274. * Gets the Exposure used in the effect.
  8275. */
  8276. /**
  8277. * Sets the Exposure used in the effect.
  8278. */
  8279. exposure: number;
  8280. private _toneMappingEnabled;
  8281. /**
  8282. * Gets wether the tone mapping effect is enabled.
  8283. */
  8284. /**
  8285. * Sets wether the tone mapping effect is enabled.
  8286. */
  8287. toneMappingEnabled: boolean;
  8288. private _toneMappingType;
  8289. /**
  8290. * Gets the type of tone mapping effect.
  8291. */
  8292. /**
  8293. * Sets the type of tone mapping effect used in BabylonJS.
  8294. */
  8295. toneMappingType: number;
  8296. protected _contrast: number;
  8297. /**
  8298. * Gets the contrast used in the effect.
  8299. */
  8300. /**
  8301. * Sets the contrast used in the effect.
  8302. */
  8303. contrast: number;
  8304. /**
  8305. * Vignette stretch size.
  8306. */
  8307. vignetteStretch: number;
  8308. /**
  8309. * Vignette centre X Offset.
  8310. */
  8311. vignetteCentreX: number;
  8312. /**
  8313. * Vignette centre Y Offset.
  8314. */
  8315. vignetteCentreY: number;
  8316. /**
  8317. * Vignette weight or intensity of the vignette effect.
  8318. */
  8319. vignetteWeight: number;
  8320. /**
  8321. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8322. * if vignetteEnabled is set to true.
  8323. */
  8324. vignetteColor: Color4;
  8325. /**
  8326. * Camera field of view used by the Vignette effect.
  8327. */
  8328. vignetteCameraFov: number;
  8329. private _vignetteBlendMode;
  8330. /**
  8331. * Gets the vignette blend mode allowing different kind of effect.
  8332. */
  8333. /**
  8334. * Sets the vignette blend mode allowing different kind of effect.
  8335. */
  8336. vignetteBlendMode: number;
  8337. private _vignetteEnabled;
  8338. /**
  8339. * Gets wether the vignette effect is enabled.
  8340. */
  8341. /**
  8342. * Sets wether the vignette effect is enabled.
  8343. */
  8344. vignetteEnabled: boolean;
  8345. private _applyByPostProcess;
  8346. /**
  8347. * Gets wether the image processing is applied through a post process or not.
  8348. */
  8349. /**
  8350. * Sets wether the image processing is applied through a post process or not.
  8351. */
  8352. applyByPostProcess: boolean;
  8353. private _isEnabled;
  8354. /**
  8355. * Gets wether the image processing is enabled or not.
  8356. */
  8357. /**
  8358. * Sets wether the image processing is enabled or not.
  8359. */
  8360. isEnabled: boolean;
  8361. /**
  8362. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8363. */
  8364. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8365. /**
  8366. * Method called each time the image processing information changes requires to recompile the effect.
  8367. */
  8368. protected _updateParameters(): void;
  8369. /**
  8370. * Gets the current class name.
  8371. * @return "ImageProcessingConfiguration"
  8372. */
  8373. getClassName(): string;
  8374. /**
  8375. * Prepare the list of uniforms associated with the Image Processing effects.
  8376. * @param uniforms The list of uniforms used in the effect
  8377. * @param defines the list of defines currently in use
  8378. */
  8379. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8380. /**
  8381. * Prepare the list of samplers associated with the Image Processing effects.
  8382. * @param samplersList The list of uniforms used in the effect
  8383. * @param defines the list of defines currently in use
  8384. */
  8385. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8386. /**
  8387. * Prepare the list of defines associated to the shader.
  8388. * @param defines the list of defines to complete
  8389. * @param forPostProcess Define if we are currently in post process mode or not
  8390. */
  8391. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8392. /**
  8393. * Returns true if all the image processing information are ready.
  8394. * @returns True if ready, otherwise, false
  8395. */
  8396. isReady(): boolean;
  8397. /**
  8398. * Binds the image processing to the shader.
  8399. * @param effect The effect to bind to
  8400. * @param aspectRatio Define the current aspect ratio of the effect
  8401. */
  8402. bind(effect: Effect, aspectRatio?: number): void;
  8403. /**
  8404. * Clones the current image processing instance.
  8405. * @return The cloned image processing
  8406. */
  8407. clone(): ImageProcessingConfiguration;
  8408. /**
  8409. * Serializes the current image processing instance to a json representation.
  8410. * @return a JSON representation
  8411. */
  8412. serialize(): any;
  8413. /**
  8414. * Parses the image processing from a json representation.
  8415. * @param source the JSON source to parse
  8416. * @return The parsed image processing
  8417. */
  8418. static Parse(source: any): ImageProcessingConfiguration;
  8419. private static _VIGNETTEMODE_MULTIPLY;
  8420. private static _VIGNETTEMODE_OPAQUE;
  8421. /**
  8422. * Used to apply the vignette as a mix with the pixel color.
  8423. */
  8424. static readonly VIGNETTEMODE_MULTIPLY: number;
  8425. /**
  8426. * Used to apply the vignette as a replacement of the pixel color.
  8427. */
  8428. static readonly VIGNETTEMODE_OPAQUE: number;
  8429. }
  8430. }
  8431. declare module "babylonjs/Shaders/postprocess.vertex" {
  8432. /** @hidden */
  8433. export var postprocessVertexShader: {
  8434. name: string;
  8435. shader: string;
  8436. };
  8437. }
  8438. declare module "babylonjs/Maths/math.axis" {
  8439. import { Vector3 } from "babylonjs/Maths/math.vector";
  8440. /** Defines supported spaces */
  8441. export enum Space {
  8442. /** Local (object) space */
  8443. LOCAL = 0,
  8444. /** World space */
  8445. WORLD = 1,
  8446. /** Bone space */
  8447. BONE = 2
  8448. }
  8449. /** Defines the 3 main axes */
  8450. export class Axis {
  8451. /** X axis */
  8452. static X: Vector3;
  8453. /** Y axis */
  8454. static Y: Vector3;
  8455. /** Z axis */
  8456. static Z: Vector3;
  8457. }
  8458. }
  8459. declare module "babylonjs/Cameras/targetCamera" {
  8460. import { Nullable } from "babylonjs/types";
  8461. import { Camera } from "babylonjs/Cameras/camera";
  8462. import { Scene } from "babylonjs/scene";
  8463. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8464. /**
  8465. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8466. * This is the base of the follow, arc rotate cameras and Free camera
  8467. * @see http://doc.babylonjs.com/features/cameras
  8468. */
  8469. export class TargetCamera extends Camera {
  8470. private static _RigCamTransformMatrix;
  8471. private static _TargetTransformMatrix;
  8472. private static _TargetFocalPoint;
  8473. /**
  8474. * Define the current direction the camera is moving to
  8475. */
  8476. cameraDirection: Vector3;
  8477. /**
  8478. * Define the current rotation the camera is rotating to
  8479. */
  8480. cameraRotation: Vector2;
  8481. /**
  8482. * When set, the up vector of the camera will be updated by the rotation of the camera
  8483. */
  8484. updateUpVectorFromRotation: boolean;
  8485. private _tmpQuaternion;
  8486. /**
  8487. * Define the current rotation of the camera
  8488. */
  8489. rotation: Vector3;
  8490. /**
  8491. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8492. */
  8493. rotationQuaternion: Quaternion;
  8494. /**
  8495. * Define the current speed of the camera
  8496. */
  8497. speed: number;
  8498. /**
  8499. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8500. * around all axis.
  8501. */
  8502. noRotationConstraint: boolean;
  8503. /**
  8504. * Define the current target of the camera as an object or a position.
  8505. */
  8506. lockedTarget: any;
  8507. /** @hidden */
  8508. _currentTarget: Vector3;
  8509. /** @hidden */
  8510. _initialFocalDistance: number;
  8511. /** @hidden */
  8512. _viewMatrix: Matrix;
  8513. /** @hidden */
  8514. _camMatrix: Matrix;
  8515. /** @hidden */
  8516. _cameraTransformMatrix: Matrix;
  8517. /** @hidden */
  8518. _cameraRotationMatrix: Matrix;
  8519. /** @hidden */
  8520. _referencePoint: Vector3;
  8521. /** @hidden */
  8522. _transformedReferencePoint: Vector3;
  8523. protected _globalCurrentTarget: Vector3;
  8524. protected _globalCurrentUpVector: Vector3;
  8525. /** @hidden */
  8526. _reset: () => void;
  8527. private _defaultUp;
  8528. /**
  8529. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8530. * This is the base of the follow, arc rotate cameras and Free camera
  8531. * @see http://doc.babylonjs.com/features/cameras
  8532. * @param name Defines the name of the camera in the scene
  8533. * @param position Defines the start position of the camera in the scene
  8534. * @param scene Defines the scene the camera belongs to
  8535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8536. */
  8537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8538. /**
  8539. * Gets the position in front of the camera at a given distance.
  8540. * @param distance The distance from the camera we want the position to be
  8541. * @returns the position
  8542. */
  8543. getFrontPosition(distance: number): Vector3;
  8544. /** @hidden */
  8545. _getLockedTargetPosition(): Nullable<Vector3>;
  8546. private _storedPosition;
  8547. private _storedRotation;
  8548. private _storedRotationQuaternion;
  8549. /**
  8550. * Store current camera state of the camera (fov, position, rotation, etc..)
  8551. * @returns the camera
  8552. */
  8553. storeState(): Camera;
  8554. /**
  8555. * Restored camera state. You must call storeState() first
  8556. * @returns whether it was successful or not
  8557. * @hidden
  8558. */
  8559. _restoreStateValues(): boolean;
  8560. /** @hidden */
  8561. _initCache(): void;
  8562. /** @hidden */
  8563. _updateCache(ignoreParentClass?: boolean): void;
  8564. /** @hidden */
  8565. _isSynchronizedViewMatrix(): boolean;
  8566. /** @hidden */
  8567. _computeLocalCameraSpeed(): number;
  8568. /**
  8569. * Defines the target the camera should look at.
  8570. * @param target Defines the new target as a Vector or a mesh
  8571. */
  8572. setTarget(target: Vector3): void;
  8573. /**
  8574. * Return the current target position of the camera. This value is expressed in local space.
  8575. * @returns the target position
  8576. */
  8577. getTarget(): Vector3;
  8578. /** @hidden */
  8579. _decideIfNeedsToMove(): boolean;
  8580. /** @hidden */
  8581. _updatePosition(): void;
  8582. /** @hidden */
  8583. _checkInputs(): void;
  8584. protected _updateCameraRotationMatrix(): void;
  8585. /**
  8586. * 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)
  8587. * @returns the current camera
  8588. */
  8589. private _rotateUpVectorWithCameraRotationMatrix;
  8590. private _cachedRotationZ;
  8591. private _cachedQuaternionRotationZ;
  8592. /** @hidden */
  8593. _getViewMatrix(): Matrix;
  8594. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8595. /**
  8596. * @hidden
  8597. */
  8598. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8599. /**
  8600. * @hidden
  8601. */
  8602. _updateRigCameras(): void;
  8603. private _getRigCamPositionAndTarget;
  8604. /**
  8605. * Gets the current object class name.
  8606. * @return the class name
  8607. */
  8608. getClassName(): string;
  8609. }
  8610. }
  8611. declare module "babylonjs/Events/keyboardEvents" {
  8612. /**
  8613. * Gather the list of keyboard event types as constants.
  8614. */
  8615. export class KeyboardEventTypes {
  8616. /**
  8617. * The keydown event is fired when a key becomes active (pressed).
  8618. */
  8619. static readonly KEYDOWN: number;
  8620. /**
  8621. * The keyup event is fired when a key has been released.
  8622. */
  8623. static readonly KEYUP: number;
  8624. }
  8625. /**
  8626. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8627. */
  8628. export class KeyboardInfo {
  8629. /**
  8630. * Defines the type of event (KeyboardEventTypes)
  8631. */
  8632. type: number;
  8633. /**
  8634. * Defines the related dom event
  8635. */
  8636. event: KeyboardEvent;
  8637. /**
  8638. * Instantiates a new keyboard info.
  8639. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8640. * @param type Defines the type of event (KeyboardEventTypes)
  8641. * @param event Defines the related dom event
  8642. */
  8643. constructor(
  8644. /**
  8645. * Defines the type of event (KeyboardEventTypes)
  8646. */
  8647. type: number,
  8648. /**
  8649. * Defines the related dom event
  8650. */
  8651. event: KeyboardEvent);
  8652. }
  8653. /**
  8654. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8655. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8656. */
  8657. export class KeyboardInfoPre extends KeyboardInfo {
  8658. /**
  8659. * Defines the type of event (KeyboardEventTypes)
  8660. */
  8661. type: number;
  8662. /**
  8663. * Defines the related dom event
  8664. */
  8665. event: KeyboardEvent;
  8666. /**
  8667. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8668. */
  8669. skipOnPointerObservable: boolean;
  8670. /**
  8671. * Instantiates a new keyboard pre info.
  8672. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8673. * @param type Defines the type of event (KeyboardEventTypes)
  8674. * @param event Defines the related dom event
  8675. */
  8676. constructor(
  8677. /**
  8678. * Defines the type of event (KeyboardEventTypes)
  8679. */
  8680. type: number,
  8681. /**
  8682. * Defines the related dom event
  8683. */
  8684. event: KeyboardEvent);
  8685. }
  8686. }
  8687. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8688. import { Nullable } from "babylonjs/types";
  8689. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8690. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8691. /**
  8692. * Manage the keyboard inputs to control the movement of a free camera.
  8693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8694. */
  8695. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8696. /**
  8697. * Defines the camera the input is attached to.
  8698. */
  8699. camera: FreeCamera;
  8700. /**
  8701. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8702. */
  8703. keysUp: number[];
  8704. /**
  8705. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8706. */
  8707. keysDown: number[];
  8708. /**
  8709. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8710. */
  8711. keysLeft: number[];
  8712. /**
  8713. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8714. */
  8715. keysRight: number[];
  8716. private _keys;
  8717. private _onCanvasBlurObserver;
  8718. private _onKeyboardObserver;
  8719. private _engine;
  8720. private _scene;
  8721. /**
  8722. * Attach the input controls to a specific dom element to get the input from.
  8723. * @param element Defines the element the controls should be listened from
  8724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8725. */
  8726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8727. /**
  8728. * Detach the current controls from the specified dom element.
  8729. * @param element Defines the element to stop listening the inputs from
  8730. */
  8731. detachControl(element: Nullable<HTMLElement>): void;
  8732. /**
  8733. * Update the current camera state depending on the inputs that have been used this frame.
  8734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8735. */
  8736. checkInputs(): void;
  8737. /**
  8738. * Gets the class name of the current intput.
  8739. * @returns the class name
  8740. */
  8741. getClassName(): string;
  8742. /** @hidden */
  8743. _onLostFocus(): void;
  8744. /**
  8745. * Get the friendly name associated with the input class.
  8746. * @returns the input friendly name
  8747. */
  8748. getSimpleName(): string;
  8749. }
  8750. }
  8751. declare module "babylonjs/Lights/shadowLight" {
  8752. import { Camera } from "babylonjs/Cameras/camera";
  8753. import { Scene } from "babylonjs/scene";
  8754. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8756. import { Light } from "babylonjs/Lights/light";
  8757. /**
  8758. * Interface describing all the common properties and methods a shadow light needs to implement.
  8759. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8760. * as well as binding the different shadow properties to the effects.
  8761. */
  8762. export interface IShadowLight extends Light {
  8763. /**
  8764. * The light id in the scene (used in scene.findLighById for instance)
  8765. */
  8766. id: string;
  8767. /**
  8768. * The position the shdow will be casted from.
  8769. */
  8770. position: Vector3;
  8771. /**
  8772. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8773. */
  8774. direction: Vector3;
  8775. /**
  8776. * The transformed position. Position of the light in world space taking parenting in account.
  8777. */
  8778. transformedPosition: Vector3;
  8779. /**
  8780. * The transformed direction. Direction of the light in world space taking parenting in account.
  8781. */
  8782. transformedDirection: Vector3;
  8783. /**
  8784. * The friendly name of the light in the scene.
  8785. */
  8786. name: string;
  8787. /**
  8788. * Defines the shadow projection clipping minimum z value.
  8789. */
  8790. shadowMinZ: number;
  8791. /**
  8792. * Defines the shadow projection clipping maximum z value.
  8793. */
  8794. shadowMaxZ: number;
  8795. /**
  8796. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8797. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8798. */
  8799. computeTransformedInformation(): boolean;
  8800. /**
  8801. * Gets the scene the light belongs to.
  8802. * @returns The scene
  8803. */
  8804. getScene(): Scene;
  8805. /**
  8806. * Callback defining a custom Projection Matrix Builder.
  8807. * This can be used to override the default projection matrix computation.
  8808. */
  8809. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8810. /**
  8811. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8812. * @param matrix The materix to updated with the projection information
  8813. * @param viewMatrix The transform matrix of the light
  8814. * @param renderList The list of mesh to render in the map
  8815. * @returns The current light
  8816. */
  8817. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8818. /**
  8819. * Gets the current depth scale used in ESM.
  8820. * @returns The scale
  8821. */
  8822. getDepthScale(): number;
  8823. /**
  8824. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8825. * @returns true if a cube texture needs to be use
  8826. */
  8827. needCube(): boolean;
  8828. /**
  8829. * Detects if the projection matrix requires to be recomputed this frame.
  8830. * @returns true if it requires to be recomputed otherwise, false.
  8831. */
  8832. needProjectionMatrixCompute(): boolean;
  8833. /**
  8834. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8835. */
  8836. forceProjectionMatrixCompute(): void;
  8837. /**
  8838. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8839. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8840. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8841. */
  8842. getShadowDirection(faceIndex?: number): Vector3;
  8843. /**
  8844. * Gets the minZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the min for
  8846. * @returns the depth min z
  8847. */
  8848. getDepthMinZ(activeCamera: Camera): number;
  8849. /**
  8850. * Gets the maxZ used for shadow according to both the scene and the light.
  8851. * @param activeCamera The camera we are returning the max for
  8852. * @returns the depth max z
  8853. */
  8854. getDepthMaxZ(activeCamera: Camera): number;
  8855. }
  8856. /**
  8857. * Base implementation IShadowLight
  8858. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8859. */
  8860. export abstract class ShadowLight extends Light implements IShadowLight {
  8861. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8862. protected _position: Vector3;
  8863. protected _setPosition(value: Vector3): void;
  8864. /**
  8865. * Sets the position the shadow will be casted from. Also use as the light position for both
  8866. * point and spot lights.
  8867. */
  8868. /**
  8869. * Sets the position the shadow will be casted from. Also use as the light position for both
  8870. * point and spot lights.
  8871. */
  8872. position: Vector3;
  8873. protected _direction: Vector3;
  8874. protected _setDirection(value: Vector3): void;
  8875. /**
  8876. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8877. * Also use as the light direction on spot and directional lights.
  8878. */
  8879. /**
  8880. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8881. * Also use as the light direction on spot and directional lights.
  8882. */
  8883. direction: Vector3;
  8884. private _shadowMinZ;
  8885. /**
  8886. * Gets the shadow projection clipping minimum z value.
  8887. */
  8888. /**
  8889. * Sets the shadow projection clipping minimum z value.
  8890. */
  8891. shadowMinZ: number;
  8892. private _shadowMaxZ;
  8893. /**
  8894. * Sets the shadow projection clipping maximum z value.
  8895. */
  8896. /**
  8897. * Gets the shadow projection clipping maximum z value.
  8898. */
  8899. shadowMaxZ: number;
  8900. /**
  8901. * Callback defining a custom Projection Matrix Builder.
  8902. * This can be used to override the default projection matrix computation.
  8903. */
  8904. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8905. /**
  8906. * The transformed position. Position of the light in world space taking parenting in account.
  8907. */
  8908. transformedPosition: Vector3;
  8909. /**
  8910. * The transformed direction. Direction of the light in world space taking parenting in account.
  8911. */
  8912. transformedDirection: Vector3;
  8913. private _needProjectionMatrixCompute;
  8914. /**
  8915. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8916. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8917. */
  8918. computeTransformedInformation(): boolean;
  8919. /**
  8920. * Return the depth scale used for the shadow map.
  8921. * @returns the depth scale.
  8922. */
  8923. getDepthScale(): number;
  8924. /**
  8925. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8926. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8927. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8928. */
  8929. getShadowDirection(faceIndex?: number): Vector3;
  8930. /**
  8931. * Returns the ShadowLight absolute position in the World.
  8932. * @returns the position vector in world space
  8933. */
  8934. getAbsolutePosition(): Vector3;
  8935. /**
  8936. * Sets the ShadowLight direction toward the passed target.
  8937. * @param target The point to target in local space
  8938. * @returns the updated ShadowLight direction
  8939. */
  8940. setDirectionToTarget(target: Vector3): Vector3;
  8941. /**
  8942. * Returns the light rotation in euler definition.
  8943. * @returns the x y z rotation in local space.
  8944. */
  8945. getRotation(): Vector3;
  8946. /**
  8947. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8948. * @returns true if a cube texture needs to be use
  8949. */
  8950. needCube(): boolean;
  8951. /**
  8952. * Detects if the projection matrix requires to be recomputed this frame.
  8953. * @returns true if it requires to be recomputed otherwise, false.
  8954. */
  8955. needProjectionMatrixCompute(): boolean;
  8956. /**
  8957. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8958. */
  8959. forceProjectionMatrixCompute(): void;
  8960. /** @hidden */
  8961. _initCache(): void;
  8962. /** @hidden */
  8963. _isSynchronized(): boolean;
  8964. /**
  8965. * Computes the world matrix of the node
  8966. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8967. * @returns the world matrix
  8968. */
  8969. computeWorldMatrix(force?: boolean): Matrix;
  8970. /**
  8971. * Gets the minZ used for shadow according to both the scene and the light.
  8972. * @param activeCamera The camera we are returning the min for
  8973. * @returns the depth min z
  8974. */
  8975. getDepthMinZ(activeCamera: Camera): number;
  8976. /**
  8977. * Gets the maxZ used for shadow according to both the scene and the light.
  8978. * @param activeCamera The camera we are returning the max for
  8979. * @returns the depth max z
  8980. */
  8981. getDepthMaxZ(activeCamera: Camera): number;
  8982. /**
  8983. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8984. * @param matrix The materix to updated with the projection information
  8985. * @param viewMatrix The transform matrix of the light
  8986. * @param renderList The list of mesh to render in the map
  8987. * @returns The current light
  8988. */
  8989. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8990. }
  8991. }
  8992. declare module "babylonjs/Materials/effectFallbacks" {
  8993. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8994. import { Effect } from "babylonjs/Materials/effect";
  8995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8996. /**
  8997. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8998. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8999. */
  9000. export class EffectFallbacks implements IEffectFallbacks {
  9001. private _defines;
  9002. private _currentRank;
  9003. private _maxRank;
  9004. private _mesh;
  9005. /**
  9006. * Removes the fallback from the bound mesh.
  9007. */
  9008. unBindMesh(): void;
  9009. /**
  9010. * Adds a fallback on the specified property.
  9011. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9012. * @param define The name of the define in the shader
  9013. */
  9014. addFallback(rank: number, define: string): void;
  9015. /**
  9016. * Sets the mesh to use CPU skinning when needing to fallback.
  9017. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9018. * @param mesh The mesh to use the fallbacks.
  9019. */
  9020. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9021. /**
  9022. * Checks to see if more fallbacks are still availible.
  9023. */
  9024. readonly hasMoreFallbacks: boolean;
  9025. /**
  9026. * Removes the defines that should be removed when falling back.
  9027. * @param currentDefines defines the current define statements for the shader.
  9028. * @param effect defines the current effect we try to compile
  9029. * @returns The resulting defines with defines of the current rank removed.
  9030. */
  9031. reduce(currentDefines: string, effect: Effect): string;
  9032. }
  9033. }
  9034. declare module "babylonjs/Materials/materialHelper" {
  9035. import { Nullable } from "babylonjs/types";
  9036. import { Scene } from "babylonjs/scene";
  9037. import { Engine } from "babylonjs/Engines/engine";
  9038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9039. import { Light } from "babylonjs/Lights/light";
  9040. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9041. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  9042. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9043. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9044. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9045. /**
  9046. * "Static Class" containing the most commonly used helper while dealing with material for
  9047. * rendering purpose.
  9048. *
  9049. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9050. *
  9051. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9052. */
  9053. export class MaterialHelper {
  9054. /**
  9055. * Bind the current view position to an effect.
  9056. * @param effect The effect to be bound
  9057. * @param scene The scene the eyes position is used from
  9058. */
  9059. static BindEyePosition(effect: Effect, scene: Scene): void;
  9060. /**
  9061. * Helps preparing the defines values about the UVs in used in the effect.
  9062. * UVs are shared as much as we can accross channels in the shaders.
  9063. * @param texture The texture we are preparing the UVs for
  9064. * @param defines The defines to update
  9065. * @param key The channel key "diffuse", "specular"... used in the shader
  9066. */
  9067. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9068. /**
  9069. * Binds a texture matrix value to its corrsponding uniform
  9070. * @param texture The texture to bind the matrix for
  9071. * @param uniformBuffer The uniform buffer receivin the data
  9072. * @param key The channel key "diffuse", "specular"... used in the shader
  9073. */
  9074. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9075. /**
  9076. * Gets the current status of the fog (should it be enabled?)
  9077. * @param mesh defines the mesh to evaluate for fog support
  9078. * @param scene defines the hosting scene
  9079. * @returns true if fog must be enabled
  9080. */
  9081. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9082. /**
  9083. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9084. * @param mesh defines the current mesh
  9085. * @param scene defines the current scene
  9086. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9087. * @param pointsCloud defines if point cloud rendering has to be turned on
  9088. * @param fogEnabled defines if fog has to be turned on
  9089. * @param alphaTest defines if alpha testing has to be turned on
  9090. * @param defines defines the current list of defines
  9091. */
  9092. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9093. /**
  9094. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9095. * @param scene defines the current scene
  9096. * @param engine defines the current engine
  9097. * @param defines specifies the list of active defines
  9098. * @param useInstances defines if instances have to be turned on
  9099. * @param useClipPlane defines if clip plane have to be turned on
  9100. */
  9101. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9102. /**
  9103. * Prepares the defines for bones
  9104. * @param mesh The mesh containing the geometry data we will draw
  9105. * @param defines The defines to update
  9106. */
  9107. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9108. /**
  9109. * Prepares the defines for morph targets
  9110. * @param mesh The mesh containing the geometry data we will draw
  9111. * @param defines The defines to update
  9112. */
  9113. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9114. /**
  9115. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9116. * @param mesh The mesh containing the geometry data we will draw
  9117. * @param defines The defines to update
  9118. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9119. * @param useBones Precise whether bones should be used or not (override mesh info)
  9120. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9121. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9122. * @returns false if defines are considered not dirty and have not been checked
  9123. */
  9124. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9125. /**
  9126. * Prepares the defines related to multiview
  9127. * @param scene The scene we are intending to draw
  9128. * @param defines The defines to update
  9129. */
  9130. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9131. /**
  9132. * Prepares the defines related to the light information passed in parameter
  9133. * @param scene The scene we are intending to draw
  9134. * @param mesh The mesh the effect is compiling for
  9135. * @param light The light the effect is compiling for
  9136. * @param lightIndex The index of the light
  9137. * @param defines The defines to update
  9138. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9139. * @param state Defines the current state regarding what is needed (normals, etc...)
  9140. */
  9141. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9142. needNormals: boolean;
  9143. needRebuild: boolean;
  9144. shadowEnabled: boolean;
  9145. specularEnabled: boolean;
  9146. lightmapMode: boolean;
  9147. }): void;
  9148. /**
  9149. * Prepares the defines related to the light information passed in parameter
  9150. * @param scene The scene we are intending to draw
  9151. * @param mesh The mesh the effect is compiling for
  9152. * @param defines The defines to update
  9153. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9154. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9155. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9156. * @returns true if normals will be required for the rest of the effect
  9157. */
  9158. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9159. /**
  9160. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9161. * @param lightIndex defines the light index
  9162. * @param uniformsList The uniform list
  9163. * @param samplersList The sampler list
  9164. * @param projectedLightTexture defines if projected texture must be used
  9165. * @param uniformBuffersList defines an optional list of uniform buffers
  9166. */
  9167. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9168. /**
  9169. * Prepares the uniforms and samplers list to be used in the effect
  9170. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9171. * @param samplersList The sampler list
  9172. * @param defines The defines helping in the list generation
  9173. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9174. */
  9175. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9176. /**
  9177. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9178. * @param defines The defines to update while falling back
  9179. * @param fallbacks The authorized effect fallbacks
  9180. * @param maxSimultaneousLights The maximum number of lights allowed
  9181. * @param rank the current rank of the Effect
  9182. * @returns The newly affected rank
  9183. */
  9184. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9185. private static _TmpMorphInfluencers;
  9186. /**
  9187. * Prepares the list of attributes required for morph targets according to the effect defines.
  9188. * @param attribs The current list of supported attribs
  9189. * @param mesh The mesh to prepare the morph targets attributes for
  9190. * @param influencers The number of influencers
  9191. */
  9192. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9193. /**
  9194. * Prepares the list of attributes required for morph targets according to the effect defines.
  9195. * @param attribs The current list of supported attribs
  9196. * @param mesh The mesh to prepare the morph targets attributes for
  9197. * @param defines The current Defines of the effect
  9198. */
  9199. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9200. /**
  9201. * Prepares the list of attributes required for bones according to the effect defines.
  9202. * @param attribs The current list of supported attribs
  9203. * @param mesh The mesh to prepare the bones attributes for
  9204. * @param defines The current Defines of the effect
  9205. * @param fallbacks The current efffect fallback strategy
  9206. */
  9207. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9208. /**
  9209. * Check and prepare the list of attributes required for instances according to the effect defines.
  9210. * @param attribs The current list of supported attribs
  9211. * @param defines The current MaterialDefines of the effect
  9212. */
  9213. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9214. /**
  9215. * Add the list of attributes required for instances to the attribs array.
  9216. * @param attribs The current list of supported attribs
  9217. */
  9218. static PushAttributesForInstances(attribs: string[]): void;
  9219. /**
  9220. * Binds the light shadow information to the effect for the given mesh.
  9221. * @param light The light containing the generator
  9222. * @param scene The scene the lights belongs to
  9223. * @param mesh The mesh we are binding the information to render
  9224. * @param lightIndex The light index in the effect used to render the mesh
  9225. * @param effect The effect we are binding the data to
  9226. */
  9227. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9228. /**
  9229. * Binds the light information to the effect.
  9230. * @param light The light containing the generator
  9231. * @param effect The effect we are binding the data to
  9232. * @param lightIndex The light index in the effect used to render
  9233. */
  9234. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9235. /**
  9236. * Binds the lights information from the scene to the effect for the given mesh.
  9237. * @param light Light to bind
  9238. * @param lightIndex Light index
  9239. * @param scene The scene where the light belongs to
  9240. * @param mesh The mesh we are binding the information to render
  9241. * @param effect The effect we are binding the data to
  9242. * @param useSpecular Defines if specular is supported
  9243. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9244. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9245. */
  9246. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9247. /**
  9248. * Binds the lights information from the scene to the effect for the given mesh.
  9249. * @param scene The scene the lights belongs to
  9250. * @param mesh The mesh we are binding the information to render
  9251. * @param effect The effect we are binding the data to
  9252. * @param defines The generated defines for the effect
  9253. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9254. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9255. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9256. */
  9257. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9258. private static _tempFogColor;
  9259. /**
  9260. * Binds the fog information from the scene to the effect for the given mesh.
  9261. * @param scene The scene the lights belongs to
  9262. * @param mesh The mesh we are binding the information to render
  9263. * @param effect The effect we are binding the data to
  9264. * @param linearSpace Defines if the fog effect is applied in linear space
  9265. */
  9266. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9267. /**
  9268. * Binds the bones information from the mesh to the effect.
  9269. * @param mesh The mesh we are binding the information to render
  9270. * @param effect The effect we are binding the data to
  9271. */
  9272. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9273. /**
  9274. * Binds the morph targets information from the mesh to the effect.
  9275. * @param abstractMesh The mesh we are binding the information to render
  9276. * @param effect The effect we are binding the data to
  9277. */
  9278. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9279. /**
  9280. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9281. * @param defines The generated defines used in the effect
  9282. * @param effect The effect we are binding the data to
  9283. * @param scene The scene we are willing to render with logarithmic scale for
  9284. */
  9285. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9286. /**
  9287. * Binds the clip plane information from the scene to the effect.
  9288. * @param scene The scene the clip plane information are extracted from
  9289. * @param effect The effect we are binding the data to
  9290. */
  9291. static BindClipPlane(effect: Effect, scene: Scene): void;
  9292. }
  9293. }
  9294. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9295. /** @hidden */
  9296. export var packingFunctions: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9302. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9303. /** @hidden */
  9304. export var shadowMapPixelShader: {
  9305. name: string;
  9306. shader: string;
  9307. };
  9308. }
  9309. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9310. /** @hidden */
  9311. export var bonesDeclaration: {
  9312. name: string;
  9313. shader: string;
  9314. };
  9315. }
  9316. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9317. /** @hidden */
  9318. export var morphTargetsVertexGlobalDeclaration: {
  9319. name: string;
  9320. shader: string;
  9321. };
  9322. }
  9323. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9324. /** @hidden */
  9325. export var morphTargetsVertexDeclaration: {
  9326. name: string;
  9327. shader: string;
  9328. };
  9329. }
  9330. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9331. /** @hidden */
  9332. export var instancesDeclaration: {
  9333. name: string;
  9334. shader: string;
  9335. };
  9336. }
  9337. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9338. /** @hidden */
  9339. export var helperFunctions: {
  9340. name: string;
  9341. shader: string;
  9342. };
  9343. }
  9344. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9345. /** @hidden */
  9346. export var morphTargetsVertex: {
  9347. name: string;
  9348. shader: string;
  9349. };
  9350. }
  9351. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9352. /** @hidden */
  9353. export var instancesVertex: {
  9354. name: string;
  9355. shader: string;
  9356. };
  9357. }
  9358. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9359. /** @hidden */
  9360. export var bonesVertex: {
  9361. name: string;
  9362. shader: string;
  9363. };
  9364. }
  9365. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9366. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9367. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9368. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9369. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9370. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9371. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9372. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9373. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9374. /** @hidden */
  9375. export var shadowMapVertexShader: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9381. /** @hidden */
  9382. export var depthBoxBlurPixelShader: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9388. import { Nullable } from "babylonjs/types";
  9389. import { Scene } from "babylonjs/scene";
  9390. import { Matrix } from "babylonjs/Maths/math.vector";
  9391. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9393. import { Mesh } from "babylonjs/Meshes/mesh";
  9394. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9395. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9396. import { Effect } from "babylonjs/Materials/effect";
  9397. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9398. import "babylonjs/Shaders/shadowMap.fragment";
  9399. import "babylonjs/Shaders/shadowMap.vertex";
  9400. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9401. import { Observable } from "babylonjs/Misc/observable";
  9402. /**
  9403. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9404. */
  9405. export interface ICustomShaderOptions {
  9406. /**
  9407. * Gets or sets the custom shader name to use
  9408. */
  9409. shaderName: string;
  9410. /**
  9411. * The list of attribute names used in the shader
  9412. */
  9413. attributes?: string[];
  9414. /**
  9415. * The list of unifrom names used in the shader
  9416. */
  9417. uniforms?: string[];
  9418. /**
  9419. * The list of sampler names used in the shader
  9420. */
  9421. samplers?: string[];
  9422. /**
  9423. * The list of defines used in the shader
  9424. */
  9425. defines?: string[];
  9426. }
  9427. /**
  9428. * Interface to implement to create a shadow generator compatible with BJS.
  9429. */
  9430. export interface IShadowGenerator {
  9431. /**
  9432. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9433. * @returns The render target texture if present otherwise, null
  9434. */
  9435. getShadowMap(): Nullable<RenderTargetTexture>;
  9436. /**
  9437. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9438. * @returns The render target texture if the shadow map is present otherwise, null
  9439. */
  9440. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9441. /**
  9442. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9443. * @param subMesh The submesh we want to render in the shadow map
  9444. * @param useInstances Defines wether will draw in the map using instances
  9445. * @returns true if ready otherwise, false
  9446. */
  9447. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9448. /**
  9449. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9450. * @param defines Defines of the material we want to update
  9451. * @param lightIndex Index of the light in the enabled light list of the material
  9452. */
  9453. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9454. /**
  9455. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9456. * defined in the generator but impacting the effect).
  9457. * It implies the unifroms available on the materials are the standard BJS ones.
  9458. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9459. * @param effect The effect we are binfing the information for
  9460. */
  9461. bindShadowLight(lightIndex: string, effect: Effect): void;
  9462. /**
  9463. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9464. * (eq to shadow prjection matrix * light transform matrix)
  9465. * @returns The transform matrix used to create the shadow map
  9466. */
  9467. getTransformMatrix(): Matrix;
  9468. /**
  9469. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9470. * Cube and 2D textures for instance.
  9471. */
  9472. recreateShadowMap(): void;
  9473. /**
  9474. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9475. * @param onCompiled Callback triggered at the and of the effects compilation
  9476. * @param options Sets of optional options forcing the compilation with different modes
  9477. */
  9478. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9479. useInstances: boolean;
  9480. }>): void;
  9481. /**
  9482. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9483. * @param options Sets of optional options forcing the compilation with different modes
  9484. * @returns A promise that resolves when the compilation completes
  9485. */
  9486. forceCompilationAsync(options?: Partial<{
  9487. useInstances: boolean;
  9488. }>): Promise<void>;
  9489. /**
  9490. * Serializes the shadow generator setup to a json object.
  9491. * @returns The serialized JSON object
  9492. */
  9493. serialize(): any;
  9494. /**
  9495. * Disposes the Shadow map and related Textures and effects.
  9496. */
  9497. dispose(): void;
  9498. }
  9499. /**
  9500. * Default implementation IShadowGenerator.
  9501. * This is the main object responsible of generating shadows in the framework.
  9502. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9503. */
  9504. export class ShadowGenerator implements IShadowGenerator {
  9505. /**
  9506. * Shadow generator mode None: no filtering applied.
  9507. */
  9508. static readonly FILTER_NONE: number;
  9509. /**
  9510. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9511. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9512. */
  9513. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9514. /**
  9515. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9516. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9517. */
  9518. static readonly FILTER_POISSONSAMPLING: number;
  9519. /**
  9520. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9521. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9522. */
  9523. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9524. /**
  9525. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9526. * edge artifacts on steep falloff.
  9527. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9528. */
  9529. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9530. /**
  9531. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9532. * edge artifacts on steep falloff.
  9533. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9534. */
  9535. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9536. /**
  9537. * Shadow generator mode PCF: Percentage Closer Filtering
  9538. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9539. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9540. */
  9541. static readonly FILTER_PCF: number;
  9542. /**
  9543. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9544. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9545. * Contact Hardening
  9546. */
  9547. static readonly FILTER_PCSS: number;
  9548. /**
  9549. * Reserved for PCF and PCSS
  9550. * Highest Quality.
  9551. *
  9552. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9553. *
  9554. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9555. */
  9556. static readonly QUALITY_HIGH: number;
  9557. /**
  9558. * Reserved for PCF and PCSS
  9559. * Good tradeoff for quality/perf cross devices
  9560. *
  9561. * Execute PCF on a 3*3 kernel.
  9562. *
  9563. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9564. */
  9565. static readonly QUALITY_MEDIUM: number;
  9566. /**
  9567. * Reserved for PCF and PCSS
  9568. * The lowest quality but the fastest.
  9569. *
  9570. * Execute PCF on a 1*1 kernel.
  9571. *
  9572. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9573. */
  9574. static readonly QUALITY_LOW: number;
  9575. /** Gets or sets the custom shader name to use */
  9576. customShaderOptions: ICustomShaderOptions;
  9577. /**
  9578. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9579. */
  9580. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9581. /**
  9582. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9583. */
  9584. onAfterShadowMapRenderObservable: Observable<Effect>;
  9585. /**
  9586. * Observable triggered before a mesh is rendered in the shadow map.
  9587. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9588. */
  9589. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9590. /**
  9591. * Observable triggered after a mesh is rendered in the shadow map.
  9592. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9593. */
  9594. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9595. private _bias;
  9596. /**
  9597. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9598. */
  9599. /**
  9600. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9601. */
  9602. bias: number;
  9603. private _normalBias;
  9604. /**
  9605. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9606. */
  9607. /**
  9608. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9609. */
  9610. normalBias: number;
  9611. private _blurBoxOffset;
  9612. /**
  9613. * Gets the blur box offset: offset applied during the blur pass.
  9614. * Only useful if useKernelBlur = false
  9615. */
  9616. /**
  9617. * Sets the blur box offset: offset applied during the blur pass.
  9618. * Only useful if useKernelBlur = false
  9619. */
  9620. blurBoxOffset: number;
  9621. private _blurScale;
  9622. /**
  9623. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9624. * 2 means half of the size.
  9625. */
  9626. /**
  9627. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9628. * 2 means half of the size.
  9629. */
  9630. blurScale: number;
  9631. private _blurKernel;
  9632. /**
  9633. * Gets the blur kernel: kernel size of the blur pass.
  9634. * Only useful if useKernelBlur = true
  9635. */
  9636. /**
  9637. * Sets the blur kernel: kernel size of the blur pass.
  9638. * Only useful if useKernelBlur = true
  9639. */
  9640. blurKernel: number;
  9641. private _useKernelBlur;
  9642. /**
  9643. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9644. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9645. */
  9646. /**
  9647. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9648. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9649. */
  9650. useKernelBlur: boolean;
  9651. private _depthScale;
  9652. /**
  9653. * Gets the depth scale used in ESM mode.
  9654. */
  9655. /**
  9656. * Sets the depth scale used in ESM mode.
  9657. * This can override the scale stored on the light.
  9658. */
  9659. depthScale: number;
  9660. private _filter;
  9661. /**
  9662. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9663. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9664. */
  9665. /**
  9666. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9667. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9668. */
  9669. filter: number;
  9670. /**
  9671. * Gets if the current filter is set to Poisson Sampling.
  9672. */
  9673. /**
  9674. * Sets the current filter to Poisson Sampling.
  9675. */
  9676. usePoissonSampling: boolean;
  9677. /**
  9678. * Gets if the current filter is set to ESM.
  9679. */
  9680. /**
  9681. * Sets the current filter is to ESM.
  9682. */
  9683. useExponentialShadowMap: boolean;
  9684. /**
  9685. * Gets if the current filter is set to filtered ESM.
  9686. */
  9687. /**
  9688. * Gets if the current filter is set to filtered ESM.
  9689. */
  9690. useBlurExponentialShadowMap: boolean;
  9691. /**
  9692. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9693. * exponential to prevent steep falloff artifacts).
  9694. */
  9695. /**
  9696. * Sets the current filter to "close ESM" (using the inverse of the
  9697. * exponential to prevent steep falloff artifacts).
  9698. */
  9699. useCloseExponentialShadowMap: boolean;
  9700. /**
  9701. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9702. * exponential to prevent steep falloff artifacts).
  9703. */
  9704. /**
  9705. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9706. * exponential to prevent steep falloff artifacts).
  9707. */
  9708. useBlurCloseExponentialShadowMap: boolean;
  9709. /**
  9710. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9711. */
  9712. /**
  9713. * Sets the current filter to "PCF" (percentage closer filtering).
  9714. */
  9715. usePercentageCloserFiltering: boolean;
  9716. private _filteringQuality;
  9717. /**
  9718. * Gets the PCF or PCSS Quality.
  9719. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9720. */
  9721. /**
  9722. * Sets the PCF or PCSS Quality.
  9723. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9724. */
  9725. filteringQuality: number;
  9726. /**
  9727. * Gets if the current filter is set to "PCSS" (contact hardening).
  9728. */
  9729. /**
  9730. * Sets the current filter to "PCSS" (contact hardening).
  9731. */
  9732. useContactHardeningShadow: boolean;
  9733. private _contactHardeningLightSizeUVRatio;
  9734. /**
  9735. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9736. * Using a ratio helps keeping shape stability independently of the map size.
  9737. *
  9738. * It does not account for the light projection as it was having too much
  9739. * instability during the light setup or during light position changes.
  9740. *
  9741. * Only valid if useContactHardeningShadow is true.
  9742. */
  9743. /**
  9744. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9745. * Using a ratio helps keeping shape stability independently of the map size.
  9746. *
  9747. * It does not account for the light projection as it was having too much
  9748. * instability during the light setup or during light position changes.
  9749. *
  9750. * Only valid if useContactHardeningShadow is true.
  9751. */
  9752. contactHardeningLightSizeUVRatio: number;
  9753. private _darkness;
  9754. /** Gets or sets the actual darkness of a shadow */
  9755. darkness: number;
  9756. /**
  9757. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9758. * 0 means strongest and 1 would means no shadow.
  9759. * @returns the darkness.
  9760. */
  9761. getDarkness(): number;
  9762. /**
  9763. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9764. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9765. * @returns the shadow generator allowing fluent coding.
  9766. */
  9767. setDarkness(darkness: number): ShadowGenerator;
  9768. private _transparencyShadow;
  9769. /** Gets or sets the ability to have transparent shadow */
  9770. transparencyShadow: boolean;
  9771. /**
  9772. * Sets the ability to have transparent shadow (boolean).
  9773. * @param transparent True if transparent else False
  9774. * @returns the shadow generator allowing fluent coding
  9775. */
  9776. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9777. private _shadowMap;
  9778. private _shadowMap2;
  9779. /**
  9780. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9781. * @returns The render target texture if present otherwise, null
  9782. */
  9783. getShadowMap(): Nullable<RenderTargetTexture>;
  9784. /**
  9785. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9786. * @returns The render target texture if the shadow map is present otherwise, null
  9787. */
  9788. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9789. /**
  9790. * Gets the class name of that object
  9791. * @returns "ShadowGenerator"
  9792. */
  9793. getClassName(): string;
  9794. /**
  9795. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9796. * @param mesh Mesh to add
  9797. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9798. * @returns the Shadow Generator itself
  9799. */
  9800. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9801. /**
  9802. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9803. * @param mesh Mesh to remove
  9804. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9805. * @returns the Shadow Generator itself
  9806. */
  9807. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9808. /**
  9809. * Controls the extent to which the shadows fade out at the edge of the frustum
  9810. * Used only by directionals and spots
  9811. */
  9812. frustumEdgeFalloff: number;
  9813. private _light;
  9814. /**
  9815. * Returns the associated light object.
  9816. * @returns the light generating the shadow
  9817. */
  9818. getLight(): IShadowLight;
  9819. /**
  9820. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9821. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9822. * It might on the other hand introduce peter panning.
  9823. */
  9824. forceBackFacesOnly: boolean;
  9825. private _scene;
  9826. private _lightDirection;
  9827. private _effect;
  9828. private _viewMatrix;
  9829. private _projectionMatrix;
  9830. private _transformMatrix;
  9831. private _cachedPosition;
  9832. private _cachedDirection;
  9833. private _cachedDefines;
  9834. private _currentRenderID;
  9835. private _boxBlurPostprocess;
  9836. private _kernelBlurXPostprocess;
  9837. private _kernelBlurYPostprocess;
  9838. private _blurPostProcesses;
  9839. private _mapSize;
  9840. private _currentFaceIndex;
  9841. private _currentFaceIndexCache;
  9842. private _textureType;
  9843. private _defaultTextureMatrix;
  9844. /** @hidden */
  9845. static _SceneComponentInitialization: (scene: Scene) => void;
  9846. /**
  9847. * Creates a ShadowGenerator object.
  9848. * A ShadowGenerator is the required tool to use the shadows.
  9849. * Each light casting shadows needs to use its own ShadowGenerator.
  9850. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9851. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9852. * @param light The light object generating the shadows.
  9853. * @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.
  9854. */
  9855. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9856. private _initializeGenerator;
  9857. private _initializeShadowMap;
  9858. private _initializeBlurRTTAndPostProcesses;
  9859. private _renderForShadowMap;
  9860. private _renderSubMeshForShadowMap;
  9861. private _applyFilterValues;
  9862. /**
  9863. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9864. * @param onCompiled Callback triggered at the and of the effects compilation
  9865. * @param options Sets of optional options forcing the compilation with different modes
  9866. */
  9867. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9868. useInstances: boolean;
  9869. }>): void;
  9870. /**
  9871. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9872. * @param options Sets of optional options forcing the compilation with different modes
  9873. * @returns A promise that resolves when the compilation completes
  9874. */
  9875. forceCompilationAsync(options?: Partial<{
  9876. useInstances: boolean;
  9877. }>): Promise<void>;
  9878. /**
  9879. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9880. * @param subMesh The submesh we want to render in the shadow map
  9881. * @param useInstances Defines wether will draw in the map using instances
  9882. * @returns true if ready otherwise, false
  9883. */
  9884. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9885. /**
  9886. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9887. * @param defines Defines of the material we want to update
  9888. * @param lightIndex Index of the light in the enabled light list of the material
  9889. */
  9890. prepareDefines(defines: any, lightIndex: number): void;
  9891. /**
  9892. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9893. * defined in the generator but impacting the effect).
  9894. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9895. * @param effect The effect we are binfing the information for
  9896. */
  9897. bindShadowLight(lightIndex: string, effect: Effect): void;
  9898. /**
  9899. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9900. * (eq to shadow prjection matrix * light transform matrix)
  9901. * @returns The transform matrix used to create the shadow map
  9902. */
  9903. getTransformMatrix(): Matrix;
  9904. /**
  9905. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9906. * Cube and 2D textures for instance.
  9907. */
  9908. recreateShadowMap(): void;
  9909. private _disposeBlurPostProcesses;
  9910. private _disposeRTTandPostProcesses;
  9911. /**
  9912. * Disposes the ShadowGenerator.
  9913. * Returns nothing.
  9914. */
  9915. dispose(): void;
  9916. /**
  9917. * Serializes the shadow generator setup to a json object.
  9918. * @returns The serialized JSON object
  9919. */
  9920. serialize(): any;
  9921. /**
  9922. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9923. * @param parsedShadowGenerator The JSON object to parse
  9924. * @param scene The scene to create the shadow map for
  9925. * @returns The parsed shadow generator
  9926. */
  9927. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9928. }
  9929. }
  9930. declare module "babylonjs/Lights/light" {
  9931. import { Nullable } from "babylonjs/types";
  9932. import { Scene } from "babylonjs/scene";
  9933. import { Vector3 } from "babylonjs/Maths/math.vector";
  9934. import { Color3 } from "babylonjs/Maths/math.color";
  9935. import { Node } from "babylonjs/node";
  9936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9937. import { Effect } from "babylonjs/Materials/effect";
  9938. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9939. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9940. /**
  9941. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9942. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9943. * 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.
  9944. */
  9945. export abstract class Light extends Node {
  9946. /**
  9947. * Falloff Default: light is falling off following the material specification:
  9948. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9949. */
  9950. static readonly FALLOFF_DEFAULT: number;
  9951. /**
  9952. * Falloff Physical: light is falling off following the inverse squared distance law.
  9953. */
  9954. static readonly FALLOFF_PHYSICAL: number;
  9955. /**
  9956. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9957. * to enhance interoperability with other engines.
  9958. */
  9959. static readonly FALLOFF_GLTF: number;
  9960. /**
  9961. * Falloff Standard: light is falling off like in the standard material
  9962. * to enhance interoperability with other materials.
  9963. */
  9964. static readonly FALLOFF_STANDARD: number;
  9965. /**
  9966. * If every light affecting the material is in this lightmapMode,
  9967. * material.lightmapTexture adds or multiplies
  9968. * (depends on material.useLightmapAsShadowmap)
  9969. * after every other light calculations.
  9970. */
  9971. static readonly LIGHTMAP_DEFAULT: number;
  9972. /**
  9973. * material.lightmapTexture as only diffuse lighting from this light
  9974. * adds only specular lighting from this light
  9975. * adds dynamic shadows
  9976. */
  9977. static readonly LIGHTMAP_SPECULAR: number;
  9978. /**
  9979. * material.lightmapTexture as only lighting
  9980. * no light calculation from this light
  9981. * only adds dynamic shadows from this light
  9982. */
  9983. static readonly LIGHTMAP_SHADOWSONLY: number;
  9984. /**
  9985. * Each light type uses the default quantity according to its type:
  9986. * point/spot lights use luminous intensity
  9987. * directional lights use illuminance
  9988. */
  9989. static readonly INTENSITYMODE_AUTOMATIC: number;
  9990. /**
  9991. * lumen (lm)
  9992. */
  9993. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9994. /**
  9995. * candela (lm/sr)
  9996. */
  9997. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9998. /**
  9999. * lux (lm/m^2)
  10000. */
  10001. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10002. /**
  10003. * nit (cd/m^2)
  10004. */
  10005. static readonly INTENSITYMODE_LUMINANCE: number;
  10006. /**
  10007. * Light type const id of the point light.
  10008. */
  10009. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10010. /**
  10011. * Light type const id of the directional light.
  10012. */
  10013. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10014. /**
  10015. * Light type const id of the spot light.
  10016. */
  10017. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10018. /**
  10019. * Light type const id of the hemispheric light.
  10020. */
  10021. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10022. /**
  10023. * Diffuse gives the basic color to an object.
  10024. */
  10025. diffuse: Color3;
  10026. /**
  10027. * Specular produces a highlight color on an object.
  10028. * Note: This is note affecting PBR materials.
  10029. */
  10030. specular: Color3;
  10031. /**
  10032. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10033. * falling off base on range or angle.
  10034. * This can be set to any values in Light.FALLOFF_x.
  10035. *
  10036. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10037. * other types of materials.
  10038. */
  10039. falloffType: number;
  10040. /**
  10041. * Strength of the light.
  10042. * Note: By default it is define in the framework own unit.
  10043. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10044. */
  10045. intensity: number;
  10046. private _range;
  10047. protected _inverseSquaredRange: number;
  10048. /**
  10049. * Defines how far from the source the light is impacting in scene units.
  10050. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10051. */
  10052. /**
  10053. * Defines how far from the source the light is impacting in scene units.
  10054. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10055. */
  10056. range: number;
  10057. /**
  10058. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10059. * of light.
  10060. */
  10061. private _photometricScale;
  10062. private _intensityMode;
  10063. /**
  10064. * Gets the photometric scale used to interpret the intensity.
  10065. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10066. */
  10067. /**
  10068. * Sets the photometric scale used to interpret the intensity.
  10069. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10070. */
  10071. intensityMode: number;
  10072. private _radius;
  10073. /**
  10074. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10075. */
  10076. /**
  10077. * sets the light radius used by PBR Materials to simulate soft area lights.
  10078. */
  10079. radius: number;
  10080. private _renderPriority;
  10081. /**
  10082. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10083. * exceeding the number allowed of the materials.
  10084. */
  10085. renderPriority: number;
  10086. private _shadowEnabled;
  10087. /**
  10088. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10089. * the current shadow generator.
  10090. */
  10091. /**
  10092. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10093. * the current shadow generator.
  10094. */
  10095. shadowEnabled: boolean;
  10096. private _includedOnlyMeshes;
  10097. /**
  10098. * Gets the only meshes impacted by this light.
  10099. */
  10100. /**
  10101. * Sets the only meshes impacted by this light.
  10102. */
  10103. includedOnlyMeshes: AbstractMesh[];
  10104. private _excludedMeshes;
  10105. /**
  10106. * Gets the meshes not impacted by this light.
  10107. */
  10108. /**
  10109. * Sets the meshes not impacted by this light.
  10110. */
  10111. excludedMeshes: AbstractMesh[];
  10112. private _excludeWithLayerMask;
  10113. /**
  10114. * Gets the layer id use to find what meshes are not impacted by the light.
  10115. * Inactive if 0
  10116. */
  10117. /**
  10118. * Sets the layer id use to find what meshes are not impacted by the light.
  10119. * Inactive if 0
  10120. */
  10121. excludeWithLayerMask: number;
  10122. private _includeOnlyWithLayerMask;
  10123. /**
  10124. * Gets the layer id use to find what meshes are impacted by the light.
  10125. * Inactive if 0
  10126. */
  10127. /**
  10128. * Sets the layer id use to find what meshes are impacted by the light.
  10129. * Inactive if 0
  10130. */
  10131. includeOnlyWithLayerMask: number;
  10132. private _lightmapMode;
  10133. /**
  10134. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10135. */
  10136. /**
  10137. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10138. */
  10139. lightmapMode: number;
  10140. /**
  10141. * Shadow generator associted to the light.
  10142. * @hidden Internal use only.
  10143. */
  10144. _shadowGenerator: Nullable<IShadowGenerator>;
  10145. /**
  10146. * @hidden Internal use only.
  10147. */
  10148. _excludedMeshesIds: string[];
  10149. /**
  10150. * @hidden Internal use only.
  10151. */
  10152. _includedOnlyMeshesIds: string[];
  10153. /**
  10154. * The current light unifom buffer.
  10155. * @hidden Internal use only.
  10156. */
  10157. _uniformBuffer: UniformBuffer;
  10158. /**
  10159. * Creates a Light object in the scene.
  10160. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10161. * @param name The firendly name of the light
  10162. * @param scene The scene the light belongs too
  10163. */
  10164. constructor(name: string, scene: Scene);
  10165. protected abstract _buildUniformLayout(): void;
  10166. /**
  10167. * Sets the passed Effect "effect" with the Light information.
  10168. * @param effect The effect to update
  10169. * @param lightIndex The index of the light in the effect to update
  10170. * @returns The light
  10171. */
  10172. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10173. /**
  10174. * Sets the passed Effect "effect" with the Light information.
  10175. * @param effect The effect to update
  10176. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10177. * @returns The light
  10178. */
  10179. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10180. /**
  10181. * Returns the string "Light".
  10182. * @returns the class name
  10183. */
  10184. getClassName(): string;
  10185. /** @hidden */
  10186. readonly _isLight: boolean;
  10187. /**
  10188. * Converts the light information to a readable string for debug purpose.
  10189. * @param fullDetails Supports for multiple levels of logging within scene loading
  10190. * @returns the human readable light info
  10191. */
  10192. toString(fullDetails?: boolean): string;
  10193. /** @hidden */
  10194. protected _syncParentEnabledState(): void;
  10195. /**
  10196. * Set the enabled state of this node.
  10197. * @param value - the new enabled state
  10198. */
  10199. setEnabled(value: boolean): void;
  10200. /**
  10201. * Returns the Light associated shadow generator if any.
  10202. * @return the associated shadow generator.
  10203. */
  10204. getShadowGenerator(): Nullable<IShadowGenerator>;
  10205. /**
  10206. * Returns a Vector3, the absolute light position in the World.
  10207. * @returns the world space position of the light
  10208. */
  10209. getAbsolutePosition(): Vector3;
  10210. /**
  10211. * Specifies if the light will affect the passed mesh.
  10212. * @param mesh The mesh to test against the light
  10213. * @return true the mesh is affected otherwise, false.
  10214. */
  10215. canAffectMesh(mesh: AbstractMesh): boolean;
  10216. /**
  10217. * Sort function to order lights for rendering.
  10218. * @param a First Light object to compare to second.
  10219. * @param b Second Light object to compare first.
  10220. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10221. */
  10222. static CompareLightsPriority(a: Light, b: Light): number;
  10223. /**
  10224. * Releases resources associated with this node.
  10225. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10226. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10227. */
  10228. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10229. /**
  10230. * Returns the light type ID (integer).
  10231. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10232. */
  10233. getTypeID(): number;
  10234. /**
  10235. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10236. * @returns the scaled intensity in intensity mode unit
  10237. */
  10238. getScaledIntensity(): number;
  10239. /**
  10240. * Returns a new Light object, named "name", from the current one.
  10241. * @param name The name of the cloned light
  10242. * @returns the new created light
  10243. */
  10244. clone(name: string): Nullable<Light>;
  10245. /**
  10246. * Serializes the current light into a Serialization object.
  10247. * @returns the serialized object.
  10248. */
  10249. serialize(): any;
  10250. /**
  10251. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10252. * This new light is named "name" and added to the passed scene.
  10253. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10254. * @param name The friendly name of the light
  10255. * @param scene The scene the new light will belong to
  10256. * @returns the constructor function
  10257. */
  10258. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10259. /**
  10260. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10261. * @param parsedLight The JSON representation of the light
  10262. * @param scene The scene to create the parsed light in
  10263. * @returns the created light after parsing
  10264. */
  10265. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10266. private _hookArrayForExcluded;
  10267. private _hookArrayForIncludedOnly;
  10268. private _resyncMeshes;
  10269. /**
  10270. * Forces the meshes to update their light related information in their rendering used effects
  10271. * @hidden Internal Use Only
  10272. */
  10273. _markMeshesAsLightDirty(): void;
  10274. /**
  10275. * Recomputes the cached photometric scale if needed.
  10276. */
  10277. private _computePhotometricScale;
  10278. /**
  10279. * Returns the Photometric Scale according to the light type and intensity mode.
  10280. */
  10281. private _getPhotometricScale;
  10282. /**
  10283. * Reorder the light in the scene according to their defined priority.
  10284. * @hidden Internal Use Only
  10285. */
  10286. _reorderLightsInScene(): void;
  10287. /**
  10288. * Prepares the list of defines specific to the light type.
  10289. * @param defines the list of defines
  10290. * @param lightIndex defines the index of the light for the effect
  10291. */
  10292. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10293. }
  10294. }
  10295. declare module "babylonjs/Actions/action" {
  10296. import { Observable } from "babylonjs/Misc/observable";
  10297. import { Condition } from "babylonjs/Actions/condition";
  10298. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10299. import { ActionManager } from "babylonjs/Actions/actionManager";
  10300. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10301. /**
  10302. * Interface used to define Action
  10303. */
  10304. export interface IAction {
  10305. /**
  10306. * Trigger for the action
  10307. */
  10308. trigger: number;
  10309. /** Options of the trigger */
  10310. triggerOptions: any;
  10311. /**
  10312. * Gets the trigger parameters
  10313. * @returns the trigger parameters
  10314. */
  10315. getTriggerParameter(): any;
  10316. /**
  10317. * Internal only - executes current action event
  10318. * @hidden
  10319. */
  10320. _executeCurrent(evt?: ActionEvent): void;
  10321. /**
  10322. * Serialize placeholder for child classes
  10323. * @param parent of child
  10324. * @returns the serialized object
  10325. */
  10326. serialize(parent: any): any;
  10327. /**
  10328. * Internal only
  10329. * @hidden
  10330. */
  10331. _prepare(): void;
  10332. /**
  10333. * Internal only - manager for action
  10334. * @hidden
  10335. */
  10336. _actionManager: AbstractActionManager;
  10337. /**
  10338. * Adds action to chain of actions, may be a DoNothingAction
  10339. * @param action defines the next action to execute
  10340. * @returns The action passed in
  10341. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10342. */
  10343. then(action: IAction): IAction;
  10344. }
  10345. /**
  10346. * The action to be carried out following a trigger
  10347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10348. */
  10349. export class Action implements IAction {
  10350. /** the trigger, with or without parameters, for the action */
  10351. triggerOptions: any;
  10352. /**
  10353. * Trigger for the action
  10354. */
  10355. trigger: number;
  10356. /**
  10357. * Internal only - manager for action
  10358. * @hidden
  10359. */
  10360. _actionManager: ActionManager;
  10361. private _nextActiveAction;
  10362. private _child;
  10363. private _condition?;
  10364. private _triggerParameter;
  10365. /**
  10366. * An event triggered prior to action being executed.
  10367. */
  10368. onBeforeExecuteObservable: Observable<Action>;
  10369. /**
  10370. * Creates a new Action
  10371. * @param triggerOptions the trigger, with or without parameters, for the action
  10372. * @param condition an optional determinant of action
  10373. */
  10374. constructor(
  10375. /** the trigger, with or without parameters, for the action */
  10376. triggerOptions: any, condition?: Condition);
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. _prepare(): void;
  10382. /**
  10383. * Gets the trigger parameters
  10384. * @returns the trigger parameters
  10385. */
  10386. getTriggerParameter(): any;
  10387. /**
  10388. * Internal only - executes current action event
  10389. * @hidden
  10390. */
  10391. _executeCurrent(evt?: ActionEvent): void;
  10392. /**
  10393. * Execute placeholder for child classes
  10394. * @param evt optional action event
  10395. */
  10396. execute(evt?: ActionEvent): void;
  10397. /**
  10398. * Skips to next active action
  10399. */
  10400. skipToNextActiveAction(): void;
  10401. /**
  10402. * Adds action to chain of actions, may be a DoNothingAction
  10403. * @param action defines the next action to execute
  10404. * @returns The action passed in
  10405. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10406. */
  10407. then(action: Action): Action;
  10408. /**
  10409. * Internal only
  10410. * @hidden
  10411. */
  10412. _getProperty(propertyPath: string): string;
  10413. /**
  10414. * Internal only
  10415. * @hidden
  10416. */
  10417. _getEffectiveTarget(target: any, propertyPath: string): any;
  10418. /**
  10419. * Serialize placeholder for child classes
  10420. * @param parent of child
  10421. * @returns the serialized object
  10422. */
  10423. serialize(parent: any): any;
  10424. /**
  10425. * Internal only called by serialize
  10426. * @hidden
  10427. */
  10428. protected _serialize(serializedAction: any, parent?: any): any;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. static _SerializeValueAsString: (value: any) => string;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10439. name: string;
  10440. targetType: string;
  10441. value: string;
  10442. };
  10443. }
  10444. }
  10445. declare module "babylonjs/Actions/condition" {
  10446. import { ActionManager } from "babylonjs/Actions/actionManager";
  10447. /**
  10448. * A Condition applied to an Action
  10449. */
  10450. export class Condition {
  10451. /**
  10452. * Internal only - manager for action
  10453. * @hidden
  10454. */
  10455. _actionManager: ActionManager;
  10456. /**
  10457. * Internal only
  10458. * @hidden
  10459. */
  10460. _evaluationId: number;
  10461. /**
  10462. * Internal only
  10463. * @hidden
  10464. */
  10465. _currentResult: boolean;
  10466. /**
  10467. * Creates a new Condition
  10468. * @param actionManager the manager of the action the condition is applied to
  10469. */
  10470. constructor(actionManager: ActionManager);
  10471. /**
  10472. * Check if the current condition is valid
  10473. * @returns a boolean
  10474. */
  10475. isValid(): boolean;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. _getProperty(propertyPath: string): string;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. _getEffectiveTarget(target: any, propertyPath: string): any;
  10486. /**
  10487. * Serialize placeholder for child classes
  10488. * @returns the serialized object
  10489. */
  10490. serialize(): any;
  10491. /**
  10492. * Internal only
  10493. * @hidden
  10494. */
  10495. protected _serialize(serializedCondition: any): any;
  10496. }
  10497. /**
  10498. * Defines specific conditional operators as extensions of Condition
  10499. */
  10500. export class ValueCondition extends Condition {
  10501. /** path to specify the property of the target the conditional operator uses */
  10502. propertyPath: string;
  10503. /** the value compared by the conditional operator against the current value of the property */
  10504. value: any;
  10505. /** the conditional operator, default ValueCondition.IsEqual */
  10506. operator: number;
  10507. /**
  10508. * Internal only
  10509. * @hidden
  10510. */
  10511. private static _IsEqual;
  10512. /**
  10513. * Internal only
  10514. * @hidden
  10515. */
  10516. private static _IsDifferent;
  10517. /**
  10518. * Internal only
  10519. * @hidden
  10520. */
  10521. private static _IsGreater;
  10522. /**
  10523. * Internal only
  10524. * @hidden
  10525. */
  10526. private static _IsLesser;
  10527. /**
  10528. * returns the number for IsEqual
  10529. */
  10530. static readonly IsEqual: number;
  10531. /**
  10532. * Returns the number for IsDifferent
  10533. */
  10534. static readonly IsDifferent: number;
  10535. /**
  10536. * Returns the number for IsGreater
  10537. */
  10538. static readonly IsGreater: number;
  10539. /**
  10540. * Returns the number for IsLesser
  10541. */
  10542. static readonly IsLesser: number;
  10543. /**
  10544. * Internal only The action manager for the condition
  10545. * @hidden
  10546. */
  10547. _actionManager: ActionManager;
  10548. /**
  10549. * Internal only
  10550. * @hidden
  10551. */
  10552. private _target;
  10553. /**
  10554. * Internal only
  10555. * @hidden
  10556. */
  10557. private _effectiveTarget;
  10558. /**
  10559. * Internal only
  10560. * @hidden
  10561. */
  10562. private _property;
  10563. /**
  10564. * Creates a new ValueCondition
  10565. * @param actionManager manager for the action the condition applies to
  10566. * @param target for the action
  10567. * @param propertyPath path to specify the property of the target the conditional operator uses
  10568. * @param value the value compared by the conditional operator against the current value of the property
  10569. * @param operator the conditional operator, default ValueCondition.IsEqual
  10570. */
  10571. constructor(actionManager: ActionManager, target: any,
  10572. /** path to specify the property of the target the conditional operator uses */
  10573. propertyPath: string,
  10574. /** the value compared by the conditional operator against the current value of the property */
  10575. value: any,
  10576. /** the conditional operator, default ValueCondition.IsEqual */
  10577. operator?: number);
  10578. /**
  10579. * Compares the given value with the property value for the specified conditional operator
  10580. * @returns the result of the comparison
  10581. */
  10582. isValid(): boolean;
  10583. /**
  10584. * Serialize the ValueCondition into a JSON compatible object
  10585. * @returns serialization object
  10586. */
  10587. serialize(): any;
  10588. /**
  10589. * Gets the name of the conditional operator for the ValueCondition
  10590. * @param operator the conditional operator
  10591. * @returns the name
  10592. */
  10593. static GetOperatorName(operator: number): string;
  10594. }
  10595. /**
  10596. * Defines a predicate condition as an extension of Condition
  10597. */
  10598. export class PredicateCondition extends Condition {
  10599. /** defines the predicate function used to validate the condition */
  10600. predicate: () => boolean;
  10601. /**
  10602. * Internal only - manager for action
  10603. * @hidden
  10604. */
  10605. _actionManager: ActionManager;
  10606. /**
  10607. * Creates a new PredicateCondition
  10608. * @param actionManager manager for the action the condition applies to
  10609. * @param predicate defines the predicate function used to validate the condition
  10610. */
  10611. constructor(actionManager: ActionManager,
  10612. /** defines the predicate function used to validate the condition */
  10613. predicate: () => boolean);
  10614. /**
  10615. * @returns the validity of the predicate condition
  10616. */
  10617. isValid(): boolean;
  10618. }
  10619. /**
  10620. * Defines a state condition as an extension of Condition
  10621. */
  10622. export class StateCondition extends Condition {
  10623. /** Value to compare with target state */
  10624. value: string;
  10625. /**
  10626. * Internal only - manager for action
  10627. * @hidden
  10628. */
  10629. _actionManager: ActionManager;
  10630. /**
  10631. * Internal only
  10632. * @hidden
  10633. */
  10634. private _target;
  10635. /**
  10636. * Creates a new StateCondition
  10637. * @param actionManager manager for the action the condition applies to
  10638. * @param target of the condition
  10639. * @param value to compare with target state
  10640. */
  10641. constructor(actionManager: ActionManager, target: any,
  10642. /** Value to compare with target state */
  10643. value: string);
  10644. /**
  10645. * Gets a boolean indicating if the current condition is met
  10646. * @returns the validity of the state
  10647. */
  10648. isValid(): boolean;
  10649. /**
  10650. * Serialize the StateCondition into a JSON compatible object
  10651. * @returns serialization object
  10652. */
  10653. serialize(): any;
  10654. }
  10655. }
  10656. declare module "babylonjs/Actions/directActions" {
  10657. import { Action } from "babylonjs/Actions/action";
  10658. import { Condition } from "babylonjs/Actions/condition";
  10659. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10660. /**
  10661. * This defines an action responsible to toggle a boolean once triggered.
  10662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10663. */
  10664. export class SwitchBooleanAction extends Action {
  10665. /**
  10666. * The path to the boolean property in the target object
  10667. */
  10668. propertyPath: string;
  10669. private _target;
  10670. private _effectiveTarget;
  10671. private _property;
  10672. /**
  10673. * Instantiate the action
  10674. * @param triggerOptions defines the trigger options
  10675. * @param target defines the object containing the boolean
  10676. * @param propertyPath defines the path to the boolean property in the target object
  10677. * @param condition defines the trigger related conditions
  10678. */
  10679. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10680. /** @hidden */
  10681. _prepare(): void;
  10682. /**
  10683. * Execute the action toggle the boolean value.
  10684. */
  10685. execute(): void;
  10686. /**
  10687. * Serializes the actions and its related information.
  10688. * @param parent defines the object to serialize in
  10689. * @returns the serialized object
  10690. */
  10691. serialize(parent: any): any;
  10692. }
  10693. /**
  10694. * This defines an action responsible to set a the state field of the target
  10695. * to a desired value once triggered.
  10696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10697. */
  10698. export class SetStateAction extends Action {
  10699. /**
  10700. * The value to store in the state field.
  10701. */
  10702. value: string;
  10703. private _target;
  10704. /**
  10705. * Instantiate the action
  10706. * @param triggerOptions defines the trigger options
  10707. * @param target defines the object containing the state property
  10708. * @param value defines the value to store in the state field
  10709. * @param condition defines the trigger related conditions
  10710. */
  10711. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10712. /**
  10713. * Execute the action and store the value on the target state property.
  10714. */
  10715. execute(): void;
  10716. /**
  10717. * Serializes the actions and its related information.
  10718. * @param parent defines the object to serialize in
  10719. * @returns the serialized object
  10720. */
  10721. serialize(parent: any): any;
  10722. }
  10723. /**
  10724. * This defines an action responsible to set a property of the target
  10725. * to a desired value once triggered.
  10726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10727. */
  10728. export class SetValueAction extends Action {
  10729. /**
  10730. * The path of the property to set in the target.
  10731. */
  10732. propertyPath: string;
  10733. /**
  10734. * The value to set in the property
  10735. */
  10736. value: any;
  10737. private _target;
  10738. private _effectiveTarget;
  10739. private _property;
  10740. /**
  10741. * Instantiate the action
  10742. * @param triggerOptions defines the trigger options
  10743. * @param target defines the object containing the property
  10744. * @param propertyPath defines the path of the property to set in the target
  10745. * @param value defines the value to set in the property
  10746. * @param condition defines the trigger related conditions
  10747. */
  10748. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10749. /** @hidden */
  10750. _prepare(): void;
  10751. /**
  10752. * Execute the action and set the targetted property to the desired value.
  10753. */
  10754. execute(): void;
  10755. /**
  10756. * Serializes the actions and its related information.
  10757. * @param parent defines the object to serialize in
  10758. * @returns the serialized object
  10759. */
  10760. serialize(parent: any): any;
  10761. }
  10762. /**
  10763. * This defines an action responsible to increment the target value
  10764. * to a desired value once triggered.
  10765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10766. */
  10767. export class IncrementValueAction extends Action {
  10768. /**
  10769. * The path of the property to increment in the target.
  10770. */
  10771. propertyPath: string;
  10772. /**
  10773. * The value we should increment the property by.
  10774. */
  10775. value: any;
  10776. private _target;
  10777. private _effectiveTarget;
  10778. private _property;
  10779. /**
  10780. * Instantiate the action
  10781. * @param triggerOptions defines the trigger options
  10782. * @param target defines the object containing the property
  10783. * @param propertyPath defines the path of the property to increment in the target
  10784. * @param value defines the value value we should increment the property by
  10785. * @param condition defines the trigger related conditions
  10786. */
  10787. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10788. /** @hidden */
  10789. _prepare(): void;
  10790. /**
  10791. * Execute the action and increment the target of the value amount.
  10792. */
  10793. execute(): void;
  10794. /**
  10795. * Serializes the actions and its related information.
  10796. * @param parent defines the object to serialize in
  10797. * @returns the serialized object
  10798. */
  10799. serialize(parent: any): any;
  10800. }
  10801. /**
  10802. * This defines an action responsible to start an animation once triggered.
  10803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10804. */
  10805. export class PlayAnimationAction extends Action {
  10806. /**
  10807. * Where the animation should start (animation frame)
  10808. */
  10809. from: number;
  10810. /**
  10811. * Where the animation should stop (animation frame)
  10812. */
  10813. to: number;
  10814. /**
  10815. * Define if the animation should loop or stop after the first play.
  10816. */
  10817. loop?: boolean;
  10818. private _target;
  10819. /**
  10820. * Instantiate the action
  10821. * @param triggerOptions defines the trigger options
  10822. * @param target defines the target animation or animation name
  10823. * @param from defines from where the animation should start (animation frame)
  10824. * @param end defines where the animation should stop (animation frame)
  10825. * @param loop defines if the animation should loop or stop after the first play
  10826. * @param condition defines the trigger related conditions
  10827. */
  10828. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10829. /** @hidden */
  10830. _prepare(): void;
  10831. /**
  10832. * Execute the action and play the animation.
  10833. */
  10834. execute(): void;
  10835. /**
  10836. * Serializes the actions and its related information.
  10837. * @param parent defines the object to serialize in
  10838. * @returns the serialized object
  10839. */
  10840. serialize(parent: any): any;
  10841. }
  10842. /**
  10843. * This defines an action responsible to stop an animation once triggered.
  10844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10845. */
  10846. export class StopAnimationAction extends Action {
  10847. private _target;
  10848. /**
  10849. * Instantiate the action
  10850. * @param triggerOptions defines the trigger options
  10851. * @param target defines the target animation or animation name
  10852. * @param condition defines the trigger related conditions
  10853. */
  10854. constructor(triggerOptions: any, target: any, condition?: Condition);
  10855. /** @hidden */
  10856. _prepare(): void;
  10857. /**
  10858. * Execute the action and stop the animation.
  10859. */
  10860. execute(): void;
  10861. /**
  10862. * Serializes the actions and its related information.
  10863. * @param parent defines the object to serialize in
  10864. * @returns the serialized object
  10865. */
  10866. serialize(parent: any): any;
  10867. }
  10868. /**
  10869. * This defines an action responsible that does nothing once triggered.
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10871. */
  10872. export class DoNothingAction extends Action {
  10873. /**
  10874. * Instantiate the action
  10875. * @param triggerOptions defines the trigger options
  10876. * @param condition defines the trigger related conditions
  10877. */
  10878. constructor(triggerOptions?: any, condition?: Condition);
  10879. /**
  10880. * Execute the action and do nothing.
  10881. */
  10882. execute(): void;
  10883. /**
  10884. * Serializes the actions and its related information.
  10885. * @param parent defines the object to serialize in
  10886. * @returns the serialized object
  10887. */
  10888. serialize(parent: any): any;
  10889. }
  10890. /**
  10891. * This defines an action responsible to trigger several actions once triggered.
  10892. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10893. */
  10894. export class CombineAction extends Action {
  10895. /**
  10896. * The list of aggregated animations to run.
  10897. */
  10898. children: Action[];
  10899. /**
  10900. * Instantiate the action
  10901. * @param triggerOptions defines the trigger options
  10902. * @param children defines the list of aggregated animations to run
  10903. * @param condition defines the trigger related conditions
  10904. */
  10905. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10906. /** @hidden */
  10907. _prepare(): void;
  10908. /**
  10909. * Execute the action and executes all the aggregated actions.
  10910. */
  10911. execute(evt: ActionEvent): void;
  10912. /**
  10913. * Serializes the actions and its related information.
  10914. * @param parent defines the object to serialize in
  10915. * @returns the serialized object
  10916. */
  10917. serialize(parent: any): any;
  10918. }
  10919. /**
  10920. * This defines an action responsible to run code (external event) once triggered.
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10922. */
  10923. export class ExecuteCodeAction extends Action {
  10924. /**
  10925. * The callback function to run.
  10926. */
  10927. func: (evt: ActionEvent) => void;
  10928. /**
  10929. * Instantiate the action
  10930. * @param triggerOptions defines the trigger options
  10931. * @param func defines the callback function to run
  10932. * @param condition defines the trigger related conditions
  10933. */
  10934. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10935. /**
  10936. * Execute the action and run the attached code.
  10937. */
  10938. execute(evt: ActionEvent): void;
  10939. }
  10940. /**
  10941. * This defines an action responsible to set the parent property of the target once triggered.
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10943. */
  10944. export class SetParentAction extends Action {
  10945. private _parent;
  10946. private _target;
  10947. /**
  10948. * Instantiate the action
  10949. * @param triggerOptions defines the trigger options
  10950. * @param target defines the target containing the parent property
  10951. * @param parent defines from where the animation should start (animation frame)
  10952. * @param condition defines the trigger related conditions
  10953. */
  10954. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10955. /** @hidden */
  10956. _prepare(): void;
  10957. /**
  10958. * Execute the action and set the parent property.
  10959. */
  10960. execute(): void;
  10961. /**
  10962. * Serializes the actions and its related information.
  10963. * @param parent defines the object to serialize in
  10964. * @returns the serialized object
  10965. */
  10966. serialize(parent: any): any;
  10967. }
  10968. }
  10969. declare module "babylonjs/Actions/actionManager" {
  10970. import { Nullable } from "babylonjs/types";
  10971. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10972. import { Scene } from "babylonjs/scene";
  10973. import { IAction } from "babylonjs/Actions/action";
  10974. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10975. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10976. /**
  10977. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10978. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10980. */
  10981. export class ActionManager extends AbstractActionManager {
  10982. /**
  10983. * Nothing
  10984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10985. */
  10986. static readonly NothingTrigger: number;
  10987. /**
  10988. * On pick
  10989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10990. */
  10991. static readonly OnPickTrigger: number;
  10992. /**
  10993. * On left pick
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10995. */
  10996. static readonly OnLeftPickTrigger: number;
  10997. /**
  10998. * On right pick
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11000. */
  11001. static readonly OnRightPickTrigger: number;
  11002. /**
  11003. * On center pick
  11004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11005. */
  11006. static readonly OnCenterPickTrigger: number;
  11007. /**
  11008. * On pick down
  11009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11010. */
  11011. static readonly OnPickDownTrigger: number;
  11012. /**
  11013. * On double pick
  11014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11015. */
  11016. static readonly OnDoublePickTrigger: number;
  11017. /**
  11018. * On pick up
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11020. */
  11021. static readonly OnPickUpTrigger: number;
  11022. /**
  11023. * On pick out.
  11024. * This trigger will only be raised if you also declared a OnPickDown
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11026. */
  11027. static readonly OnPickOutTrigger: number;
  11028. /**
  11029. * On long press
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly OnLongPressTrigger: number;
  11033. /**
  11034. * On pointer over
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnPointerOverTrigger: number;
  11038. /**
  11039. * On pointer out
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnPointerOutTrigger: number;
  11043. /**
  11044. * On every frame
  11045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11046. */
  11047. static readonly OnEveryFrameTrigger: number;
  11048. /**
  11049. * On intersection enter
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11051. */
  11052. static readonly OnIntersectionEnterTrigger: number;
  11053. /**
  11054. * On intersection exit
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly OnIntersectionExitTrigger: number;
  11058. /**
  11059. * On key down
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnKeyDownTrigger: number;
  11063. /**
  11064. * On key up
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnKeyUpTrigger: number;
  11068. private _scene;
  11069. /**
  11070. * Creates a new action manager
  11071. * @param scene defines the hosting scene
  11072. */
  11073. constructor(scene: Scene);
  11074. /**
  11075. * Releases all associated resources
  11076. */
  11077. dispose(): void;
  11078. /**
  11079. * Gets hosting scene
  11080. * @returns the hosting scene
  11081. */
  11082. getScene(): Scene;
  11083. /**
  11084. * Does this action manager handles actions of any of the given triggers
  11085. * @param triggers defines the triggers to be tested
  11086. * @return a boolean indicating whether one (or more) of the triggers is handled
  11087. */
  11088. hasSpecificTriggers(triggers: number[]): boolean;
  11089. /**
  11090. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11091. * speed.
  11092. * @param triggerA defines the trigger to be tested
  11093. * @param triggerB defines the trigger to be tested
  11094. * @return a boolean indicating whether one (or more) of the triggers is handled
  11095. */
  11096. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11097. /**
  11098. * Does this action manager handles actions of a given trigger
  11099. * @param trigger defines the trigger to be tested
  11100. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11101. * @return whether the trigger is handled
  11102. */
  11103. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11104. /**
  11105. * Does this action manager has pointer triggers
  11106. */
  11107. readonly hasPointerTriggers: boolean;
  11108. /**
  11109. * Does this action manager has pick triggers
  11110. */
  11111. readonly hasPickTriggers: boolean;
  11112. /**
  11113. * Registers an action to this action manager
  11114. * @param action defines the action to be registered
  11115. * @return the action amended (prepared) after registration
  11116. */
  11117. registerAction(action: IAction): Nullable<IAction>;
  11118. /**
  11119. * Unregisters an action to this action manager
  11120. * @param action defines the action to be unregistered
  11121. * @return a boolean indicating whether the action has been unregistered
  11122. */
  11123. unregisterAction(action: IAction): Boolean;
  11124. /**
  11125. * Process a specific trigger
  11126. * @param trigger defines the trigger to process
  11127. * @param evt defines the event details to be processed
  11128. */
  11129. processTrigger(trigger: number, evt?: IActionEvent): void;
  11130. /** @hidden */
  11131. _getEffectiveTarget(target: any, propertyPath: string): any;
  11132. /** @hidden */
  11133. _getProperty(propertyPath: string): string;
  11134. /**
  11135. * Serialize this manager to a JSON object
  11136. * @param name defines the property name to store this manager
  11137. * @returns a JSON representation of this manager
  11138. */
  11139. serialize(name: string): any;
  11140. /**
  11141. * Creates a new ActionManager from a JSON data
  11142. * @param parsedActions defines the JSON data to read from
  11143. * @param object defines the hosting mesh
  11144. * @param scene defines the hosting scene
  11145. */
  11146. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11147. /**
  11148. * Get a trigger name by index
  11149. * @param trigger defines the trigger index
  11150. * @returns a trigger name
  11151. */
  11152. static GetTriggerName(trigger: number): string;
  11153. }
  11154. }
  11155. declare module "babylonjs/Culling/ray" {
  11156. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11157. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11159. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11160. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11161. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11162. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11163. import { Plane } from "babylonjs/Maths/math.plane";
  11164. /**
  11165. * Class representing a ray with position and direction
  11166. */
  11167. export class Ray {
  11168. /** origin point */
  11169. origin: Vector3;
  11170. /** direction */
  11171. direction: Vector3;
  11172. /** length of the ray */
  11173. length: number;
  11174. private static readonly TmpVector3;
  11175. private _tmpRay;
  11176. /**
  11177. * Creates a new ray
  11178. * @param origin origin point
  11179. * @param direction direction
  11180. * @param length length of the ray
  11181. */
  11182. constructor(
  11183. /** origin point */
  11184. origin: Vector3,
  11185. /** direction */
  11186. direction: Vector3,
  11187. /** length of the ray */
  11188. length?: number);
  11189. /**
  11190. * Checks if the ray intersects a box
  11191. * @param minimum bound of the box
  11192. * @param maximum bound of the box
  11193. * @param intersectionTreshold extra extend to be added to the box in all direction
  11194. * @returns if the box was hit
  11195. */
  11196. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11197. /**
  11198. * Checks if the ray intersects a box
  11199. * @param box the bounding box to check
  11200. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11201. * @returns if the box was hit
  11202. */
  11203. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11204. /**
  11205. * If the ray hits a sphere
  11206. * @param sphere the bounding sphere to check
  11207. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11208. * @returns true if it hits the sphere
  11209. */
  11210. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11211. /**
  11212. * If the ray hits a triange
  11213. * @param vertex0 triangle vertex
  11214. * @param vertex1 triangle vertex
  11215. * @param vertex2 triangle vertex
  11216. * @returns intersection information if hit
  11217. */
  11218. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11219. /**
  11220. * Checks if ray intersects a plane
  11221. * @param plane the plane to check
  11222. * @returns the distance away it was hit
  11223. */
  11224. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11225. /**
  11226. * Calculate the intercept of a ray on a given axis
  11227. * @param axis to check 'x' | 'y' | 'z'
  11228. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11229. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11230. */
  11231. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11232. /**
  11233. * Checks if ray intersects a mesh
  11234. * @param mesh the mesh to check
  11235. * @param fastCheck if only the bounding box should checked
  11236. * @returns picking info of the intersecton
  11237. */
  11238. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11239. /**
  11240. * Checks if ray intersects a mesh
  11241. * @param meshes the meshes to check
  11242. * @param fastCheck if only the bounding box should checked
  11243. * @param results array to store result in
  11244. * @returns Array of picking infos
  11245. */
  11246. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11247. private _comparePickingInfo;
  11248. private static smallnum;
  11249. private static rayl;
  11250. /**
  11251. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11252. * @param sega the first point of the segment to test the intersection against
  11253. * @param segb the second point of the segment to test the intersection against
  11254. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11255. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11256. */
  11257. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11258. /**
  11259. * Update the ray from viewport position
  11260. * @param x position
  11261. * @param y y position
  11262. * @param viewportWidth viewport width
  11263. * @param viewportHeight viewport height
  11264. * @param world world matrix
  11265. * @param view view matrix
  11266. * @param projection projection matrix
  11267. * @returns this ray updated
  11268. */
  11269. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11270. /**
  11271. * Creates a ray with origin and direction of 0,0,0
  11272. * @returns the new ray
  11273. */
  11274. static Zero(): Ray;
  11275. /**
  11276. * Creates a new ray from screen space and viewport
  11277. * @param x position
  11278. * @param y y position
  11279. * @param viewportWidth viewport width
  11280. * @param viewportHeight viewport height
  11281. * @param world world matrix
  11282. * @param view view matrix
  11283. * @param projection projection matrix
  11284. * @returns new ray
  11285. */
  11286. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11287. /**
  11288. * 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
  11289. * transformed to the given world matrix.
  11290. * @param origin The origin point
  11291. * @param end The end point
  11292. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11293. * @returns the new ray
  11294. */
  11295. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11296. /**
  11297. * Transforms a ray by a matrix
  11298. * @param ray ray to transform
  11299. * @param matrix matrix to apply
  11300. * @returns the resulting new ray
  11301. */
  11302. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11303. /**
  11304. * Transforms a ray by a matrix
  11305. * @param ray ray to transform
  11306. * @param matrix matrix to apply
  11307. * @param result ray to store result in
  11308. */
  11309. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11310. /**
  11311. * Unproject a ray from screen space to object space
  11312. * @param sourceX defines the screen space x coordinate to use
  11313. * @param sourceY defines the screen space y coordinate to use
  11314. * @param viewportWidth defines the current width of the viewport
  11315. * @param viewportHeight defines the current height of the viewport
  11316. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11317. * @param view defines the view matrix to use
  11318. * @param projection defines the projection matrix to use
  11319. */
  11320. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11321. }
  11322. /**
  11323. * Type used to define predicate used to select faces when a mesh intersection is detected
  11324. */
  11325. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11326. module "babylonjs/scene" {
  11327. interface Scene {
  11328. /** @hidden */
  11329. _tempPickingRay: Nullable<Ray>;
  11330. /** @hidden */
  11331. _cachedRayForTransform: Ray;
  11332. /** @hidden */
  11333. _pickWithRayInverseMatrix: Matrix;
  11334. /** @hidden */
  11335. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11336. /** @hidden */
  11337. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11338. }
  11339. }
  11340. }
  11341. declare module "babylonjs/sceneComponent" {
  11342. import { Scene } from "babylonjs/scene";
  11343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11344. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11345. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11346. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11347. import { Nullable } from "babylonjs/types";
  11348. import { Camera } from "babylonjs/Cameras/camera";
  11349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11350. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11351. import { AbstractScene } from "babylonjs/abstractScene";
  11352. /**
  11353. * Groups all the scene component constants in one place to ease maintenance.
  11354. * @hidden
  11355. */
  11356. export class SceneComponentConstants {
  11357. static readonly NAME_EFFECTLAYER: string;
  11358. static readonly NAME_LAYER: string;
  11359. static readonly NAME_LENSFLARESYSTEM: string;
  11360. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11361. static readonly NAME_PARTICLESYSTEM: string;
  11362. static readonly NAME_GAMEPAD: string;
  11363. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11364. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11365. static readonly NAME_DEPTHRENDERER: string;
  11366. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11367. static readonly NAME_SPRITE: string;
  11368. static readonly NAME_OUTLINERENDERER: string;
  11369. static readonly NAME_PROCEDURALTEXTURE: string;
  11370. static readonly NAME_SHADOWGENERATOR: string;
  11371. static readonly NAME_OCTREE: string;
  11372. static readonly NAME_PHYSICSENGINE: string;
  11373. static readonly NAME_AUDIO: string;
  11374. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11375. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11376. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11377. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11378. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11379. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11380. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11381. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11382. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11383. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11384. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11385. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11386. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11387. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11388. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11389. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11390. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11391. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11392. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11393. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11394. static readonly STEP_AFTERRENDER_AUDIO: number;
  11395. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11396. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11397. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11398. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11399. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11400. static readonly STEP_POINTERMOVE_SPRITE: number;
  11401. static readonly STEP_POINTERDOWN_SPRITE: number;
  11402. static readonly STEP_POINTERUP_SPRITE: number;
  11403. }
  11404. /**
  11405. * This represents a scene component.
  11406. *
  11407. * This is used to decouple the dependency the scene is having on the different workloads like
  11408. * layers, post processes...
  11409. */
  11410. export interface ISceneComponent {
  11411. /**
  11412. * The name of the component. Each component must have a unique name.
  11413. */
  11414. name: string;
  11415. /**
  11416. * The scene the component belongs to.
  11417. */
  11418. scene: Scene;
  11419. /**
  11420. * Register the component to one instance of a scene.
  11421. */
  11422. register(): void;
  11423. /**
  11424. * Rebuilds the elements related to this component in case of
  11425. * context lost for instance.
  11426. */
  11427. rebuild(): void;
  11428. /**
  11429. * Disposes the component and the associated ressources.
  11430. */
  11431. dispose(): void;
  11432. }
  11433. /**
  11434. * This represents a SERIALIZABLE scene component.
  11435. *
  11436. * This extends Scene Component to add Serialization methods on top.
  11437. */
  11438. export interface ISceneSerializableComponent extends ISceneComponent {
  11439. /**
  11440. * Adds all the elements from the container to the scene
  11441. * @param container the container holding the elements
  11442. */
  11443. addFromContainer(container: AbstractScene): void;
  11444. /**
  11445. * Removes all the elements in the container from the scene
  11446. * @param container contains the elements to remove
  11447. * @param dispose if the removed element should be disposed (default: false)
  11448. */
  11449. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11450. /**
  11451. * Serializes the component data to the specified json object
  11452. * @param serializationObject The object to serialize to
  11453. */
  11454. serialize(serializationObject: any): void;
  11455. }
  11456. /**
  11457. * Strong typing of a Mesh related stage step action
  11458. */
  11459. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11460. /**
  11461. * Strong typing of a Evaluate Sub Mesh related stage step action
  11462. */
  11463. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11464. /**
  11465. * Strong typing of a Active Mesh related stage step action
  11466. */
  11467. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11468. /**
  11469. * Strong typing of a Camera related stage step action
  11470. */
  11471. export type CameraStageAction = (camera: Camera) => void;
  11472. /**
  11473. * Strong typing of a Camera Frame buffer related stage step action
  11474. */
  11475. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11476. /**
  11477. * Strong typing of a Render Target related stage step action
  11478. */
  11479. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11480. /**
  11481. * Strong typing of a RenderingGroup related stage step action
  11482. */
  11483. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11484. /**
  11485. * Strong typing of a Mesh Render related stage step action
  11486. */
  11487. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11488. /**
  11489. * Strong typing of a simple stage step action
  11490. */
  11491. export type SimpleStageAction = () => void;
  11492. /**
  11493. * Strong typing of a render target action.
  11494. */
  11495. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11496. /**
  11497. * Strong typing of a pointer move action.
  11498. */
  11499. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11500. /**
  11501. * Strong typing of a pointer up/down action.
  11502. */
  11503. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11504. /**
  11505. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11506. * @hidden
  11507. */
  11508. export class Stage<T extends Function> extends Array<{
  11509. index: number;
  11510. component: ISceneComponent;
  11511. action: T;
  11512. }> {
  11513. /**
  11514. * Hide ctor from the rest of the world.
  11515. * @param items The items to add.
  11516. */
  11517. private constructor();
  11518. /**
  11519. * Creates a new Stage.
  11520. * @returns A new instance of a Stage
  11521. */
  11522. static Create<T extends Function>(): Stage<T>;
  11523. /**
  11524. * Registers a step in an ordered way in the targeted stage.
  11525. * @param index Defines the position to register the step in
  11526. * @param component Defines the component attached to the step
  11527. * @param action Defines the action to launch during the step
  11528. */
  11529. registerStep(index: number, component: ISceneComponent, action: T): void;
  11530. /**
  11531. * Clears all the steps from the stage.
  11532. */
  11533. clear(): void;
  11534. }
  11535. }
  11536. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11537. import { Nullable } from "babylonjs/types";
  11538. import { Observable } from "babylonjs/Misc/observable";
  11539. import { Scene } from "babylonjs/scene";
  11540. import { Sprite } from "babylonjs/Sprites/sprite";
  11541. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11542. import { Ray } from "babylonjs/Culling/ray";
  11543. import { Camera } from "babylonjs/Cameras/camera";
  11544. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11545. import { ISceneComponent } from "babylonjs/sceneComponent";
  11546. module "babylonjs/scene" {
  11547. interface Scene {
  11548. /** @hidden */
  11549. _pointerOverSprite: Nullable<Sprite>;
  11550. /** @hidden */
  11551. _pickedDownSprite: Nullable<Sprite>;
  11552. /** @hidden */
  11553. _tempSpritePickingRay: Nullable<Ray>;
  11554. /**
  11555. * All of the sprite managers added to this scene
  11556. * @see http://doc.babylonjs.com/babylon101/sprites
  11557. */
  11558. spriteManagers: Array<ISpriteManager>;
  11559. /**
  11560. * An event triggered when sprites rendering is about to start
  11561. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11562. */
  11563. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11564. /**
  11565. * An event triggered when sprites rendering is done
  11566. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11567. */
  11568. onAfterSpritesRenderingObservable: Observable<Scene>;
  11569. /** @hidden */
  11570. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11571. /** Launch a ray to try to pick a sprite in the scene
  11572. * @param x position on screen
  11573. * @param y position on screen
  11574. * @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
  11575. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11576. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11577. * @returns a PickingInfo
  11578. */
  11579. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11580. /** Use the given ray to pick a sprite in the scene
  11581. * @param ray The ray (in world space) to use to pick meshes
  11582. * @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
  11583. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11584. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11585. * @returns a PickingInfo
  11586. */
  11587. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11588. /** @hidden */
  11589. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11590. /** Launch a ray to try to pick sprites in the scene
  11591. * @param x position on screen
  11592. * @param y position on screen
  11593. * @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
  11594. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11595. * @returns a PickingInfo array
  11596. */
  11597. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11598. /** Use the given ray to pick sprites in the scene
  11599. * @param ray The ray (in world space) to use to pick meshes
  11600. * @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
  11601. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11602. * @returns a PickingInfo array
  11603. */
  11604. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11605. /**
  11606. * Force the sprite under the pointer
  11607. * @param sprite defines the sprite to use
  11608. */
  11609. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11610. /**
  11611. * Gets the sprite under the pointer
  11612. * @returns a Sprite or null if no sprite is under the pointer
  11613. */
  11614. getPointerOverSprite(): Nullable<Sprite>;
  11615. }
  11616. }
  11617. /**
  11618. * Defines the sprite scene component responsible to manage sprites
  11619. * in a given scene.
  11620. */
  11621. export class SpriteSceneComponent implements ISceneComponent {
  11622. /**
  11623. * The component name helpfull to identify the component in the list of scene components.
  11624. */
  11625. readonly name: string;
  11626. /**
  11627. * The scene the component belongs to.
  11628. */
  11629. scene: Scene;
  11630. /** @hidden */
  11631. private _spritePredicate;
  11632. /**
  11633. * Creates a new instance of the component for the given scene
  11634. * @param scene Defines the scene to register the component in
  11635. */
  11636. constructor(scene: Scene);
  11637. /**
  11638. * Registers the component in a given scene
  11639. */
  11640. register(): void;
  11641. /**
  11642. * Rebuilds the elements related to this component in case of
  11643. * context lost for instance.
  11644. */
  11645. rebuild(): void;
  11646. /**
  11647. * Disposes the component and the associated ressources.
  11648. */
  11649. dispose(): void;
  11650. private _pickSpriteButKeepRay;
  11651. private _pointerMove;
  11652. private _pointerDown;
  11653. private _pointerUp;
  11654. }
  11655. }
  11656. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11657. /** @hidden */
  11658. export var fogFragmentDeclaration: {
  11659. name: string;
  11660. shader: string;
  11661. };
  11662. }
  11663. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11664. /** @hidden */
  11665. export var fogFragment: {
  11666. name: string;
  11667. shader: string;
  11668. };
  11669. }
  11670. declare module "babylonjs/Shaders/sprites.fragment" {
  11671. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11672. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11673. /** @hidden */
  11674. export var spritesPixelShader: {
  11675. name: string;
  11676. shader: string;
  11677. };
  11678. }
  11679. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11680. /** @hidden */
  11681. export var fogVertexDeclaration: {
  11682. name: string;
  11683. shader: string;
  11684. };
  11685. }
  11686. declare module "babylonjs/Shaders/sprites.vertex" {
  11687. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11688. /** @hidden */
  11689. export var spritesVertexShader: {
  11690. name: string;
  11691. shader: string;
  11692. };
  11693. }
  11694. declare module "babylonjs/Sprites/spriteManager" {
  11695. import { IDisposable, Scene } from "babylonjs/scene";
  11696. import { Nullable } from "babylonjs/types";
  11697. import { Observable } from "babylonjs/Misc/observable";
  11698. import { Sprite } from "babylonjs/Sprites/sprite";
  11699. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11700. import { Camera } from "babylonjs/Cameras/camera";
  11701. import { Texture } from "babylonjs/Materials/Textures/texture";
  11702. import "babylonjs/Shaders/sprites.fragment";
  11703. import "babylonjs/Shaders/sprites.vertex";
  11704. import { Ray } from "babylonjs/Culling/ray";
  11705. /**
  11706. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11707. */
  11708. export interface ISpriteManager extends IDisposable {
  11709. /**
  11710. * Restricts the camera to viewing objects with the same layerMask.
  11711. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11712. */
  11713. layerMask: number;
  11714. /**
  11715. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11716. */
  11717. isPickable: boolean;
  11718. /**
  11719. * Specifies the rendering group id for this mesh (0 by default)
  11720. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11721. */
  11722. renderingGroupId: number;
  11723. /**
  11724. * Defines the list of sprites managed by the manager.
  11725. */
  11726. sprites: Array<Sprite>;
  11727. /**
  11728. * Tests the intersection of a sprite with a specific ray.
  11729. * @param ray The ray we are sending to test the collision
  11730. * @param camera The camera space we are sending rays in
  11731. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11732. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11733. * @returns picking info or null.
  11734. */
  11735. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11736. /**
  11737. * Intersects the sprites with a ray
  11738. * @param ray defines the ray to intersect with
  11739. * @param camera defines the current active camera
  11740. * @param predicate defines a predicate used to select candidate sprites
  11741. * @returns null if no hit or a PickingInfo array
  11742. */
  11743. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11744. /**
  11745. * Renders the list of sprites on screen.
  11746. */
  11747. render(): void;
  11748. }
  11749. /**
  11750. * Class used to manage multiple sprites on the same spritesheet
  11751. * @see http://doc.babylonjs.com/babylon101/sprites
  11752. */
  11753. export class SpriteManager implements ISpriteManager {
  11754. /** defines the manager's name */
  11755. name: string;
  11756. /** Gets the list of sprites */
  11757. sprites: Sprite[];
  11758. /** Gets or sets the rendering group id (0 by default) */
  11759. renderingGroupId: number;
  11760. /** Gets or sets camera layer mask */
  11761. layerMask: number;
  11762. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11763. fogEnabled: boolean;
  11764. /** Gets or sets a boolean indicating if the sprites are pickable */
  11765. isPickable: boolean;
  11766. /** Defines the default width of a cell in the spritesheet */
  11767. cellWidth: number;
  11768. /** Defines the default height of a cell in the spritesheet */
  11769. cellHeight: number;
  11770. /** Associative array from JSON sprite data file */
  11771. private _cellData;
  11772. /** Array of sprite names from JSON sprite data file */
  11773. private _spriteMap;
  11774. /** True when packed cell data from JSON file is ready*/
  11775. private _packedAndReady;
  11776. /**
  11777. * An event triggered when the manager is disposed.
  11778. */
  11779. onDisposeObservable: Observable<SpriteManager>;
  11780. private _onDisposeObserver;
  11781. /**
  11782. * Callback called when the manager is disposed
  11783. */
  11784. onDispose: () => void;
  11785. private _capacity;
  11786. private _fromPacked;
  11787. private _spriteTexture;
  11788. private _epsilon;
  11789. private _scene;
  11790. private _vertexData;
  11791. private _buffer;
  11792. private _vertexBuffers;
  11793. private _indexBuffer;
  11794. private _effectBase;
  11795. private _effectFog;
  11796. /**
  11797. * Gets or sets the spritesheet texture
  11798. */
  11799. texture: Texture;
  11800. /**
  11801. * Creates a new sprite manager
  11802. * @param name defines the manager's name
  11803. * @param imgUrl defines the sprite sheet url
  11804. * @param capacity defines the maximum allowed number of sprites
  11805. * @param cellSize defines the size of a sprite cell
  11806. * @param scene defines the hosting scene
  11807. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11808. * @param samplingMode defines the smapling mode to use with spritesheet
  11809. * @param fromPacked set to false; do not alter
  11810. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11811. */
  11812. constructor(
  11813. /** defines the manager's name */
  11814. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11815. private _makePacked;
  11816. private _appendSpriteVertex;
  11817. /**
  11818. * Intersects the sprites with a ray
  11819. * @param ray defines the ray to intersect with
  11820. * @param camera defines the current active camera
  11821. * @param predicate defines a predicate used to select candidate sprites
  11822. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11823. * @returns null if no hit or a PickingInfo
  11824. */
  11825. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11826. /**
  11827. * Intersects the sprites with a ray
  11828. * @param ray defines the ray to intersect with
  11829. * @param camera defines the current active camera
  11830. * @param predicate defines a predicate used to select candidate sprites
  11831. * @returns null if no hit or a PickingInfo array
  11832. */
  11833. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11834. /**
  11835. * Render all child sprites
  11836. */
  11837. render(): void;
  11838. /**
  11839. * Release associated resources
  11840. */
  11841. dispose(): void;
  11842. }
  11843. }
  11844. declare module "babylonjs/Sprites/sprite" {
  11845. import { Vector3 } from "babylonjs/Maths/math.vector";
  11846. import { Nullable } from "babylonjs/types";
  11847. import { ActionManager } from "babylonjs/Actions/actionManager";
  11848. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11849. import { Color4 } from "babylonjs/Maths/math.color";
  11850. /**
  11851. * Class used to represent a sprite
  11852. * @see http://doc.babylonjs.com/babylon101/sprites
  11853. */
  11854. export class Sprite {
  11855. /** defines the name */
  11856. name: string;
  11857. /** Gets or sets the current world position */
  11858. position: Vector3;
  11859. /** Gets or sets the main color */
  11860. color: Color4;
  11861. /** Gets or sets the width */
  11862. width: number;
  11863. /** Gets or sets the height */
  11864. height: number;
  11865. /** Gets or sets rotation angle */
  11866. angle: number;
  11867. /** Gets or sets the cell index in the sprite sheet */
  11868. cellIndex: number;
  11869. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11870. cellRef: string;
  11871. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11872. invertU: number;
  11873. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11874. invertV: number;
  11875. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11876. disposeWhenFinishedAnimating: boolean;
  11877. /** Gets the list of attached animations */
  11878. animations: Animation[];
  11879. /** Gets or sets a boolean indicating if the sprite can be picked */
  11880. isPickable: boolean;
  11881. /**
  11882. * Gets or sets the associated action manager
  11883. */
  11884. actionManager: Nullable<ActionManager>;
  11885. private _animationStarted;
  11886. private _loopAnimation;
  11887. private _fromIndex;
  11888. private _toIndex;
  11889. private _delay;
  11890. private _direction;
  11891. private _manager;
  11892. private _time;
  11893. private _onAnimationEnd;
  11894. /**
  11895. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11896. */
  11897. isVisible: boolean;
  11898. /**
  11899. * Gets or sets the sprite size
  11900. */
  11901. size: number;
  11902. /**
  11903. * Creates a new Sprite
  11904. * @param name defines the name
  11905. * @param manager defines the manager
  11906. */
  11907. constructor(
  11908. /** defines the name */
  11909. name: string, manager: ISpriteManager);
  11910. /**
  11911. * Starts an animation
  11912. * @param from defines the initial key
  11913. * @param to defines the end key
  11914. * @param loop defines if the animation must loop
  11915. * @param delay defines the start delay (in ms)
  11916. * @param onAnimationEnd defines a callback to call when animation ends
  11917. */
  11918. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11919. /** Stops current animation (if any) */
  11920. stopAnimation(): void;
  11921. /** @hidden */
  11922. _animate(deltaTime: number): void;
  11923. /** Release associated resources */
  11924. dispose(): void;
  11925. }
  11926. }
  11927. declare module "babylonjs/Collisions/pickingInfo" {
  11928. import { Nullable } from "babylonjs/types";
  11929. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11931. import { Sprite } from "babylonjs/Sprites/sprite";
  11932. import { Ray } from "babylonjs/Culling/ray";
  11933. /**
  11934. * Information about the result of picking within a scene
  11935. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11936. */
  11937. export class PickingInfo {
  11938. /** @hidden */
  11939. _pickingUnavailable: boolean;
  11940. /**
  11941. * If the pick collided with an object
  11942. */
  11943. hit: boolean;
  11944. /**
  11945. * Distance away where the pick collided
  11946. */
  11947. distance: number;
  11948. /**
  11949. * The location of pick collision
  11950. */
  11951. pickedPoint: Nullable<Vector3>;
  11952. /**
  11953. * The mesh corresponding the the pick collision
  11954. */
  11955. pickedMesh: Nullable<AbstractMesh>;
  11956. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11957. bu: number;
  11958. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11959. bv: number;
  11960. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11961. faceId: number;
  11962. /** Id of the the submesh that was picked */
  11963. subMeshId: number;
  11964. /** If a sprite was picked, this will be the sprite the pick collided with */
  11965. pickedSprite: Nullable<Sprite>;
  11966. /**
  11967. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11968. */
  11969. originMesh: Nullable<AbstractMesh>;
  11970. /**
  11971. * The ray that was used to perform the picking.
  11972. */
  11973. ray: Nullable<Ray>;
  11974. /**
  11975. * Gets the normal correspodning to the face the pick collided with
  11976. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11977. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11978. * @returns The normal correspodning to the face the pick collided with
  11979. */
  11980. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11981. /**
  11982. * Gets the texture coordinates of where the pick occured
  11983. * @returns the vector containing the coordnates of the texture
  11984. */
  11985. getTextureCoordinates(): Nullable<Vector2>;
  11986. }
  11987. }
  11988. declare module "babylonjs/Events/pointerEvents" {
  11989. import { Nullable } from "babylonjs/types";
  11990. import { Vector2 } from "babylonjs/Maths/math.vector";
  11991. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11992. import { Ray } from "babylonjs/Culling/ray";
  11993. /**
  11994. * Gather the list of pointer event types as constants.
  11995. */
  11996. export class PointerEventTypes {
  11997. /**
  11998. * 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.
  11999. */
  12000. static readonly POINTERDOWN: number;
  12001. /**
  12002. * The pointerup event is fired when a pointer is no longer active.
  12003. */
  12004. static readonly POINTERUP: number;
  12005. /**
  12006. * The pointermove event is fired when a pointer changes coordinates.
  12007. */
  12008. static readonly POINTERMOVE: number;
  12009. /**
  12010. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12011. */
  12012. static readonly POINTERWHEEL: number;
  12013. /**
  12014. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12015. */
  12016. static readonly POINTERPICK: number;
  12017. /**
  12018. * The pointertap event is fired when a the object has been touched and released without drag.
  12019. */
  12020. static readonly POINTERTAP: number;
  12021. /**
  12022. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12023. */
  12024. static readonly POINTERDOUBLETAP: number;
  12025. }
  12026. /**
  12027. * Base class of pointer info types.
  12028. */
  12029. export class PointerInfoBase {
  12030. /**
  12031. * Defines the type of event (PointerEventTypes)
  12032. */
  12033. type: number;
  12034. /**
  12035. * Defines the related dom event
  12036. */
  12037. event: PointerEvent | MouseWheelEvent;
  12038. /**
  12039. * Instantiates the base class of pointers info.
  12040. * @param type Defines the type of event (PointerEventTypes)
  12041. * @param event Defines the related dom event
  12042. */
  12043. constructor(
  12044. /**
  12045. * Defines the type of event (PointerEventTypes)
  12046. */
  12047. type: number,
  12048. /**
  12049. * Defines the related dom event
  12050. */
  12051. event: PointerEvent | MouseWheelEvent);
  12052. }
  12053. /**
  12054. * This class is used to store pointer related info for the onPrePointerObservable event.
  12055. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12056. */
  12057. export class PointerInfoPre extends PointerInfoBase {
  12058. /**
  12059. * Ray from a pointer if availible (eg. 6dof controller)
  12060. */
  12061. ray: Nullable<Ray>;
  12062. /**
  12063. * Defines the local position of the pointer on the canvas.
  12064. */
  12065. localPosition: Vector2;
  12066. /**
  12067. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12068. */
  12069. skipOnPointerObservable: boolean;
  12070. /**
  12071. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12072. * @param type Defines the type of event (PointerEventTypes)
  12073. * @param event Defines the related dom event
  12074. * @param localX Defines the local x coordinates of the pointer when the event occured
  12075. * @param localY Defines the local y coordinates of the pointer when the event occured
  12076. */
  12077. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12078. }
  12079. /**
  12080. * This type contains all the data related to a pointer event in Babylon.js.
  12081. * 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.
  12082. */
  12083. export class PointerInfo extends PointerInfoBase {
  12084. /**
  12085. * Defines the picking info associated to the info (if any)\
  12086. */
  12087. pickInfo: Nullable<PickingInfo>;
  12088. /**
  12089. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12090. * @param type Defines the type of event (PointerEventTypes)
  12091. * @param event Defines the related dom event
  12092. * @param pickInfo Defines the picking info associated to the info (if any)\
  12093. */
  12094. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12095. /**
  12096. * Defines the picking info associated to the info (if any)\
  12097. */
  12098. pickInfo: Nullable<PickingInfo>);
  12099. }
  12100. /**
  12101. * Data relating to a touch event on the screen.
  12102. */
  12103. export interface PointerTouch {
  12104. /**
  12105. * X coordinate of touch.
  12106. */
  12107. x: number;
  12108. /**
  12109. * Y coordinate of touch.
  12110. */
  12111. y: number;
  12112. /**
  12113. * Id of touch. Unique for each finger.
  12114. */
  12115. pointerId: number;
  12116. /**
  12117. * Event type passed from DOM.
  12118. */
  12119. type: any;
  12120. }
  12121. }
  12122. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12123. import { Observable } from "babylonjs/Misc/observable";
  12124. import { Nullable } from "babylonjs/types";
  12125. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12126. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12127. /**
  12128. * Manage the mouse inputs to control the movement of a free camera.
  12129. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12130. */
  12131. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12132. /**
  12133. * Define if touch is enabled in the mouse input
  12134. */
  12135. touchEnabled: boolean;
  12136. /**
  12137. * Defines the camera the input is attached to.
  12138. */
  12139. camera: FreeCamera;
  12140. /**
  12141. * Defines the buttons associated with the input to handle camera move.
  12142. */
  12143. buttons: number[];
  12144. /**
  12145. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12146. */
  12147. angularSensibility: number;
  12148. private _pointerInput;
  12149. private _onMouseMove;
  12150. private _observer;
  12151. private previousPosition;
  12152. /**
  12153. * Observable for when a pointer move event occurs containing the move offset
  12154. */
  12155. onPointerMovedObservable: Observable<{
  12156. offsetX: number;
  12157. offsetY: number;
  12158. }>;
  12159. /**
  12160. * @hidden
  12161. * If the camera should be rotated automatically based on pointer movement
  12162. */
  12163. _allowCameraRotation: boolean;
  12164. /**
  12165. * Manage the mouse inputs to control the movement of a free camera.
  12166. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12167. * @param touchEnabled Defines if touch is enabled or not
  12168. */
  12169. constructor(
  12170. /**
  12171. * Define if touch is enabled in the mouse input
  12172. */
  12173. touchEnabled?: boolean);
  12174. /**
  12175. * Attach the input controls to a specific dom element to get the input from.
  12176. * @param element Defines the element the controls should be listened from
  12177. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12178. */
  12179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12180. /**
  12181. * Called on JS contextmenu event.
  12182. * Override this method to provide functionality.
  12183. */
  12184. protected onContextMenu(evt: PointerEvent): void;
  12185. /**
  12186. * Detach the current controls from the specified dom element.
  12187. * @param element Defines the element to stop listening the inputs from
  12188. */
  12189. detachControl(element: Nullable<HTMLElement>): void;
  12190. /**
  12191. * Gets the class name of the current intput.
  12192. * @returns the class name
  12193. */
  12194. getClassName(): string;
  12195. /**
  12196. * Get the friendly name associated with the input class.
  12197. * @returns the input friendly name
  12198. */
  12199. getSimpleName(): string;
  12200. }
  12201. }
  12202. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12203. import { Nullable } from "babylonjs/types";
  12204. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12205. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12206. /**
  12207. * Manage the touch inputs to control the movement of a free camera.
  12208. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12209. */
  12210. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12211. /**
  12212. * Defines the camera the input is attached to.
  12213. */
  12214. camera: FreeCamera;
  12215. /**
  12216. * Defines the touch sensibility for rotation.
  12217. * The higher the faster.
  12218. */
  12219. touchAngularSensibility: number;
  12220. /**
  12221. * Defines the touch sensibility for move.
  12222. * The higher the faster.
  12223. */
  12224. touchMoveSensibility: number;
  12225. private _offsetX;
  12226. private _offsetY;
  12227. private _pointerPressed;
  12228. private _pointerInput;
  12229. private _observer;
  12230. private _onLostFocus;
  12231. /**
  12232. * Attach the input controls to a specific dom element to get the input from.
  12233. * @param element Defines the element the controls should be listened from
  12234. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12235. */
  12236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12237. /**
  12238. * Detach the current controls from the specified dom element.
  12239. * @param element Defines the element to stop listening the inputs from
  12240. */
  12241. detachControl(element: Nullable<HTMLElement>): void;
  12242. /**
  12243. * Update the current camera state depending on the inputs that have been used this frame.
  12244. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12245. */
  12246. checkInputs(): void;
  12247. /**
  12248. * Gets the class name of the current intput.
  12249. * @returns the class name
  12250. */
  12251. getClassName(): string;
  12252. /**
  12253. * Get the friendly name associated with the input class.
  12254. * @returns the input friendly name
  12255. */
  12256. getSimpleName(): string;
  12257. }
  12258. }
  12259. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12260. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12261. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12262. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12263. import { Nullable } from "babylonjs/types";
  12264. /**
  12265. * Default Inputs manager for the FreeCamera.
  12266. * It groups all the default supported inputs for ease of use.
  12267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12268. */
  12269. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12270. /**
  12271. * @hidden
  12272. */
  12273. _mouseInput: Nullable<FreeCameraMouseInput>;
  12274. /**
  12275. * Instantiates a new FreeCameraInputsManager.
  12276. * @param camera Defines the camera the inputs belong to
  12277. */
  12278. constructor(camera: FreeCamera);
  12279. /**
  12280. * Add keyboard input support to the input manager.
  12281. * @returns the current input manager
  12282. */
  12283. addKeyboard(): FreeCameraInputsManager;
  12284. /**
  12285. * Add mouse input support to the input manager.
  12286. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12287. * @returns the current input manager
  12288. */
  12289. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12290. /**
  12291. * Removes the mouse input support from the manager
  12292. * @returns the current input manager
  12293. */
  12294. removeMouse(): FreeCameraInputsManager;
  12295. /**
  12296. * Add touch input support to the input manager.
  12297. * @returns the current input manager
  12298. */
  12299. addTouch(): FreeCameraInputsManager;
  12300. /**
  12301. * Remove all attached input methods from a camera
  12302. */
  12303. clear(): void;
  12304. }
  12305. }
  12306. declare module "babylonjs/Cameras/freeCamera" {
  12307. import { Vector3 } from "babylonjs/Maths/math.vector";
  12308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12309. import { Scene } from "babylonjs/scene";
  12310. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12311. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12312. /**
  12313. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12314. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12315. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12316. */
  12317. export class FreeCamera extends TargetCamera {
  12318. /**
  12319. * Define the collision ellipsoid of the camera.
  12320. * This is helpful to simulate a camera body like the player body around the camera
  12321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12322. */
  12323. ellipsoid: Vector3;
  12324. /**
  12325. * Define an offset for the position of the ellipsoid around the camera.
  12326. * This can be helpful to determine the center of the body near the gravity center of the body
  12327. * instead of its head.
  12328. */
  12329. ellipsoidOffset: Vector3;
  12330. /**
  12331. * Enable or disable collisions of the camera with the rest of the scene objects.
  12332. */
  12333. checkCollisions: boolean;
  12334. /**
  12335. * Enable or disable gravity on the camera.
  12336. */
  12337. applyGravity: boolean;
  12338. /**
  12339. * Define the input manager associated to the camera.
  12340. */
  12341. inputs: FreeCameraInputsManager;
  12342. /**
  12343. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12344. * Higher values reduce sensitivity.
  12345. */
  12346. /**
  12347. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12348. * Higher values reduce sensitivity.
  12349. */
  12350. angularSensibility: number;
  12351. /**
  12352. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12353. */
  12354. keysUp: number[];
  12355. /**
  12356. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12357. */
  12358. keysDown: number[];
  12359. /**
  12360. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12361. */
  12362. keysLeft: number[];
  12363. /**
  12364. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12365. */
  12366. keysRight: number[];
  12367. /**
  12368. * Event raised when the camera collide with a mesh in the scene.
  12369. */
  12370. onCollide: (collidedMesh: AbstractMesh) => void;
  12371. private _collider;
  12372. private _needMoveForGravity;
  12373. private _oldPosition;
  12374. private _diffPosition;
  12375. private _newPosition;
  12376. /** @hidden */
  12377. _localDirection: Vector3;
  12378. /** @hidden */
  12379. _transformedDirection: Vector3;
  12380. /**
  12381. * Instantiates a Free Camera.
  12382. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12383. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12384. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12385. * @param name Define the name of the camera in the scene
  12386. * @param position Define the start position of the camera in the scene
  12387. * @param scene Define the scene the camera belongs to
  12388. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12389. */
  12390. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12391. /**
  12392. * Attached controls to the current camera.
  12393. * @param element Defines the element the controls should be listened from
  12394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12395. */
  12396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12397. /**
  12398. * Detach the current controls from the camera.
  12399. * The camera will stop reacting to inputs.
  12400. * @param element Defines the element to stop listening the inputs from
  12401. */
  12402. detachControl(element: HTMLElement): void;
  12403. private _collisionMask;
  12404. /**
  12405. * Define a collision mask to limit the list of object the camera can collide with
  12406. */
  12407. collisionMask: number;
  12408. /** @hidden */
  12409. _collideWithWorld(displacement: Vector3): void;
  12410. private _onCollisionPositionChange;
  12411. /** @hidden */
  12412. _checkInputs(): void;
  12413. /** @hidden */
  12414. _decideIfNeedsToMove(): boolean;
  12415. /** @hidden */
  12416. _updatePosition(): void;
  12417. /**
  12418. * Destroy the camera and release the current resources hold by it.
  12419. */
  12420. dispose(): void;
  12421. /**
  12422. * Gets the current object class name.
  12423. * @return the class name
  12424. */
  12425. getClassName(): string;
  12426. }
  12427. }
  12428. declare module "babylonjs/Gamepads/gamepad" {
  12429. import { Observable } from "babylonjs/Misc/observable";
  12430. /**
  12431. * Represents a gamepad control stick position
  12432. */
  12433. export class StickValues {
  12434. /**
  12435. * The x component of the control stick
  12436. */
  12437. x: number;
  12438. /**
  12439. * The y component of the control stick
  12440. */
  12441. y: number;
  12442. /**
  12443. * Initializes the gamepad x and y control stick values
  12444. * @param x The x component of the gamepad control stick value
  12445. * @param y The y component of the gamepad control stick value
  12446. */
  12447. constructor(
  12448. /**
  12449. * The x component of the control stick
  12450. */
  12451. x: number,
  12452. /**
  12453. * The y component of the control stick
  12454. */
  12455. y: number);
  12456. }
  12457. /**
  12458. * An interface which manages callbacks for gamepad button changes
  12459. */
  12460. export interface GamepadButtonChanges {
  12461. /**
  12462. * Called when a gamepad has been changed
  12463. */
  12464. changed: boolean;
  12465. /**
  12466. * Called when a gamepad press event has been triggered
  12467. */
  12468. pressChanged: boolean;
  12469. /**
  12470. * Called when a touch event has been triggered
  12471. */
  12472. touchChanged: boolean;
  12473. /**
  12474. * Called when a value has changed
  12475. */
  12476. valueChanged: boolean;
  12477. }
  12478. /**
  12479. * Represents a gamepad
  12480. */
  12481. export class Gamepad {
  12482. /**
  12483. * The id of the gamepad
  12484. */
  12485. id: string;
  12486. /**
  12487. * The index of the gamepad
  12488. */
  12489. index: number;
  12490. /**
  12491. * The browser gamepad
  12492. */
  12493. browserGamepad: any;
  12494. /**
  12495. * Specifies what type of gamepad this represents
  12496. */
  12497. type: number;
  12498. private _leftStick;
  12499. private _rightStick;
  12500. /** @hidden */
  12501. _isConnected: boolean;
  12502. private _leftStickAxisX;
  12503. private _leftStickAxisY;
  12504. private _rightStickAxisX;
  12505. private _rightStickAxisY;
  12506. /**
  12507. * Triggered when the left control stick has been changed
  12508. */
  12509. private _onleftstickchanged;
  12510. /**
  12511. * Triggered when the right control stick has been changed
  12512. */
  12513. private _onrightstickchanged;
  12514. /**
  12515. * Represents a gamepad controller
  12516. */
  12517. static GAMEPAD: number;
  12518. /**
  12519. * Represents a generic controller
  12520. */
  12521. static GENERIC: number;
  12522. /**
  12523. * Represents an XBox controller
  12524. */
  12525. static XBOX: number;
  12526. /**
  12527. * Represents a pose-enabled controller
  12528. */
  12529. static POSE_ENABLED: number;
  12530. /**
  12531. * Represents an Dual Shock controller
  12532. */
  12533. static DUALSHOCK: number;
  12534. /**
  12535. * Specifies whether the left control stick should be Y-inverted
  12536. */
  12537. protected _invertLeftStickY: boolean;
  12538. /**
  12539. * Specifies if the gamepad has been connected
  12540. */
  12541. readonly isConnected: boolean;
  12542. /**
  12543. * Initializes the gamepad
  12544. * @param id The id of the gamepad
  12545. * @param index The index of the gamepad
  12546. * @param browserGamepad The browser gamepad
  12547. * @param leftStickX The x component of the left joystick
  12548. * @param leftStickY The y component of the left joystick
  12549. * @param rightStickX The x component of the right joystick
  12550. * @param rightStickY The y component of the right joystick
  12551. */
  12552. constructor(
  12553. /**
  12554. * The id of the gamepad
  12555. */
  12556. id: string,
  12557. /**
  12558. * The index of the gamepad
  12559. */
  12560. index: number,
  12561. /**
  12562. * The browser gamepad
  12563. */
  12564. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12565. /**
  12566. * Callback triggered when the left joystick has changed
  12567. * @param callback
  12568. */
  12569. onleftstickchanged(callback: (values: StickValues) => void): void;
  12570. /**
  12571. * Callback triggered when the right joystick has changed
  12572. * @param callback
  12573. */
  12574. onrightstickchanged(callback: (values: StickValues) => void): void;
  12575. /**
  12576. * Gets the left joystick
  12577. */
  12578. /**
  12579. * Sets the left joystick values
  12580. */
  12581. leftStick: StickValues;
  12582. /**
  12583. * Gets the right joystick
  12584. */
  12585. /**
  12586. * Sets the right joystick value
  12587. */
  12588. rightStick: StickValues;
  12589. /**
  12590. * Updates the gamepad joystick positions
  12591. */
  12592. update(): void;
  12593. /**
  12594. * Disposes the gamepad
  12595. */
  12596. dispose(): void;
  12597. }
  12598. /**
  12599. * Represents a generic gamepad
  12600. */
  12601. export class GenericPad extends Gamepad {
  12602. private _buttons;
  12603. private _onbuttondown;
  12604. private _onbuttonup;
  12605. /**
  12606. * Observable triggered when a button has been pressed
  12607. */
  12608. onButtonDownObservable: Observable<number>;
  12609. /**
  12610. * Observable triggered when a button has been released
  12611. */
  12612. onButtonUpObservable: Observable<number>;
  12613. /**
  12614. * Callback triggered when a button has been pressed
  12615. * @param callback Called when a button has been pressed
  12616. */
  12617. onbuttondown(callback: (buttonPressed: number) => void): void;
  12618. /**
  12619. * Callback triggered when a button has been released
  12620. * @param callback Called when a button has been released
  12621. */
  12622. onbuttonup(callback: (buttonReleased: number) => void): void;
  12623. /**
  12624. * Initializes the generic gamepad
  12625. * @param id The id of the generic gamepad
  12626. * @param index The index of the generic gamepad
  12627. * @param browserGamepad The browser gamepad
  12628. */
  12629. constructor(id: string, index: number, browserGamepad: any);
  12630. private _setButtonValue;
  12631. /**
  12632. * Updates the generic gamepad
  12633. */
  12634. update(): void;
  12635. /**
  12636. * Disposes the generic gamepad
  12637. */
  12638. dispose(): void;
  12639. }
  12640. }
  12641. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12642. import { Nullable } from "babylonjs/types";
  12643. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12644. import { Scene } from "babylonjs/scene";
  12645. module "babylonjs/Engines/engine" {
  12646. interface Engine {
  12647. /**
  12648. * Creates a raw texture
  12649. * @param data defines the data to store in the texture
  12650. * @param width defines the width of the texture
  12651. * @param height defines the height of the texture
  12652. * @param format defines the format of the data
  12653. * @param generateMipMaps defines if the engine should generate the mip levels
  12654. * @param invertY defines if data must be stored with Y axis inverted
  12655. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12656. * @param compression defines the compression used (null by default)
  12657. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12658. * @returns the raw texture inside an InternalTexture
  12659. */
  12660. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12661. /**
  12662. * Update a raw texture
  12663. * @param texture defines the texture to update
  12664. * @param data defines the data to store in the texture
  12665. * @param format defines the format of the data
  12666. * @param invertY defines if data must be stored with Y axis inverted
  12667. */
  12668. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12669. /**
  12670. * Update a raw texture
  12671. * @param texture defines the texture to update
  12672. * @param data defines the data to store in the texture
  12673. * @param format defines the format of the data
  12674. * @param invertY defines if data must be stored with Y axis inverted
  12675. * @param compression defines the compression used (null by default)
  12676. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12677. */
  12678. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12679. /**
  12680. * Creates a new raw cube texture
  12681. * @param data defines the array of data to use to create each face
  12682. * @param size defines the size of the textures
  12683. * @param format defines the format of the data
  12684. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12685. * @param generateMipMaps defines if the engine should generate the mip levels
  12686. * @param invertY defines if data must be stored with Y axis inverted
  12687. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12688. * @param compression defines the compression used (null by default)
  12689. * @returns the cube texture as an InternalTexture
  12690. */
  12691. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12692. /**
  12693. * Update a raw cube texture
  12694. * @param texture defines the texture to udpdate
  12695. * @param data defines the data to store
  12696. * @param format defines the data format
  12697. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12698. * @param invertY defines if data must be stored with Y axis inverted
  12699. */
  12700. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12701. /**
  12702. * Update a raw cube texture
  12703. * @param texture defines the texture to udpdate
  12704. * @param data defines the data to store
  12705. * @param format defines the data format
  12706. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param compression defines the compression used (null by default)
  12709. */
  12710. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12711. /**
  12712. * Update a raw cube texture
  12713. * @param texture defines the texture to udpdate
  12714. * @param data defines the data to store
  12715. * @param format defines the data format
  12716. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12717. * @param invertY defines if data must be stored with Y axis inverted
  12718. * @param compression defines the compression used (null by default)
  12719. * @param level defines which level of the texture to update
  12720. */
  12721. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12722. /**
  12723. * Creates a new raw cube texture from a specified url
  12724. * @param url defines the url where the data is located
  12725. * @param scene defines the current scene
  12726. * @param size defines the size of the textures
  12727. * @param format defines the format of the data
  12728. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12729. * @param noMipmap defines if the engine should avoid generating the mip levels
  12730. * @param callback defines a callback used to extract texture data from loaded data
  12731. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12732. * @param onLoad defines a callback called when texture is loaded
  12733. * @param onError defines a callback called if there is an error
  12734. * @returns the cube texture as an InternalTexture
  12735. */
  12736. 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;
  12737. /**
  12738. * Creates a new raw cube texture from a specified url
  12739. * @param url defines the url where the data is located
  12740. * @param scene defines the current scene
  12741. * @param size defines the size of the textures
  12742. * @param format defines the format of the data
  12743. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12744. * @param noMipmap defines if the engine should avoid generating the mip levels
  12745. * @param callback defines a callback used to extract texture data from loaded data
  12746. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12747. * @param onLoad defines a callback called when texture is loaded
  12748. * @param onError defines a callback called if there is an error
  12749. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12750. * @param invertY defines if data must be stored with Y axis inverted
  12751. * @returns the cube texture as an InternalTexture
  12752. */
  12753. 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;
  12754. /**
  12755. * Creates a new raw 3D texture
  12756. * @param data defines the data used to create the texture
  12757. * @param width defines the width of the texture
  12758. * @param height defines the height of the texture
  12759. * @param depth defines the depth of the texture
  12760. * @param format defines the format of the texture
  12761. * @param generateMipMaps defines if the engine must generate mip levels
  12762. * @param invertY defines if data must be stored with Y axis inverted
  12763. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12764. * @param compression defines the compressed used (can be null)
  12765. * @param textureType defines the compressed used (can be null)
  12766. * @returns a new raw 3D texture (stored in an InternalTexture)
  12767. */
  12768. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12769. /**
  12770. * Update a raw 3D texture
  12771. * @param texture defines the texture to update
  12772. * @param data defines the data to store
  12773. * @param format defines the data format
  12774. * @param invertY defines if data must be stored with Y axis inverted
  12775. */
  12776. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12777. /**
  12778. * Update a raw 3D texture
  12779. * @param texture defines the texture to update
  12780. * @param data defines the data to store
  12781. * @param format defines the data format
  12782. * @param invertY defines if data must be stored with Y axis inverted
  12783. * @param compression defines the used compression (can be null)
  12784. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12785. */
  12786. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12787. }
  12788. }
  12789. }
  12790. declare module "babylonjs/Materials/Textures/rawTexture" {
  12791. import { Scene } from "babylonjs/scene";
  12792. import { Texture } from "babylonjs/Materials/Textures/texture";
  12793. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12794. /**
  12795. * Raw texture can help creating a texture directly from an array of data.
  12796. * This can be super useful if you either get the data from an uncompressed source or
  12797. * if you wish to create your texture pixel by pixel.
  12798. */
  12799. export class RawTexture extends Texture {
  12800. /**
  12801. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12802. */
  12803. format: number;
  12804. private _engine;
  12805. /**
  12806. * Instantiates a new RawTexture.
  12807. * Raw texture can help creating a texture directly from an array of data.
  12808. * This can be super useful if you either get the data from an uncompressed source or
  12809. * if you wish to create your texture pixel by pixel.
  12810. * @param data define the array of data to use to create the texture
  12811. * @param width define the width of the texture
  12812. * @param height define the height of the texture
  12813. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12814. * @param scene define the scene the texture belongs to
  12815. * @param generateMipMaps define whether mip maps should be generated or not
  12816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12818. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12819. */
  12820. constructor(data: ArrayBufferView, width: number, height: number,
  12821. /**
  12822. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12823. */
  12824. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12825. /**
  12826. * Updates the texture underlying data.
  12827. * @param data Define the new data of the texture
  12828. */
  12829. update(data: ArrayBufferView): void;
  12830. /**
  12831. * Creates a luminance texture from some data.
  12832. * @param data Define the texture data
  12833. * @param width Define the width of the texture
  12834. * @param height Define the height of the texture
  12835. * @param scene Define the scene the texture belongs to
  12836. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12837. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12838. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12839. * @returns the luminance texture
  12840. */
  12841. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12842. /**
  12843. * Creates a luminance alpha texture from some data.
  12844. * @param data Define the texture data
  12845. * @param width Define the width of the texture
  12846. * @param height Define the height of the texture
  12847. * @param scene Define the scene the texture belongs to
  12848. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12849. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12850. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12851. * @returns the luminance alpha texture
  12852. */
  12853. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12854. /**
  12855. * Creates an alpha texture from some data.
  12856. * @param data Define the texture data
  12857. * @param width Define the width of the texture
  12858. * @param height Define the height of the texture
  12859. * @param scene Define the scene the texture belongs to
  12860. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12861. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12862. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12863. * @returns the alpha texture
  12864. */
  12865. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12866. /**
  12867. * Creates a RGB texture from some data.
  12868. * @param data Define the texture data
  12869. * @param width Define the width of the texture
  12870. * @param height Define the height of the texture
  12871. * @param scene Define the scene the texture belongs to
  12872. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12873. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12874. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12875. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12876. * @returns the RGB alpha texture
  12877. */
  12878. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12879. /**
  12880. * Creates a RGBA texture from some data.
  12881. * @param data Define the texture data
  12882. * @param width Define the width of the texture
  12883. * @param height Define the height of the texture
  12884. * @param scene Define the scene the texture belongs to
  12885. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12886. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12887. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12888. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12889. * @returns the RGBA texture
  12890. */
  12891. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12892. /**
  12893. * Creates a R texture from some data.
  12894. * @param data Define the texture data
  12895. * @param width Define the width of the texture
  12896. * @param height Define the height of the texture
  12897. * @param scene Define the scene the texture belongs to
  12898. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12899. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12900. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12901. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12902. * @returns the R texture
  12903. */
  12904. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12905. }
  12906. }
  12907. declare module "babylonjs/Maths/math.size" {
  12908. /**
  12909. * Interface for the size containing width and height
  12910. */
  12911. export interface ISize {
  12912. /**
  12913. * Width
  12914. */
  12915. width: number;
  12916. /**
  12917. * Heighht
  12918. */
  12919. height: number;
  12920. }
  12921. /**
  12922. * Size containing widht and height
  12923. */
  12924. export class Size implements ISize {
  12925. /**
  12926. * Width
  12927. */
  12928. width: number;
  12929. /**
  12930. * Height
  12931. */
  12932. height: number;
  12933. /**
  12934. * Creates a Size object from the given width and height (floats).
  12935. * @param width width of the new size
  12936. * @param height height of the new size
  12937. */
  12938. constructor(width: number, height: number);
  12939. /**
  12940. * Returns a string with the Size width and height
  12941. * @returns a string with the Size width and height
  12942. */
  12943. toString(): string;
  12944. /**
  12945. * "Size"
  12946. * @returns the string "Size"
  12947. */
  12948. getClassName(): string;
  12949. /**
  12950. * Returns the Size hash code.
  12951. * @returns a hash code for a unique width and height
  12952. */
  12953. getHashCode(): number;
  12954. /**
  12955. * Updates the current size from the given one.
  12956. * @param src the given size
  12957. */
  12958. copyFrom(src: Size): void;
  12959. /**
  12960. * Updates in place the current Size from the given floats.
  12961. * @param width width of the new size
  12962. * @param height height of the new size
  12963. * @returns the updated Size.
  12964. */
  12965. copyFromFloats(width: number, height: number): Size;
  12966. /**
  12967. * Updates in place the current Size from the given floats.
  12968. * @param width width to set
  12969. * @param height height to set
  12970. * @returns the updated Size.
  12971. */
  12972. set(width: number, height: number): Size;
  12973. /**
  12974. * Multiplies the width and height by numbers
  12975. * @param w factor to multiple the width by
  12976. * @param h factor to multiple the height by
  12977. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12978. */
  12979. multiplyByFloats(w: number, h: number): Size;
  12980. /**
  12981. * Clones the size
  12982. * @returns a new Size copied from the given one.
  12983. */
  12984. clone(): Size;
  12985. /**
  12986. * True if the current Size and the given one width and height are strictly equal.
  12987. * @param other the other size to compare against
  12988. * @returns True if the current Size and the given one width and height are strictly equal.
  12989. */
  12990. equals(other: Size): boolean;
  12991. /**
  12992. * The surface of the Size : width * height (float).
  12993. */
  12994. readonly surface: number;
  12995. /**
  12996. * Create a new size of zero
  12997. * @returns a new Size set to (0.0, 0.0)
  12998. */
  12999. static Zero(): Size;
  13000. /**
  13001. * Sums the width and height of two sizes
  13002. * @param otherSize size to add to this size
  13003. * @returns a new Size set as the addition result of the current Size and the given one.
  13004. */
  13005. add(otherSize: Size): Size;
  13006. /**
  13007. * Subtracts the width and height of two
  13008. * @param otherSize size to subtract to this size
  13009. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13010. */
  13011. subtract(otherSize: Size): Size;
  13012. /**
  13013. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13014. * @param start starting size to lerp between
  13015. * @param end end size to lerp between
  13016. * @param amount amount to lerp between the start and end values
  13017. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13018. */
  13019. static Lerp(start: Size, end: Size, amount: number): Size;
  13020. }
  13021. }
  13022. declare module "babylonjs/Animations/runtimeAnimation" {
  13023. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13024. import { Animatable } from "babylonjs/Animations/animatable";
  13025. import { Scene } from "babylonjs/scene";
  13026. /**
  13027. * Defines a runtime animation
  13028. */
  13029. export class RuntimeAnimation {
  13030. private _events;
  13031. /**
  13032. * The current frame of the runtime animation
  13033. */
  13034. private _currentFrame;
  13035. /**
  13036. * The animation used by the runtime animation
  13037. */
  13038. private _animation;
  13039. /**
  13040. * The target of the runtime animation
  13041. */
  13042. private _target;
  13043. /**
  13044. * The initiating animatable
  13045. */
  13046. private _host;
  13047. /**
  13048. * The original value of the runtime animation
  13049. */
  13050. private _originalValue;
  13051. /**
  13052. * The original blend value of the runtime animation
  13053. */
  13054. private _originalBlendValue;
  13055. /**
  13056. * The offsets cache of the runtime animation
  13057. */
  13058. private _offsetsCache;
  13059. /**
  13060. * The high limits cache of the runtime animation
  13061. */
  13062. private _highLimitsCache;
  13063. /**
  13064. * Specifies if the runtime animation has been stopped
  13065. */
  13066. private _stopped;
  13067. /**
  13068. * The blending factor of the runtime animation
  13069. */
  13070. private _blendingFactor;
  13071. /**
  13072. * The BabylonJS scene
  13073. */
  13074. private _scene;
  13075. /**
  13076. * The current value of the runtime animation
  13077. */
  13078. private _currentValue;
  13079. /** @hidden */
  13080. _animationState: _IAnimationState;
  13081. /**
  13082. * The active target of the runtime animation
  13083. */
  13084. private _activeTargets;
  13085. private _currentActiveTarget;
  13086. private _directTarget;
  13087. /**
  13088. * The target path of the runtime animation
  13089. */
  13090. private _targetPath;
  13091. /**
  13092. * The weight of the runtime animation
  13093. */
  13094. private _weight;
  13095. /**
  13096. * The ratio offset of the runtime animation
  13097. */
  13098. private _ratioOffset;
  13099. /**
  13100. * The previous delay of the runtime animation
  13101. */
  13102. private _previousDelay;
  13103. /**
  13104. * The previous ratio of the runtime animation
  13105. */
  13106. private _previousRatio;
  13107. private _enableBlending;
  13108. private _keys;
  13109. private _minFrame;
  13110. private _maxFrame;
  13111. private _minValue;
  13112. private _maxValue;
  13113. private _targetIsArray;
  13114. /**
  13115. * Gets the current frame of the runtime animation
  13116. */
  13117. readonly currentFrame: number;
  13118. /**
  13119. * Gets the weight of the runtime animation
  13120. */
  13121. readonly weight: number;
  13122. /**
  13123. * Gets the current value of the runtime animation
  13124. */
  13125. readonly currentValue: any;
  13126. /**
  13127. * Gets the target path of the runtime animation
  13128. */
  13129. readonly targetPath: string;
  13130. /**
  13131. * Gets the actual target of the runtime animation
  13132. */
  13133. readonly target: any;
  13134. /** @hidden */
  13135. _onLoop: () => void;
  13136. /**
  13137. * Create a new RuntimeAnimation object
  13138. * @param target defines the target of the animation
  13139. * @param animation defines the source animation object
  13140. * @param scene defines the hosting scene
  13141. * @param host defines the initiating Animatable
  13142. */
  13143. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13144. private _preparePath;
  13145. /**
  13146. * Gets the animation from the runtime animation
  13147. */
  13148. readonly animation: Animation;
  13149. /**
  13150. * Resets the runtime animation to the beginning
  13151. * @param restoreOriginal defines whether to restore the target property to the original value
  13152. */
  13153. reset(restoreOriginal?: boolean): void;
  13154. /**
  13155. * Specifies if the runtime animation is stopped
  13156. * @returns Boolean specifying if the runtime animation is stopped
  13157. */
  13158. isStopped(): boolean;
  13159. /**
  13160. * Disposes of the runtime animation
  13161. */
  13162. dispose(): void;
  13163. /**
  13164. * Apply the interpolated value to the target
  13165. * @param currentValue defines the value computed by the animation
  13166. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13167. */
  13168. setValue(currentValue: any, weight: number): void;
  13169. private _getOriginalValues;
  13170. private _setValue;
  13171. /**
  13172. * Gets the loop pmode of the runtime animation
  13173. * @returns Loop Mode
  13174. */
  13175. private _getCorrectLoopMode;
  13176. /**
  13177. * Move the current animation to a given frame
  13178. * @param frame defines the frame to move to
  13179. */
  13180. goToFrame(frame: number): void;
  13181. /**
  13182. * @hidden Internal use only
  13183. */
  13184. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13185. /**
  13186. * Execute the current animation
  13187. * @param delay defines the delay to add to the current frame
  13188. * @param from defines the lower bound of the animation range
  13189. * @param to defines the upper bound of the animation range
  13190. * @param loop defines if the current animation must loop
  13191. * @param speedRatio defines the current speed ratio
  13192. * @param weight defines the weight of the animation (default is -1 so no weight)
  13193. * @param onLoop optional callback called when animation loops
  13194. * @returns a boolean indicating if the animation is running
  13195. */
  13196. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13197. }
  13198. }
  13199. declare module "babylonjs/Animations/animatable" {
  13200. import { Animation } from "babylonjs/Animations/animation";
  13201. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13202. import { Nullable } from "babylonjs/types";
  13203. import { Observable } from "babylonjs/Misc/observable";
  13204. import { Scene } from "babylonjs/scene";
  13205. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13206. import { Node } from "babylonjs/node";
  13207. /**
  13208. * Class used to store an actual running animation
  13209. */
  13210. export class Animatable {
  13211. /** defines the target object */
  13212. target: any;
  13213. /** defines the starting frame number (default is 0) */
  13214. fromFrame: number;
  13215. /** defines the ending frame number (default is 100) */
  13216. toFrame: number;
  13217. /** defines if the animation must loop (default is false) */
  13218. loopAnimation: boolean;
  13219. /** defines a callback to call when animation ends if it is not looping */
  13220. onAnimationEnd?: (() => void) | null | undefined;
  13221. /** defines a callback to call when animation loops */
  13222. onAnimationLoop?: (() => void) | null | undefined;
  13223. private _localDelayOffset;
  13224. private _pausedDelay;
  13225. private _runtimeAnimations;
  13226. private _paused;
  13227. private _scene;
  13228. private _speedRatio;
  13229. private _weight;
  13230. private _syncRoot;
  13231. /**
  13232. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13233. * This will only apply for non looping animation (default is true)
  13234. */
  13235. disposeOnEnd: boolean;
  13236. /**
  13237. * Gets a boolean indicating if the animation has started
  13238. */
  13239. animationStarted: boolean;
  13240. /**
  13241. * Observer raised when the animation ends
  13242. */
  13243. onAnimationEndObservable: Observable<Animatable>;
  13244. /**
  13245. * Observer raised when the animation loops
  13246. */
  13247. onAnimationLoopObservable: Observable<Animatable>;
  13248. /**
  13249. * Gets the root Animatable used to synchronize and normalize animations
  13250. */
  13251. readonly syncRoot: Nullable<Animatable>;
  13252. /**
  13253. * Gets the current frame of the first RuntimeAnimation
  13254. * Used to synchronize Animatables
  13255. */
  13256. readonly masterFrame: number;
  13257. /**
  13258. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13259. */
  13260. weight: number;
  13261. /**
  13262. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13263. */
  13264. speedRatio: number;
  13265. /**
  13266. * Creates a new Animatable
  13267. * @param scene defines the hosting scene
  13268. * @param target defines the target object
  13269. * @param fromFrame defines the starting frame number (default is 0)
  13270. * @param toFrame defines the ending frame number (default is 100)
  13271. * @param loopAnimation defines if the animation must loop (default is false)
  13272. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13273. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13274. * @param animations defines a group of animation to add to the new Animatable
  13275. * @param onAnimationLoop defines a callback to call when animation loops
  13276. */
  13277. constructor(scene: Scene,
  13278. /** defines the target object */
  13279. target: any,
  13280. /** defines the starting frame number (default is 0) */
  13281. fromFrame?: number,
  13282. /** defines the ending frame number (default is 100) */
  13283. toFrame?: number,
  13284. /** defines if the animation must loop (default is false) */
  13285. loopAnimation?: boolean, speedRatio?: number,
  13286. /** defines a callback to call when animation ends if it is not looping */
  13287. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13288. /** defines a callback to call when animation loops */
  13289. onAnimationLoop?: (() => void) | null | undefined);
  13290. /**
  13291. * Synchronize and normalize current Animatable with a source Animatable
  13292. * This is useful when using animation weights and when animations are not of the same length
  13293. * @param root defines the root Animatable to synchronize with
  13294. * @returns the current Animatable
  13295. */
  13296. syncWith(root: Animatable): Animatable;
  13297. /**
  13298. * Gets the list of runtime animations
  13299. * @returns an array of RuntimeAnimation
  13300. */
  13301. getAnimations(): RuntimeAnimation[];
  13302. /**
  13303. * Adds more animations to the current animatable
  13304. * @param target defines the target of the animations
  13305. * @param animations defines the new animations to add
  13306. */
  13307. appendAnimations(target: any, animations: Animation[]): void;
  13308. /**
  13309. * Gets the source animation for a specific property
  13310. * @param property defines the propertyu to look for
  13311. * @returns null or the source animation for the given property
  13312. */
  13313. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13314. /**
  13315. * Gets the runtime animation for a specific property
  13316. * @param property defines the propertyu to look for
  13317. * @returns null or the runtime animation for the given property
  13318. */
  13319. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13320. /**
  13321. * Resets the animatable to its original state
  13322. */
  13323. reset(): void;
  13324. /**
  13325. * Allows the animatable to blend with current running animations
  13326. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13327. * @param blendingSpeed defines the blending speed to use
  13328. */
  13329. enableBlending(blendingSpeed: number): void;
  13330. /**
  13331. * Disable animation blending
  13332. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13333. */
  13334. disableBlending(): void;
  13335. /**
  13336. * Jump directly to a given frame
  13337. * @param frame defines the frame to jump to
  13338. */
  13339. goToFrame(frame: number): void;
  13340. /**
  13341. * Pause the animation
  13342. */
  13343. pause(): void;
  13344. /**
  13345. * Restart the animation
  13346. */
  13347. restart(): void;
  13348. private _raiseOnAnimationEnd;
  13349. /**
  13350. * Stop and delete the current animation
  13351. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13352. * @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)
  13353. */
  13354. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13355. /**
  13356. * Wait asynchronously for the animation to end
  13357. * @returns a promise which will be fullfilled when the animation ends
  13358. */
  13359. waitAsync(): Promise<Animatable>;
  13360. /** @hidden */
  13361. _animate(delay: number): boolean;
  13362. }
  13363. module "babylonjs/scene" {
  13364. interface Scene {
  13365. /** @hidden */
  13366. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13367. /** @hidden */
  13368. _processLateAnimationBindingsForMatrices(holder: {
  13369. totalWeight: number;
  13370. animations: RuntimeAnimation[];
  13371. originalValue: Matrix;
  13372. }): any;
  13373. /** @hidden */
  13374. _processLateAnimationBindingsForQuaternions(holder: {
  13375. totalWeight: number;
  13376. animations: RuntimeAnimation[];
  13377. originalValue: Quaternion;
  13378. }, refQuaternion: Quaternion): Quaternion;
  13379. /** @hidden */
  13380. _processLateAnimationBindings(): void;
  13381. /**
  13382. * Will start the animation sequence of a given target
  13383. * @param target defines the target
  13384. * @param from defines from which frame should animation start
  13385. * @param to defines until which frame should animation run.
  13386. * @param weight defines the weight to apply to the animation (1.0 by default)
  13387. * @param loop defines if the animation loops
  13388. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13389. * @param onAnimationEnd defines the function to be executed when the animation ends
  13390. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13391. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13392. * @param onAnimationLoop defines the callback to call when an animation loops
  13393. * @returns the animatable object created for this animation
  13394. */
  13395. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13396. /**
  13397. * Will start the animation sequence of a given target
  13398. * @param target defines the target
  13399. * @param from defines from which frame should animation start
  13400. * @param to defines until which frame should animation run.
  13401. * @param loop defines if the animation loops
  13402. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13403. * @param onAnimationEnd defines the function to be executed when the animation ends
  13404. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13405. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13406. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13407. * @param onAnimationLoop defines the callback to call when an animation loops
  13408. * @returns the animatable object created for this animation
  13409. */
  13410. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13411. /**
  13412. * Will start the animation sequence of a given target and its hierarchy
  13413. * @param target defines the target
  13414. * @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.
  13415. * @param from defines from which frame should animation start
  13416. * @param to defines until which frame should animation run.
  13417. * @param loop defines if the animation loops
  13418. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13419. * @param onAnimationEnd defines the function to be executed when the animation ends
  13420. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13421. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13422. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13423. * @param onAnimationLoop defines the callback to call when an animation loops
  13424. * @returns the list of created animatables
  13425. */
  13426. 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[];
  13427. /**
  13428. * Begin a new animation on a given node
  13429. * @param target defines the target where the animation will take place
  13430. * @param animations defines the list of animations to start
  13431. * @param from defines the initial value
  13432. * @param to defines the final value
  13433. * @param loop defines if you want animation to loop (off by default)
  13434. * @param speedRatio defines the speed ratio to apply to all animations
  13435. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13436. * @param onAnimationLoop defines the callback to call when an animation loops
  13437. * @returns the list of created animatables
  13438. */
  13439. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13440. /**
  13441. * Begin a new animation on a given node and its hierarchy
  13442. * @param target defines the root node where the animation will take place
  13443. * @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.
  13444. * @param animations defines the list of animations to start
  13445. * @param from defines the initial value
  13446. * @param to defines the final value
  13447. * @param loop defines if you want animation to loop (off by default)
  13448. * @param speedRatio defines the speed ratio to apply to all animations
  13449. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13450. * @param onAnimationLoop defines the callback to call when an animation loops
  13451. * @returns the list of animatables created for all nodes
  13452. */
  13453. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13454. /**
  13455. * Gets the animatable associated with a specific target
  13456. * @param target defines the target of the animatable
  13457. * @returns the required animatable if found
  13458. */
  13459. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13460. /**
  13461. * Gets all animatables associated with a given target
  13462. * @param target defines the target to look animatables for
  13463. * @returns an array of Animatables
  13464. */
  13465. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13466. /**
  13467. * Stops and removes all animations that have been applied to the scene
  13468. */
  13469. stopAllAnimations(): void;
  13470. /**
  13471. * Gets the current delta time used by animation engine
  13472. */
  13473. deltaTime: number;
  13474. }
  13475. }
  13476. module "babylonjs/Bones/bone" {
  13477. interface Bone {
  13478. /**
  13479. * Copy an animation range from another bone
  13480. * @param source defines the source bone
  13481. * @param rangeName defines the range name to copy
  13482. * @param frameOffset defines the frame offset
  13483. * @param rescaleAsRequired defines if rescaling must be applied if required
  13484. * @param skelDimensionsRatio defines the scaling ratio
  13485. * @returns true if operation was successful
  13486. */
  13487. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13488. }
  13489. }
  13490. }
  13491. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13492. /**
  13493. * Class used to override all child animations of a given target
  13494. */
  13495. export class AnimationPropertiesOverride {
  13496. /**
  13497. * Gets or sets a value indicating if animation blending must be used
  13498. */
  13499. enableBlending: boolean;
  13500. /**
  13501. * Gets or sets the blending speed to use when enableBlending is true
  13502. */
  13503. blendingSpeed: number;
  13504. /**
  13505. * Gets or sets the default loop mode to use
  13506. */
  13507. loopMode: number;
  13508. }
  13509. }
  13510. declare module "babylonjs/Bones/skeleton" {
  13511. import { Bone } from "babylonjs/Bones/bone";
  13512. import { Observable } from "babylonjs/Misc/observable";
  13513. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13514. import { Scene } from "babylonjs/scene";
  13515. import { Nullable } from "babylonjs/types";
  13516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13517. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13518. import { Animatable } from "babylonjs/Animations/animatable";
  13519. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13520. import { Animation } from "babylonjs/Animations/animation";
  13521. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13522. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13523. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13524. /**
  13525. * Class used to handle skinning animations
  13526. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13527. */
  13528. export class Skeleton implements IAnimatable {
  13529. /** defines the skeleton name */
  13530. name: string;
  13531. /** defines the skeleton Id */
  13532. id: string;
  13533. /**
  13534. * Defines the list of child bones
  13535. */
  13536. bones: Bone[];
  13537. /**
  13538. * Defines an estimate of the dimension of the skeleton at rest
  13539. */
  13540. dimensionsAtRest: Vector3;
  13541. /**
  13542. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13543. */
  13544. needInitialSkinMatrix: boolean;
  13545. /**
  13546. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13547. */
  13548. overrideMesh: Nullable<AbstractMesh>;
  13549. /**
  13550. * Gets the list of animations attached to this skeleton
  13551. */
  13552. animations: Array<Animation>;
  13553. private _scene;
  13554. private _isDirty;
  13555. private _transformMatrices;
  13556. private _transformMatrixTexture;
  13557. private _meshesWithPoseMatrix;
  13558. private _animatables;
  13559. private _identity;
  13560. private _synchronizedWithMesh;
  13561. private _ranges;
  13562. private _lastAbsoluteTransformsUpdateId;
  13563. private _canUseTextureForBones;
  13564. private _uniqueId;
  13565. /** @hidden */
  13566. _numBonesWithLinkedTransformNode: number;
  13567. /** @hidden */
  13568. _hasWaitingData: Nullable<boolean>;
  13569. /**
  13570. * Specifies if the skeleton should be serialized
  13571. */
  13572. doNotSerialize: boolean;
  13573. private _useTextureToStoreBoneMatrices;
  13574. /**
  13575. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13576. * Please note that this option is not available if the hardware does not support it
  13577. */
  13578. useTextureToStoreBoneMatrices: boolean;
  13579. private _animationPropertiesOverride;
  13580. /**
  13581. * Gets or sets the animation properties override
  13582. */
  13583. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13584. /**
  13585. * List of inspectable custom properties (used by the Inspector)
  13586. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13587. */
  13588. inspectableCustomProperties: IInspectable[];
  13589. /**
  13590. * An observable triggered before computing the skeleton's matrices
  13591. */
  13592. onBeforeComputeObservable: Observable<Skeleton>;
  13593. /**
  13594. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13595. */
  13596. readonly isUsingTextureForMatrices: boolean;
  13597. /**
  13598. * Gets the unique ID of this skeleton
  13599. */
  13600. readonly uniqueId: number;
  13601. /**
  13602. * Creates a new skeleton
  13603. * @param name defines the skeleton name
  13604. * @param id defines the skeleton Id
  13605. * @param scene defines the hosting scene
  13606. */
  13607. constructor(
  13608. /** defines the skeleton name */
  13609. name: string,
  13610. /** defines the skeleton Id */
  13611. id: string, scene: Scene);
  13612. /**
  13613. * Gets the current object class name.
  13614. * @return the class name
  13615. */
  13616. getClassName(): string;
  13617. /**
  13618. * Returns an array containing the root bones
  13619. * @returns an array containing the root bones
  13620. */
  13621. getChildren(): Array<Bone>;
  13622. /**
  13623. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13624. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13625. * @returns a Float32Array containing matrices data
  13626. */
  13627. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13628. /**
  13629. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13630. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13631. * @returns a raw texture containing the data
  13632. */
  13633. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13634. /**
  13635. * Gets the current hosting scene
  13636. * @returns a scene object
  13637. */
  13638. getScene(): Scene;
  13639. /**
  13640. * Gets a string representing the current skeleton data
  13641. * @param fullDetails defines a boolean indicating if we want a verbose version
  13642. * @returns a string representing the current skeleton data
  13643. */
  13644. toString(fullDetails?: boolean): string;
  13645. /**
  13646. * Get bone's index searching by name
  13647. * @param name defines bone's name to search for
  13648. * @return the indice of the bone. Returns -1 if not found
  13649. */
  13650. getBoneIndexByName(name: string): number;
  13651. /**
  13652. * Creater a new animation range
  13653. * @param name defines the name of the range
  13654. * @param from defines the start key
  13655. * @param to defines the end key
  13656. */
  13657. createAnimationRange(name: string, from: number, to: number): void;
  13658. /**
  13659. * Delete a specific animation range
  13660. * @param name defines the name of the range
  13661. * @param deleteFrames defines if frames must be removed as well
  13662. */
  13663. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13664. /**
  13665. * Gets a specific animation range
  13666. * @param name defines the name of the range to look for
  13667. * @returns the requested animation range or null if not found
  13668. */
  13669. getAnimationRange(name: string): Nullable<AnimationRange>;
  13670. /**
  13671. * Gets the list of all animation ranges defined on this skeleton
  13672. * @returns an array
  13673. */
  13674. getAnimationRanges(): Nullable<AnimationRange>[];
  13675. /**
  13676. * Copy animation range from a source skeleton.
  13677. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13678. * @param source defines the source skeleton
  13679. * @param name defines the name of the range to copy
  13680. * @param rescaleAsRequired defines if rescaling must be applied if required
  13681. * @returns true if operation was successful
  13682. */
  13683. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13684. /**
  13685. * Forces the skeleton to go to rest pose
  13686. */
  13687. returnToRest(): void;
  13688. private _getHighestAnimationFrame;
  13689. /**
  13690. * Begin a specific animation range
  13691. * @param name defines the name of the range to start
  13692. * @param loop defines if looping must be turned on (false by default)
  13693. * @param speedRatio defines the speed ratio to apply (1 by default)
  13694. * @param onAnimationEnd defines a callback which will be called when animation will end
  13695. * @returns a new animatable
  13696. */
  13697. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13698. /** @hidden */
  13699. _markAsDirty(): void;
  13700. /** @hidden */
  13701. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13702. /** @hidden */
  13703. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13704. private _computeTransformMatrices;
  13705. /**
  13706. * Build all resources required to render a skeleton
  13707. */
  13708. prepare(): void;
  13709. /**
  13710. * Gets the list of animatables currently running for this skeleton
  13711. * @returns an array of animatables
  13712. */
  13713. getAnimatables(): IAnimatable[];
  13714. /**
  13715. * Clone the current skeleton
  13716. * @param name defines the name of the new skeleton
  13717. * @param id defines the id of the new skeleton
  13718. * @returns the new skeleton
  13719. */
  13720. clone(name: string, id: string): Skeleton;
  13721. /**
  13722. * Enable animation blending for this skeleton
  13723. * @param blendingSpeed defines the blending speed to apply
  13724. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13725. */
  13726. enableBlending(blendingSpeed?: number): void;
  13727. /**
  13728. * Releases all resources associated with the current skeleton
  13729. */
  13730. dispose(): void;
  13731. /**
  13732. * Serialize the skeleton in a JSON object
  13733. * @returns a JSON object
  13734. */
  13735. serialize(): any;
  13736. /**
  13737. * Creates a new skeleton from serialized data
  13738. * @param parsedSkeleton defines the serialized data
  13739. * @param scene defines the hosting scene
  13740. * @returns a new skeleton
  13741. */
  13742. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13743. /**
  13744. * Compute all node absolute transforms
  13745. * @param forceUpdate defines if computation must be done even if cache is up to date
  13746. */
  13747. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13748. /**
  13749. * Gets the root pose matrix
  13750. * @returns a matrix
  13751. */
  13752. getPoseMatrix(): Nullable<Matrix>;
  13753. /**
  13754. * Sorts bones per internal index
  13755. */
  13756. sortBones(): void;
  13757. private _sortBones;
  13758. }
  13759. }
  13760. declare module "babylonjs/Bones/bone" {
  13761. import { Skeleton } from "babylonjs/Bones/skeleton";
  13762. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13763. import { Nullable } from "babylonjs/types";
  13764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13765. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13766. import { Node } from "babylonjs/node";
  13767. import { Space } from "babylonjs/Maths/math.axis";
  13768. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13769. /**
  13770. * Class used to store bone information
  13771. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13772. */
  13773. export class Bone extends Node {
  13774. /**
  13775. * defines the bone name
  13776. */
  13777. name: string;
  13778. private static _tmpVecs;
  13779. private static _tmpQuat;
  13780. private static _tmpMats;
  13781. /**
  13782. * Gets the list of child bones
  13783. */
  13784. children: Bone[];
  13785. /** Gets the animations associated with this bone */
  13786. animations: import("babylonjs/Animations/animation").Animation[];
  13787. /**
  13788. * Gets or sets bone length
  13789. */
  13790. length: number;
  13791. /**
  13792. * @hidden Internal only
  13793. * Set this value to map this bone to a different index in the transform matrices
  13794. * Set this value to -1 to exclude the bone from the transform matrices
  13795. */
  13796. _index: Nullable<number>;
  13797. private _skeleton;
  13798. private _localMatrix;
  13799. private _restPose;
  13800. private _baseMatrix;
  13801. private _absoluteTransform;
  13802. private _invertedAbsoluteTransform;
  13803. private _parent;
  13804. private _scalingDeterminant;
  13805. private _worldTransform;
  13806. private _localScaling;
  13807. private _localRotation;
  13808. private _localPosition;
  13809. private _needToDecompose;
  13810. private _needToCompose;
  13811. /** @hidden */
  13812. _linkedTransformNode: Nullable<TransformNode>;
  13813. /** @hidden */
  13814. _waitingTransformNodeId: Nullable<string>;
  13815. /** @hidden */
  13816. /** @hidden */
  13817. _matrix: Matrix;
  13818. /**
  13819. * Create a new bone
  13820. * @param name defines the bone name
  13821. * @param skeleton defines the parent skeleton
  13822. * @param parentBone defines the parent (can be null if the bone is the root)
  13823. * @param localMatrix defines the local matrix
  13824. * @param restPose defines the rest pose matrix
  13825. * @param baseMatrix defines the base matrix
  13826. * @param index defines index of the bone in the hiearchy
  13827. */
  13828. constructor(
  13829. /**
  13830. * defines the bone name
  13831. */
  13832. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13833. /**
  13834. * Gets the current object class name.
  13835. * @return the class name
  13836. */
  13837. getClassName(): string;
  13838. /**
  13839. * Gets the parent skeleton
  13840. * @returns a skeleton
  13841. */
  13842. getSkeleton(): Skeleton;
  13843. /**
  13844. * Gets parent bone
  13845. * @returns a bone or null if the bone is the root of the bone hierarchy
  13846. */
  13847. getParent(): Nullable<Bone>;
  13848. /**
  13849. * Returns an array containing the root bones
  13850. * @returns an array containing the root bones
  13851. */
  13852. getChildren(): Array<Bone>;
  13853. /**
  13854. * Sets the parent bone
  13855. * @param parent defines the parent (can be null if the bone is the root)
  13856. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13857. */
  13858. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13859. /**
  13860. * Gets the local matrix
  13861. * @returns a matrix
  13862. */
  13863. getLocalMatrix(): Matrix;
  13864. /**
  13865. * Gets the base matrix (initial matrix which remains unchanged)
  13866. * @returns a matrix
  13867. */
  13868. getBaseMatrix(): Matrix;
  13869. /**
  13870. * Gets the rest pose matrix
  13871. * @returns a matrix
  13872. */
  13873. getRestPose(): Matrix;
  13874. /**
  13875. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13876. */
  13877. getWorldMatrix(): Matrix;
  13878. /**
  13879. * Sets the local matrix to rest pose matrix
  13880. */
  13881. returnToRest(): void;
  13882. /**
  13883. * Gets the inverse of the absolute transform matrix.
  13884. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13885. * @returns a matrix
  13886. */
  13887. getInvertedAbsoluteTransform(): Matrix;
  13888. /**
  13889. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13890. * @returns a matrix
  13891. */
  13892. getAbsoluteTransform(): Matrix;
  13893. /**
  13894. * Links with the given transform node.
  13895. * The local matrix of this bone is copied from the transform node every frame.
  13896. * @param transformNode defines the transform node to link to
  13897. */
  13898. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13899. /**
  13900. * Gets the node used to drive the bone's transformation
  13901. * @returns a transform node or null
  13902. */
  13903. getTransformNode(): Nullable<TransformNode>;
  13904. /** Gets or sets current position (in local space) */
  13905. position: Vector3;
  13906. /** Gets or sets current rotation (in local space) */
  13907. rotation: Vector3;
  13908. /** Gets or sets current rotation quaternion (in local space) */
  13909. rotationQuaternion: Quaternion;
  13910. /** Gets or sets current scaling (in local space) */
  13911. scaling: Vector3;
  13912. /**
  13913. * Gets the animation properties override
  13914. */
  13915. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13916. private _decompose;
  13917. private _compose;
  13918. /**
  13919. * Update the base and local matrices
  13920. * @param matrix defines the new base or local matrix
  13921. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13922. * @param updateLocalMatrix defines if the local matrix should be updated
  13923. */
  13924. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13925. /** @hidden */
  13926. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13927. /**
  13928. * Flag the bone as dirty (Forcing it to update everything)
  13929. */
  13930. markAsDirty(): void;
  13931. /** @hidden */
  13932. _markAsDirtyAndCompose(): void;
  13933. private _markAsDirtyAndDecompose;
  13934. /**
  13935. * Translate the bone in local or world space
  13936. * @param vec The amount to translate the bone
  13937. * @param space The space that the translation is in
  13938. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13939. */
  13940. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13941. /**
  13942. * Set the postion of the bone in local or world space
  13943. * @param position The position to set the bone
  13944. * @param space The space that the position is in
  13945. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13946. */
  13947. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13948. /**
  13949. * Set the absolute position of the bone (world space)
  13950. * @param position The position to set the bone
  13951. * @param mesh The mesh that this bone is attached to
  13952. */
  13953. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13954. /**
  13955. * Scale the bone on the x, y and z axes (in local space)
  13956. * @param x The amount to scale the bone on the x axis
  13957. * @param y The amount to scale the bone on the y axis
  13958. * @param z The amount to scale the bone on the z axis
  13959. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13960. */
  13961. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13962. /**
  13963. * Set the bone scaling in local space
  13964. * @param scale defines the scaling vector
  13965. */
  13966. setScale(scale: Vector3): void;
  13967. /**
  13968. * Gets the current scaling in local space
  13969. * @returns the current scaling vector
  13970. */
  13971. getScale(): Vector3;
  13972. /**
  13973. * Gets the current scaling in local space and stores it in a target vector
  13974. * @param result defines the target vector
  13975. */
  13976. getScaleToRef(result: Vector3): void;
  13977. /**
  13978. * Set the yaw, pitch, and roll of the bone in local or world space
  13979. * @param yaw The rotation of the bone on the y axis
  13980. * @param pitch The rotation of the bone on the x axis
  13981. * @param roll The rotation of the bone on the z axis
  13982. * @param space The space that the axes of rotation are in
  13983. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13984. */
  13985. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13986. /**
  13987. * Add a rotation to the bone on an axis in local or world space
  13988. * @param axis The axis to rotate the bone on
  13989. * @param amount The amount to rotate the bone
  13990. * @param space The space that the axis is in
  13991. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13992. */
  13993. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13994. /**
  13995. * Set the rotation of the bone to a particular axis angle in local or world space
  13996. * @param axis The axis to rotate the bone on
  13997. * @param angle The angle that the bone should be rotated to
  13998. * @param space The space that the axis is in
  13999. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14000. */
  14001. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14002. /**
  14003. * Set the euler rotation of the bone in local of world space
  14004. * @param rotation The euler rotation that the bone should be set to
  14005. * @param space The space that the rotation is in
  14006. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14007. */
  14008. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14009. /**
  14010. * Set the quaternion rotation of the bone in local of world space
  14011. * @param quat The quaternion rotation that the bone should be set to
  14012. * @param space The space that the rotation is in
  14013. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14014. */
  14015. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14016. /**
  14017. * Set the rotation matrix of the bone in local of world space
  14018. * @param rotMat The rotation matrix that the bone should be set to
  14019. * @param space The space that the rotation is in
  14020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14021. */
  14022. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14023. private _rotateWithMatrix;
  14024. private _getNegativeRotationToRef;
  14025. /**
  14026. * Get the position of the bone in local or world space
  14027. * @param space The space that the returned position is in
  14028. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14029. * @returns The position of the bone
  14030. */
  14031. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14032. /**
  14033. * Copy the position of the bone to a vector3 in local or world space
  14034. * @param space The space that the returned position is in
  14035. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14036. * @param result The vector3 to copy the position to
  14037. */
  14038. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14039. /**
  14040. * Get the absolute position of the bone (world space)
  14041. * @param mesh The mesh that this bone is attached to
  14042. * @returns The absolute position of the bone
  14043. */
  14044. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14045. /**
  14046. * Copy the absolute position of the bone (world space) to the result param
  14047. * @param mesh The mesh that this bone is attached to
  14048. * @param result The vector3 to copy the absolute position to
  14049. */
  14050. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14051. /**
  14052. * Compute the absolute transforms of this bone and its children
  14053. */
  14054. computeAbsoluteTransforms(): void;
  14055. /**
  14056. * Get the world direction from an axis that is in the local space of the bone
  14057. * @param localAxis The local direction that is used to compute the world direction
  14058. * @param mesh The mesh that this bone is attached to
  14059. * @returns The world direction
  14060. */
  14061. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14062. /**
  14063. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14064. * @param localAxis The local direction that is used to compute the world direction
  14065. * @param mesh The mesh that this bone is attached to
  14066. * @param result The vector3 that the world direction will be copied to
  14067. */
  14068. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14069. /**
  14070. * Get the euler rotation of the bone in local or world space
  14071. * @param space The space that the rotation should be in
  14072. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14073. * @returns The euler rotation
  14074. */
  14075. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14076. /**
  14077. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14078. * @param space The space that the rotation should be in
  14079. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14080. * @param result The vector3 that the rotation should be copied to
  14081. */
  14082. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14083. /**
  14084. * Get the quaternion rotation of the bone in either local or world space
  14085. * @param space The space that the rotation should be in
  14086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14087. * @returns The quaternion rotation
  14088. */
  14089. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14090. /**
  14091. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14092. * @param space The space that the rotation should be in
  14093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14094. * @param result The quaternion that the rotation should be copied to
  14095. */
  14096. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14097. /**
  14098. * Get the rotation matrix of the bone in local or world space
  14099. * @param space The space that the rotation should be in
  14100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14101. * @returns The rotation matrix
  14102. */
  14103. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14104. /**
  14105. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14106. * @param space The space that the rotation should be in
  14107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14108. * @param result The quaternion that the rotation should be copied to
  14109. */
  14110. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14111. /**
  14112. * Get the world position of a point that is in the local space of the bone
  14113. * @param position The local position
  14114. * @param mesh The mesh that this bone is attached to
  14115. * @returns The world position
  14116. */
  14117. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14118. /**
  14119. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14120. * @param position The local position
  14121. * @param mesh The mesh that this bone is attached to
  14122. * @param result The vector3 that the world position should be copied to
  14123. */
  14124. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14125. /**
  14126. * Get the local position of a point that is in world space
  14127. * @param position The world position
  14128. * @param mesh The mesh that this bone is attached to
  14129. * @returns The local position
  14130. */
  14131. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14132. /**
  14133. * Get the local position of a point that is in world space and copy it to the result param
  14134. * @param position The world position
  14135. * @param mesh The mesh that this bone is attached to
  14136. * @param result The vector3 that the local position should be copied to
  14137. */
  14138. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14139. }
  14140. }
  14141. declare module "babylonjs/Meshes/transformNode" {
  14142. import { DeepImmutable } from "babylonjs/types";
  14143. import { Observable } from "babylonjs/Misc/observable";
  14144. import { Nullable } from "babylonjs/types";
  14145. import { Camera } from "babylonjs/Cameras/camera";
  14146. import { Scene } from "babylonjs/scene";
  14147. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14148. import { Node } from "babylonjs/node";
  14149. import { Bone } from "babylonjs/Bones/bone";
  14150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14151. import { Space } from "babylonjs/Maths/math.axis";
  14152. /**
  14153. * 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.
  14154. * @see https://doc.babylonjs.com/how_to/transformnode
  14155. */
  14156. export class TransformNode extends Node {
  14157. /**
  14158. * Object will not rotate to face the camera
  14159. */
  14160. static BILLBOARDMODE_NONE: number;
  14161. /**
  14162. * Object will rotate to face the camera but only on the x axis
  14163. */
  14164. static BILLBOARDMODE_X: number;
  14165. /**
  14166. * Object will rotate to face the camera but only on the y axis
  14167. */
  14168. static BILLBOARDMODE_Y: number;
  14169. /**
  14170. * Object will rotate to face the camera but only on the z axis
  14171. */
  14172. static BILLBOARDMODE_Z: number;
  14173. /**
  14174. * Object will rotate to face the camera
  14175. */
  14176. static BILLBOARDMODE_ALL: number;
  14177. /**
  14178. * Object will rotate to face the camera's position instead of orientation
  14179. */
  14180. static BILLBOARDMODE_USE_POSITION: number;
  14181. private _forward;
  14182. private _forwardInverted;
  14183. private _up;
  14184. private _right;
  14185. private _rightInverted;
  14186. private _position;
  14187. private _rotation;
  14188. private _rotationQuaternion;
  14189. protected _scaling: Vector3;
  14190. protected _isDirty: boolean;
  14191. private _transformToBoneReferal;
  14192. private _isAbsoluteSynced;
  14193. private _billboardMode;
  14194. /**
  14195. * Gets or sets the billboard mode. Default is 0.
  14196. *
  14197. * | Value | Type | Description |
  14198. * | --- | --- | --- |
  14199. * | 0 | BILLBOARDMODE_NONE | |
  14200. * | 1 | BILLBOARDMODE_X | |
  14201. * | 2 | BILLBOARDMODE_Y | |
  14202. * | 4 | BILLBOARDMODE_Z | |
  14203. * | 7 | BILLBOARDMODE_ALL | |
  14204. *
  14205. */
  14206. billboardMode: number;
  14207. private _preserveParentRotationForBillboard;
  14208. /**
  14209. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14210. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14211. */
  14212. preserveParentRotationForBillboard: boolean;
  14213. /**
  14214. * 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
  14215. */
  14216. scalingDeterminant: number;
  14217. private _infiniteDistance;
  14218. /**
  14219. * Gets or sets the distance of the object to max, often used by skybox
  14220. */
  14221. infiniteDistance: boolean;
  14222. /**
  14223. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14224. * By default the system will update normals to compensate
  14225. */
  14226. ignoreNonUniformScaling: boolean;
  14227. /**
  14228. * 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
  14229. */
  14230. reIntegrateRotationIntoRotationQuaternion: boolean;
  14231. /** @hidden */
  14232. _poseMatrix: Nullable<Matrix>;
  14233. /** @hidden */
  14234. _localMatrix: Matrix;
  14235. private _usePivotMatrix;
  14236. private _absolutePosition;
  14237. private _absoluteScaling;
  14238. private _absoluteRotationQuaternion;
  14239. private _pivotMatrix;
  14240. private _pivotMatrixInverse;
  14241. protected _postMultiplyPivotMatrix: boolean;
  14242. protected _isWorldMatrixFrozen: boolean;
  14243. /** @hidden */
  14244. _indexInSceneTransformNodesArray: number;
  14245. /**
  14246. * An event triggered after the world matrix is updated
  14247. */
  14248. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14249. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14250. /**
  14251. * Gets a string identifying the name of the class
  14252. * @returns "TransformNode" string
  14253. */
  14254. getClassName(): string;
  14255. /**
  14256. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14257. */
  14258. position: Vector3;
  14259. /**
  14260. * 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)).
  14261. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14262. */
  14263. rotation: Vector3;
  14264. /**
  14265. * 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)).
  14266. */
  14267. scaling: Vector3;
  14268. /**
  14269. * 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).
  14270. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14271. */
  14272. rotationQuaternion: Nullable<Quaternion>;
  14273. /**
  14274. * The forward direction of that transform in world space.
  14275. */
  14276. readonly forward: Vector3;
  14277. /**
  14278. * The up direction of that transform in world space.
  14279. */
  14280. readonly up: Vector3;
  14281. /**
  14282. * The right direction of that transform in world space.
  14283. */
  14284. readonly right: Vector3;
  14285. /**
  14286. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14287. * @param matrix the matrix to copy the pose from
  14288. * @returns this TransformNode.
  14289. */
  14290. updatePoseMatrix(matrix: Matrix): TransformNode;
  14291. /**
  14292. * Returns the mesh Pose matrix.
  14293. * @returns the pose matrix
  14294. */
  14295. getPoseMatrix(): Matrix;
  14296. /** @hidden */
  14297. _isSynchronized(): boolean;
  14298. /** @hidden */
  14299. _initCache(): void;
  14300. /**
  14301. * Flag the transform node as dirty (Forcing it to update everything)
  14302. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14303. * @returns this transform node
  14304. */
  14305. markAsDirty(property: string): TransformNode;
  14306. /**
  14307. * Returns the current mesh absolute position.
  14308. * Returns a Vector3.
  14309. */
  14310. readonly absolutePosition: Vector3;
  14311. /**
  14312. * Returns the current mesh absolute scaling.
  14313. * Returns a Vector3.
  14314. */
  14315. readonly absoluteScaling: Vector3;
  14316. /**
  14317. * Returns the current mesh absolute rotation.
  14318. * Returns a Quaternion.
  14319. */
  14320. readonly absoluteRotationQuaternion: Quaternion;
  14321. /**
  14322. * Sets a new matrix to apply before all other transformation
  14323. * @param matrix defines the transform matrix
  14324. * @returns the current TransformNode
  14325. */
  14326. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14327. /**
  14328. * Sets a new pivot matrix to the current node
  14329. * @param matrix defines the new pivot matrix to use
  14330. * @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
  14331. * @returns the current TransformNode
  14332. */
  14333. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14334. /**
  14335. * Returns the mesh pivot matrix.
  14336. * Default : Identity.
  14337. * @returns the matrix
  14338. */
  14339. getPivotMatrix(): Matrix;
  14340. /**
  14341. * Instantiate (when possible) or clone that node with its hierarchy
  14342. * @param newParent defines the new parent to use for the instance (or clone)
  14343. * @returns an instance (or a clone) of the current node with its hiearchy
  14344. */
  14345. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14346. /**
  14347. * Prevents the World matrix to be computed any longer
  14348. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14349. * @returns the TransformNode.
  14350. */
  14351. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14352. /**
  14353. * Allows back the World matrix computation.
  14354. * @returns the TransformNode.
  14355. */
  14356. unfreezeWorldMatrix(): this;
  14357. /**
  14358. * True if the World matrix has been frozen.
  14359. */
  14360. readonly isWorldMatrixFrozen: boolean;
  14361. /**
  14362. * Retuns the mesh absolute position in the World.
  14363. * @returns a Vector3.
  14364. */
  14365. getAbsolutePosition(): Vector3;
  14366. /**
  14367. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14368. * @param absolutePosition the absolute position to set
  14369. * @returns the TransformNode.
  14370. */
  14371. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14372. /**
  14373. * Sets the mesh position in its local space.
  14374. * @param vector3 the position to set in localspace
  14375. * @returns the TransformNode.
  14376. */
  14377. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14378. /**
  14379. * Returns the mesh position in the local space from the current World matrix values.
  14380. * @returns a new Vector3.
  14381. */
  14382. getPositionExpressedInLocalSpace(): Vector3;
  14383. /**
  14384. * Translates the mesh along the passed Vector3 in its local space.
  14385. * @param vector3 the distance to translate in localspace
  14386. * @returns the TransformNode.
  14387. */
  14388. locallyTranslate(vector3: Vector3): TransformNode;
  14389. private static _lookAtVectorCache;
  14390. /**
  14391. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14392. * @param targetPoint the position (must be in same space as current mesh) to look at
  14393. * @param yawCor optional yaw (y-axis) correction in radians
  14394. * @param pitchCor optional pitch (x-axis) correction in radians
  14395. * @param rollCor optional roll (z-axis) correction in radians
  14396. * @param space the choosen space of the target
  14397. * @returns the TransformNode.
  14398. */
  14399. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14400. /**
  14401. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14402. * This Vector3 is expressed in the World space.
  14403. * @param localAxis axis to rotate
  14404. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14405. */
  14406. getDirection(localAxis: Vector3): Vector3;
  14407. /**
  14408. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14409. * localAxis is expressed in the mesh local space.
  14410. * result is computed in the Wordl space from the mesh World matrix.
  14411. * @param localAxis axis to rotate
  14412. * @param result the resulting transformnode
  14413. * @returns this TransformNode.
  14414. */
  14415. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14416. /**
  14417. * Sets this transform node rotation to the given local axis.
  14418. * @param localAxis the axis in local space
  14419. * @param yawCor optional yaw (y-axis) correction in radians
  14420. * @param pitchCor optional pitch (x-axis) correction in radians
  14421. * @param rollCor optional roll (z-axis) correction in radians
  14422. * @returns this TransformNode
  14423. */
  14424. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14425. /**
  14426. * Sets a new pivot point to the current node
  14427. * @param point defines the new pivot point to use
  14428. * @param space defines if the point is in world or local space (local by default)
  14429. * @returns the current TransformNode
  14430. */
  14431. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14432. /**
  14433. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14434. * @returns the pivot point
  14435. */
  14436. getPivotPoint(): Vector3;
  14437. /**
  14438. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14439. * @param result the vector3 to store the result
  14440. * @returns this TransformNode.
  14441. */
  14442. getPivotPointToRef(result: Vector3): TransformNode;
  14443. /**
  14444. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14445. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14446. */
  14447. getAbsolutePivotPoint(): Vector3;
  14448. /**
  14449. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14450. * @param result vector3 to store the result
  14451. * @returns this TransformNode.
  14452. */
  14453. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14454. /**
  14455. * Defines the passed node as the parent of the current node.
  14456. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14457. * @see https://doc.babylonjs.com/how_to/parenting
  14458. * @param node the node ot set as the parent
  14459. * @returns this TransformNode.
  14460. */
  14461. setParent(node: Nullable<Node>): TransformNode;
  14462. private _nonUniformScaling;
  14463. /**
  14464. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14465. */
  14466. readonly nonUniformScaling: boolean;
  14467. /** @hidden */
  14468. _updateNonUniformScalingState(value: boolean): boolean;
  14469. /**
  14470. * Attach the current TransformNode to another TransformNode associated with a bone
  14471. * @param bone Bone affecting the TransformNode
  14472. * @param affectedTransformNode TransformNode associated with the bone
  14473. * @returns this object
  14474. */
  14475. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14476. /**
  14477. * Detach the transform node if its associated with a bone
  14478. * @returns this object
  14479. */
  14480. detachFromBone(): TransformNode;
  14481. private static _rotationAxisCache;
  14482. /**
  14483. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14484. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14485. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14486. * The passed axis is also normalized.
  14487. * @param axis the axis to rotate around
  14488. * @param amount the amount to rotate in radians
  14489. * @param space Space to rotate in (Default: local)
  14490. * @returns the TransformNode.
  14491. */
  14492. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14493. /**
  14494. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14495. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14496. * The passed axis is also normalized. .
  14497. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14498. * @param point the point to rotate around
  14499. * @param axis the axis to rotate around
  14500. * @param amount the amount to rotate in radians
  14501. * @returns the TransformNode
  14502. */
  14503. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14504. /**
  14505. * Translates the mesh along the axis vector for the passed distance in the given space.
  14506. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14507. * @param axis the axis to translate in
  14508. * @param distance the distance to translate
  14509. * @param space Space to rotate in (Default: local)
  14510. * @returns the TransformNode.
  14511. */
  14512. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14513. /**
  14514. * Adds a rotation step to the mesh current rotation.
  14515. * x, y, z are Euler angles expressed in radians.
  14516. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14517. * This means this rotation is made in the mesh local space only.
  14518. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14519. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14520. * ```javascript
  14521. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14522. * ```
  14523. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14524. * 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.
  14525. * @param x Rotation to add
  14526. * @param y Rotation to add
  14527. * @param z Rotation to add
  14528. * @returns the TransformNode.
  14529. */
  14530. addRotation(x: number, y: number, z: number): TransformNode;
  14531. /**
  14532. * @hidden
  14533. */
  14534. protected _getEffectiveParent(): Nullable<Node>;
  14535. /**
  14536. * Computes the world matrix of the node
  14537. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14538. * @returns the world matrix
  14539. */
  14540. computeWorldMatrix(force?: boolean): Matrix;
  14541. protected _afterComputeWorldMatrix(): void;
  14542. /**
  14543. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14544. * @param func callback function to add
  14545. *
  14546. * @returns the TransformNode.
  14547. */
  14548. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14549. /**
  14550. * Removes a registered callback function.
  14551. * @param func callback function to remove
  14552. * @returns the TransformNode.
  14553. */
  14554. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14555. /**
  14556. * Gets the position of the current mesh in camera space
  14557. * @param camera defines the camera to use
  14558. * @returns a position
  14559. */
  14560. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14561. /**
  14562. * Returns the distance from the mesh to the active camera
  14563. * @param camera defines the camera to use
  14564. * @returns the distance
  14565. */
  14566. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14567. /**
  14568. * Clone the current transform node
  14569. * @param name Name of the new clone
  14570. * @param newParent New parent for the clone
  14571. * @param doNotCloneChildren Do not clone children hierarchy
  14572. * @returns the new transform node
  14573. */
  14574. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14575. /**
  14576. * Serializes the objects information.
  14577. * @param currentSerializationObject defines the object to serialize in
  14578. * @returns the serialized object
  14579. */
  14580. serialize(currentSerializationObject?: any): any;
  14581. /**
  14582. * Returns a new TransformNode object parsed from the source provided.
  14583. * @param parsedTransformNode is the source.
  14584. * @param scene the scne the object belongs to
  14585. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14586. * @returns a new TransformNode object parsed from the source provided.
  14587. */
  14588. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14589. /**
  14590. * Get all child-transformNodes of this node
  14591. * @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
  14592. * @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
  14593. * @returns an array of TransformNode
  14594. */
  14595. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14596. /**
  14597. * Releases resources associated with this transform node.
  14598. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14599. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14600. */
  14601. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14602. /**
  14603. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14604. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14605. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14606. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14607. * @returns the current mesh
  14608. */
  14609. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14610. private _syncAbsoluteScalingAndRotation;
  14611. }
  14612. }
  14613. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14614. import { Observable } from "babylonjs/Misc/observable";
  14615. import { Nullable } from "babylonjs/types";
  14616. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14617. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14619. import { Ray } from "babylonjs/Culling/ray";
  14620. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14621. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14622. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14623. /**
  14624. * Defines the types of pose enabled controllers that are supported
  14625. */
  14626. export enum PoseEnabledControllerType {
  14627. /**
  14628. * HTC Vive
  14629. */
  14630. VIVE = 0,
  14631. /**
  14632. * Oculus Rift
  14633. */
  14634. OCULUS = 1,
  14635. /**
  14636. * Windows mixed reality
  14637. */
  14638. WINDOWS = 2,
  14639. /**
  14640. * Samsung gear VR
  14641. */
  14642. GEAR_VR = 3,
  14643. /**
  14644. * Google Daydream
  14645. */
  14646. DAYDREAM = 4,
  14647. /**
  14648. * Generic
  14649. */
  14650. GENERIC = 5
  14651. }
  14652. /**
  14653. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14654. */
  14655. export interface MutableGamepadButton {
  14656. /**
  14657. * Value of the button/trigger
  14658. */
  14659. value: number;
  14660. /**
  14661. * If the button/trigger is currently touched
  14662. */
  14663. touched: boolean;
  14664. /**
  14665. * If the button/trigger is currently pressed
  14666. */
  14667. pressed: boolean;
  14668. }
  14669. /**
  14670. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14671. * @hidden
  14672. */
  14673. export interface ExtendedGamepadButton extends GamepadButton {
  14674. /**
  14675. * If the button/trigger is currently pressed
  14676. */
  14677. readonly pressed: boolean;
  14678. /**
  14679. * If the button/trigger is currently touched
  14680. */
  14681. readonly touched: boolean;
  14682. /**
  14683. * Value of the button/trigger
  14684. */
  14685. readonly value: number;
  14686. }
  14687. /** @hidden */
  14688. export interface _GamePadFactory {
  14689. /**
  14690. * Returns wether or not the current gamepad can be created for this type of controller.
  14691. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14692. * @returns true if it can be created, otherwise false
  14693. */
  14694. canCreate(gamepadInfo: any): boolean;
  14695. /**
  14696. * Creates a new instance of the Gamepad.
  14697. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14698. * @returns the new gamepad instance
  14699. */
  14700. create(gamepadInfo: any): Gamepad;
  14701. }
  14702. /**
  14703. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14704. */
  14705. export class PoseEnabledControllerHelper {
  14706. /** @hidden */
  14707. static _ControllerFactories: _GamePadFactory[];
  14708. /** @hidden */
  14709. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14710. /**
  14711. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14712. * @param vrGamepad the gamepad to initialized
  14713. * @returns a vr controller of the type the gamepad identified as
  14714. */
  14715. static InitiateController(vrGamepad: any): Gamepad;
  14716. }
  14717. /**
  14718. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14719. */
  14720. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14721. /**
  14722. * If the controller is used in a webXR session
  14723. */
  14724. isXR: boolean;
  14725. private _deviceRoomPosition;
  14726. private _deviceRoomRotationQuaternion;
  14727. /**
  14728. * The device position in babylon space
  14729. */
  14730. devicePosition: Vector3;
  14731. /**
  14732. * The device rotation in babylon space
  14733. */
  14734. deviceRotationQuaternion: Quaternion;
  14735. /**
  14736. * The scale factor of the device in babylon space
  14737. */
  14738. deviceScaleFactor: number;
  14739. /**
  14740. * (Likely devicePosition should be used instead) The device position in its room space
  14741. */
  14742. position: Vector3;
  14743. /**
  14744. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14745. */
  14746. rotationQuaternion: Quaternion;
  14747. /**
  14748. * The type of controller (Eg. Windows mixed reality)
  14749. */
  14750. controllerType: PoseEnabledControllerType;
  14751. protected _calculatedPosition: Vector3;
  14752. private _calculatedRotation;
  14753. /**
  14754. * The raw pose from the device
  14755. */
  14756. rawPose: DevicePose;
  14757. private _trackPosition;
  14758. private _maxRotationDistFromHeadset;
  14759. private _draggedRoomRotation;
  14760. /**
  14761. * @hidden
  14762. */
  14763. _disableTrackPosition(fixedPosition: Vector3): void;
  14764. /**
  14765. * Internal, the mesh attached to the controller
  14766. * @hidden
  14767. */
  14768. _mesh: Nullable<AbstractMesh>;
  14769. private _poseControlledCamera;
  14770. private _leftHandSystemQuaternion;
  14771. /**
  14772. * Internal, matrix used to convert room space to babylon space
  14773. * @hidden
  14774. */
  14775. _deviceToWorld: Matrix;
  14776. /**
  14777. * Node to be used when casting a ray from the controller
  14778. * @hidden
  14779. */
  14780. _pointingPoseNode: Nullable<TransformNode>;
  14781. /**
  14782. * Name of the child mesh that can be used to cast a ray from the controller
  14783. */
  14784. static readonly POINTING_POSE: string;
  14785. /**
  14786. * Creates a new PoseEnabledController from a gamepad
  14787. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14788. */
  14789. constructor(browserGamepad: any);
  14790. private _workingMatrix;
  14791. /**
  14792. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14793. */
  14794. update(): void;
  14795. /**
  14796. * Updates only the pose device and mesh without doing any button event checking
  14797. */
  14798. protected _updatePoseAndMesh(): void;
  14799. /**
  14800. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14801. * @param poseData raw pose fromthe device
  14802. */
  14803. updateFromDevice(poseData: DevicePose): void;
  14804. /**
  14805. * @hidden
  14806. */
  14807. _meshAttachedObservable: Observable<AbstractMesh>;
  14808. /**
  14809. * Attaches a mesh to the controller
  14810. * @param mesh the mesh to be attached
  14811. */
  14812. attachToMesh(mesh: AbstractMesh): void;
  14813. /**
  14814. * Attaches the controllers mesh to a camera
  14815. * @param camera the camera the mesh should be attached to
  14816. */
  14817. attachToPoseControlledCamera(camera: TargetCamera): void;
  14818. /**
  14819. * Disposes of the controller
  14820. */
  14821. dispose(): void;
  14822. /**
  14823. * The mesh that is attached to the controller
  14824. */
  14825. readonly mesh: Nullable<AbstractMesh>;
  14826. /**
  14827. * Gets the ray of the controller in the direction the controller is pointing
  14828. * @param length the length the resulting ray should be
  14829. * @returns a ray in the direction the controller is pointing
  14830. */
  14831. getForwardRay(length?: number): Ray;
  14832. }
  14833. }
  14834. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14835. import { Observable } from "babylonjs/Misc/observable";
  14836. import { Scene } from "babylonjs/scene";
  14837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14838. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14839. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14840. import { Nullable } from "babylonjs/types";
  14841. /**
  14842. * Defines the WebVRController object that represents controllers tracked in 3D space
  14843. */
  14844. export abstract class WebVRController extends PoseEnabledController {
  14845. /**
  14846. * Internal, the default controller model for the controller
  14847. */
  14848. protected _defaultModel: Nullable<AbstractMesh>;
  14849. /**
  14850. * Fired when the trigger state has changed
  14851. */
  14852. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14853. /**
  14854. * Fired when the main button state has changed
  14855. */
  14856. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14857. /**
  14858. * Fired when the secondary button state has changed
  14859. */
  14860. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14861. /**
  14862. * Fired when the pad state has changed
  14863. */
  14864. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14865. /**
  14866. * Fired when controllers stick values have changed
  14867. */
  14868. onPadValuesChangedObservable: Observable<StickValues>;
  14869. /**
  14870. * Array of button availible on the controller
  14871. */
  14872. protected _buttons: Array<MutableGamepadButton>;
  14873. private _onButtonStateChange;
  14874. /**
  14875. * Fired when a controller button's state has changed
  14876. * @param callback the callback containing the button that was modified
  14877. */
  14878. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14879. /**
  14880. * X and Y axis corresponding to the controllers joystick
  14881. */
  14882. pad: StickValues;
  14883. /**
  14884. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14885. */
  14886. hand: string;
  14887. /**
  14888. * The default controller model for the controller
  14889. */
  14890. readonly defaultModel: Nullable<AbstractMesh>;
  14891. /**
  14892. * Creates a new WebVRController from a gamepad
  14893. * @param vrGamepad the gamepad that the WebVRController should be created from
  14894. */
  14895. constructor(vrGamepad: any);
  14896. /**
  14897. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14898. */
  14899. update(): void;
  14900. /**
  14901. * Function to be called when a button is modified
  14902. */
  14903. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14904. /**
  14905. * Loads a mesh and attaches it to the controller
  14906. * @param scene the scene the mesh should be added to
  14907. * @param meshLoaded callback for when the mesh has been loaded
  14908. */
  14909. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14910. private _setButtonValue;
  14911. private _changes;
  14912. private _checkChanges;
  14913. /**
  14914. * Disposes of th webVRCOntroller
  14915. */
  14916. dispose(): void;
  14917. }
  14918. }
  14919. declare module "babylonjs/Lights/hemisphericLight" {
  14920. import { Nullable } from "babylonjs/types";
  14921. import { Scene } from "babylonjs/scene";
  14922. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14923. import { Color3 } from "babylonjs/Maths/math.color";
  14924. import { Effect } from "babylonjs/Materials/effect";
  14925. import { Light } from "babylonjs/Lights/light";
  14926. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14927. /**
  14928. * The HemisphericLight simulates the ambient environment light,
  14929. * so the passed direction is the light reflection direction, not the incoming direction.
  14930. */
  14931. export class HemisphericLight extends Light {
  14932. /**
  14933. * The groundColor is the light in the opposite direction to the one specified during creation.
  14934. * 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.
  14935. */
  14936. groundColor: Color3;
  14937. /**
  14938. * The light reflection direction, not the incoming direction.
  14939. */
  14940. direction: Vector3;
  14941. /**
  14942. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14943. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14944. * The HemisphericLight can't cast shadows.
  14945. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14946. * @param name The friendly name of the light
  14947. * @param direction The direction of the light reflection
  14948. * @param scene The scene the light belongs to
  14949. */
  14950. constructor(name: string, direction: Vector3, scene: Scene);
  14951. protected _buildUniformLayout(): void;
  14952. /**
  14953. * Returns the string "HemisphericLight".
  14954. * @return The class name
  14955. */
  14956. getClassName(): string;
  14957. /**
  14958. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14959. * Returns the updated direction.
  14960. * @param target The target the direction should point to
  14961. * @return The computed direction
  14962. */
  14963. setDirectionToTarget(target: Vector3): Vector3;
  14964. /**
  14965. * Returns the shadow generator associated to the light.
  14966. * @returns Always null for hemispheric lights because it does not support shadows.
  14967. */
  14968. getShadowGenerator(): Nullable<IShadowGenerator>;
  14969. /**
  14970. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14971. * @param effect The effect to update
  14972. * @param lightIndex The index of the light in the effect to update
  14973. * @returns The hemispheric light
  14974. */
  14975. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14976. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14977. /**
  14978. * Computes the world matrix of the node
  14979. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14980. * @param useWasUpdatedFlag defines a reserved property
  14981. * @returns the world matrix
  14982. */
  14983. computeWorldMatrix(): Matrix;
  14984. /**
  14985. * Returns the integer 3.
  14986. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14987. */
  14988. getTypeID(): number;
  14989. /**
  14990. * Prepares the list of defines specific to the light type.
  14991. * @param defines the list of defines
  14992. * @param lightIndex defines the index of the light for the effect
  14993. */
  14994. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14995. }
  14996. }
  14997. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14998. /** @hidden */
  14999. export var vrMultiviewToSingleviewPixelShader: {
  15000. name: string;
  15001. shader: string;
  15002. };
  15003. }
  15004. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15005. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15006. import { Scene } from "babylonjs/scene";
  15007. /**
  15008. * Renders to multiple views with a single draw call
  15009. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15010. */
  15011. export class MultiviewRenderTarget extends RenderTargetTexture {
  15012. /**
  15013. * Creates a multiview render target
  15014. * @param scene scene used with the render target
  15015. * @param size the size of the render target (used for each view)
  15016. */
  15017. constructor(scene: Scene, size?: number | {
  15018. width: number;
  15019. height: number;
  15020. } | {
  15021. ratio: number;
  15022. });
  15023. /**
  15024. * @hidden
  15025. * @param faceIndex the face index, if its a cube texture
  15026. */
  15027. _bindFrameBuffer(faceIndex?: number): void;
  15028. /**
  15029. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15030. * @returns the view count
  15031. */
  15032. getViewCount(): number;
  15033. }
  15034. }
  15035. declare module "babylonjs/Maths/math.frustum" {
  15036. import { Matrix } from "babylonjs/Maths/math.vector";
  15037. import { DeepImmutable } from "babylonjs/types";
  15038. import { Plane } from "babylonjs/Maths/math.plane";
  15039. /**
  15040. * Represents a camera frustum
  15041. */
  15042. export class Frustum {
  15043. /**
  15044. * Gets the planes representing the frustum
  15045. * @param transform matrix to be applied to the returned planes
  15046. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15047. */
  15048. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15049. /**
  15050. * Gets the near frustum plane transformed by the transform matrix
  15051. * @param transform transformation matrix to be applied to the resulting frustum plane
  15052. * @param frustumPlane the resuling frustum plane
  15053. */
  15054. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15055. /**
  15056. * Gets the far frustum plane transformed by the transform matrix
  15057. * @param transform transformation matrix to be applied to the resulting frustum plane
  15058. * @param frustumPlane the resuling frustum plane
  15059. */
  15060. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15061. /**
  15062. * Gets the left frustum plane transformed by the transform matrix
  15063. * @param transform transformation matrix to be applied to the resulting frustum plane
  15064. * @param frustumPlane the resuling frustum plane
  15065. */
  15066. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15067. /**
  15068. * Gets the right frustum plane transformed by the transform matrix
  15069. * @param transform transformation matrix to be applied to the resulting frustum plane
  15070. * @param frustumPlane the resuling frustum plane
  15071. */
  15072. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15073. /**
  15074. * Gets the top frustum plane transformed by the transform matrix
  15075. * @param transform transformation matrix to be applied to the resulting frustum plane
  15076. * @param frustumPlane the resuling frustum plane
  15077. */
  15078. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15079. /**
  15080. * Gets the bottom frustum plane transformed by the transform matrix
  15081. * @param transform transformation matrix to be applied to the resulting frustum plane
  15082. * @param frustumPlane the resuling frustum plane
  15083. */
  15084. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15085. /**
  15086. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15087. * @param transform transformation matrix to be applied to the resulting frustum planes
  15088. * @param frustumPlanes the resuling frustum planes
  15089. */
  15090. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15091. }
  15092. }
  15093. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15094. import { Camera } from "babylonjs/Cameras/camera";
  15095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15096. import { Nullable } from "babylonjs/types";
  15097. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15098. import { Matrix } from "babylonjs/Maths/math.vector";
  15099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15100. module "babylonjs/Engines/engine" {
  15101. interface Engine {
  15102. /**
  15103. * Creates a new multiview render target
  15104. * @param width defines the width of the texture
  15105. * @param height defines the height of the texture
  15106. * @returns the created multiview texture
  15107. */
  15108. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15109. /**
  15110. * Binds a multiview framebuffer to be drawn to
  15111. * @param multiviewTexture texture to bind
  15112. */
  15113. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15114. }
  15115. }
  15116. module "babylonjs/Cameras/camera" {
  15117. interface Camera {
  15118. /**
  15119. * @hidden
  15120. * 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)
  15121. */
  15122. _useMultiviewToSingleView: boolean;
  15123. /**
  15124. * @hidden
  15125. * 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)
  15126. */
  15127. _multiviewTexture: Nullable<RenderTargetTexture>;
  15128. /**
  15129. * @hidden
  15130. * ensures the multiview texture of the camera exists and has the specified width/height
  15131. * @param width height to set on the multiview texture
  15132. * @param height width to set on the multiview texture
  15133. */
  15134. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15135. }
  15136. }
  15137. module "babylonjs/scene" {
  15138. interface Scene {
  15139. /** @hidden */
  15140. _transformMatrixR: Matrix;
  15141. /** @hidden */
  15142. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15143. /** @hidden */
  15144. _createMultiviewUbo(): void;
  15145. /** @hidden */
  15146. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15147. /** @hidden */
  15148. _renderMultiviewToSingleView(camera: Camera): void;
  15149. }
  15150. }
  15151. }
  15152. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15153. import { Camera } from "babylonjs/Cameras/camera";
  15154. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15155. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15156. import "babylonjs/Engines/Extensions/engine.multiview";
  15157. /**
  15158. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15159. * This will not be used for webXR as it supports displaying texture arrays directly
  15160. */
  15161. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15162. /**
  15163. * Initializes a VRMultiviewToSingleview
  15164. * @param name name of the post process
  15165. * @param camera camera to be applied to
  15166. * @param scaleFactor scaling factor to the size of the output texture
  15167. */
  15168. constructor(name: string, camera: Camera, scaleFactor: number);
  15169. }
  15170. }
  15171. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15172. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15173. import { Nullable } from "babylonjs/types";
  15174. import { Size } from "babylonjs/Maths/math.size";
  15175. import { Observable } from "babylonjs/Misc/observable";
  15176. module "babylonjs/Engines/engine" {
  15177. interface Engine {
  15178. /** @hidden */
  15179. _vrDisplay: any;
  15180. /** @hidden */
  15181. _vrSupported: boolean;
  15182. /** @hidden */
  15183. _oldSize: Size;
  15184. /** @hidden */
  15185. _oldHardwareScaleFactor: number;
  15186. /** @hidden */
  15187. _vrExclusivePointerMode: boolean;
  15188. /** @hidden */
  15189. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15190. /** @hidden */
  15191. _onVRDisplayPointerRestricted: () => void;
  15192. /** @hidden */
  15193. _onVRDisplayPointerUnrestricted: () => void;
  15194. /** @hidden */
  15195. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15196. /** @hidden */
  15197. _onVrDisplayDisconnect: Nullable<() => void>;
  15198. /** @hidden */
  15199. _onVrDisplayPresentChange: Nullable<() => void>;
  15200. /**
  15201. * Observable signaled when VR display mode changes
  15202. */
  15203. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15204. /**
  15205. * Observable signaled when VR request present is complete
  15206. */
  15207. onVRRequestPresentComplete: Observable<boolean>;
  15208. /**
  15209. * Observable signaled when VR request present starts
  15210. */
  15211. onVRRequestPresentStart: Observable<Engine>;
  15212. /**
  15213. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15214. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15215. */
  15216. isInVRExclusivePointerMode: boolean;
  15217. /**
  15218. * Gets a boolean indicating if a webVR device was detected
  15219. * @returns true if a webVR device was detected
  15220. */
  15221. isVRDevicePresent(): boolean;
  15222. /**
  15223. * Gets the current webVR device
  15224. * @returns the current webVR device (or null)
  15225. */
  15226. getVRDevice(): any;
  15227. /**
  15228. * Initializes a webVR display and starts listening to display change events
  15229. * The onVRDisplayChangedObservable will be notified upon these changes
  15230. * @returns A promise containing a VRDisplay and if vr is supported
  15231. */
  15232. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15233. /** @hidden */
  15234. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15235. /**
  15236. * Call this function to switch to webVR mode
  15237. * Will do nothing if webVR is not supported or if there is no webVR device
  15238. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15239. */
  15240. enableVR(): void;
  15241. /** @hidden */
  15242. _onVRFullScreenTriggered(): void;
  15243. }
  15244. }
  15245. }
  15246. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15247. import { Nullable } from "babylonjs/types";
  15248. import { Observable } from "babylonjs/Misc/observable";
  15249. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15250. import { Scene } from "babylonjs/scene";
  15251. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15252. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15253. import { Node } from "babylonjs/node";
  15254. import { Ray } from "babylonjs/Culling/ray";
  15255. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15256. import "babylonjs/Engines/Extensions/engine.webVR";
  15257. /**
  15258. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15259. * IMPORTANT!! The data is right-hand data.
  15260. * @export
  15261. * @interface DevicePose
  15262. */
  15263. export interface DevicePose {
  15264. /**
  15265. * The position of the device, values in array are [x,y,z].
  15266. */
  15267. readonly position: Nullable<Float32Array>;
  15268. /**
  15269. * The linearVelocity of the device, values in array are [x,y,z].
  15270. */
  15271. readonly linearVelocity: Nullable<Float32Array>;
  15272. /**
  15273. * The linearAcceleration of the device, values in array are [x,y,z].
  15274. */
  15275. readonly linearAcceleration: Nullable<Float32Array>;
  15276. /**
  15277. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15278. */
  15279. readonly orientation: Nullable<Float32Array>;
  15280. /**
  15281. * The angularVelocity of the device, values in array are [x,y,z].
  15282. */
  15283. readonly angularVelocity: Nullable<Float32Array>;
  15284. /**
  15285. * The angularAcceleration of the device, values in array are [x,y,z].
  15286. */
  15287. readonly angularAcceleration: Nullable<Float32Array>;
  15288. }
  15289. /**
  15290. * Interface representing a pose controlled object in Babylon.
  15291. * A pose controlled object has both regular pose values as well as pose values
  15292. * from an external device such as a VR head mounted display
  15293. */
  15294. export interface PoseControlled {
  15295. /**
  15296. * The position of the object in babylon space.
  15297. */
  15298. position: Vector3;
  15299. /**
  15300. * The rotation quaternion of the object in babylon space.
  15301. */
  15302. rotationQuaternion: Quaternion;
  15303. /**
  15304. * The position of the device in babylon space.
  15305. */
  15306. devicePosition?: Vector3;
  15307. /**
  15308. * The rotation quaternion of the device in babylon space.
  15309. */
  15310. deviceRotationQuaternion: Quaternion;
  15311. /**
  15312. * The raw pose coming from the device.
  15313. */
  15314. rawPose: Nullable<DevicePose>;
  15315. /**
  15316. * The scale of the device to be used when translating from device space to babylon space.
  15317. */
  15318. deviceScaleFactor: number;
  15319. /**
  15320. * Updates the poseControlled values based on the input device pose.
  15321. * @param poseData the pose data to update the object with
  15322. */
  15323. updateFromDevice(poseData: DevicePose): void;
  15324. }
  15325. /**
  15326. * Set of options to customize the webVRCamera
  15327. */
  15328. export interface WebVROptions {
  15329. /**
  15330. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15331. */
  15332. trackPosition?: boolean;
  15333. /**
  15334. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15335. */
  15336. positionScale?: number;
  15337. /**
  15338. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15339. */
  15340. displayName?: string;
  15341. /**
  15342. * Should the native controller meshes be initialized. (default: true)
  15343. */
  15344. controllerMeshes?: boolean;
  15345. /**
  15346. * Creating a default HemiLight only on controllers. (default: true)
  15347. */
  15348. defaultLightingOnControllers?: boolean;
  15349. /**
  15350. * If you don't want to use the default VR button of the helper. (default: false)
  15351. */
  15352. useCustomVRButton?: boolean;
  15353. /**
  15354. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15355. */
  15356. customVRButton?: HTMLButtonElement;
  15357. /**
  15358. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15359. */
  15360. rayLength?: number;
  15361. /**
  15362. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15363. */
  15364. defaultHeight?: number;
  15365. /**
  15366. * If multiview should be used if availible (default: false)
  15367. */
  15368. useMultiview?: boolean;
  15369. }
  15370. /**
  15371. * This represents a WebVR camera.
  15372. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15373. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15374. */
  15375. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15376. private webVROptions;
  15377. /**
  15378. * @hidden
  15379. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15380. */
  15381. _vrDevice: any;
  15382. /**
  15383. * The rawPose of the vrDevice.
  15384. */
  15385. rawPose: Nullable<DevicePose>;
  15386. private _onVREnabled;
  15387. private _specsVersion;
  15388. private _attached;
  15389. private _frameData;
  15390. protected _descendants: Array<Node>;
  15391. private _deviceRoomPosition;
  15392. /** @hidden */
  15393. _deviceRoomRotationQuaternion: Quaternion;
  15394. private _standingMatrix;
  15395. /**
  15396. * Represents device position in babylon space.
  15397. */
  15398. devicePosition: Vector3;
  15399. /**
  15400. * Represents device rotation in babylon space.
  15401. */
  15402. deviceRotationQuaternion: Quaternion;
  15403. /**
  15404. * The scale of the device to be used when translating from device space to babylon space.
  15405. */
  15406. deviceScaleFactor: number;
  15407. private _deviceToWorld;
  15408. private _worldToDevice;
  15409. /**
  15410. * References to the webVR controllers for the vrDevice.
  15411. */
  15412. controllers: Array<WebVRController>;
  15413. /**
  15414. * Emits an event when a controller is attached.
  15415. */
  15416. onControllersAttachedObservable: Observable<WebVRController[]>;
  15417. /**
  15418. * Emits an event when a controller's mesh has been loaded;
  15419. */
  15420. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15421. /**
  15422. * Emits an event when the HMD's pose has been updated.
  15423. */
  15424. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15425. private _poseSet;
  15426. /**
  15427. * If the rig cameras be used as parent instead of this camera.
  15428. */
  15429. rigParenting: boolean;
  15430. private _lightOnControllers;
  15431. private _defaultHeight?;
  15432. /**
  15433. * Instantiates a WebVRFreeCamera.
  15434. * @param name The name of the WebVRFreeCamera
  15435. * @param position The starting anchor position for the camera
  15436. * @param scene The scene the camera belongs to
  15437. * @param webVROptions a set of customizable options for the webVRCamera
  15438. */
  15439. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15440. /**
  15441. * Gets the device distance from the ground in meters.
  15442. * @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.
  15443. */
  15444. deviceDistanceToRoomGround(): number;
  15445. /**
  15446. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15447. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15448. */
  15449. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15450. /**
  15451. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15452. * @returns A promise with a boolean set to if the standing matrix is supported.
  15453. */
  15454. useStandingMatrixAsync(): Promise<boolean>;
  15455. /**
  15456. * Disposes the camera
  15457. */
  15458. dispose(): void;
  15459. /**
  15460. * Gets a vrController by name.
  15461. * @param name The name of the controller to retreive
  15462. * @returns the controller matching the name specified or null if not found
  15463. */
  15464. getControllerByName(name: string): Nullable<WebVRController>;
  15465. private _leftController;
  15466. /**
  15467. * The controller corresponding to the users left hand.
  15468. */
  15469. readonly leftController: Nullable<WebVRController>;
  15470. private _rightController;
  15471. /**
  15472. * The controller corresponding to the users right hand.
  15473. */
  15474. readonly rightController: Nullable<WebVRController>;
  15475. /**
  15476. * Casts a ray forward from the vrCamera's gaze.
  15477. * @param length Length of the ray (default: 100)
  15478. * @returns the ray corresponding to the gaze
  15479. */
  15480. getForwardRay(length?: number): Ray;
  15481. /**
  15482. * @hidden
  15483. * Updates the camera based on device's frame data
  15484. */
  15485. _checkInputs(): void;
  15486. /**
  15487. * Updates the poseControlled values based on the input device pose.
  15488. * @param poseData Pose coming from the device
  15489. */
  15490. updateFromDevice(poseData: DevicePose): void;
  15491. private _htmlElementAttached;
  15492. private _detachIfAttached;
  15493. /**
  15494. * WebVR's attach control will start broadcasting frames to the device.
  15495. * Note that in certain browsers (chrome for example) this function must be called
  15496. * within a user-interaction callback. Example:
  15497. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15498. *
  15499. * @param element html element to attach the vrDevice to
  15500. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15501. */
  15502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15503. /**
  15504. * Detaches the camera from the html element and disables VR
  15505. *
  15506. * @param element html element to detach from
  15507. */
  15508. detachControl(element: HTMLElement): void;
  15509. /**
  15510. * @returns the name of this class
  15511. */
  15512. getClassName(): string;
  15513. /**
  15514. * Calls resetPose on the vrDisplay
  15515. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15516. */
  15517. resetToCurrentRotation(): void;
  15518. /**
  15519. * @hidden
  15520. * Updates the rig cameras (left and right eye)
  15521. */
  15522. _updateRigCameras(): void;
  15523. private _workingVector;
  15524. private _oneVector;
  15525. private _workingMatrix;
  15526. private updateCacheCalled;
  15527. private _correctPositionIfNotTrackPosition;
  15528. /**
  15529. * @hidden
  15530. * Updates the cached values of the camera
  15531. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15532. */
  15533. _updateCache(ignoreParentClass?: boolean): void;
  15534. /**
  15535. * @hidden
  15536. * Get current device position in babylon world
  15537. */
  15538. _computeDevicePosition(): void;
  15539. /**
  15540. * Updates the current device position and rotation in the babylon world
  15541. */
  15542. update(): void;
  15543. /**
  15544. * @hidden
  15545. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15546. * @returns an identity matrix
  15547. */
  15548. _getViewMatrix(): Matrix;
  15549. private _tmpMatrix;
  15550. /**
  15551. * This function is called by the two RIG cameras.
  15552. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15553. * @hidden
  15554. */
  15555. _getWebVRViewMatrix(): Matrix;
  15556. /** @hidden */
  15557. _getWebVRProjectionMatrix(): Matrix;
  15558. private _onGamepadConnectedObserver;
  15559. private _onGamepadDisconnectedObserver;
  15560. private _updateCacheWhenTrackingDisabledObserver;
  15561. /**
  15562. * Initializes the controllers and their meshes
  15563. */
  15564. initControllers(): void;
  15565. }
  15566. }
  15567. declare module "babylonjs/PostProcesses/postProcess" {
  15568. import { Nullable } from "babylonjs/types";
  15569. import { SmartArray } from "babylonjs/Misc/smartArray";
  15570. import { Observable } from "babylonjs/Misc/observable";
  15571. import { Vector2 } from "babylonjs/Maths/math.vector";
  15572. import { Camera } from "babylonjs/Cameras/camera";
  15573. import { Effect } from "babylonjs/Materials/effect";
  15574. import "babylonjs/Shaders/postprocess.vertex";
  15575. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15576. import { Engine } from "babylonjs/Engines/engine";
  15577. import { Color4 } from "babylonjs/Maths/math.color";
  15578. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15579. /**
  15580. * Size options for a post process
  15581. */
  15582. export type PostProcessOptions = {
  15583. width: number;
  15584. height: number;
  15585. };
  15586. /**
  15587. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15588. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15589. */
  15590. export class PostProcess {
  15591. /** Name of the PostProcess. */
  15592. name: string;
  15593. /**
  15594. * Gets or sets the unique id of the post process
  15595. */
  15596. uniqueId: number;
  15597. /**
  15598. * Width of the texture to apply the post process on
  15599. */
  15600. width: number;
  15601. /**
  15602. * Height of the texture to apply the post process on
  15603. */
  15604. height: number;
  15605. /**
  15606. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15607. * @hidden
  15608. */
  15609. _outputTexture: Nullable<InternalTexture>;
  15610. /**
  15611. * Sampling mode used by the shader
  15612. * See https://doc.babylonjs.com/classes/3.1/texture
  15613. */
  15614. renderTargetSamplingMode: number;
  15615. /**
  15616. * Clear color to use when screen clearing
  15617. */
  15618. clearColor: Color4;
  15619. /**
  15620. * If the buffer needs to be cleared before applying the post process. (default: true)
  15621. * Should be set to false if shader will overwrite all previous pixels.
  15622. */
  15623. autoClear: boolean;
  15624. /**
  15625. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15626. */
  15627. alphaMode: number;
  15628. /**
  15629. * Sets the setAlphaBlendConstants of the babylon engine
  15630. */
  15631. alphaConstants: Color4;
  15632. /**
  15633. * Animations to be used for the post processing
  15634. */
  15635. animations: import("babylonjs/Animations/animation").Animation[];
  15636. /**
  15637. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15638. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15639. */
  15640. enablePixelPerfectMode: boolean;
  15641. /**
  15642. * Force the postprocess to be applied without taking in account viewport
  15643. */
  15644. forceFullscreenViewport: boolean;
  15645. /**
  15646. * List of inspectable custom properties (used by the Inspector)
  15647. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15648. */
  15649. inspectableCustomProperties: IInspectable[];
  15650. /**
  15651. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15652. *
  15653. * | Value | Type | Description |
  15654. * | ----- | ----------------------------------- | ----------- |
  15655. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15656. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15657. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15658. *
  15659. */
  15660. scaleMode: number;
  15661. /**
  15662. * Force textures to be a power of two (default: false)
  15663. */
  15664. alwaysForcePOT: boolean;
  15665. private _samples;
  15666. /**
  15667. * Number of sample textures (default: 1)
  15668. */
  15669. samples: number;
  15670. /**
  15671. * Modify the scale of the post process to be the same as the viewport (default: false)
  15672. */
  15673. adaptScaleToCurrentViewport: boolean;
  15674. private _camera;
  15675. private _scene;
  15676. private _engine;
  15677. private _options;
  15678. private _reusable;
  15679. private _textureType;
  15680. /**
  15681. * Smart array of input and output textures for the post process.
  15682. * @hidden
  15683. */
  15684. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15685. /**
  15686. * The index in _textures that corresponds to the output texture.
  15687. * @hidden
  15688. */
  15689. _currentRenderTextureInd: number;
  15690. private _effect;
  15691. private _samplers;
  15692. private _fragmentUrl;
  15693. private _vertexUrl;
  15694. private _parameters;
  15695. private _scaleRatio;
  15696. protected _indexParameters: any;
  15697. private _shareOutputWithPostProcess;
  15698. private _texelSize;
  15699. private _forcedOutputTexture;
  15700. /**
  15701. * Returns the fragment url or shader name used in the post process.
  15702. * @returns the fragment url or name in the shader store.
  15703. */
  15704. getEffectName(): string;
  15705. /**
  15706. * An event triggered when the postprocess is activated.
  15707. */
  15708. onActivateObservable: Observable<Camera>;
  15709. private _onActivateObserver;
  15710. /**
  15711. * A function that is added to the onActivateObservable
  15712. */
  15713. onActivate: Nullable<(camera: Camera) => void>;
  15714. /**
  15715. * An event triggered when the postprocess changes its size.
  15716. */
  15717. onSizeChangedObservable: Observable<PostProcess>;
  15718. private _onSizeChangedObserver;
  15719. /**
  15720. * A function that is added to the onSizeChangedObservable
  15721. */
  15722. onSizeChanged: (postProcess: PostProcess) => void;
  15723. /**
  15724. * An event triggered when the postprocess applies its effect.
  15725. */
  15726. onApplyObservable: Observable<Effect>;
  15727. private _onApplyObserver;
  15728. /**
  15729. * A function that is added to the onApplyObservable
  15730. */
  15731. onApply: (effect: Effect) => void;
  15732. /**
  15733. * An event triggered before rendering the postprocess
  15734. */
  15735. onBeforeRenderObservable: Observable<Effect>;
  15736. private _onBeforeRenderObserver;
  15737. /**
  15738. * A function that is added to the onBeforeRenderObservable
  15739. */
  15740. onBeforeRender: (effect: Effect) => void;
  15741. /**
  15742. * An event triggered after rendering the postprocess
  15743. */
  15744. onAfterRenderObservable: Observable<Effect>;
  15745. private _onAfterRenderObserver;
  15746. /**
  15747. * A function that is added to the onAfterRenderObservable
  15748. */
  15749. onAfterRender: (efect: Effect) => void;
  15750. /**
  15751. * 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
  15752. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15753. */
  15754. inputTexture: InternalTexture;
  15755. /**
  15756. * Gets the camera which post process is applied to.
  15757. * @returns The camera the post process is applied to.
  15758. */
  15759. getCamera(): Camera;
  15760. /**
  15761. * Gets the texel size of the postprocess.
  15762. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15763. */
  15764. readonly texelSize: Vector2;
  15765. /**
  15766. * Creates a new instance PostProcess
  15767. * @param name The name of the PostProcess.
  15768. * @param fragmentUrl The url of the fragment shader to be used.
  15769. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15770. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15771. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15772. * @param camera The camera to apply the render pass to.
  15773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15774. * @param engine The engine which the post process will be applied. (default: current engine)
  15775. * @param reusable If the post process can be reused on the same frame. (default: false)
  15776. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15777. * @param textureType Type of textures used when performing the post process. (default: 0)
  15778. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15779. * @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
  15780. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15781. */
  15782. constructor(
  15783. /** Name of the PostProcess. */
  15784. 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);
  15785. /**
  15786. * Gets a string idenfifying the name of the class
  15787. * @returns "PostProcess" string
  15788. */
  15789. getClassName(): string;
  15790. /**
  15791. * Gets the engine which this post process belongs to.
  15792. * @returns The engine the post process was enabled with.
  15793. */
  15794. getEngine(): Engine;
  15795. /**
  15796. * The effect that is created when initializing the post process.
  15797. * @returns The created effect corresponding the the postprocess.
  15798. */
  15799. getEffect(): Effect;
  15800. /**
  15801. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15802. * @param postProcess The post process to share the output with.
  15803. * @returns This post process.
  15804. */
  15805. shareOutputWith(postProcess: PostProcess): PostProcess;
  15806. /**
  15807. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15808. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15809. */
  15810. useOwnOutput(): void;
  15811. /**
  15812. * Updates the effect with the current post process compile time values and recompiles the shader.
  15813. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15814. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15815. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15816. * @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
  15817. * @param onCompiled Called when the shader has been compiled.
  15818. * @param onError Called if there is an error when compiling a shader.
  15819. */
  15820. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15821. /**
  15822. * The post process is reusable if it can be used multiple times within one frame.
  15823. * @returns If the post process is reusable
  15824. */
  15825. isReusable(): boolean;
  15826. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15827. markTextureDirty(): void;
  15828. /**
  15829. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15830. * 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.
  15831. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15832. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15833. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15834. * @returns The target texture that was bound to be written to.
  15835. */
  15836. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15837. /**
  15838. * If the post process is supported.
  15839. */
  15840. readonly isSupported: boolean;
  15841. /**
  15842. * The aspect ratio of the output texture.
  15843. */
  15844. readonly aspectRatio: number;
  15845. /**
  15846. * Get a value indicating if the post-process is ready to be used
  15847. * @returns true if the post-process is ready (shader is compiled)
  15848. */
  15849. isReady(): boolean;
  15850. /**
  15851. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15852. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15853. */
  15854. apply(): Nullable<Effect>;
  15855. private _disposeTextures;
  15856. /**
  15857. * Disposes the post process.
  15858. * @param camera The camera to dispose the post process on.
  15859. */
  15860. dispose(camera?: Camera): void;
  15861. }
  15862. }
  15863. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15864. /** @hidden */
  15865. export var kernelBlurVaryingDeclaration: {
  15866. name: string;
  15867. shader: string;
  15868. };
  15869. }
  15870. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15871. /** @hidden */
  15872. export var kernelBlurFragment: {
  15873. name: string;
  15874. shader: string;
  15875. };
  15876. }
  15877. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15878. /** @hidden */
  15879. export var kernelBlurFragment2: {
  15880. name: string;
  15881. shader: string;
  15882. };
  15883. }
  15884. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15885. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15886. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15887. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15888. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15889. /** @hidden */
  15890. export var kernelBlurPixelShader: {
  15891. name: string;
  15892. shader: string;
  15893. };
  15894. }
  15895. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15896. /** @hidden */
  15897. export var kernelBlurVertex: {
  15898. name: string;
  15899. shader: string;
  15900. };
  15901. }
  15902. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15903. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15904. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15905. /** @hidden */
  15906. export var kernelBlurVertexShader: {
  15907. name: string;
  15908. shader: string;
  15909. };
  15910. }
  15911. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15912. import { Vector2 } from "babylonjs/Maths/math.vector";
  15913. import { Nullable } from "babylonjs/types";
  15914. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15915. import { Camera } from "babylonjs/Cameras/camera";
  15916. import { Effect } from "babylonjs/Materials/effect";
  15917. import { Engine } from "babylonjs/Engines/engine";
  15918. import "babylonjs/Shaders/kernelBlur.fragment";
  15919. import "babylonjs/Shaders/kernelBlur.vertex";
  15920. /**
  15921. * The Blur Post Process which blurs an image based on a kernel and direction.
  15922. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15923. */
  15924. export class BlurPostProcess extends PostProcess {
  15925. /** The direction in which to blur the image. */
  15926. direction: Vector2;
  15927. private blockCompilation;
  15928. protected _kernel: number;
  15929. protected _idealKernel: number;
  15930. protected _packedFloat: boolean;
  15931. private _staticDefines;
  15932. /**
  15933. * Sets the length in pixels of the blur sample region
  15934. */
  15935. /**
  15936. * Gets the length in pixels of the blur sample region
  15937. */
  15938. kernel: number;
  15939. /**
  15940. * Sets wether or not the blur needs to unpack/repack floats
  15941. */
  15942. /**
  15943. * Gets wether or not the blur is unpacking/repacking floats
  15944. */
  15945. packedFloat: boolean;
  15946. /**
  15947. * Creates a new instance BlurPostProcess
  15948. * @param name The name of the effect.
  15949. * @param direction The direction in which to blur the image.
  15950. * @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.
  15951. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15952. * @param camera The camera to apply the render pass to.
  15953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15954. * @param engine The engine which the post process will be applied. (default: current engine)
  15955. * @param reusable If the post process can be reused on the same frame. (default: false)
  15956. * @param textureType Type of textures used when performing the post process. (default: 0)
  15957. * @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)
  15958. */
  15959. constructor(name: string,
  15960. /** The direction in which to blur the image. */
  15961. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15962. /**
  15963. * Updates the effect with the current post process compile time values and recompiles the shader.
  15964. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15965. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15966. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15967. * @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
  15968. * @param onCompiled Called when the shader has been compiled.
  15969. * @param onError Called if there is an error when compiling a shader.
  15970. */
  15971. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15972. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15973. /**
  15974. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15975. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15976. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15977. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15978. * The gaps between physical kernels are compensated for in the weighting of the samples
  15979. * @param idealKernel Ideal blur kernel.
  15980. * @return Nearest best kernel.
  15981. */
  15982. protected _nearestBestKernel(idealKernel: number): number;
  15983. /**
  15984. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15985. * @param x The point on the Gaussian distribution to sample.
  15986. * @return the value of the Gaussian function at x.
  15987. */
  15988. protected _gaussianWeight(x: number): number;
  15989. /**
  15990. * Generates a string that can be used as a floating point number in GLSL.
  15991. * @param x Value to print.
  15992. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15993. * @return GLSL float string.
  15994. */
  15995. protected _glslFloat(x: number, decimalFigures?: number): string;
  15996. }
  15997. }
  15998. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15999. import { Scene } from "babylonjs/scene";
  16000. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16001. import { Plane } from "babylonjs/Maths/math.plane";
  16002. /**
  16003. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16004. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16005. * You can then easily use it as a reflectionTexture on a flat surface.
  16006. * In case the surface is not a plane, please consider relying on reflection probes.
  16007. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16008. */
  16009. export class MirrorTexture extends RenderTargetTexture {
  16010. private scene;
  16011. /**
  16012. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16013. * 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.
  16014. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16015. */
  16016. mirrorPlane: Plane;
  16017. /**
  16018. * Define the blur ratio used to blur the reflection if needed.
  16019. */
  16020. blurRatio: number;
  16021. /**
  16022. * Define the adaptive blur kernel used to blur the reflection if needed.
  16023. * This will autocompute the closest best match for the `blurKernel`
  16024. */
  16025. adaptiveBlurKernel: number;
  16026. /**
  16027. * Define the blur kernel used to blur the reflection if needed.
  16028. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16029. */
  16030. blurKernel: number;
  16031. /**
  16032. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16033. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16034. */
  16035. blurKernelX: number;
  16036. /**
  16037. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16038. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16039. */
  16040. blurKernelY: number;
  16041. private _autoComputeBlurKernel;
  16042. protected _onRatioRescale(): void;
  16043. private _updateGammaSpace;
  16044. private _imageProcessingConfigChangeObserver;
  16045. private _transformMatrix;
  16046. private _mirrorMatrix;
  16047. private _savedViewMatrix;
  16048. private _blurX;
  16049. private _blurY;
  16050. private _adaptiveBlurKernel;
  16051. private _blurKernelX;
  16052. private _blurKernelY;
  16053. private _blurRatio;
  16054. /**
  16055. * Instantiates a Mirror Texture.
  16056. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16057. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16058. * You can then easily use it as a reflectionTexture on a flat surface.
  16059. * In case the surface is not a plane, please consider relying on reflection probes.
  16060. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16061. * @param name
  16062. * @param size
  16063. * @param scene
  16064. * @param generateMipMaps
  16065. * @param type
  16066. * @param samplingMode
  16067. * @param generateDepthBuffer
  16068. */
  16069. constructor(name: string, size: number | {
  16070. width: number;
  16071. height: number;
  16072. } | {
  16073. ratio: number;
  16074. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16075. private _preparePostProcesses;
  16076. /**
  16077. * Clone the mirror texture.
  16078. * @returns the cloned texture
  16079. */
  16080. clone(): MirrorTexture;
  16081. /**
  16082. * Serialize the texture to a JSON representation you could use in Parse later on
  16083. * @returns the serialized JSON representation
  16084. */
  16085. serialize(): any;
  16086. /**
  16087. * Dispose the texture and release its associated resources.
  16088. */
  16089. dispose(): void;
  16090. }
  16091. }
  16092. declare module "babylonjs/Materials/Textures/texture" {
  16093. import { Observable } from "babylonjs/Misc/observable";
  16094. import { Nullable } from "babylonjs/types";
  16095. import { Scene } from "babylonjs/scene";
  16096. import { Matrix } from "babylonjs/Maths/math.vector";
  16097. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16098. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16099. import { Engine } from "babylonjs/Engines/engine";
  16100. /**
  16101. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16102. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16103. */
  16104. export class Texture extends BaseTexture {
  16105. /**
  16106. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16107. */
  16108. static SerializeBuffers: boolean;
  16109. /** @hidden */
  16110. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16111. /** @hidden */
  16112. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16113. /** @hidden */
  16114. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16115. /** nearest is mag = nearest and min = nearest and mip = linear */
  16116. static readonly NEAREST_SAMPLINGMODE: number;
  16117. /** nearest is mag = nearest and min = nearest and mip = linear */
  16118. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16119. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16120. static readonly BILINEAR_SAMPLINGMODE: number;
  16121. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16122. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16123. /** Trilinear is mag = linear and min = linear and mip = linear */
  16124. static readonly TRILINEAR_SAMPLINGMODE: number;
  16125. /** Trilinear is mag = linear and min = linear and mip = linear */
  16126. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16127. /** mag = nearest and min = nearest and mip = nearest */
  16128. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16129. /** mag = nearest and min = linear and mip = nearest */
  16130. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16131. /** mag = nearest and min = linear and mip = linear */
  16132. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16133. /** mag = nearest and min = linear and mip = none */
  16134. static readonly NEAREST_LINEAR: number;
  16135. /** mag = nearest and min = nearest and mip = none */
  16136. static readonly NEAREST_NEAREST: number;
  16137. /** mag = linear and min = nearest and mip = nearest */
  16138. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16139. /** mag = linear and min = nearest and mip = linear */
  16140. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16141. /** mag = linear and min = linear and mip = none */
  16142. static readonly LINEAR_LINEAR: number;
  16143. /** mag = linear and min = nearest and mip = none */
  16144. static readonly LINEAR_NEAREST: number;
  16145. /** Explicit coordinates mode */
  16146. static readonly EXPLICIT_MODE: number;
  16147. /** Spherical coordinates mode */
  16148. static readonly SPHERICAL_MODE: number;
  16149. /** Planar coordinates mode */
  16150. static readonly PLANAR_MODE: number;
  16151. /** Cubic coordinates mode */
  16152. static readonly CUBIC_MODE: number;
  16153. /** Projection coordinates mode */
  16154. static readonly PROJECTION_MODE: number;
  16155. /** Inverse Cubic coordinates mode */
  16156. static readonly SKYBOX_MODE: number;
  16157. /** Inverse Cubic coordinates mode */
  16158. static readonly INVCUBIC_MODE: number;
  16159. /** Equirectangular coordinates mode */
  16160. static readonly EQUIRECTANGULAR_MODE: number;
  16161. /** Equirectangular Fixed coordinates mode */
  16162. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16163. /** Equirectangular Fixed Mirrored coordinates mode */
  16164. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16165. /** Texture is not repeating outside of 0..1 UVs */
  16166. static readonly CLAMP_ADDRESSMODE: number;
  16167. /** Texture is repeating outside of 0..1 UVs */
  16168. static readonly WRAP_ADDRESSMODE: number;
  16169. /** Texture is repeating and mirrored */
  16170. static readonly MIRROR_ADDRESSMODE: number;
  16171. /**
  16172. * 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
  16173. */
  16174. static UseSerializedUrlIfAny: boolean;
  16175. /**
  16176. * Define the url of the texture.
  16177. */
  16178. url: Nullable<string>;
  16179. /**
  16180. * Define an offset on the texture to offset the u coordinates of the UVs
  16181. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16182. */
  16183. uOffset: number;
  16184. /**
  16185. * Define an offset on the texture to offset the v coordinates of the UVs
  16186. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16187. */
  16188. vOffset: number;
  16189. /**
  16190. * Define an offset on the texture to scale the u coordinates of the UVs
  16191. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16192. */
  16193. uScale: number;
  16194. /**
  16195. * Define an offset on the texture to scale the v coordinates of the UVs
  16196. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16197. */
  16198. vScale: number;
  16199. /**
  16200. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16201. * @see http://doc.babylonjs.com/how_to/more_materials
  16202. */
  16203. uAng: number;
  16204. /**
  16205. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16206. * @see http://doc.babylonjs.com/how_to/more_materials
  16207. */
  16208. vAng: number;
  16209. /**
  16210. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16211. * @see http://doc.babylonjs.com/how_to/more_materials
  16212. */
  16213. wAng: number;
  16214. /**
  16215. * Defines the center of rotation (U)
  16216. */
  16217. uRotationCenter: number;
  16218. /**
  16219. * Defines the center of rotation (V)
  16220. */
  16221. vRotationCenter: number;
  16222. /**
  16223. * Defines the center of rotation (W)
  16224. */
  16225. wRotationCenter: number;
  16226. /**
  16227. * Are mip maps generated for this texture or not.
  16228. */
  16229. readonly noMipmap: boolean;
  16230. /**
  16231. * List of inspectable custom properties (used by the Inspector)
  16232. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16233. */
  16234. inspectableCustomProperties: Nullable<IInspectable[]>;
  16235. private _noMipmap;
  16236. /** @hidden */
  16237. _invertY: boolean;
  16238. private _rowGenerationMatrix;
  16239. private _cachedTextureMatrix;
  16240. private _projectionModeMatrix;
  16241. private _t0;
  16242. private _t1;
  16243. private _t2;
  16244. private _cachedUOffset;
  16245. private _cachedVOffset;
  16246. private _cachedUScale;
  16247. private _cachedVScale;
  16248. private _cachedUAng;
  16249. private _cachedVAng;
  16250. private _cachedWAng;
  16251. private _cachedProjectionMatrixId;
  16252. private _cachedCoordinatesMode;
  16253. /** @hidden */
  16254. protected _initialSamplingMode: number;
  16255. /** @hidden */
  16256. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16257. private _deleteBuffer;
  16258. protected _format: Nullable<number>;
  16259. private _delayedOnLoad;
  16260. private _delayedOnError;
  16261. /**
  16262. * Observable triggered once the texture has been loaded.
  16263. */
  16264. onLoadObservable: Observable<Texture>;
  16265. protected _isBlocking: boolean;
  16266. /**
  16267. * Is the texture preventing material to render while loading.
  16268. * If false, a default texture will be used instead of the loading one during the preparation step.
  16269. */
  16270. isBlocking: boolean;
  16271. /**
  16272. * Get the current sampling mode associated with the texture.
  16273. */
  16274. readonly samplingMode: number;
  16275. /**
  16276. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16277. */
  16278. readonly invertY: boolean;
  16279. /**
  16280. * Instantiates a new texture.
  16281. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16282. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16283. * @param url define the url of the picture to load as a texture
  16284. * @param scene define the scene or engine the texture will belong to
  16285. * @param noMipmap define if the texture will require mip maps or not
  16286. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16287. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16288. * @param onLoad define a callback triggered when the texture has been loaded
  16289. * @param onError define a callback triggered when an error occurred during the loading session
  16290. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16291. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16292. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16293. */
  16294. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16295. /**
  16296. * Update the url (and optional buffer) of this texture if url was null during construction.
  16297. * @param url the url of the texture
  16298. * @param buffer the buffer of the texture (defaults to null)
  16299. * @param onLoad callback called when the texture is loaded (defaults to null)
  16300. */
  16301. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16302. /**
  16303. * Finish the loading sequence of a texture flagged as delayed load.
  16304. * @hidden
  16305. */
  16306. delayLoad(): void;
  16307. private _prepareRowForTextureGeneration;
  16308. /**
  16309. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16310. * @returns the transform matrix of the texture.
  16311. */
  16312. getTextureMatrix(): Matrix;
  16313. /**
  16314. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16315. * @returns The reflection texture transform
  16316. */
  16317. getReflectionTextureMatrix(): Matrix;
  16318. /**
  16319. * Clones the texture.
  16320. * @returns the cloned texture
  16321. */
  16322. clone(): Texture;
  16323. /**
  16324. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16325. * @returns The JSON representation of the texture
  16326. */
  16327. serialize(): any;
  16328. /**
  16329. * Get the current class name of the texture useful for serialization or dynamic coding.
  16330. * @returns "Texture"
  16331. */
  16332. getClassName(): string;
  16333. /**
  16334. * Dispose the texture and release its associated resources.
  16335. */
  16336. dispose(): void;
  16337. /**
  16338. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16339. * @param parsedTexture Define the JSON representation of the texture
  16340. * @param scene Define the scene the parsed texture should be instantiated in
  16341. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16342. * @returns The parsed texture if successful
  16343. */
  16344. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16345. /**
  16346. * Creates a texture from its base 64 representation.
  16347. * @param data Define the base64 payload without the data: prefix
  16348. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16349. * @param scene Define the scene the texture should belong to
  16350. * @param noMipmap Forces the texture to not create mip map information if true
  16351. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16352. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16353. * @param onLoad define a callback triggered when the texture has been loaded
  16354. * @param onError define a callback triggered when an error occurred during the loading session
  16355. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16356. * @returns the created texture
  16357. */
  16358. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16359. /**
  16360. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16361. * @param data Define the base64 payload without the data: prefix
  16362. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16363. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16364. * @param scene Define the scene the texture should belong to
  16365. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16366. * @param noMipmap Forces the texture to not create mip map information if true
  16367. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16368. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16369. * @param onLoad define a callback triggered when the texture has been loaded
  16370. * @param onError define a callback triggered when an error occurred during the loading session
  16371. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16372. * @returns the created texture
  16373. */
  16374. 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;
  16375. }
  16376. }
  16377. declare module "babylonjs/PostProcesses/postProcessManager" {
  16378. import { Nullable } from "babylonjs/types";
  16379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16380. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16381. import { Scene } from "babylonjs/scene";
  16382. /**
  16383. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16384. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16385. */
  16386. export class PostProcessManager {
  16387. private _scene;
  16388. private _indexBuffer;
  16389. private _vertexBuffers;
  16390. /**
  16391. * Creates a new instance PostProcess
  16392. * @param scene The scene that the post process is associated with.
  16393. */
  16394. constructor(scene: Scene);
  16395. private _prepareBuffers;
  16396. private _buildIndexBuffer;
  16397. /**
  16398. * Rebuilds the vertex buffers of the manager.
  16399. * @hidden
  16400. */
  16401. _rebuild(): void;
  16402. /**
  16403. * Prepares a frame to be run through a post process.
  16404. * @param sourceTexture The input texture to the post procesess. (default: null)
  16405. * @param postProcesses An array of post processes to be run. (default: null)
  16406. * @returns True if the post processes were able to be run.
  16407. * @hidden
  16408. */
  16409. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16410. /**
  16411. * Manually render a set of post processes to a texture.
  16412. * @param postProcesses An array of post processes to be run.
  16413. * @param targetTexture The target texture to render to.
  16414. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16415. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16416. * @param lodLevel defines which lod of the texture to render to
  16417. */
  16418. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16419. /**
  16420. * Finalize the result of the output of the postprocesses.
  16421. * @param doNotPresent If true the result will not be displayed to the screen.
  16422. * @param targetTexture The target texture to render to.
  16423. * @param faceIndex The index of the face to bind the target texture to.
  16424. * @param postProcesses The array of post processes to render.
  16425. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16426. * @hidden
  16427. */
  16428. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16429. /**
  16430. * Disposes of the post process manager.
  16431. */
  16432. dispose(): void;
  16433. }
  16434. }
  16435. declare module "babylonjs/Misc/gradients" {
  16436. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16437. /** Interface used by value gradients (color, factor, ...) */
  16438. export interface IValueGradient {
  16439. /**
  16440. * Gets or sets the gradient value (between 0 and 1)
  16441. */
  16442. gradient: number;
  16443. }
  16444. /** Class used to store color4 gradient */
  16445. export class ColorGradient implements IValueGradient {
  16446. /**
  16447. * Gets or sets the gradient value (between 0 and 1)
  16448. */
  16449. gradient: number;
  16450. /**
  16451. * Gets or sets first associated color
  16452. */
  16453. color1: Color4;
  16454. /**
  16455. * Gets or sets second associated color
  16456. */
  16457. color2?: Color4;
  16458. /**
  16459. * Will get a color picked randomly between color1 and color2.
  16460. * If color2 is undefined then color1 will be used
  16461. * @param result defines the target Color4 to store the result in
  16462. */
  16463. getColorToRef(result: Color4): void;
  16464. }
  16465. /** Class used to store color 3 gradient */
  16466. export class Color3Gradient implements IValueGradient {
  16467. /**
  16468. * Gets or sets the gradient value (between 0 and 1)
  16469. */
  16470. gradient: number;
  16471. /**
  16472. * Gets or sets the associated color
  16473. */
  16474. color: Color3;
  16475. }
  16476. /** Class used to store factor gradient */
  16477. export class FactorGradient implements IValueGradient {
  16478. /**
  16479. * Gets or sets the gradient value (between 0 and 1)
  16480. */
  16481. gradient: number;
  16482. /**
  16483. * Gets or sets first associated factor
  16484. */
  16485. factor1: number;
  16486. /**
  16487. * Gets or sets second associated factor
  16488. */
  16489. factor2?: number;
  16490. /**
  16491. * Will get a number picked randomly between factor1 and factor2.
  16492. * If factor2 is undefined then factor1 will be used
  16493. * @returns the picked number
  16494. */
  16495. getFactor(): number;
  16496. }
  16497. /**
  16498. * Helper used to simplify some generic gradient tasks
  16499. */
  16500. export class GradientHelper {
  16501. /**
  16502. * Gets the current gradient from an array of IValueGradient
  16503. * @param ratio defines the current ratio to get
  16504. * @param gradients defines the array of IValueGradient
  16505. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16506. */
  16507. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16508. }
  16509. }
  16510. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16511. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16512. import { Nullable } from "babylonjs/types";
  16513. module "babylonjs/Engines/thinEngine" {
  16514. interface ThinEngine {
  16515. /**
  16516. * Creates a dynamic texture
  16517. * @param width defines the width of the texture
  16518. * @param height defines the height of the texture
  16519. * @param generateMipMaps defines if the engine should generate the mip levels
  16520. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16521. * @returns the dynamic texture inside an InternalTexture
  16522. */
  16523. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16524. /**
  16525. * Update the content of a dynamic texture
  16526. * @param texture defines the texture to update
  16527. * @param canvas defines the canvas containing the source
  16528. * @param invertY defines if data must be stored with Y axis inverted
  16529. * @param premulAlpha defines if alpha is stored as premultiplied
  16530. * @param format defines the format of the data
  16531. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16532. */
  16533. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16534. }
  16535. }
  16536. }
  16537. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16538. import { Scene } from "babylonjs/scene";
  16539. import { Texture } from "babylonjs/Materials/Textures/texture";
  16540. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16541. /**
  16542. * A class extending Texture allowing drawing on a texture
  16543. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16544. */
  16545. export class DynamicTexture extends Texture {
  16546. private _generateMipMaps;
  16547. private _canvas;
  16548. private _context;
  16549. private _engine;
  16550. /**
  16551. * Creates a DynamicTexture
  16552. * @param name defines the name of the texture
  16553. * @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
  16554. * @param scene defines the scene where you want the texture
  16555. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16556. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16557. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16558. */
  16559. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16560. /**
  16561. * Get the current class name of the texture useful for serialization or dynamic coding.
  16562. * @returns "DynamicTexture"
  16563. */
  16564. getClassName(): string;
  16565. /**
  16566. * Gets the current state of canRescale
  16567. */
  16568. readonly canRescale: boolean;
  16569. private _recreate;
  16570. /**
  16571. * Scales the texture
  16572. * @param ratio the scale factor to apply to both width and height
  16573. */
  16574. scale(ratio: number): void;
  16575. /**
  16576. * Resizes the texture
  16577. * @param width the new width
  16578. * @param height the new height
  16579. */
  16580. scaleTo(width: number, height: number): void;
  16581. /**
  16582. * Gets the context of the canvas used by the texture
  16583. * @returns the canvas context of the dynamic texture
  16584. */
  16585. getContext(): CanvasRenderingContext2D;
  16586. /**
  16587. * Clears the texture
  16588. */
  16589. clear(): void;
  16590. /**
  16591. * Updates the texture
  16592. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16593. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16594. */
  16595. update(invertY?: boolean, premulAlpha?: boolean): void;
  16596. /**
  16597. * Draws text onto the texture
  16598. * @param text defines the text to be drawn
  16599. * @param x defines the placement of the text from the left
  16600. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16601. * @param font defines the font to be used with font-style, font-size, font-name
  16602. * @param color defines the color used for the text
  16603. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16604. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16605. * @param update defines whether texture is immediately update (default is true)
  16606. */
  16607. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16608. /**
  16609. * Clones the texture
  16610. * @returns the clone of the texture.
  16611. */
  16612. clone(): DynamicTexture;
  16613. /**
  16614. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16615. * @returns a serialized dynamic texture object
  16616. */
  16617. serialize(): any;
  16618. /** @hidden */
  16619. _rebuild(): void;
  16620. }
  16621. }
  16622. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16623. import { Scene } from "babylonjs/scene";
  16624. import { ISceneComponent } from "babylonjs/sceneComponent";
  16625. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16626. module "babylonjs/abstractScene" {
  16627. interface AbstractScene {
  16628. /**
  16629. * The list of procedural textures added to the scene
  16630. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16631. */
  16632. proceduralTextures: Array<ProceduralTexture>;
  16633. }
  16634. }
  16635. /**
  16636. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16637. * in a given scene.
  16638. */
  16639. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16640. /**
  16641. * The component name helpfull to identify the component in the list of scene components.
  16642. */
  16643. readonly name: string;
  16644. /**
  16645. * The scene the component belongs to.
  16646. */
  16647. scene: Scene;
  16648. /**
  16649. * Creates a new instance of the component for the given scene
  16650. * @param scene Defines the scene to register the component in
  16651. */
  16652. constructor(scene: Scene);
  16653. /**
  16654. * Registers the component in a given scene
  16655. */
  16656. register(): void;
  16657. /**
  16658. * Rebuilds the elements related to this component in case of
  16659. * context lost for instance.
  16660. */
  16661. rebuild(): void;
  16662. /**
  16663. * Disposes the component and the associated ressources.
  16664. */
  16665. dispose(): void;
  16666. private _beforeClear;
  16667. }
  16668. }
  16669. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16670. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16671. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16672. module "babylonjs/Engines/thinEngine" {
  16673. interface ThinEngine {
  16674. /**
  16675. * Creates a new render target cube texture
  16676. * @param size defines the size of the texture
  16677. * @param options defines the options used to create the texture
  16678. * @returns a new render target cube texture stored in an InternalTexture
  16679. */
  16680. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16681. }
  16682. }
  16683. }
  16684. declare module "babylonjs/Shaders/procedural.vertex" {
  16685. /** @hidden */
  16686. export var proceduralVertexShader: {
  16687. name: string;
  16688. shader: string;
  16689. };
  16690. }
  16691. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16692. import { Observable } from "babylonjs/Misc/observable";
  16693. import { Nullable } from "babylonjs/types";
  16694. import { Scene } from "babylonjs/scene";
  16695. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16696. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16697. import { Effect } from "babylonjs/Materials/effect";
  16698. import { Texture } from "babylonjs/Materials/Textures/texture";
  16699. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16700. import "babylonjs/Shaders/procedural.vertex";
  16701. /**
  16702. * 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.
  16703. * This is the base class of any Procedural texture and contains most of the shareable code.
  16704. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16705. */
  16706. export class ProceduralTexture extends Texture {
  16707. isCube: boolean;
  16708. /**
  16709. * Define if the texture is enabled or not (disabled texture will not render)
  16710. */
  16711. isEnabled: boolean;
  16712. /**
  16713. * Define if the texture must be cleared before rendering (default is true)
  16714. */
  16715. autoClear: boolean;
  16716. /**
  16717. * Callback called when the texture is generated
  16718. */
  16719. onGenerated: () => void;
  16720. /**
  16721. * Event raised when the texture is generated
  16722. */
  16723. onGeneratedObservable: Observable<ProceduralTexture>;
  16724. /** @hidden */
  16725. _generateMipMaps: boolean;
  16726. /** @hidden **/
  16727. _effect: Effect;
  16728. /** @hidden */
  16729. _textures: {
  16730. [key: string]: Texture;
  16731. };
  16732. private _size;
  16733. private _currentRefreshId;
  16734. private _refreshRate;
  16735. private _vertexBuffers;
  16736. private _indexBuffer;
  16737. private _uniforms;
  16738. private _samplers;
  16739. private _fragment;
  16740. private _floats;
  16741. private _ints;
  16742. private _floatsArrays;
  16743. private _colors3;
  16744. private _colors4;
  16745. private _vectors2;
  16746. private _vectors3;
  16747. private _matrices;
  16748. private _fallbackTexture;
  16749. private _fallbackTextureUsed;
  16750. private _engine;
  16751. private _cachedDefines;
  16752. private _contentUpdateId;
  16753. private _contentData;
  16754. /**
  16755. * Instantiates a new procedural texture.
  16756. * 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.
  16757. * This is the base class of any Procedural texture and contains most of the shareable code.
  16758. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16759. * @param name Define the name of the texture
  16760. * @param size Define the size of the texture to create
  16761. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16762. * @param scene Define the scene the texture belongs to
  16763. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16764. * @param generateMipMaps Define if the texture should creates mip maps or not
  16765. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16766. */
  16767. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16768. /**
  16769. * The effect that is created when initializing the post process.
  16770. * @returns The created effect corresponding the the postprocess.
  16771. */
  16772. getEffect(): Effect;
  16773. /**
  16774. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16775. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16776. */
  16777. getContent(): Nullable<ArrayBufferView>;
  16778. private _createIndexBuffer;
  16779. /** @hidden */
  16780. _rebuild(): void;
  16781. /**
  16782. * Resets the texture in order to recreate its associated resources.
  16783. * This can be called in case of context loss
  16784. */
  16785. reset(): void;
  16786. protected _getDefines(): string;
  16787. /**
  16788. * Is the texture ready to be used ? (rendered at least once)
  16789. * @returns true if ready, otherwise, false.
  16790. */
  16791. isReady(): boolean;
  16792. /**
  16793. * Resets the refresh counter of the texture and start bak from scratch.
  16794. * Could be useful to regenerate the texture if it is setup to render only once.
  16795. */
  16796. resetRefreshCounter(): void;
  16797. /**
  16798. * Set the fragment shader to use in order to render the texture.
  16799. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16800. */
  16801. setFragment(fragment: any): void;
  16802. /**
  16803. * Define the refresh rate of the texture or the rendering frequency.
  16804. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16805. */
  16806. refreshRate: number;
  16807. /** @hidden */
  16808. _shouldRender(): boolean;
  16809. /**
  16810. * Get the size the texture is rendering at.
  16811. * @returns the size (texture is always squared)
  16812. */
  16813. getRenderSize(): number;
  16814. /**
  16815. * Resize the texture to new value.
  16816. * @param size Define the new size the texture should have
  16817. * @param generateMipMaps Define whether the new texture should create mip maps
  16818. */
  16819. resize(size: number, generateMipMaps: boolean): void;
  16820. private _checkUniform;
  16821. /**
  16822. * Set a texture in the shader program used to render.
  16823. * @param name Define the name of the uniform samplers as defined in the shader
  16824. * @param texture Define the texture to bind to this sampler
  16825. * @return the texture itself allowing "fluent" like uniform updates
  16826. */
  16827. setTexture(name: string, texture: Texture): ProceduralTexture;
  16828. /**
  16829. * Set a float in the shader.
  16830. * @param name Define the name of the uniform as defined in the shader
  16831. * @param value Define the value to give to the uniform
  16832. * @return the texture itself allowing "fluent" like uniform updates
  16833. */
  16834. setFloat(name: string, value: number): ProceduralTexture;
  16835. /**
  16836. * Set a int in the shader.
  16837. * @param name Define the name of the uniform as defined in the shader
  16838. * @param value Define the value to give to the uniform
  16839. * @return the texture itself allowing "fluent" like uniform updates
  16840. */
  16841. setInt(name: string, value: number): ProceduralTexture;
  16842. /**
  16843. * Set an array of floats in the shader.
  16844. * @param name Define the name of the uniform as defined in the shader
  16845. * @param value Define the value to give to the uniform
  16846. * @return the texture itself allowing "fluent" like uniform updates
  16847. */
  16848. setFloats(name: string, value: number[]): ProceduralTexture;
  16849. /**
  16850. * Set a vec3 in the shader from a Color3.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the texture itself allowing "fluent" like uniform updates
  16854. */
  16855. setColor3(name: string, value: Color3): ProceduralTexture;
  16856. /**
  16857. * Set a vec4 in the shader from a Color4.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the texture itself allowing "fluent" like uniform updates
  16861. */
  16862. setColor4(name: string, value: Color4): ProceduralTexture;
  16863. /**
  16864. * Set a vec2 in the shader from a Vector2.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the texture itself allowing "fluent" like uniform updates
  16868. */
  16869. setVector2(name: string, value: Vector2): ProceduralTexture;
  16870. /**
  16871. * Set a vec3 in the shader from a Vector3.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the texture itself allowing "fluent" like uniform updates
  16875. */
  16876. setVector3(name: string, value: Vector3): ProceduralTexture;
  16877. /**
  16878. * Set a mat4 in the shader from a MAtrix.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the texture itself allowing "fluent" like uniform updates
  16882. */
  16883. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16884. /**
  16885. * Render the texture to its associated render target.
  16886. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16887. */
  16888. render(useCameraPostProcess?: boolean): void;
  16889. /**
  16890. * Clone the texture.
  16891. * @returns the cloned texture
  16892. */
  16893. clone(): ProceduralTexture;
  16894. /**
  16895. * Dispose the texture and release its asoociated resources.
  16896. */
  16897. dispose(): void;
  16898. }
  16899. }
  16900. declare module "babylonjs/Particles/baseParticleSystem" {
  16901. import { Nullable } from "babylonjs/types";
  16902. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16904. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16905. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16906. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16907. import { Scene } from "babylonjs/scene";
  16908. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16909. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16910. import { Texture } from "babylonjs/Materials/Textures/texture";
  16911. import { Color4 } from "babylonjs/Maths/math.color";
  16912. import { Animation } from "babylonjs/Animations/animation";
  16913. /**
  16914. * This represents the base class for particle system in Babylon.
  16915. * 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.
  16916. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16917. * @example https://doc.babylonjs.com/babylon101/particles
  16918. */
  16919. export class BaseParticleSystem {
  16920. /**
  16921. * Source color is added to the destination color without alpha affecting the result
  16922. */
  16923. static BLENDMODE_ONEONE: number;
  16924. /**
  16925. * Blend current color and particle color using particle’s alpha
  16926. */
  16927. static BLENDMODE_STANDARD: number;
  16928. /**
  16929. * Add current color and particle color multiplied by particle’s alpha
  16930. */
  16931. static BLENDMODE_ADD: number;
  16932. /**
  16933. * Multiply current color with particle color
  16934. */
  16935. static BLENDMODE_MULTIPLY: number;
  16936. /**
  16937. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16938. */
  16939. static BLENDMODE_MULTIPLYADD: number;
  16940. /**
  16941. * List of animations used by the particle system.
  16942. */
  16943. animations: Animation[];
  16944. /**
  16945. * The id of the Particle system.
  16946. */
  16947. id: string;
  16948. /**
  16949. * The friendly name of the Particle system.
  16950. */
  16951. name: string;
  16952. /**
  16953. * The rendering group used by the Particle system to chose when to render.
  16954. */
  16955. renderingGroupId: number;
  16956. /**
  16957. * The emitter represents the Mesh or position we are attaching the particle system to.
  16958. */
  16959. emitter: Nullable<AbstractMesh | Vector3>;
  16960. /**
  16961. * The maximum number of particles to emit per frame
  16962. */
  16963. emitRate: number;
  16964. /**
  16965. * If you want to launch only a few particles at once, that can be done, as well.
  16966. */
  16967. manualEmitCount: number;
  16968. /**
  16969. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16970. */
  16971. updateSpeed: number;
  16972. /**
  16973. * The amount of time the particle system is running (depends of the overall update speed).
  16974. */
  16975. targetStopDuration: number;
  16976. /**
  16977. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16978. */
  16979. disposeOnStop: boolean;
  16980. /**
  16981. * Minimum power of emitting particles.
  16982. */
  16983. minEmitPower: number;
  16984. /**
  16985. * Maximum power of emitting particles.
  16986. */
  16987. maxEmitPower: number;
  16988. /**
  16989. * Minimum life time of emitting particles.
  16990. */
  16991. minLifeTime: number;
  16992. /**
  16993. * Maximum life time of emitting particles.
  16994. */
  16995. maxLifeTime: number;
  16996. /**
  16997. * Minimum Size of emitting particles.
  16998. */
  16999. minSize: number;
  17000. /**
  17001. * Maximum Size of emitting particles.
  17002. */
  17003. maxSize: number;
  17004. /**
  17005. * Minimum scale of emitting particles on X axis.
  17006. */
  17007. minScaleX: number;
  17008. /**
  17009. * Maximum scale of emitting particles on X axis.
  17010. */
  17011. maxScaleX: number;
  17012. /**
  17013. * Minimum scale of emitting particles on Y axis.
  17014. */
  17015. minScaleY: number;
  17016. /**
  17017. * Maximum scale of emitting particles on Y axis.
  17018. */
  17019. maxScaleY: number;
  17020. /**
  17021. * Gets or sets the minimal initial rotation in radians.
  17022. */
  17023. minInitialRotation: number;
  17024. /**
  17025. * Gets or sets the maximal initial rotation in radians.
  17026. */
  17027. maxInitialRotation: number;
  17028. /**
  17029. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17030. */
  17031. minAngularSpeed: number;
  17032. /**
  17033. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17034. */
  17035. maxAngularSpeed: number;
  17036. /**
  17037. * The texture used to render each particle. (this can be a spritesheet)
  17038. */
  17039. particleTexture: Nullable<Texture>;
  17040. /**
  17041. * The layer mask we are rendering the particles through.
  17042. */
  17043. layerMask: number;
  17044. /**
  17045. * This can help using your own shader to render the particle system.
  17046. * The according effect will be created
  17047. */
  17048. customShader: any;
  17049. /**
  17050. * By default particle system starts as soon as they are created. This prevents the
  17051. * automatic start to happen and let you decide when to start emitting particles.
  17052. */
  17053. preventAutoStart: boolean;
  17054. private _noiseTexture;
  17055. /**
  17056. * Gets or sets a texture used to add random noise to particle positions
  17057. */
  17058. noiseTexture: Nullable<ProceduralTexture>;
  17059. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17060. noiseStrength: Vector3;
  17061. /**
  17062. * Callback triggered when the particle animation is ending.
  17063. */
  17064. onAnimationEnd: Nullable<() => void>;
  17065. /**
  17066. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17067. */
  17068. blendMode: number;
  17069. /**
  17070. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17071. * to override the particles.
  17072. */
  17073. forceDepthWrite: boolean;
  17074. /** 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 */
  17075. preWarmCycles: number;
  17076. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17077. preWarmStepOffset: number;
  17078. /**
  17079. * 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)
  17080. */
  17081. spriteCellChangeSpeed: number;
  17082. /**
  17083. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17084. */
  17085. startSpriteCellID: number;
  17086. /**
  17087. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17088. */
  17089. endSpriteCellID: number;
  17090. /**
  17091. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17092. */
  17093. spriteCellWidth: number;
  17094. /**
  17095. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17096. */
  17097. spriteCellHeight: number;
  17098. /**
  17099. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17100. */
  17101. spriteRandomStartCell: boolean;
  17102. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17103. translationPivot: Vector2;
  17104. /** @hidden */
  17105. protected _isAnimationSheetEnabled: boolean;
  17106. /**
  17107. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17108. */
  17109. beginAnimationOnStart: boolean;
  17110. /**
  17111. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17112. */
  17113. beginAnimationFrom: number;
  17114. /**
  17115. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17116. */
  17117. beginAnimationTo: number;
  17118. /**
  17119. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17120. */
  17121. beginAnimationLoop: boolean;
  17122. /**
  17123. * Gets or sets a world offset applied to all particles
  17124. */
  17125. worldOffset: Vector3;
  17126. /**
  17127. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17128. */
  17129. isAnimationSheetEnabled: boolean;
  17130. /**
  17131. * Get hosting scene
  17132. * @returns the scene
  17133. */
  17134. getScene(): Scene;
  17135. /**
  17136. * You can use gravity if you want to give an orientation to your particles.
  17137. */
  17138. gravity: Vector3;
  17139. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17140. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17141. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17142. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17143. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17144. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17145. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17146. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17147. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17148. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17149. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17150. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17151. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17152. /**
  17153. * Defines the delay in milliseconds before starting the system (0 by default)
  17154. */
  17155. startDelay: number;
  17156. /**
  17157. * Gets the current list of drag gradients.
  17158. * You must use addDragGradient and removeDragGradient to udpate this list
  17159. * @returns the list of drag gradients
  17160. */
  17161. getDragGradients(): Nullable<Array<FactorGradient>>;
  17162. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17163. limitVelocityDamping: number;
  17164. /**
  17165. * Gets the current list of limit velocity gradients.
  17166. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17167. * @returns the list of limit velocity gradients
  17168. */
  17169. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17170. /**
  17171. * Gets the current list of color gradients.
  17172. * You must use addColorGradient and removeColorGradient to udpate this list
  17173. * @returns the list of color gradients
  17174. */
  17175. getColorGradients(): Nullable<Array<ColorGradient>>;
  17176. /**
  17177. * Gets the current list of size gradients.
  17178. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17179. * @returns the list of size gradients
  17180. */
  17181. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17182. /**
  17183. * Gets the current list of color remap gradients.
  17184. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17185. * @returns the list of color remap gradients
  17186. */
  17187. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17188. /**
  17189. * Gets the current list of alpha remap gradients.
  17190. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17191. * @returns the list of alpha remap gradients
  17192. */
  17193. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17194. /**
  17195. * Gets the current list of life time gradients.
  17196. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17197. * @returns the list of life time gradients
  17198. */
  17199. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17200. /**
  17201. * Gets the current list of angular speed gradients.
  17202. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17203. * @returns the list of angular speed gradients
  17204. */
  17205. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17206. /**
  17207. * Gets the current list of velocity gradients.
  17208. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17209. * @returns the list of velocity gradients
  17210. */
  17211. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17212. /**
  17213. * Gets the current list of start size gradients.
  17214. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17215. * @returns the list of start size gradients
  17216. */
  17217. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17218. /**
  17219. * Gets the current list of emit rate gradients.
  17220. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17221. * @returns the list of emit rate gradients
  17222. */
  17223. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17224. /**
  17225. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17226. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17227. */
  17228. direction1: Vector3;
  17229. /**
  17230. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17231. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17232. */
  17233. direction2: Vector3;
  17234. /**
  17235. * 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.
  17236. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17237. */
  17238. minEmitBox: Vector3;
  17239. /**
  17240. * 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.
  17241. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17242. */
  17243. maxEmitBox: Vector3;
  17244. /**
  17245. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17246. */
  17247. color1: Color4;
  17248. /**
  17249. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17250. */
  17251. color2: Color4;
  17252. /**
  17253. * Color the particle will have at the end of its lifetime
  17254. */
  17255. colorDead: Color4;
  17256. /**
  17257. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17258. */
  17259. textureMask: Color4;
  17260. /**
  17261. * The particle emitter type defines the emitter used by the particle system.
  17262. * It can be for example box, sphere, or cone...
  17263. */
  17264. particleEmitterType: IParticleEmitterType;
  17265. /** @hidden */
  17266. _isSubEmitter: boolean;
  17267. /**
  17268. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17269. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17270. */
  17271. billboardMode: number;
  17272. protected _isBillboardBased: boolean;
  17273. /**
  17274. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17275. */
  17276. isBillboardBased: boolean;
  17277. /**
  17278. * The scene the particle system belongs to.
  17279. */
  17280. protected _scene: Scene;
  17281. /**
  17282. * Local cache of defines for image processing.
  17283. */
  17284. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17285. /**
  17286. * Default configuration related to image processing available in the standard Material.
  17287. */
  17288. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17289. /**
  17290. * Gets the image processing configuration used either in this material.
  17291. */
  17292. /**
  17293. * Sets the Default image processing configuration used either in the this material.
  17294. *
  17295. * If sets to null, the scene one is in use.
  17296. */
  17297. imageProcessingConfiguration: ImageProcessingConfiguration;
  17298. /**
  17299. * Attaches a new image processing configuration to the Standard Material.
  17300. * @param configuration
  17301. */
  17302. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17303. /** @hidden */
  17304. protected _reset(): void;
  17305. /** @hidden */
  17306. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17307. /**
  17308. * Instantiates a particle system.
  17309. * 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.
  17310. * @param name The name of the particle system
  17311. */
  17312. constructor(name: string);
  17313. /**
  17314. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17315. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17316. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17317. * @returns the emitter
  17318. */
  17319. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17320. /**
  17321. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17322. * @param radius The radius of the hemisphere to emit from
  17323. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17324. * @returns the emitter
  17325. */
  17326. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17327. /**
  17328. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17329. * @param radius The radius of the sphere to emit from
  17330. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17331. * @returns the emitter
  17332. */
  17333. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17334. /**
  17335. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17336. * @param radius The radius of the sphere to emit from
  17337. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17338. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17339. * @returns the emitter
  17340. */
  17341. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17342. /**
  17343. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17344. * @param radius The radius of the emission cylinder
  17345. * @param height The height of the emission cylinder
  17346. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17347. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17348. * @returns the emitter
  17349. */
  17350. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17351. /**
  17352. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17353. * @param radius The radius of the cylinder to emit from
  17354. * @param height The height of the emission cylinder
  17355. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17356. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17357. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17358. * @returns the emitter
  17359. */
  17360. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17361. /**
  17362. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17363. * @param radius The radius of the cone to emit from
  17364. * @param angle The base angle of the cone
  17365. * @returns the emitter
  17366. */
  17367. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17368. /**
  17369. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17370. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17371. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17372. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17373. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17374. * @returns the emitter
  17375. */
  17376. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17377. }
  17378. }
  17379. declare module "babylonjs/Particles/subEmitter" {
  17380. import { Scene } from "babylonjs/scene";
  17381. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17382. /**
  17383. * Type of sub emitter
  17384. */
  17385. export enum SubEmitterType {
  17386. /**
  17387. * Attached to the particle over it's lifetime
  17388. */
  17389. ATTACHED = 0,
  17390. /**
  17391. * Created when the particle dies
  17392. */
  17393. END = 1
  17394. }
  17395. /**
  17396. * Sub emitter class used to emit particles from an existing particle
  17397. */
  17398. export class SubEmitter {
  17399. /**
  17400. * the particle system to be used by the sub emitter
  17401. */
  17402. particleSystem: ParticleSystem;
  17403. /**
  17404. * Type of the submitter (Default: END)
  17405. */
  17406. type: SubEmitterType;
  17407. /**
  17408. * 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)
  17409. * Note: This only is supported when using an emitter of type Mesh
  17410. */
  17411. inheritDirection: boolean;
  17412. /**
  17413. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17414. */
  17415. inheritedVelocityAmount: number;
  17416. /**
  17417. * Creates a sub emitter
  17418. * @param particleSystem the particle system to be used by the sub emitter
  17419. */
  17420. constructor(
  17421. /**
  17422. * the particle system to be used by the sub emitter
  17423. */
  17424. particleSystem: ParticleSystem);
  17425. /**
  17426. * Clones the sub emitter
  17427. * @returns the cloned sub emitter
  17428. */
  17429. clone(): SubEmitter;
  17430. /**
  17431. * Serialize current object to a JSON object
  17432. * @returns the serialized object
  17433. */
  17434. serialize(): any;
  17435. /** @hidden */
  17436. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17437. /**
  17438. * Creates a new SubEmitter from a serialized JSON version
  17439. * @param serializationObject defines the JSON object to read from
  17440. * @param scene defines the hosting scene
  17441. * @param rootUrl defines the rootUrl for data loading
  17442. * @returns a new SubEmitter
  17443. */
  17444. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17445. /** Release associated resources */
  17446. dispose(): void;
  17447. }
  17448. }
  17449. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17450. /** @hidden */
  17451. export var clipPlaneFragmentDeclaration: {
  17452. name: string;
  17453. shader: string;
  17454. };
  17455. }
  17456. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17457. /** @hidden */
  17458. export var imageProcessingDeclaration: {
  17459. name: string;
  17460. shader: string;
  17461. };
  17462. }
  17463. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17464. /** @hidden */
  17465. export var imageProcessingFunctions: {
  17466. name: string;
  17467. shader: string;
  17468. };
  17469. }
  17470. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17471. /** @hidden */
  17472. export var clipPlaneFragment: {
  17473. name: string;
  17474. shader: string;
  17475. };
  17476. }
  17477. declare module "babylonjs/Shaders/particles.fragment" {
  17478. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17479. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17480. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17481. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17482. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17483. /** @hidden */
  17484. export var particlesPixelShader: {
  17485. name: string;
  17486. shader: string;
  17487. };
  17488. }
  17489. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17490. /** @hidden */
  17491. export var clipPlaneVertexDeclaration: {
  17492. name: string;
  17493. shader: string;
  17494. };
  17495. }
  17496. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17497. /** @hidden */
  17498. export var clipPlaneVertex: {
  17499. name: string;
  17500. shader: string;
  17501. };
  17502. }
  17503. declare module "babylonjs/Shaders/particles.vertex" {
  17504. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17505. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17506. /** @hidden */
  17507. export var particlesVertexShader: {
  17508. name: string;
  17509. shader: string;
  17510. };
  17511. }
  17512. declare module "babylonjs/Particles/particleSystem" {
  17513. import { Nullable } from "babylonjs/types";
  17514. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17515. import { Observable } from "babylonjs/Misc/observable";
  17516. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17517. import { Effect } from "babylonjs/Materials/effect";
  17518. import { Scene, IDisposable } from "babylonjs/scene";
  17519. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17520. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17521. import { Particle } from "babylonjs/Particles/particle";
  17522. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17523. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17524. import "babylonjs/Shaders/particles.fragment";
  17525. import "babylonjs/Shaders/particles.vertex";
  17526. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17527. /**
  17528. * This represents a particle system in Babylon.
  17529. * 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.
  17530. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17531. * @example https://doc.babylonjs.com/babylon101/particles
  17532. */
  17533. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17534. /**
  17535. * Billboard mode will only apply to Y axis
  17536. */
  17537. static readonly BILLBOARDMODE_Y: number;
  17538. /**
  17539. * Billboard mode will apply to all axes
  17540. */
  17541. static readonly BILLBOARDMODE_ALL: number;
  17542. /**
  17543. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17544. */
  17545. static readonly BILLBOARDMODE_STRETCHED: number;
  17546. /**
  17547. * This function can be defined to provide custom update for active particles.
  17548. * This function will be called instead of regular update (age, position, color, etc.).
  17549. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17550. */
  17551. updateFunction: (particles: Particle[]) => void;
  17552. private _emitterWorldMatrix;
  17553. /**
  17554. * This function can be defined to specify initial direction for every new particle.
  17555. * It by default use the emitterType defined function
  17556. */
  17557. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17558. /**
  17559. * This function can be defined to specify initial position for every new particle.
  17560. * It by default use the emitterType defined function
  17561. */
  17562. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17563. /**
  17564. * @hidden
  17565. */
  17566. _inheritedVelocityOffset: Vector3;
  17567. /**
  17568. * An event triggered when the system is disposed
  17569. */
  17570. onDisposeObservable: Observable<ParticleSystem>;
  17571. private _onDisposeObserver;
  17572. /**
  17573. * Sets a callback that will be triggered when the system is disposed
  17574. */
  17575. onDispose: () => void;
  17576. private _particles;
  17577. private _epsilon;
  17578. private _capacity;
  17579. private _stockParticles;
  17580. private _newPartsExcess;
  17581. private _vertexData;
  17582. private _vertexBuffer;
  17583. private _vertexBuffers;
  17584. private _spriteBuffer;
  17585. private _indexBuffer;
  17586. private _effect;
  17587. private _customEffect;
  17588. private _cachedDefines;
  17589. private _scaledColorStep;
  17590. private _colorDiff;
  17591. private _scaledDirection;
  17592. private _scaledGravity;
  17593. private _currentRenderId;
  17594. private _alive;
  17595. private _useInstancing;
  17596. private _started;
  17597. private _stopped;
  17598. private _actualFrame;
  17599. private _scaledUpdateSpeed;
  17600. private _vertexBufferSize;
  17601. /** @hidden */
  17602. _currentEmitRateGradient: Nullable<FactorGradient>;
  17603. /** @hidden */
  17604. _currentEmitRate1: number;
  17605. /** @hidden */
  17606. _currentEmitRate2: number;
  17607. /** @hidden */
  17608. _currentStartSizeGradient: Nullable<FactorGradient>;
  17609. /** @hidden */
  17610. _currentStartSize1: number;
  17611. /** @hidden */
  17612. _currentStartSize2: number;
  17613. private readonly _rawTextureWidth;
  17614. private _rampGradientsTexture;
  17615. private _useRampGradients;
  17616. /** Gets or sets a boolean indicating that ramp gradients must be used
  17617. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17618. */
  17619. useRampGradients: boolean;
  17620. /**
  17621. * 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.
  17622. * 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: [])
  17623. */
  17624. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17625. private _subEmitters;
  17626. /**
  17627. * @hidden
  17628. * If the particle systems emitter should be disposed when the particle system is disposed
  17629. */
  17630. _disposeEmitterOnDispose: boolean;
  17631. /**
  17632. * The current active Sub-systems, this property is used by the root particle system only.
  17633. */
  17634. activeSubSystems: Array<ParticleSystem>;
  17635. private _rootParticleSystem;
  17636. /**
  17637. * Gets the current list of active particles
  17638. */
  17639. readonly particles: Particle[];
  17640. /**
  17641. * Returns the string "ParticleSystem"
  17642. * @returns a string containing the class name
  17643. */
  17644. getClassName(): string;
  17645. /**
  17646. * Instantiates a particle system.
  17647. * 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.
  17648. * @param name The name of the particle system
  17649. * @param capacity The max number of particles alive at the same time
  17650. * @param scene The scene the particle system belongs to
  17651. * @param customEffect a custom effect used to change the way particles are rendered by default
  17652. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17653. * @param epsilon Offset used to render the particles
  17654. */
  17655. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17656. private _addFactorGradient;
  17657. private _removeFactorGradient;
  17658. /**
  17659. * Adds a new life time gradient
  17660. * @param gradient defines the gradient to use (between 0 and 1)
  17661. * @param factor defines the life time factor to affect to the specified gradient
  17662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17663. * @returns the current particle system
  17664. */
  17665. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17666. /**
  17667. * Remove a specific life time gradient
  17668. * @param gradient defines the gradient to remove
  17669. * @returns the current particle system
  17670. */
  17671. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17672. /**
  17673. * Adds a new size gradient
  17674. * @param gradient defines the gradient to use (between 0 and 1)
  17675. * @param factor defines the size factor to affect to the specified gradient
  17676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17677. * @returns the current particle system
  17678. */
  17679. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17680. /**
  17681. * Remove a specific size gradient
  17682. * @param gradient defines the gradient to remove
  17683. * @returns the current particle system
  17684. */
  17685. removeSizeGradient(gradient: number): IParticleSystem;
  17686. /**
  17687. * Adds a new color remap gradient
  17688. * @param gradient defines the gradient to use (between 0 and 1)
  17689. * @param min defines the color remap minimal range
  17690. * @param max defines the color remap maximal range
  17691. * @returns the current particle system
  17692. */
  17693. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17694. /**
  17695. * Remove a specific color remap gradient
  17696. * @param gradient defines the gradient to remove
  17697. * @returns the current particle system
  17698. */
  17699. removeColorRemapGradient(gradient: number): IParticleSystem;
  17700. /**
  17701. * Adds a new alpha remap gradient
  17702. * @param gradient defines the gradient to use (between 0 and 1)
  17703. * @param min defines the alpha remap minimal range
  17704. * @param max defines the alpha remap maximal range
  17705. * @returns the current particle system
  17706. */
  17707. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17708. /**
  17709. * Remove a specific alpha remap gradient
  17710. * @param gradient defines the gradient to remove
  17711. * @returns the current particle system
  17712. */
  17713. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17714. /**
  17715. * Adds a new angular speed gradient
  17716. * @param gradient defines the gradient to use (between 0 and 1)
  17717. * @param factor defines the angular speed to affect to the specified gradient
  17718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17719. * @returns the current particle system
  17720. */
  17721. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17722. /**
  17723. * Remove a specific angular speed gradient
  17724. * @param gradient defines the gradient to remove
  17725. * @returns the current particle system
  17726. */
  17727. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17728. /**
  17729. * Adds a new velocity gradient
  17730. * @param gradient defines the gradient to use (between 0 and 1)
  17731. * @param factor defines the velocity to affect to the specified gradient
  17732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17733. * @returns the current particle system
  17734. */
  17735. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17736. /**
  17737. * Remove a specific velocity gradient
  17738. * @param gradient defines the gradient to remove
  17739. * @returns the current particle system
  17740. */
  17741. removeVelocityGradient(gradient: number): IParticleSystem;
  17742. /**
  17743. * Adds a new limit velocity gradient
  17744. * @param gradient defines the gradient to use (between 0 and 1)
  17745. * @param factor defines the limit velocity value to affect to the specified gradient
  17746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17747. * @returns the current particle system
  17748. */
  17749. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17750. /**
  17751. * Remove a specific limit velocity gradient
  17752. * @param gradient defines the gradient to remove
  17753. * @returns the current particle system
  17754. */
  17755. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17756. /**
  17757. * Adds a new drag gradient
  17758. * @param gradient defines the gradient to use (between 0 and 1)
  17759. * @param factor defines the drag value to affect to the specified gradient
  17760. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17761. * @returns the current particle system
  17762. */
  17763. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17764. /**
  17765. * Remove a specific drag gradient
  17766. * @param gradient defines the gradient to remove
  17767. * @returns the current particle system
  17768. */
  17769. removeDragGradient(gradient: number): IParticleSystem;
  17770. /**
  17771. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17772. * @param gradient defines the gradient to use (between 0 and 1)
  17773. * @param factor defines the emit rate value to affect to the specified gradient
  17774. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17775. * @returns the current particle system
  17776. */
  17777. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17778. /**
  17779. * Remove a specific emit rate gradient
  17780. * @param gradient defines the gradient to remove
  17781. * @returns the current particle system
  17782. */
  17783. removeEmitRateGradient(gradient: number): IParticleSystem;
  17784. /**
  17785. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17786. * @param gradient defines the gradient to use (between 0 and 1)
  17787. * @param factor defines the start size value to affect to the specified gradient
  17788. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17789. * @returns the current particle system
  17790. */
  17791. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17792. /**
  17793. * Remove a specific start size gradient
  17794. * @param gradient defines the gradient to remove
  17795. * @returns the current particle system
  17796. */
  17797. removeStartSizeGradient(gradient: number): IParticleSystem;
  17798. private _createRampGradientTexture;
  17799. /**
  17800. * Gets the current list of ramp gradients.
  17801. * You must use addRampGradient and removeRampGradient to udpate this list
  17802. * @returns the list of ramp gradients
  17803. */
  17804. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17805. /**
  17806. * Adds a new ramp gradient used to remap particle colors
  17807. * @param gradient defines the gradient to use (between 0 and 1)
  17808. * @param color defines the color to affect to the specified gradient
  17809. * @returns the current particle system
  17810. */
  17811. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17812. /**
  17813. * Remove a specific ramp gradient
  17814. * @param gradient defines the gradient to remove
  17815. * @returns the current particle system
  17816. */
  17817. removeRampGradient(gradient: number): ParticleSystem;
  17818. /**
  17819. * Adds a new color gradient
  17820. * @param gradient defines the gradient to use (between 0 and 1)
  17821. * @param color1 defines the color to affect to the specified gradient
  17822. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17823. * @returns this particle system
  17824. */
  17825. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17826. /**
  17827. * Remove a specific color gradient
  17828. * @param gradient defines the gradient to remove
  17829. * @returns this particle system
  17830. */
  17831. removeColorGradient(gradient: number): IParticleSystem;
  17832. private _fetchR;
  17833. protected _reset(): void;
  17834. private _resetEffect;
  17835. private _createVertexBuffers;
  17836. private _createIndexBuffer;
  17837. /**
  17838. * Gets the maximum number of particles active at the same time.
  17839. * @returns The max number of active particles.
  17840. */
  17841. getCapacity(): number;
  17842. /**
  17843. * Gets whether there are still active particles in the system.
  17844. * @returns True if it is alive, otherwise false.
  17845. */
  17846. isAlive(): boolean;
  17847. /**
  17848. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17849. * @returns True if it has been started, otherwise false.
  17850. */
  17851. isStarted(): boolean;
  17852. private _prepareSubEmitterInternalArray;
  17853. /**
  17854. * Starts the particle system and begins to emit
  17855. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17856. */
  17857. start(delay?: number): void;
  17858. /**
  17859. * Stops the particle system.
  17860. * @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.
  17861. */
  17862. stop(stopSubEmitters?: boolean): void;
  17863. /**
  17864. * Remove all active particles
  17865. */
  17866. reset(): void;
  17867. /**
  17868. * @hidden (for internal use only)
  17869. */
  17870. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17871. /**
  17872. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17873. * Its lifetime will start back at 0.
  17874. */
  17875. recycleParticle: (particle: Particle) => void;
  17876. private _stopSubEmitters;
  17877. private _createParticle;
  17878. private _removeFromRoot;
  17879. private _emitFromParticle;
  17880. private _update;
  17881. /** @hidden */
  17882. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17883. /** @hidden */
  17884. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17885. /** @hidden */
  17886. private _getEffect;
  17887. /**
  17888. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17889. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17890. */
  17891. animate(preWarmOnly?: boolean): void;
  17892. private _appendParticleVertices;
  17893. /**
  17894. * Rebuilds the particle system.
  17895. */
  17896. rebuild(): void;
  17897. /**
  17898. * Is this system ready to be used/rendered
  17899. * @return true if the system is ready
  17900. */
  17901. isReady(): boolean;
  17902. private _render;
  17903. /**
  17904. * Renders the particle system in its current state.
  17905. * @returns the current number of particles
  17906. */
  17907. render(): number;
  17908. /**
  17909. * Disposes the particle system and free the associated resources
  17910. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17911. */
  17912. dispose(disposeTexture?: boolean): void;
  17913. /**
  17914. * Clones the particle system.
  17915. * @param name The name of the cloned object
  17916. * @param newEmitter The new emitter to use
  17917. * @returns the cloned particle system
  17918. */
  17919. clone(name: string, newEmitter: any): ParticleSystem;
  17920. /**
  17921. * Serializes the particle system to a JSON object.
  17922. * @returns the JSON object
  17923. */
  17924. serialize(): any;
  17925. /** @hidden */
  17926. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17927. /** @hidden */
  17928. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17929. /**
  17930. * Parses a JSON object to create a particle system.
  17931. * @param parsedParticleSystem The JSON object to parse
  17932. * @param scene The scene to create the particle system in
  17933. * @param rootUrl The root url to use to load external dependencies like texture
  17934. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17935. * @returns the Parsed particle system
  17936. */
  17937. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17938. }
  17939. }
  17940. declare module "babylonjs/Particles/particle" {
  17941. import { Nullable } from "babylonjs/types";
  17942. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17943. import { Color4 } from "babylonjs/Maths/math.color";
  17944. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17945. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17946. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17947. /**
  17948. * A particle represents one of the element emitted by a particle system.
  17949. * This is mainly define by its coordinates, direction, velocity and age.
  17950. */
  17951. export class Particle {
  17952. /**
  17953. * The particle system the particle belongs to.
  17954. */
  17955. particleSystem: ParticleSystem;
  17956. private static _Count;
  17957. /**
  17958. * Unique ID of the particle
  17959. */
  17960. id: number;
  17961. /**
  17962. * The world position of the particle in the scene.
  17963. */
  17964. position: Vector3;
  17965. /**
  17966. * The world direction of the particle in the scene.
  17967. */
  17968. direction: Vector3;
  17969. /**
  17970. * The color of the particle.
  17971. */
  17972. color: Color4;
  17973. /**
  17974. * The color change of the particle per step.
  17975. */
  17976. colorStep: Color4;
  17977. /**
  17978. * Defines how long will the life of the particle be.
  17979. */
  17980. lifeTime: number;
  17981. /**
  17982. * The current age of the particle.
  17983. */
  17984. age: number;
  17985. /**
  17986. * The current size of the particle.
  17987. */
  17988. size: number;
  17989. /**
  17990. * The current scale of the particle.
  17991. */
  17992. scale: Vector2;
  17993. /**
  17994. * The current angle of the particle.
  17995. */
  17996. angle: number;
  17997. /**
  17998. * Defines how fast is the angle changing.
  17999. */
  18000. angularSpeed: number;
  18001. /**
  18002. * Defines the cell index used by the particle to be rendered from a sprite.
  18003. */
  18004. cellIndex: number;
  18005. /**
  18006. * The information required to support color remapping
  18007. */
  18008. remapData: Vector4;
  18009. /** @hidden */
  18010. _randomCellOffset?: number;
  18011. /** @hidden */
  18012. _initialDirection: Nullable<Vector3>;
  18013. /** @hidden */
  18014. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18015. /** @hidden */
  18016. _initialStartSpriteCellID: number;
  18017. /** @hidden */
  18018. _initialEndSpriteCellID: number;
  18019. /** @hidden */
  18020. _currentColorGradient: Nullable<ColorGradient>;
  18021. /** @hidden */
  18022. _currentColor1: Color4;
  18023. /** @hidden */
  18024. _currentColor2: Color4;
  18025. /** @hidden */
  18026. _currentSizeGradient: Nullable<FactorGradient>;
  18027. /** @hidden */
  18028. _currentSize1: number;
  18029. /** @hidden */
  18030. _currentSize2: number;
  18031. /** @hidden */
  18032. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18033. /** @hidden */
  18034. _currentAngularSpeed1: number;
  18035. /** @hidden */
  18036. _currentAngularSpeed2: number;
  18037. /** @hidden */
  18038. _currentVelocityGradient: Nullable<FactorGradient>;
  18039. /** @hidden */
  18040. _currentVelocity1: number;
  18041. /** @hidden */
  18042. _currentVelocity2: number;
  18043. /** @hidden */
  18044. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18045. /** @hidden */
  18046. _currentLimitVelocity1: number;
  18047. /** @hidden */
  18048. _currentLimitVelocity2: number;
  18049. /** @hidden */
  18050. _currentDragGradient: Nullable<FactorGradient>;
  18051. /** @hidden */
  18052. _currentDrag1: number;
  18053. /** @hidden */
  18054. _currentDrag2: number;
  18055. /** @hidden */
  18056. _randomNoiseCoordinates1: Vector3;
  18057. /** @hidden */
  18058. _randomNoiseCoordinates2: Vector3;
  18059. /**
  18060. * Creates a new instance Particle
  18061. * @param particleSystem the particle system the particle belongs to
  18062. */
  18063. constructor(
  18064. /**
  18065. * The particle system the particle belongs to.
  18066. */
  18067. particleSystem: ParticleSystem);
  18068. private updateCellInfoFromSystem;
  18069. /**
  18070. * Defines how the sprite cell index is updated for the particle
  18071. */
  18072. updateCellIndex(): void;
  18073. /** @hidden */
  18074. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18075. /** @hidden */
  18076. _inheritParticleInfoToSubEmitters(): void;
  18077. /** @hidden */
  18078. _reset(): void;
  18079. /**
  18080. * Copy the properties of particle to another one.
  18081. * @param other the particle to copy the information to.
  18082. */
  18083. copyTo(other: Particle): void;
  18084. }
  18085. }
  18086. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18087. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18088. import { Effect } from "babylonjs/Materials/effect";
  18089. import { Particle } from "babylonjs/Particles/particle";
  18090. /**
  18091. * Particle emitter represents a volume emitting particles.
  18092. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18093. */
  18094. export interface IParticleEmitterType {
  18095. /**
  18096. * Called by the particle System when the direction is computed for the created particle.
  18097. * @param worldMatrix is the world matrix of the particle system
  18098. * @param directionToUpdate is the direction vector to update with the result
  18099. * @param particle is the particle we are computed the direction for
  18100. */
  18101. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18102. /**
  18103. * Called by the particle System when the position is computed for the created particle.
  18104. * @param worldMatrix is the world matrix of the particle system
  18105. * @param positionToUpdate is the position vector to update with the result
  18106. * @param particle is the particle we are computed the position for
  18107. */
  18108. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18109. /**
  18110. * Clones the current emitter and returns a copy of it
  18111. * @returns the new emitter
  18112. */
  18113. clone(): IParticleEmitterType;
  18114. /**
  18115. * Called by the GPUParticleSystem to setup the update shader
  18116. * @param effect defines the update shader
  18117. */
  18118. applyToShader(effect: Effect): void;
  18119. /**
  18120. * Returns a string to use to update the GPU particles update shader
  18121. * @returns the effect defines string
  18122. */
  18123. getEffectDefines(): string;
  18124. /**
  18125. * Returns a string representing the class name
  18126. * @returns a string containing the class name
  18127. */
  18128. getClassName(): string;
  18129. /**
  18130. * Serializes the particle system to a JSON object.
  18131. * @returns the JSON object
  18132. */
  18133. serialize(): any;
  18134. /**
  18135. * Parse properties from a JSON object
  18136. * @param serializationObject defines the JSON object
  18137. */
  18138. parse(serializationObject: any): void;
  18139. }
  18140. }
  18141. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18142. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18143. import { Effect } from "babylonjs/Materials/effect";
  18144. import { Particle } from "babylonjs/Particles/particle";
  18145. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18146. /**
  18147. * Particle emitter emitting particles from the inside of a box.
  18148. * It emits the particles randomly between 2 given directions.
  18149. */
  18150. export class BoxParticleEmitter implements IParticleEmitterType {
  18151. /**
  18152. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18153. */
  18154. direction1: Vector3;
  18155. /**
  18156. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18157. */
  18158. direction2: Vector3;
  18159. /**
  18160. * 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.
  18161. */
  18162. minEmitBox: Vector3;
  18163. /**
  18164. * 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.
  18165. */
  18166. maxEmitBox: Vector3;
  18167. /**
  18168. * Creates a new instance BoxParticleEmitter
  18169. */
  18170. constructor();
  18171. /**
  18172. * Called by the particle System when the direction is computed for the created particle.
  18173. * @param worldMatrix is the world matrix of the particle system
  18174. * @param directionToUpdate is the direction vector to update with the result
  18175. * @param particle is the particle we are computed the direction for
  18176. */
  18177. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18178. /**
  18179. * Called by the particle System when the position is computed for the created particle.
  18180. * @param worldMatrix is the world matrix of the particle system
  18181. * @param positionToUpdate is the position vector to update with the result
  18182. * @param particle is the particle we are computed the position for
  18183. */
  18184. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18185. /**
  18186. * Clones the current emitter and returns a copy of it
  18187. * @returns the new emitter
  18188. */
  18189. clone(): BoxParticleEmitter;
  18190. /**
  18191. * Called by the GPUParticleSystem to setup the update shader
  18192. * @param effect defines the update shader
  18193. */
  18194. applyToShader(effect: Effect): void;
  18195. /**
  18196. * Returns a string to use to update the GPU particles update shader
  18197. * @returns a string containng the defines string
  18198. */
  18199. getEffectDefines(): string;
  18200. /**
  18201. * Returns the string "BoxParticleEmitter"
  18202. * @returns a string containing the class name
  18203. */
  18204. getClassName(): string;
  18205. /**
  18206. * Serializes the particle system to a JSON object.
  18207. * @returns the JSON object
  18208. */
  18209. serialize(): any;
  18210. /**
  18211. * Parse properties from a JSON object
  18212. * @param serializationObject defines the JSON object
  18213. */
  18214. parse(serializationObject: any): void;
  18215. }
  18216. }
  18217. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18218. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18219. import { Effect } from "babylonjs/Materials/effect";
  18220. import { Particle } from "babylonjs/Particles/particle";
  18221. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18222. /**
  18223. * Particle emitter emitting particles from the inside of a cone.
  18224. * It emits the particles alongside the cone volume from the base to the particle.
  18225. * The emission direction might be randomized.
  18226. */
  18227. export class ConeParticleEmitter implements IParticleEmitterType {
  18228. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18229. directionRandomizer: number;
  18230. private _radius;
  18231. private _angle;
  18232. private _height;
  18233. /**
  18234. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18235. */
  18236. radiusRange: number;
  18237. /**
  18238. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18239. */
  18240. heightRange: number;
  18241. /**
  18242. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18243. */
  18244. emitFromSpawnPointOnly: boolean;
  18245. /**
  18246. * Gets or sets the radius of the emission cone
  18247. */
  18248. radius: number;
  18249. /**
  18250. * Gets or sets the angle of the emission cone
  18251. */
  18252. angle: number;
  18253. private _buildHeight;
  18254. /**
  18255. * Creates a new instance ConeParticleEmitter
  18256. * @param radius the radius of the emission cone (1 by default)
  18257. * @param angle the cone base angle (PI by default)
  18258. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18259. */
  18260. constructor(radius?: number, angle?: number,
  18261. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18262. directionRandomizer?: number);
  18263. /**
  18264. * Called by the particle System when the direction is computed for the created particle.
  18265. * @param worldMatrix is the world matrix of the particle system
  18266. * @param directionToUpdate is the direction vector to update with the result
  18267. * @param particle is the particle we are computed the direction for
  18268. */
  18269. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18270. /**
  18271. * Called by the particle System when the position is computed for the created particle.
  18272. * @param worldMatrix is the world matrix of the particle system
  18273. * @param positionToUpdate is the position vector to update with the result
  18274. * @param particle is the particle we are computed the position for
  18275. */
  18276. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18277. /**
  18278. * Clones the current emitter and returns a copy of it
  18279. * @returns the new emitter
  18280. */
  18281. clone(): ConeParticleEmitter;
  18282. /**
  18283. * Called by the GPUParticleSystem to setup the update shader
  18284. * @param effect defines the update shader
  18285. */
  18286. applyToShader(effect: Effect): void;
  18287. /**
  18288. * Returns a string to use to update the GPU particles update shader
  18289. * @returns a string containng the defines string
  18290. */
  18291. getEffectDefines(): string;
  18292. /**
  18293. * Returns the string "ConeParticleEmitter"
  18294. * @returns a string containing the class name
  18295. */
  18296. getClassName(): string;
  18297. /**
  18298. * Serializes the particle system to a JSON object.
  18299. * @returns the JSON object
  18300. */
  18301. serialize(): any;
  18302. /**
  18303. * Parse properties from a JSON object
  18304. * @param serializationObject defines the JSON object
  18305. */
  18306. parse(serializationObject: any): void;
  18307. }
  18308. }
  18309. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18310. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18311. import { Effect } from "babylonjs/Materials/effect";
  18312. import { Particle } from "babylonjs/Particles/particle";
  18313. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18314. /**
  18315. * Particle emitter emitting particles from the inside of a cylinder.
  18316. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18317. */
  18318. export class CylinderParticleEmitter implements IParticleEmitterType {
  18319. /**
  18320. * The radius of the emission cylinder.
  18321. */
  18322. radius: number;
  18323. /**
  18324. * The height of the emission cylinder.
  18325. */
  18326. height: number;
  18327. /**
  18328. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18329. */
  18330. radiusRange: number;
  18331. /**
  18332. * How much to randomize the particle direction [0-1].
  18333. */
  18334. directionRandomizer: number;
  18335. /**
  18336. * Creates a new instance CylinderParticleEmitter
  18337. * @param radius the radius of the emission cylinder (1 by default)
  18338. * @param height the height of the emission cylinder (1 by default)
  18339. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18340. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18341. */
  18342. constructor(
  18343. /**
  18344. * The radius of the emission cylinder.
  18345. */
  18346. radius?: number,
  18347. /**
  18348. * The height of the emission cylinder.
  18349. */
  18350. height?: number,
  18351. /**
  18352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18353. */
  18354. radiusRange?: number,
  18355. /**
  18356. * How much to randomize the particle direction [0-1].
  18357. */
  18358. directionRandomizer?: number);
  18359. /**
  18360. * Called by the particle System when the direction is computed for the created particle.
  18361. * @param worldMatrix is the world matrix of the particle system
  18362. * @param directionToUpdate is the direction vector to update with the result
  18363. * @param particle is the particle we are computed the direction for
  18364. */
  18365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18366. /**
  18367. * Called by the particle System when the position is computed for the created particle.
  18368. * @param worldMatrix is the world matrix of the particle system
  18369. * @param positionToUpdate is the position vector to update with the result
  18370. * @param particle is the particle we are computed the position for
  18371. */
  18372. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18373. /**
  18374. * Clones the current emitter and returns a copy of it
  18375. * @returns the new emitter
  18376. */
  18377. clone(): CylinderParticleEmitter;
  18378. /**
  18379. * Called by the GPUParticleSystem to setup the update shader
  18380. * @param effect defines the update shader
  18381. */
  18382. applyToShader(effect: Effect): void;
  18383. /**
  18384. * Returns a string to use to update the GPU particles update shader
  18385. * @returns a string containng the defines string
  18386. */
  18387. getEffectDefines(): string;
  18388. /**
  18389. * Returns the string "CylinderParticleEmitter"
  18390. * @returns a string containing the class name
  18391. */
  18392. getClassName(): string;
  18393. /**
  18394. * Serializes the particle system to a JSON object.
  18395. * @returns the JSON object
  18396. */
  18397. serialize(): any;
  18398. /**
  18399. * Parse properties from a JSON object
  18400. * @param serializationObject defines the JSON object
  18401. */
  18402. parse(serializationObject: any): void;
  18403. }
  18404. /**
  18405. * Particle emitter emitting particles from the inside of a cylinder.
  18406. * It emits the particles randomly between two vectors.
  18407. */
  18408. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18409. /**
  18410. * The min limit of the emission direction.
  18411. */
  18412. direction1: Vector3;
  18413. /**
  18414. * The max limit of the emission direction.
  18415. */
  18416. direction2: Vector3;
  18417. /**
  18418. * Creates a new instance CylinderDirectedParticleEmitter
  18419. * @param radius the radius of the emission cylinder (1 by default)
  18420. * @param height the height of the emission cylinder (1 by default)
  18421. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18422. * @param direction1 the min limit of the emission direction (up vector by default)
  18423. * @param direction2 the max limit of the emission direction (up vector by default)
  18424. */
  18425. constructor(radius?: number, height?: number, radiusRange?: number,
  18426. /**
  18427. * The min limit of the emission direction.
  18428. */
  18429. direction1?: Vector3,
  18430. /**
  18431. * The max limit of the emission direction.
  18432. */
  18433. direction2?: Vector3);
  18434. /**
  18435. * Called by the particle System when the direction is computed for the created particle.
  18436. * @param worldMatrix is the world matrix of the particle system
  18437. * @param directionToUpdate is the direction vector to update with the result
  18438. * @param particle is the particle we are computed the direction for
  18439. */
  18440. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18441. /**
  18442. * Clones the current emitter and returns a copy of it
  18443. * @returns the new emitter
  18444. */
  18445. clone(): CylinderDirectedParticleEmitter;
  18446. /**
  18447. * Called by the GPUParticleSystem to setup the update shader
  18448. * @param effect defines the update shader
  18449. */
  18450. applyToShader(effect: Effect): void;
  18451. /**
  18452. * Returns a string to use to update the GPU particles update shader
  18453. * @returns a string containng the defines string
  18454. */
  18455. getEffectDefines(): string;
  18456. /**
  18457. * Returns the string "CylinderDirectedParticleEmitter"
  18458. * @returns a string containing the class name
  18459. */
  18460. getClassName(): string;
  18461. /**
  18462. * Serializes the particle system to a JSON object.
  18463. * @returns the JSON object
  18464. */
  18465. serialize(): any;
  18466. /**
  18467. * Parse properties from a JSON object
  18468. * @param serializationObject defines the JSON object
  18469. */
  18470. parse(serializationObject: any): void;
  18471. }
  18472. }
  18473. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18474. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18475. import { Effect } from "babylonjs/Materials/effect";
  18476. import { Particle } from "babylonjs/Particles/particle";
  18477. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18478. /**
  18479. * Particle emitter emitting particles from the inside of a hemisphere.
  18480. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18481. */
  18482. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18483. /**
  18484. * The radius of the emission hemisphere.
  18485. */
  18486. radius: number;
  18487. /**
  18488. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18489. */
  18490. radiusRange: number;
  18491. /**
  18492. * How much to randomize the particle direction [0-1].
  18493. */
  18494. directionRandomizer: number;
  18495. /**
  18496. * Creates a new instance HemisphericParticleEmitter
  18497. * @param radius the radius of the emission hemisphere (1 by default)
  18498. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18499. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18500. */
  18501. constructor(
  18502. /**
  18503. * The radius of the emission hemisphere.
  18504. */
  18505. radius?: number,
  18506. /**
  18507. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18508. */
  18509. radiusRange?: number,
  18510. /**
  18511. * How much to randomize the particle direction [0-1].
  18512. */
  18513. directionRandomizer?: number);
  18514. /**
  18515. * Called by the particle System when the direction is computed for the created particle.
  18516. * @param worldMatrix is the world matrix of the particle system
  18517. * @param directionToUpdate is the direction vector to update with the result
  18518. * @param particle is the particle we are computed the direction for
  18519. */
  18520. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18521. /**
  18522. * Called by the particle System when the position is computed for the created particle.
  18523. * @param worldMatrix is the world matrix of the particle system
  18524. * @param positionToUpdate is the position vector to update with the result
  18525. * @param particle is the particle we are computed the position for
  18526. */
  18527. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18528. /**
  18529. * Clones the current emitter and returns a copy of it
  18530. * @returns the new emitter
  18531. */
  18532. clone(): HemisphericParticleEmitter;
  18533. /**
  18534. * Called by the GPUParticleSystem to setup the update shader
  18535. * @param effect defines the update shader
  18536. */
  18537. applyToShader(effect: Effect): void;
  18538. /**
  18539. * Returns a string to use to update the GPU particles update shader
  18540. * @returns a string containng the defines string
  18541. */
  18542. getEffectDefines(): string;
  18543. /**
  18544. * Returns the string "HemisphericParticleEmitter"
  18545. * @returns a string containing the class name
  18546. */
  18547. getClassName(): string;
  18548. /**
  18549. * Serializes the particle system to a JSON object.
  18550. * @returns the JSON object
  18551. */
  18552. serialize(): any;
  18553. /**
  18554. * Parse properties from a JSON object
  18555. * @param serializationObject defines the JSON object
  18556. */
  18557. parse(serializationObject: any): void;
  18558. }
  18559. }
  18560. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18561. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18562. import { Effect } from "babylonjs/Materials/effect";
  18563. import { Particle } from "babylonjs/Particles/particle";
  18564. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18565. /**
  18566. * Particle emitter emitting particles from a point.
  18567. * It emits the particles randomly between 2 given directions.
  18568. */
  18569. export class PointParticleEmitter implements IParticleEmitterType {
  18570. /**
  18571. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18572. */
  18573. direction1: Vector3;
  18574. /**
  18575. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18576. */
  18577. direction2: Vector3;
  18578. /**
  18579. * Creates a new instance PointParticleEmitter
  18580. */
  18581. constructor();
  18582. /**
  18583. * Called by the particle System when the direction is computed for the created particle.
  18584. * @param worldMatrix is the world matrix of the particle system
  18585. * @param directionToUpdate is the direction vector to update with the result
  18586. * @param particle is the particle we are computed the direction for
  18587. */
  18588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18589. /**
  18590. * Called by the particle System when the position is computed for the created particle.
  18591. * @param worldMatrix is the world matrix of the particle system
  18592. * @param positionToUpdate is the position vector to update with the result
  18593. * @param particle is the particle we are computed the position for
  18594. */
  18595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18596. /**
  18597. * Clones the current emitter and returns a copy of it
  18598. * @returns the new emitter
  18599. */
  18600. clone(): PointParticleEmitter;
  18601. /**
  18602. * Called by the GPUParticleSystem to setup the update shader
  18603. * @param effect defines the update shader
  18604. */
  18605. applyToShader(effect: Effect): void;
  18606. /**
  18607. * Returns a string to use to update the GPU particles update shader
  18608. * @returns a string containng the defines string
  18609. */
  18610. getEffectDefines(): string;
  18611. /**
  18612. * Returns the string "PointParticleEmitter"
  18613. * @returns a string containing the class name
  18614. */
  18615. getClassName(): string;
  18616. /**
  18617. * Serializes the particle system to a JSON object.
  18618. * @returns the JSON object
  18619. */
  18620. serialize(): any;
  18621. /**
  18622. * Parse properties from a JSON object
  18623. * @param serializationObject defines the JSON object
  18624. */
  18625. parse(serializationObject: any): void;
  18626. }
  18627. }
  18628. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18629. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18630. import { Effect } from "babylonjs/Materials/effect";
  18631. import { Particle } from "babylonjs/Particles/particle";
  18632. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18633. /**
  18634. * Particle emitter emitting particles from the inside of a sphere.
  18635. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18636. */
  18637. export class SphereParticleEmitter implements IParticleEmitterType {
  18638. /**
  18639. * The radius of the emission sphere.
  18640. */
  18641. radius: number;
  18642. /**
  18643. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18644. */
  18645. radiusRange: number;
  18646. /**
  18647. * How much to randomize the particle direction [0-1].
  18648. */
  18649. directionRandomizer: number;
  18650. /**
  18651. * Creates a new instance SphereParticleEmitter
  18652. * @param radius the radius of the emission sphere (1 by default)
  18653. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18654. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18655. */
  18656. constructor(
  18657. /**
  18658. * The radius of the emission sphere.
  18659. */
  18660. radius?: number,
  18661. /**
  18662. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18663. */
  18664. radiusRange?: number,
  18665. /**
  18666. * How much to randomize the particle direction [0-1].
  18667. */
  18668. directionRandomizer?: number);
  18669. /**
  18670. * Called by the particle System when the direction is computed for the created particle.
  18671. * @param worldMatrix is the world matrix of the particle system
  18672. * @param directionToUpdate is the direction vector to update with the result
  18673. * @param particle is the particle we are computed the direction for
  18674. */
  18675. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18676. /**
  18677. * Called by the particle System when the position is computed for the created particle.
  18678. * @param worldMatrix is the world matrix of the particle system
  18679. * @param positionToUpdate is the position vector to update with the result
  18680. * @param particle is the particle we are computed the position for
  18681. */
  18682. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18683. /**
  18684. * Clones the current emitter and returns a copy of it
  18685. * @returns the new emitter
  18686. */
  18687. clone(): SphereParticleEmitter;
  18688. /**
  18689. * Called by the GPUParticleSystem to setup the update shader
  18690. * @param effect defines the update shader
  18691. */
  18692. applyToShader(effect: Effect): void;
  18693. /**
  18694. * Returns a string to use to update the GPU particles update shader
  18695. * @returns a string containng the defines string
  18696. */
  18697. getEffectDefines(): string;
  18698. /**
  18699. * Returns the string "SphereParticleEmitter"
  18700. * @returns a string containing the class name
  18701. */
  18702. getClassName(): string;
  18703. /**
  18704. * Serializes the particle system to a JSON object.
  18705. * @returns the JSON object
  18706. */
  18707. serialize(): any;
  18708. /**
  18709. * Parse properties from a JSON object
  18710. * @param serializationObject defines the JSON object
  18711. */
  18712. parse(serializationObject: any): void;
  18713. }
  18714. /**
  18715. * Particle emitter emitting particles from the inside of a sphere.
  18716. * It emits the particles randomly between two vectors.
  18717. */
  18718. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18719. /**
  18720. * The min limit of the emission direction.
  18721. */
  18722. direction1: Vector3;
  18723. /**
  18724. * The max limit of the emission direction.
  18725. */
  18726. direction2: Vector3;
  18727. /**
  18728. * Creates a new instance SphereDirectedParticleEmitter
  18729. * @param radius the radius of the emission sphere (1 by default)
  18730. * @param direction1 the min limit of the emission direction (up vector by default)
  18731. * @param direction2 the max limit of the emission direction (up vector by default)
  18732. */
  18733. constructor(radius?: number,
  18734. /**
  18735. * The min limit of the emission direction.
  18736. */
  18737. direction1?: Vector3,
  18738. /**
  18739. * The max limit of the emission direction.
  18740. */
  18741. direction2?: Vector3);
  18742. /**
  18743. * Called by the particle System when the direction is computed for the created particle.
  18744. * @param worldMatrix is the world matrix of the particle system
  18745. * @param directionToUpdate is the direction vector to update with the result
  18746. * @param particle is the particle we are computed the direction for
  18747. */
  18748. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18749. /**
  18750. * Clones the current emitter and returns a copy of it
  18751. * @returns the new emitter
  18752. */
  18753. clone(): SphereDirectedParticleEmitter;
  18754. /**
  18755. * Called by the GPUParticleSystem to setup the update shader
  18756. * @param effect defines the update shader
  18757. */
  18758. applyToShader(effect: Effect): void;
  18759. /**
  18760. * Returns a string to use to update the GPU particles update shader
  18761. * @returns a string containng the defines string
  18762. */
  18763. getEffectDefines(): string;
  18764. /**
  18765. * Returns the string "SphereDirectedParticleEmitter"
  18766. * @returns a string containing the class name
  18767. */
  18768. getClassName(): string;
  18769. /**
  18770. * Serializes the particle system to a JSON object.
  18771. * @returns the JSON object
  18772. */
  18773. serialize(): any;
  18774. /**
  18775. * Parse properties from a JSON object
  18776. * @param serializationObject defines the JSON object
  18777. */
  18778. parse(serializationObject: any): void;
  18779. }
  18780. }
  18781. declare module "babylonjs/Particles/EmitterTypes/index" {
  18782. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18783. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18784. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18785. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18786. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18787. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18788. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18789. }
  18790. declare module "babylonjs/Particles/IParticleSystem" {
  18791. import { Nullable } from "babylonjs/types";
  18792. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18793. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18795. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18796. import { Texture } from "babylonjs/Materials/Textures/texture";
  18797. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18798. import { Scene } from "babylonjs/scene";
  18799. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18800. import { Animation } from "babylonjs/Animations/animation";
  18801. /**
  18802. * Interface representing a particle system in Babylon.js.
  18803. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18804. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18805. */
  18806. export interface IParticleSystem {
  18807. /**
  18808. * List of animations used by the particle system.
  18809. */
  18810. animations: Animation[];
  18811. /**
  18812. * The id of the Particle system.
  18813. */
  18814. id: string;
  18815. /**
  18816. * The name of the Particle system.
  18817. */
  18818. name: string;
  18819. /**
  18820. * The emitter represents the Mesh or position we are attaching the particle system to.
  18821. */
  18822. emitter: Nullable<AbstractMesh | Vector3>;
  18823. /**
  18824. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18825. */
  18826. isBillboardBased: boolean;
  18827. /**
  18828. * The rendering group used by the Particle system to chose when to render.
  18829. */
  18830. renderingGroupId: number;
  18831. /**
  18832. * The layer mask we are rendering the particles through.
  18833. */
  18834. layerMask: number;
  18835. /**
  18836. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18837. */
  18838. updateSpeed: number;
  18839. /**
  18840. * The amount of time the particle system is running (depends of the overall update speed).
  18841. */
  18842. targetStopDuration: number;
  18843. /**
  18844. * The texture used to render each particle. (this can be a spritesheet)
  18845. */
  18846. particleTexture: Nullable<Texture>;
  18847. /**
  18848. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18849. */
  18850. blendMode: number;
  18851. /**
  18852. * Minimum life time of emitting particles.
  18853. */
  18854. minLifeTime: number;
  18855. /**
  18856. * Maximum life time of emitting particles.
  18857. */
  18858. maxLifeTime: number;
  18859. /**
  18860. * Minimum Size of emitting particles.
  18861. */
  18862. minSize: number;
  18863. /**
  18864. * Maximum Size of emitting particles.
  18865. */
  18866. maxSize: number;
  18867. /**
  18868. * Minimum scale of emitting particles on X axis.
  18869. */
  18870. minScaleX: number;
  18871. /**
  18872. * Maximum scale of emitting particles on X axis.
  18873. */
  18874. maxScaleX: number;
  18875. /**
  18876. * Minimum scale of emitting particles on Y axis.
  18877. */
  18878. minScaleY: number;
  18879. /**
  18880. * Maximum scale of emitting particles on Y axis.
  18881. */
  18882. maxScaleY: number;
  18883. /**
  18884. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18885. */
  18886. color1: Color4;
  18887. /**
  18888. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18889. */
  18890. color2: Color4;
  18891. /**
  18892. * Color the particle will have at the end of its lifetime.
  18893. */
  18894. colorDead: Color4;
  18895. /**
  18896. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18897. */
  18898. emitRate: number;
  18899. /**
  18900. * You can use gravity if you want to give an orientation to your particles.
  18901. */
  18902. gravity: Vector3;
  18903. /**
  18904. * Minimum power of emitting particles.
  18905. */
  18906. minEmitPower: number;
  18907. /**
  18908. * Maximum power of emitting particles.
  18909. */
  18910. maxEmitPower: number;
  18911. /**
  18912. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18913. */
  18914. minAngularSpeed: number;
  18915. /**
  18916. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18917. */
  18918. maxAngularSpeed: number;
  18919. /**
  18920. * Gets or sets the minimal initial rotation in radians.
  18921. */
  18922. minInitialRotation: number;
  18923. /**
  18924. * Gets or sets the maximal initial rotation in radians.
  18925. */
  18926. maxInitialRotation: number;
  18927. /**
  18928. * The particle emitter type defines the emitter used by the particle system.
  18929. * It can be for example box, sphere, or cone...
  18930. */
  18931. particleEmitterType: Nullable<IParticleEmitterType>;
  18932. /**
  18933. * Defines the delay in milliseconds before starting the system (0 by default)
  18934. */
  18935. startDelay: number;
  18936. /**
  18937. * 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
  18938. */
  18939. preWarmCycles: number;
  18940. /**
  18941. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18942. */
  18943. preWarmStepOffset: number;
  18944. /**
  18945. * 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)
  18946. */
  18947. spriteCellChangeSpeed: number;
  18948. /**
  18949. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18950. */
  18951. startSpriteCellID: number;
  18952. /**
  18953. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18954. */
  18955. endSpriteCellID: number;
  18956. /**
  18957. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18958. */
  18959. spriteCellWidth: number;
  18960. /**
  18961. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18962. */
  18963. spriteCellHeight: number;
  18964. /**
  18965. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18966. */
  18967. spriteRandomStartCell: boolean;
  18968. /**
  18969. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18970. */
  18971. isAnimationSheetEnabled: boolean;
  18972. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18973. translationPivot: Vector2;
  18974. /**
  18975. * Gets or sets a texture used to add random noise to particle positions
  18976. */
  18977. noiseTexture: Nullable<BaseTexture>;
  18978. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18979. noiseStrength: Vector3;
  18980. /**
  18981. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18982. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18983. */
  18984. billboardMode: number;
  18985. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18986. limitVelocityDamping: number;
  18987. /**
  18988. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18989. */
  18990. beginAnimationOnStart: boolean;
  18991. /**
  18992. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18993. */
  18994. beginAnimationFrom: number;
  18995. /**
  18996. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18997. */
  18998. beginAnimationTo: number;
  18999. /**
  19000. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19001. */
  19002. beginAnimationLoop: boolean;
  19003. /**
  19004. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19005. */
  19006. disposeOnStop: boolean;
  19007. /**
  19008. * Gets the maximum number of particles active at the same time.
  19009. * @returns The max number of active particles.
  19010. */
  19011. getCapacity(): number;
  19012. /**
  19013. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19014. * @returns True if it has been started, otherwise false.
  19015. */
  19016. isStarted(): boolean;
  19017. /**
  19018. * Animates the particle system for this frame.
  19019. */
  19020. animate(): void;
  19021. /**
  19022. * Renders the particle system in its current state.
  19023. * @returns the current number of particles
  19024. */
  19025. render(): number;
  19026. /**
  19027. * Dispose the particle system and frees its associated resources.
  19028. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19029. */
  19030. dispose(disposeTexture?: boolean): void;
  19031. /**
  19032. * Clones the particle system.
  19033. * @param name The name of the cloned object
  19034. * @param newEmitter The new emitter to use
  19035. * @returns the cloned particle system
  19036. */
  19037. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19038. /**
  19039. * Serializes the particle system to a JSON object.
  19040. * @returns the JSON object
  19041. */
  19042. serialize(): any;
  19043. /**
  19044. * Rebuild the particle system
  19045. */
  19046. rebuild(): void;
  19047. /**
  19048. * Starts the particle system and begins to emit
  19049. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19050. */
  19051. start(delay?: number): void;
  19052. /**
  19053. * Stops the particle system.
  19054. */
  19055. stop(): void;
  19056. /**
  19057. * Remove all active particles
  19058. */
  19059. reset(): void;
  19060. /**
  19061. * Is this system ready to be used/rendered
  19062. * @return true if the system is ready
  19063. */
  19064. isReady(): boolean;
  19065. /**
  19066. * Adds a new color gradient
  19067. * @param gradient defines the gradient to use (between 0 and 1)
  19068. * @param color1 defines the color to affect to the specified gradient
  19069. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19070. * @returns the current particle system
  19071. */
  19072. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19073. /**
  19074. * Remove a specific color gradient
  19075. * @param gradient defines the gradient to remove
  19076. * @returns the current particle system
  19077. */
  19078. removeColorGradient(gradient: number): IParticleSystem;
  19079. /**
  19080. * Adds a new size gradient
  19081. * @param gradient defines the gradient to use (between 0 and 1)
  19082. * @param factor defines the size factor to affect to the specified gradient
  19083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19084. * @returns the current particle system
  19085. */
  19086. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19087. /**
  19088. * Remove a specific size gradient
  19089. * @param gradient defines the gradient to remove
  19090. * @returns the current particle system
  19091. */
  19092. removeSizeGradient(gradient: number): IParticleSystem;
  19093. /**
  19094. * Gets the current list of color gradients.
  19095. * You must use addColorGradient and removeColorGradient to udpate this list
  19096. * @returns the list of color gradients
  19097. */
  19098. getColorGradients(): Nullable<Array<ColorGradient>>;
  19099. /**
  19100. * Gets the current list of size gradients.
  19101. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19102. * @returns the list of size gradients
  19103. */
  19104. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19105. /**
  19106. * Gets the current list of angular speed gradients.
  19107. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19108. * @returns the list of angular speed gradients
  19109. */
  19110. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19111. /**
  19112. * Adds a new angular speed gradient
  19113. * @param gradient defines the gradient to use (between 0 and 1)
  19114. * @param factor defines the angular speed to affect to the specified gradient
  19115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19116. * @returns the current particle system
  19117. */
  19118. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19119. /**
  19120. * Remove a specific angular speed gradient
  19121. * @param gradient defines the gradient to remove
  19122. * @returns the current particle system
  19123. */
  19124. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19125. /**
  19126. * Gets the current list of velocity gradients.
  19127. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19128. * @returns the list of velocity gradients
  19129. */
  19130. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19131. /**
  19132. * Adds a new velocity gradient
  19133. * @param gradient defines the gradient to use (between 0 and 1)
  19134. * @param factor defines the velocity to affect to the specified gradient
  19135. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19136. * @returns the current particle system
  19137. */
  19138. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19139. /**
  19140. * Remove a specific velocity gradient
  19141. * @param gradient defines the gradient to remove
  19142. * @returns the current particle system
  19143. */
  19144. removeVelocityGradient(gradient: number): IParticleSystem;
  19145. /**
  19146. * Gets the current list of limit velocity gradients.
  19147. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19148. * @returns the list of limit velocity gradients
  19149. */
  19150. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19151. /**
  19152. * Adds a new limit velocity gradient
  19153. * @param gradient defines the gradient to use (between 0 and 1)
  19154. * @param factor defines the limit velocity to affect to the specified gradient
  19155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19156. * @returns the current particle system
  19157. */
  19158. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19159. /**
  19160. * Remove a specific limit velocity gradient
  19161. * @param gradient defines the gradient to remove
  19162. * @returns the current particle system
  19163. */
  19164. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19165. /**
  19166. * Adds a new drag gradient
  19167. * @param gradient defines the gradient to use (between 0 and 1)
  19168. * @param factor defines the drag to affect to the specified gradient
  19169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19170. * @returns the current particle system
  19171. */
  19172. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19173. /**
  19174. * Remove a specific drag gradient
  19175. * @param gradient defines the gradient to remove
  19176. * @returns the current particle system
  19177. */
  19178. removeDragGradient(gradient: number): IParticleSystem;
  19179. /**
  19180. * Gets the current list of drag gradients.
  19181. * You must use addDragGradient and removeDragGradient to udpate this list
  19182. * @returns the list of drag gradients
  19183. */
  19184. getDragGradients(): Nullable<Array<FactorGradient>>;
  19185. /**
  19186. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19187. * @param gradient defines the gradient to use (between 0 and 1)
  19188. * @param factor defines the emit rate to affect to the specified gradient
  19189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19190. * @returns the current particle system
  19191. */
  19192. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19193. /**
  19194. * Remove a specific emit rate gradient
  19195. * @param gradient defines the gradient to remove
  19196. * @returns the current particle system
  19197. */
  19198. removeEmitRateGradient(gradient: number): IParticleSystem;
  19199. /**
  19200. * Gets the current list of emit rate gradients.
  19201. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19202. * @returns the list of emit rate gradients
  19203. */
  19204. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19205. /**
  19206. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19207. * @param gradient defines the gradient to use (between 0 and 1)
  19208. * @param factor defines the start size to affect to the specified gradient
  19209. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19210. * @returns the current particle system
  19211. */
  19212. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19213. /**
  19214. * Remove a specific start size gradient
  19215. * @param gradient defines the gradient to remove
  19216. * @returns the current particle system
  19217. */
  19218. removeStartSizeGradient(gradient: number): IParticleSystem;
  19219. /**
  19220. * Gets the current list of start size gradients.
  19221. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19222. * @returns the list of start size gradients
  19223. */
  19224. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19225. /**
  19226. * Adds a new life time gradient
  19227. * @param gradient defines the gradient to use (between 0 and 1)
  19228. * @param factor defines the life time factor to affect to the specified gradient
  19229. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19230. * @returns the current particle system
  19231. */
  19232. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19233. /**
  19234. * Remove a specific life time gradient
  19235. * @param gradient defines the gradient to remove
  19236. * @returns the current particle system
  19237. */
  19238. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19239. /**
  19240. * Gets the current list of life time gradients.
  19241. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19242. * @returns the list of life time gradients
  19243. */
  19244. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19245. /**
  19246. * Gets the current list of color gradients.
  19247. * You must use addColorGradient and removeColorGradient to udpate this list
  19248. * @returns the list of color gradients
  19249. */
  19250. getColorGradients(): Nullable<Array<ColorGradient>>;
  19251. /**
  19252. * Adds a new ramp gradient used to remap particle colors
  19253. * @param gradient defines the gradient to use (between 0 and 1)
  19254. * @param color defines the color to affect to the specified gradient
  19255. * @returns the current particle system
  19256. */
  19257. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19258. /**
  19259. * Gets the current list of ramp gradients.
  19260. * You must use addRampGradient and removeRampGradient to udpate this list
  19261. * @returns the list of ramp gradients
  19262. */
  19263. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19264. /** Gets or sets a boolean indicating that ramp gradients must be used
  19265. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19266. */
  19267. useRampGradients: boolean;
  19268. /**
  19269. * Adds a new color remap gradient
  19270. * @param gradient defines the gradient to use (between 0 and 1)
  19271. * @param min defines the color remap minimal range
  19272. * @param max defines the color remap maximal range
  19273. * @returns the current particle system
  19274. */
  19275. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19276. /**
  19277. * Gets the current list of color remap gradients.
  19278. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19279. * @returns the list of color remap gradients
  19280. */
  19281. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19282. /**
  19283. * Adds a new alpha remap gradient
  19284. * @param gradient defines the gradient to use (between 0 and 1)
  19285. * @param min defines the alpha remap minimal range
  19286. * @param max defines the alpha remap maximal range
  19287. * @returns the current particle system
  19288. */
  19289. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19290. /**
  19291. * Gets the current list of alpha remap gradients.
  19292. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19293. * @returns the list of alpha remap gradients
  19294. */
  19295. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19296. /**
  19297. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19298. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19299. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19300. * @returns the emitter
  19301. */
  19302. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19303. /**
  19304. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19305. * @param radius The radius of the hemisphere to emit from
  19306. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19307. * @returns the emitter
  19308. */
  19309. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19310. /**
  19311. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19312. * @param radius The radius of the sphere to emit from
  19313. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19314. * @returns the emitter
  19315. */
  19316. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19317. /**
  19318. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19319. * @param radius The radius of the sphere to emit from
  19320. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19321. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19322. * @returns the emitter
  19323. */
  19324. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19325. /**
  19326. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19327. * @param radius The radius of the emission cylinder
  19328. * @param height The height of the emission cylinder
  19329. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19330. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19331. * @returns the emitter
  19332. */
  19333. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19334. /**
  19335. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19336. * @param radius The radius of the cylinder to emit from
  19337. * @param height The height of the emission cylinder
  19338. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19339. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19340. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19341. * @returns the emitter
  19342. */
  19343. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19344. /**
  19345. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19346. * @param radius The radius of the cone to emit from
  19347. * @param angle The base angle of the cone
  19348. * @returns the emitter
  19349. */
  19350. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19351. /**
  19352. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19353. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19354. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19355. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19356. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19357. * @returns the emitter
  19358. */
  19359. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19360. /**
  19361. * Get hosting scene
  19362. * @returns the scene
  19363. */
  19364. getScene(): Scene;
  19365. }
  19366. }
  19367. declare module "babylonjs/Meshes/instancedMesh" {
  19368. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19369. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19370. import { Camera } from "babylonjs/Cameras/camera";
  19371. import { Node } from "babylonjs/node";
  19372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19373. import { Mesh } from "babylonjs/Meshes/mesh";
  19374. import { Material } from "babylonjs/Materials/material";
  19375. import { Skeleton } from "babylonjs/Bones/skeleton";
  19376. import { Light } from "babylonjs/Lights/light";
  19377. /**
  19378. * Creates an instance based on a source mesh.
  19379. */
  19380. export class InstancedMesh extends AbstractMesh {
  19381. private _sourceMesh;
  19382. private _currentLOD;
  19383. /** @hidden */
  19384. _indexInSourceMeshInstanceArray: number;
  19385. constructor(name: string, source: Mesh);
  19386. /**
  19387. * Returns the string "InstancedMesh".
  19388. */
  19389. getClassName(): string;
  19390. /** Gets the list of lights affecting that mesh */
  19391. readonly lightSources: Light[];
  19392. _resyncLightSources(): void;
  19393. _resyncLighSource(light: Light): void;
  19394. _removeLightSource(light: Light, dispose: boolean): void;
  19395. /**
  19396. * If the source mesh receives shadows
  19397. */
  19398. readonly receiveShadows: boolean;
  19399. /**
  19400. * The material of the source mesh
  19401. */
  19402. readonly material: Nullable<Material>;
  19403. /**
  19404. * Visibility of the source mesh
  19405. */
  19406. readonly visibility: number;
  19407. /**
  19408. * Skeleton of the source mesh
  19409. */
  19410. readonly skeleton: Nullable<Skeleton>;
  19411. /**
  19412. * Rendering ground id of the source mesh
  19413. */
  19414. renderingGroupId: number;
  19415. /**
  19416. * Returns the total number of vertices (integer).
  19417. */
  19418. getTotalVertices(): number;
  19419. /**
  19420. * Returns a positive integer : the total number of indices in this mesh geometry.
  19421. * @returns the numner of indices or zero if the mesh has no geometry.
  19422. */
  19423. getTotalIndices(): number;
  19424. /**
  19425. * The source mesh of the instance
  19426. */
  19427. readonly sourceMesh: Mesh;
  19428. /**
  19429. * Is this node ready to be used/rendered
  19430. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19431. * @return {boolean} is it ready
  19432. */
  19433. isReady(completeCheck?: boolean): boolean;
  19434. /**
  19435. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19436. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19437. * @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.
  19438. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19439. */
  19440. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19441. /**
  19442. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19443. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19444. * The `data` are either a numeric array either a Float32Array.
  19445. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19446. * 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).
  19447. * Note that a new underlying VertexBuffer object is created each call.
  19448. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19449. *
  19450. * Possible `kind` values :
  19451. * - VertexBuffer.PositionKind
  19452. * - VertexBuffer.UVKind
  19453. * - VertexBuffer.UV2Kind
  19454. * - VertexBuffer.UV3Kind
  19455. * - VertexBuffer.UV4Kind
  19456. * - VertexBuffer.UV5Kind
  19457. * - VertexBuffer.UV6Kind
  19458. * - VertexBuffer.ColorKind
  19459. * - VertexBuffer.MatricesIndicesKind
  19460. * - VertexBuffer.MatricesIndicesExtraKind
  19461. * - VertexBuffer.MatricesWeightsKind
  19462. * - VertexBuffer.MatricesWeightsExtraKind
  19463. *
  19464. * Returns the Mesh.
  19465. */
  19466. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19467. /**
  19468. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19469. * If the mesh has no geometry, it is simply returned as it is.
  19470. * The `data` are either a numeric array either a Float32Array.
  19471. * No new underlying VertexBuffer object is created.
  19472. * 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.
  19473. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19474. *
  19475. * Possible `kind` values :
  19476. * - VertexBuffer.PositionKind
  19477. * - VertexBuffer.UVKind
  19478. * - VertexBuffer.UV2Kind
  19479. * - VertexBuffer.UV3Kind
  19480. * - VertexBuffer.UV4Kind
  19481. * - VertexBuffer.UV5Kind
  19482. * - VertexBuffer.UV6Kind
  19483. * - VertexBuffer.ColorKind
  19484. * - VertexBuffer.MatricesIndicesKind
  19485. * - VertexBuffer.MatricesIndicesExtraKind
  19486. * - VertexBuffer.MatricesWeightsKind
  19487. * - VertexBuffer.MatricesWeightsExtraKind
  19488. *
  19489. * Returns the Mesh.
  19490. */
  19491. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19492. /**
  19493. * Sets the mesh indices.
  19494. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19495. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19496. * This method creates a new index buffer each call.
  19497. * Returns the Mesh.
  19498. */
  19499. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19500. /**
  19501. * Boolean : True if the mesh owns the requested kind of data.
  19502. */
  19503. isVerticesDataPresent(kind: string): boolean;
  19504. /**
  19505. * Returns an array of indices (IndicesArray).
  19506. */
  19507. getIndices(): Nullable<IndicesArray>;
  19508. readonly _positions: Nullable<Vector3[]>;
  19509. /**
  19510. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19511. * This means the mesh underlying bounding box and sphere are recomputed.
  19512. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19513. * @returns the current mesh
  19514. */
  19515. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19516. /** @hidden */
  19517. _preActivate(): InstancedMesh;
  19518. /** @hidden */
  19519. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19520. /** @hidden */
  19521. _postActivate(): void;
  19522. getWorldMatrix(): Matrix;
  19523. readonly isAnInstance: boolean;
  19524. /**
  19525. * Returns the current associated LOD AbstractMesh.
  19526. */
  19527. getLOD(camera: Camera): AbstractMesh;
  19528. /** @hidden */
  19529. _syncSubMeshes(): InstancedMesh;
  19530. /** @hidden */
  19531. _generatePointsArray(): boolean;
  19532. /**
  19533. * Creates a new InstancedMesh from the current mesh.
  19534. * - name (string) : the cloned mesh name
  19535. * - newParent (optional Node) : the optional Node to parent the clone to.
  19536. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19537. *
  19538. * Returns the clone.
  19539. */
  19540. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19541. /**
  19542. * Disposes the InstancedMesh.
  19543. * Returns nothing.
  19544. */
  19545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19546. }
  19547. }
  19548. declare module "babylonjs/Materials/shaderMaterial" {
  19549. import { Scene } from "babylonjs/scene";
  19550. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19552. import { Mesh } from "babylonjs/Meshes/mesh";
  19553. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19554. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19555. import { Texture } from "babylonjs/Materials/Textures/texture";
  19556. import { Material } from "babylonjs/Materials/material";
  19557. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19558. /**
  19559. * Defines the options associated with the creation of a shader material.
  19560. */
  19561. export interface IShaderMaterialOptions {
  19562. /**
  19563. * Does the material work in alpha blend mode
  19564. */
  19565. needAlphaBlending: boolean;
  19566. /**
  19567. * Does the material work in alpha test mode
  19568. */
  19569. needAlphaTesting: boolean;
  19570. /**
  19571. * The list of attribute names used in the shader
  19572. */
  19573. attributes: string[];
  19574. /**
  19575. * The list of unifrom names used in the shader
  19576. */
  19577. uniforms: string[];
  19578. /**
  19579. * The list of UBO names used in the shader
  19580. */
  19581. uniformBuffers: string[];
  19582. /**
  19583. * The list of sampler names used in the shader
  19584. */
  19585. samplers: string[];
  19586. /**
  19587. * The list of defines used in the shader
  19588. */
  19589. defines: string[];
  19590. }
  19591. /**
  19592. * 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.
  19593. *
  19594. * This returned material effects how the mesh will look based on the code in the shaders.
  19595. *
  19596. * @see http://doc.babylonjs.com/how_to/shader_material
  19597. */
  19598. export class ShaderMaterial extends Material {
  19599. private _shaderPath;
  19600. private _options;
  19601. private _textures;
  19602. private _textureArrays;
  19603. private _floats;
  19604. private _ints;
  19605. private _floatsArrays;
  19606. private _colors3;
  19607. private _colors3Arrays;
  19608. private _colors4;
  19609. private _colors4Arrays;
  19610. private _vectors2;
  19611. private _vectors3;
  19612. private _vectors4;
  19613. private _matrices;
  19614. private _matrices3x3;
  19615. private _matrices2x2;
  19616. private _vectors2Arrays;
  19617. private _vectors3Arrays;
  19618. private _vectors4Arrays;
  19619. private _cachedWorldViewMatrix;
  19620. private _cachedWorldViewProjectionMatrix;
  19621. private _renderId;
  19622. /**
  19623. * Instantiate a new shader material.
  19624. * 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.
  19625. * This returned material effects how the mesh will look based on the code in the shaders.
  19626. * @see http://doc.babylonjs.com/how_to/shader_material
  19627. * @param name Define the name of the material in the scene
  19628. * @param scene Define the scene the material belongs to
  19629. * @param shaderPath Defines the route to the shader code in one of three ways:
  19630. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19631. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19632. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19633. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19634. * @param options Define the options used to create the shader
  19635. */
  19636. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19637. /**
  19638. * Gets the options used to compile the shader.
  19639. * They can be modified to trigger a new compilation
  19640. */
  19641. readonly options: IShaderMaterialOptions;
  19642. /**
  19643. * Gets the current class name of the material e.g. "ShaderMaterial"
  19644. * Mainly use in serialization.
  19645. * @returns the class name
  19646. */
  19647. getClassName(): string;
  19648. /**
  19649. * Specifies if the material will require alpha blending
  19650. * @returns a boolean specifying if alpha blending is needed
  19651. */
  19652. needAlphaBlending(): boolean;
  19653. /**
  19654. * Specifies if this material should be rendered in alpha test mode
  19655. * @returns a boolean specifying if an alpha test is needed.
  19656. */
  19657. needAlphaTesting(): boolean;
  19658. private _checkUniform;
  19659. /**
  19660. * Set a texture in the shader.
  19661. * @param name Define the name of the uniform samplers as defined in the shader
  19662. * @param texture Define the texture to bind to this sampler
  19663. * @return the material itself allowing "fluent" like uniform updates
  19664. */
  19665. setTexture(name: string, texture: Texture): ShaderMaterial;
  19666. /**
  19667. * Set a texture array in the shader.
  19668. * @param name Define the name of the uniform sampler array as defined in the shader
  19669. * @param textures Define the list of textures to bind to this sampler
  19670. * @return the material itself allowing "fluent" like uniform updates
  19671. */
  19672. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19673. /**
  19674. * Set a float in the shader.
  19675. * @param name Define the name of the uniform as defined in the shader
  19676. * @param value Define the value to give to the uniform
  19677. * @return the material itself allowing "fluent" like uniform updates
  19678. */
  19679. setFloat(name: string, value: number): ShaderMaterial;
  19680. /**
  19681. * Set a int in the shader.
  19682. * @param name Define the name of the uniform as defined in the shader
  19683. * @param value Define the value to give to the uniform
  19684. * @return the material itself allowing "fluent" like uniform updates
  19685. */
  19686. setInt(name: string, value: number): ShaderMaterial;
  19687. /**
  19688. * Set an array of floats in the shader.
  19689. * @param name Define the name of the uniform as defined in the shader
  19690. * @param value Define the value to give to the uniform
  19691. * @return the material itself allowing "fluent" like uniform updates
  19692. */
  19693. setFloats(name: string, value: number[]): ShaderMaterial;
  19694. /**
  19695. * Set a vec3 in the shader from a Color3.
  19696. * @param name Define the name of the uniform as defined in the shader
  19697. * @param value Define the value to give to the uniform
  19698. * @return the material itself allowing "fluent" like uniform updates
  19699. */
  19700. setColor3(name: string, value: Color3): ShaderMaterial;
  19701. /**
  19702. * Set a vec3 array in the shader from a Color3 array.
  19703. * @param name Define the name of the uniform as defined in the shader
  19704. * @param value Define the value to give to the uniform
  19705. * @return the material itself allowing "fluent" like uniform updates
  19706. */
  19707. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19708. /**
  19709. * Set a vec4 in the shader from a Color4.
  19710. * @param name Define the name of the uniform as defined in the shader
  19711. * @param value Define the value to give to the uniform
  19712. * @return the material itself allowing "fluent" like uniform updates
  19713. */
  19714. setColor4(name: string, value: Color4): ShaderMaterial;
  19715. /**
  19716. * Set a vec4 array in the shader from a Color4 array.
  19717. * @param name Define the name of the uniform as defined in the shader
  19718. * @param value Define the value to give to the uniform
  19719. * @return the material itself allowing "fluent" like uniform updates
  19720. */
  19721. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19722. /**
  19723. * Set a vec2 in the shader from a Vector2.
  19724. * @param name Define the name of the uniform as defined in the shader
  19725. * @param value Define the value to give to the uniform
  19726. * @return the material itself allowing "fluent" like uniform updates
  19727. */
  19728. setVector2(name: string, value: Vector2): ShaderMaterial;
  19729. /**
  19730. * Set a vec3 in the shader from a Vector3.
  19731. * @param name Define the name of the uniform as defined in the shader
  19732. * @param value Define the value to give to the uniform
  19733. * @return the material itself allowing "fluent" like uniform updates
  19734. */
  19735. setVector3(name: string, value: Vector3): ShaderMaterial;
  19736. /**
  19737. * Set a vec4 in the shader from a Vector4.
  19738. * @param name Define the name of the uniform as defined in the shader
  19739. * @param value Define the value to give to the uniform
  19740. * @return the material itself allowing "fluent" like uniform updates
  19741. */
  19742. setVector4(name: string, value: Vector4): ShaderMaterial;
  19743. /**
  19744. * Set a mat4 in the shader from a Matrix.
  19745. * @param name Define the name of the uniform as defined in the shader
  19746. * @param value Define the value to give to the uniform
  19747. * @return the material itself allowing "fluent" like uniform updates
  19748. */
  19749. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19750. /**
  19751. * Set a mat3 in the shader from a Float32Array.
  19752. * @param name Define the name of the uniform as defined in the shader
  19753. * @param value Define the value to give to the uniform
  19754. * @return the material itself allowing "fluent" like uniform updates
  19755. */
  19756. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19757. /**
  19758. * Set a mat2 in the shader from a Float32Array.
  19759. * @param name Define the name of the uniform as defined in the shader
  19760. * @param value Define the value to give to the uniform
  19761. * @return the material itself allowing "fluent" like uniform updates
  19762. */
  19763. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19764. /**
  19765. * Set a vec2 array in the shader from a number array.
  19766. * @param name Define the name of the uniform as defined in the shader
  19767. * @param value Define the value to give to the uniform
  19768. * @return the material itself allowing "fluent" like uniform updates
  19769. */
  19770. setArray2(name: string, value: number[]): ShaderMaterial;
  19771. /**
  19772. * Set a vec3 array in the shader from a number array.
  19773. * @param name Define the name of the uniform as defined in the shader
  19774. * @param value Define the value to give to the uniform
  19775. * @return the material itself allowing "fluent" like uniform updates
  19776. */
  19777. setArray3(name: string, value: number[]): ShaderMaterial;
  19778. /**
  19779. * Set a vec4 array in the shader from a number array.
  19780. * @param name Define the name of the uniform as defined in the shader
  19781. * @param value Define the value to give to the uniform
  19782. * @return the material itself allowing "fluent" like uniform updates
  19783. */
  19784. setArray4(name: string, value: number[]): ShaderMaterial;
  19785. private _checkCache;
  19786. /**
  19787. * Specifies that the submesh is ready to be used
  19788. * @param mesh defines the mesh to check
  19789. * @param subMesh defines which submesh to check
  19790. * @param useInstances specifies that instances should be used
  19791. * @returns a boolean indicating that the submesh is ready or not
  19792. */
  19793. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19794. /**
  19795. * Checks if the material is ready to render the requested mesh
  19796. * @param mesh Define the mesh to render
  19797. * @param useInstances Define whether or not the material is used with instances
  19798. * @returns true if ready, otherwise false
  19799. */
  19800. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19801. /**
  19802. * Binds the world matrix to the material
  19803. * @param world defines the world transformation matrix
  19804. */
  19805. bindOnlyWorldMatrix(world: Matrix): void;
  19806. /**
  19807. * Binds the material to the mesh
  19808. * @param world defines the world transformation matrix
  19809. * @param mesh defines the mesh to bind the material to
  19810. */
  19811. bind(world: Matrix, mesh?: Mesh): void;
  19812. /**
  19813. * Gets the active textures from the material
  19814. * @returns an array of textures
  19815. */
  19816. getActiveTextures(): BaseTexture[];
  19817. /**
  19818. * Specifies if the material uses a texture
  19819. * @param texture defines the texture to check against the material
  19820. * @returns a boolean specifying if the material uses the texture
  19821. */
  19822. hasTexture(texture: BaseTexture): boolean;
  19823. /**
  19824. * Makes a duplicate of the material, and gives it a new name
  19825. * @param name defines the new name for the duplicated material
  19826. * @returns the cloned material
  19827. */
  19828. clone(name: string): ShaderMaterial;
  19829. /**
  19830. * Disposes the material
  19831. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19832. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19833. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19834. */
  19835. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19836. /**
  19837. * Serializes this material in a JSON representation
  19838. * @returns the serialized material object
  19839. */
  19840. serialize(): any;
  19841. /**
  19842. * Creates a shader material from parsed shader material data
  19843. * @param source defines the JSON represnetation of the material
  19844. * @param scene defines the hosting scene
  19845. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19846. * @returns a new material
  19847. */
  19848. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19849. }
  19850. }
  19851. declare module "babylonjs/Shaders/color.fragment" {
  19852. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19853. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19854. /** @hidden */
  19855. export var colorPixelShader: {
  19856. name: string;
  19857. shader: string;
  19858. };
  19859. }
  19860. declare module "babylonjs/Shaders/color.vertex" {
  19861. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19862. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19863. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19864. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19865. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19866. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19867. /** @hidden */
  19868. export var colorVertexShader: {
  19869. name: string;
  19870. shader: string;
  19871. };
  19872. }
  19873. declare module "babylonjs/Meshes/linesMesh" {
  19874. import { Nullable } from "babylonjs/types";
  19875. import { Scene } from "babylonjs/scene";
  19876. import { Color3 } from "babylonjs/Maths/math.color";
  19877. import { Node } from "babylonjs/node";
  19878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19879. import { Mesh } from "babylonjs/Meshes/mesh";
  19880. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19881. import { Effect } from "babylonjs/Materials/effect";
  19882. import { Material } from "babylonjs/Materials/material";
  19883. import "babylonjs/Shaders/color.fragment";
  19884. import "babylonjs/Shaders/color.vertex";
  19885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19886. /**
  19887. * Line mesh
  19888. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19889. */
  19890. export class LinesMesh extends Mesh {
  19891. /**
  19892. * If vertex color should be applied to the mesh
  19893. */
  19894. readonly useVertexColor?: boolean | undefined;
  19895. /**
  19896. * If vertex alpha should be applied to the mesh
  19897. */
  19898. readonly useVertexAlpha?: boolean | undefined;
  19899. /**
  19900. * Color of the line (Default: White)
  19901. */
  19902. color: Color3;
  19903. /**
  19904. * Alpha of the line (Default: 1)
  19905. */
  19906. alpha: number;
  19907. /**
  19908. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19909. * This margin is expressed in world space coordinates, so its value may vary.
  19910. * Default value is 0.1
  19911. */
  19912. intersectionThreshold: number;
  19913. private _colorShader;
  19914. private color4;
  19915. /**
  19916. * Creates a new LinesMesh
  19917. * @param name defines the name
  19918. * @param scene defines the hosting scene
  19919. * @param parent defines the parent mesh if any
  19920. * @param source defines the optional source LinesMesh used to clone data from
  19921. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19922. * When false, achieved by calling a clone(), also passing False.
  19923. * This will make creation of children, recursive.
  19924. * @param useVertexColor defines if this LinesMesh supports vertex color
  19925. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19926. */
  19927. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19928. /**
  19929. * If vertex color should be applied to the mesh
  19930. */
  19931. useVertexColor?: boolean | undefined,
  19932. /**
  19933. * If vertex alpha should be applied to the mesh
  19934. */
  19935. useVertexAlpha?: boolean | undefined);
  19936. private _addClipPlaneDefine;
  19937. private _removeClipPlaneDefine;
  19938. isReady(): boolean;
  19939. /**
  19940. * Returns the string "LineMesh"
  19941. */
  19942. getClassName(): string;
  19943. /**
  19944. * @hidden
  19945. */
  19946. /**
  19947. * @hidden
  19948. */
  19949. material: Material;
  19950. /**
  19951. * @hidden
  19952. */
  19953. readonly checkCollisions: boolean;
  19954. /** @hidden */
  19955. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19956. /** @hidden */
  19957. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19958. /**
  19959. * Disposes of the line mesh
  19960. * @param doNotRecurse If children should be disposed
  19961. */
  19962. dispose(doNotRecurse?: boolean): void;
  19963. /**
  19964. * Returns a new LineMesh object cloned from the current one.
  19965. */
  19966. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19967. /**
  19968. * Creates a new InstancedLinesMesh object from the mesh model.
  19969. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19970. * @param name defines the name of the new instance
  19971. * @returns a new InstancedLinesMesh
  19972. */
  19973. createInstance(name: string): InstancedLinesMesh;
  19974. }
  19975. /**
  19976. * Creates an instance based on a source LinesMesh
  19977. */
  19978. export class InstancedLinesMesh extends InstancedMesh {
  19979. /**
  19980. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19981. * This margin is expressed in world space coordinates, so its value may vary.
  19982. * Initilized with the intersectionThreshold value of the source LinesMesh
  19983. */
  19984. intersectionThreshold: number;
  19985. constructor(name: string, source: LinesMesh);
  19986. /**
  19987. * Returns the string "InstancedLinesMesh".
  19988. */
  19989. getClassName(): string;
  19990. }
  19991. }
  19992. declare module "babylonjs/Shaders/line.fragment" {
  19993. /** @hidden */
  19994. export var linePixelShader: {
  19995. name: string;
  19996. shader: string;
  19997. };
  19998. }
  19999. declare module "babylonjs/Shaders/line.vertex" {
  20000. /** @hidden */
  20001. export var lineVertexShader: {
  20002. name: string;
  20003. shader: string;
  20004. };
  20005. }
  20006. declare module "babylonjs/Rendering/edgesRenderer" {
  20007. import { Nullable } from "babylonjs/types";
  20008. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20010. import { Vector3 } from "babylonjs/Maths/math.vector";
  20011. import { IDisposable } from "babylonjs/scene";
  20012. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20013. import "babylonjs/Shaders/line.fragment";
  20014. import "babylonjs/Shaders/line.vertex";
  20015. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20016. module "babylonjs/Meshes/abstractMesh" {
  20017. interface AbstractMesh {
  20018. /**
  20019. * Gets the edgesRenderer associated with the mesh
  20020. */
  20021. edgesRenderer: Nullable<EdgesRenderer>;
  20022. }
  20023. }
  20024. module "babylonjs/Meshes/linesMesh" {
  20025. interface LinesMesh {
  20026. /**
  20027. * Enables the edge rendering mode on the mesh.
  20028. * This mode makes the mesh edges visible
  20029. * @param epsilon defines the maximal distance between two angles to detect a face
  20030. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20031. * @returns the currentAbstractMesh
  20032. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20033. */
  20034. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20035. }
  20036. }
  20037. module "babylonjs/Meshes/linesMesh" {
  20038. interface InstancedLinesMesh {
  20039. /**
  20040. * Enables the edge rendering mode on the mesh.
  20041. * This mode makes the mesh edges visible
  20042. * @param epsilon defines the maximal distance between two angles to detect a face
  20043. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20044. * @returns the current InstancedLinesMesh
  20045. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20046. */
  20047. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20048. }
  20049. }
  20050. /**
  20051. * Defines the minimum contract an Edges renderer should follow.
  20052. */
  20053. export interface IEdgesRenderer extends IDisposable {
  20054. /**
  20055. * Gets or sets a boolean indicating if the edgesRenderer is active
  20056. */
  20057. isEnabled: boolean;
  20058. /**
  20059. * Renders the edges of the attached mesh,
  20060. */
  20061. render(): void;
  20062. /**
  20063. * Checks wether or not the edges renderer is ready to render.
  20064. * @return true if ready, otherwise false.
  20065. */
  20066. isReady(): boolean;
  20067. }
  20068. /**
  20069. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20070. */
  20071. export class EdgesRenderer implements IEdgesRenderer {
  20072. /**
  20073. * Define the size of the edges with an orthographic camera
  20074. */
  20075. edgesWidthScalerForOrthographic: number;
  20076. /**
  20077. * Define the size of the edges with a perspective camera
  20078. */
  20079. edgesWidthScalerForPerspective: number;
  20080. protected _source: AbstractMesh;
  20081. protected _linesPositions: number[];
  20082. protected _linesNormals: number[];
  20083. protected _linesIndices: number[];
  20084. protected _epsilon: number;
  20085. protected _indicesCount: number;
  20086. protected _lineShader: ShaderMaterial;
  20087. protected _ib: DataBuffer;
  20088. protected _buffers: {
  20089. [key: string]: Nullable<VertexBuffer>;
  20090. };
  20091. protected _checkVerticesInsteadOfIndices: boolean;
  20092. private _meshRebuildObserver;
  20093. private _meshDisposeObserver;
  20094. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20095. isEnabled: boolean;
  20096. /**
  20097. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20098. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20099. * @param source Mesh used to create edges
  20100. * @param epsilon sum of angles in adjacency to check for edge
  20101. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20102. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20103. */
  20104. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20105. protected _prepareRessources(): void;
  20106. /** @hidden */
  20107. _rebuild(): void;
  20108. /**
  20109. * Releases the required resources for the edges renderer
  20110. */
  20111. dispose(): void;
  20112. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20113. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20114. /**
  20115. * Checks if the pair of p0 and p1 is en edge
  20116. * @param faceIndex
  20117. * @param edge
  20118. * @param faceNormals
  20119. * @param p0
  20120. * @param p1
  20121. * @private
  20122. */
  20123. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20124. /**
  20125. * push line into the position, normal and index buffer
  20126. * @protected
  20127. */
  20128. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20129. /**
  20130. * Generates lines edges from adjacencjes
  20131. * @private
  20132. */
  20133. _generateEdgesLines(): void;
  20134. /**
  20135. * Checks wether or not the edges renderer is ready to render.
  20136. * @return true if ready, otherwise false.
  20137. */
  20138. isReady(): boolean;
  20139. /**
  20140. * Renders the edges of the attached mesh,
  20141. */
  20142. render(): void;
  20143. }
  20144. /**
  20145. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20146. */
  20147. export class LineEdgesRenderer extends EdgesRenderer {
  20148. /**
  20149. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20150. * @param source LineMesh used to generate edges
  20151. * @param epsilon not important (specified angle for edge detection)
  20152. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20153. */
  20154. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20155. /**
  20156. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20157. */
  20158. _generateEdgesLines(): void;
  20159. }
  20160. }
  20161. declare module "babylonjs/Rendering/renderingGroup" {
  20162. import { SmartArray } from "babylonjs/Misc/smartArray";
  20163. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20165. import { Nullable } from "babylonjs/types";
  20166. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20167. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20168. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20169. import { Material } from "babylonjs/Materials/material";
  20170. import { Scene } from "babylonjs/scene";
  20171. /**
  20172. * This represents the object necessary to create a rendering group.
  20173. * This is exclusively used and created by the rendering manager.
  20174. * To modify the behavior, you use the available helpers in your scene or meshes.
  20175. * @hidden
  20176. */
  20177. export class RenderingGroup {
  20178. index: number;
  20179. private static _zeroVector;
  20180. private _scene;
  20181. private _opaqueSubMeshes;
  20182. private _transparentSubMeshes;
  20183. private _alphaTestSubMeshes;
  20184. private _depthOnlySubMeshes;
  20185. private _particleSystems;
  20186. private _spriteManagers;
  20187. private _opaqueSortCompareFn;
  20188. private _alphaTestSortCompareFn;
  20189. private _transparentSortCompareFn;
  20190. private _renderOpaque;
  20191. private _renderAlphaTest;
  20192. private _renderTransparent;
  20193. /** @hidden */
  20194. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20195. onBeforeTransparentRendering: () => void;
  20196. /**
  20197. * Set the opaque sort comparison function.
  20198. * If null the sub meshes will be render in the order they were created
  20199. */
  20200. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20201. /**
  20202. * Set the alpha test sort comparison function.
  20203. * If null the sub meshes will be render in the order they were created
  20204. */
  20205. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20206. /**
  20207. * Set the transparent sort comparison function.
  20208. * If null the sub meshes will be render in the order they were created
  20209. */
  20210. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20211. /**
  20212. * Creates a new rendering group.
  20213. * @param index The rendering group index
  20214. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20215. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20216. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20217. */
  20218. 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>);
  20219. /**
  20220. * Render all the sub meshes contained in the group.
  20221. * @param customRenderFunction Used to override the default render behaviour of the group.
  20222. * @returns true if rendered some submeshes.
  20223. */
  20224. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20225. /**
  20226. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20227. * @param subMeshes The submeshes to render
  20228. */
  20229. private renderOpaqueSorted;
  20230. /**
  20231. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20232. * @param subMeshes The submeshes to render
  20233. */
  20234. private renderAlphaTestSorted;
  20235. /**
  20236. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20237. * @param subMeshes The submeshes to render
  20238. */
  20239. private renderTransparentSorted;
  20240. /**
  20241. * Renders the submeshes in a specified order.
  20242. * @param subMeshes The submeshes to sort before render
  20243. * @param sortCompareFn The comparison function use to sort
  20244. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20245. * @param transparent Specifies to activate blending if true
  20246. */
  20247. private static renderSorted;
  20248. /**
  20249. * Renders the submeshes in the order they were dispatched (no sort applied).
  20250. * @param subMeshes The submeshes to render
  20251. */
  20252. private static renderUnsorted;
  20253. /**
  20254. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20255. * are rendered back to front if in the same alpha index.
  20256. *
  20257. * @param a The first submesh
  20258. * @param b The second submesh
  20259. * @returns The result of the comparison
  20260. */
  20261. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20262. /**
  20263. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20264. * are rendered back to front.
  20265. *
  20266. * @param a The first submesh
  20267. * @param b The second submesh
  20268. * @returns The result of the comparison
  20269. */
  20270. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20271. /**
  20272. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20273. * are rendered front to back (prevent overdraw).
  20274. *
  20275. * @param a The first submesh
  20276. * @param b The second submesh
  20277. * @returns The result of the comparison
  20278. */
  20279. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20280. /**
  20281. * Resets the different lists of submeshes to prepare a new frame.
  20282. */
  20283. prepare(): void;
  20284. dispose(): void;
  20285. /**
  20286. * Inserts the submesh in its correct queue depending on its material.
  20287. * @param subMesh The submesh to dispatch
  20288. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20289. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20290. */
  20291. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20292. dispatchSprites(spriteManager: ISpriteManager): void;
  20293. dispatchParticles(particleSystem: IParticleSystem): void;
  20294. private _renderParticles;
  20295. private _renderSprites;
  20296. }
  20297. }
  20298. declare module "babylonjs/Rendering/renderingManager" {
  20299. import { Nullable } from "babylonjs/types";
  20300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20301. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20302. import { SmartArray } from "babylonjs/Misc/smartArray";
  20303. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20305. import { Material } from "babylonjs/Materials/material";
  20306. import { Scene } from "babylonjs/scene";
  20307. import { Camera } from "babylonjs/Cameras/camera";
  20308. /**
  20309. * Interface describing the different options available in the rendering manager
  20310. * regarding Auto Clear between groups.
  20311. */
  20312. export interface IRenderingManagerAutoClearSetup {
  20313. /**
  20314. * Defines whether or not autoclear is enable.
  20315. */
  20316. autoClear: boolean;
  20317. /**
  20318. * Defines whether or not to autoclear the depth buffer.
  20319. */
  20320. depth: boolean;
  20321. /**
  20322. * Defines whether or not to autoclear the stencil buffer.
  20323. */
  20324. stencil: boolean;
  20325. }
  20326. /**
  20327. * This class is used by the onRenderingGroupObservable
  20328. */
  20329. export class RenderingGroupInfo {
  20330. /**
  20331. * The Scene that being rendered
  20332. */
  20333. scene: Scene;
  20334. /**
  20335. * The camera currently used for the rendering pass
  20336. */
  20337. camera: Nullable<Camera>;
  20338. /**
  20339. * The ID of the renderingGroup being processed
  20340. */
  20341. renderingGroupId: number;
  20342. }
  20343. /**
  20344. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20345. * It is enable to manage the different groups as well as the different necessary sort functions.
  20346. * This should not be used directly aside of the few static configurations
  20347. */
  20348. export class RenderingManager {
  20349. /**
  20350. * The max id used for rendering groups (not included)
  20351. */
  20352. static MAX_RENDERINGGROUPS: number;
  20353. /**
  20354. * The min id used for rendering groups (included)
  20355. */
  20356. static MIN_RENDERINGGROUPS: number;
  20357. /**
  20358. * Used to globally prevent autoclearing scenes.
  20359. */
  20360. static AUTOCLEAR: boolean;
  20361. /**
  20362. * @hidden
  20363. */
  20364. _useSceneAutoClearSetup: boolean;
  20365. private _scene;
  20366. private _renderingGroups;
  20367. private _depthStencilBufferAlreadyCleaned;
  20368. private _autoClearDepthStencil;
  20369. private _customOpaqueSortCompareFn;
  20370. private _customAlphaTestSortCompareFn;
  20371. private _customTransparentSortCompareFn;
  20372. private _renderingGroupInfo;
  20373. /**
  20374. * Instantiates a new rendering group for a particular scene
  20375. * @param scene Defines the scene the groups belongs to
  20376. */
  20377. constructor(scene: Scene);
  20378. private _clearDepthStencilBuffer;
  20379. /**
  20380. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20381. * @hidden
  20382. */
  20383. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20384. /**
  20385. * Resets the different information of the group to prepare a new frame
  20386. * @hidden
  20387. */
  20388. reset(): void;
  20389. /**
  20390. * Dispose and release the group and its associated resources.
  20391. * @hidden
  20392. */
  20393. dispose(): void;
  20394. /**
  20395. * Clear the info related to rendering groups preventing retention points during dispose.
  20396. */
  20397. freeRenderingGroups(): void;
  20398. private _prepareRenderingGroup;
  20399. /**
  20400. * Add a sprite manager to the rendering manager in order to render it this frame.
  20401. * @param spriteManager Define the sprite manager to render
  20402. */
  20403. dispatchSprites(spriteManager: ISpriteManager): void;
  20404. /**
  20405. * Add a particle system to the rendering manager in order to render it this frame.
  20406. * @param particleSystem Define the particle system to render
  20407. */
  20408. dispatchParticles(particleSystem: IParticleSystem): void;
  20409. /**
  20410. * Add a submesh to the manager in order to render it this frame
  20411. * @param subMesh The submesh to dispatch
  20412. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20413. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20414. */
  20415. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20416. /**
  20417. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20418. * This allowed control for front to back rendering or reversly depending of the special needs.
  20419. *
  20420. * @param renderingGroupId The rendering group id corresponding to its index
  20421. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20422. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20423. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20424. */
  20425. 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;
  20426. /**
  20427. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20428. *
  20429. * @param renderingGroupId The rendering group id corresponding to its index
  20430. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20431. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20432. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20433. */
  20434. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20435. /**
  20436. * Gets the current auto clear configuration for one rendering group of the rendering
  20437. * manager.
  20438. * @param index the rendering group index to get the information for
  20439. * @returns The auto clear setup for the requested rendering group
  20440. */
  20441. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20442. }
  20443. }
  20444. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20445. import { Observable } from "babylonjs/Misc/observable";
  20446. import { SmartArray } from "babylonjs/Misc/smartArray";
  20447. import { Nullable } from "babylonjs/types";
  20448. import { Camera } from "babylonjs/Cameras/camera";
  20449. import { Scene } from "babylonjs/scene";
  20450. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20451. import { Color4 } from "babylonjs/Maths/math.color";
  20452. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20453. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20454. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20455. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20456. import { Texture } from "babylonjs/Materials/Textures/texture";
  20457. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20458. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20459. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20460. import { Engine } from "babylonjs/Engines/engine";
  20461. /**
  20462. * This Helps creating a texture that will be created from a camera in your scene.
  20463. * It is basically a dynamic texture that could be used to create special effects for instance.
  20464. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20465. */
  20466. export class RenderTargetTexture extends Texture {
  20467. isCube: boolean;
  20468. /**
  20469. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20470. */
  20471. static readonly REFRESHRATE_RENDER_ONCE: number;
  20472. /**
  20473. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20474. */
  20475. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20476. /**
  20477. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20478. * the central point of your effect and can save a lot of performances.
  20479. */
  20480. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20481. /**
  20482. * Use this predicate to dynamically define the list of mesh you want to render.
  20483. * If set, the renderList property will be overwritten.
  20484. */
  20485. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20486. private _renderList;
  20487. /**
  20488. * Use this list to define the list of mesh you want to render.
  20489. */
  20490. renderList: Nullable<Array<AbstractMesh>>;
  20491. private _hookArray;
  20492. /**
  20493. * Define if particles should be rendered in your texture.
  20494. */
  20495. renderParticles: boolean;
  20496. /**
  20497. * Define if sprites should be rendered in your texture.
  20498. */
  20499. renderSprites: boolean;
  20500. /**
  20501. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20502. */
  20503. coordinatesMode: number;
  20504. /**
  20505. * Define the camera used to render the texture.
  20506. */
  20507. activeCamera: Nullable<Camera>;
  20508. /**
  20509. * Override the render function of the texture with your own one.
  20510. */
  20511. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20512. /**
  20513. * Define if camera post processes should be use while rendering the texture.
  20514. */
  20515. useCameraPostProcesses: boolean;
  20516. /**
  20517. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20518. */
  20519. ignoreCameraViewport: boolean;
  20520. private _postProcessManager;
  20521. private _postProcesses;
  20522. private _resizeObserver;
  20523. /**
  20524. * An event triggered when the texture is unbind.
  20525. */
  20526. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20527. /**
  20528. * An event triggered when the texture is unbind.
  20529. */
  20530. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20531. private _onAfterUnbindObserver;
  20532. /**
  20533. * Set a after unbind callback in the texture.
  20534. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20535. */
  20536. onAfterUnbind: () => void;
  20537. /**
  20538. * An event triggered before rendering the texture
  20539. */
  20540. onBeforeRenderObservable: Observable<number>;
  20541. private _onBeforeRenderObserver;
  20542. /**
  20543. * Set a before render callback in the texture.
  20544. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20545. */
  20546. onBeforeRender: (faceIndex: number) => void;
  20547. /**
  20548. * An event triggered after rendering the texture
  20549. */
  20550. onAfterRenderObservable: Observable<number>;
  20551. private _onAfterRenderObserver;
  20552. /**
  20553. * Set a after render callback in the texture.
  20554. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20555. */
  20556. onAfterRender: (faceIndex: number) => void;
  20557. /**
  20558. * An event triggered after the texture clear
  20559. */
  20560. onClearObservable: Observable<Engine>;
  20561. private _onClearObserver;
  20562. /**
  20563. * Set a clear callback in the texture.
  20564. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20565. */
  20566. onClear: (Engine: Engine) => void;
  20567. /**
  20568. * An event triggered when the texture is resized.
  20569. */
  20570. onResizeObservable: Observable<RenderTargetTexture>;
  20571. /**
  20572. * Define the clear color of the Render Target if it should be different from the scene.
  20573. */
  20574. clearColor: Color4;
  20575. protected _size: number | {
  20576. width: number;
  20577. height: number;
  20578. };
  20579. protected _initialSizeParameter: number | {
  20580. width: number;
  20581. height: number;
  20582. } | {
  20583. ratio: number;
  20584. };
  20585. protected _sizeRatio: Nullable<number>;
  20586. /** @hidden */
  20587. _generateMipMaps: boolean;
  20588. protected _renderingManager: RenderingManager;
  20589. /** @hidden */
  20590. _waitingRenderList: string[];
  20591. protected _doNotChangeAspectRatio: boolean;
  20592. protected _currentRefreshId: number;
  20593. protected _refreshRate: number;
  20594. protected _textureMatrix: Matrix;
  20595. protected _samples: number;
  20596. protected _renderTargetOptions: RenderTargetCreationOptions;
  20597. /**
  20598. * Gets render target creation options that were used.
  20599. */
  20600. readonly renderTargetOptions: RenderTargetCreationOptions;
  20601. protected _engine: Engine;
  20602. protected _onRatioRescale(): void;
  20603. /**
  20604. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20605. * It must define where the camera used to render the texture is set
  20606. */
  20607. boundingBoxPosition: Vector3;
  20608. private _boundingBoxSize;
  20609. /**
  20610. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20611. * When defined, the cubemap will switch to local mode
  20612. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20613. * @example https://www.babylonjs-playground.com/#RNASML
  20614. */
  20615. boundingBoxSize: Vector3;
  20616. /**
  20617. * In case the RTT has been created with a depth texture, get the associated
  20618. * depth texture.
  20619. * Otherwise, return null.
  20620. */
  20621. depthStencilTexture: Nullable<InternalTexture>;
  20622. /**
  20623. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20624. * or used a shadow, depth texture...
  20625. * @param name The friendly name of the texture
  20626. * @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)
  20627. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20628. * @param generateMipMaps True if mip maps need to be generated after render.
  20629. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20630. * @param type The type of the buffer in the RTT (int, half float, float...)
  20631. * @param isCube True if a cube texture needs to be created
  20632. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20633. * @param generateDepthBuffer True to generate a depth buffer
  20634. * @param generateStencilBuffer True to generate a stencil buffer
  20635. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20636. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20637. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20638. */
  20639. constructor(name: string, size: number | {
  20640. width: number;
  20641. height: number;
  20642. } | {
  20643. ratio: number;
  20644. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20645. /**
  20646. * Creates a depth stencil texture.
  20647. * This is only available in WebGL 2 or with the depth texture extension available.
  20648. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20649. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20650. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20651. */
  20652. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20653. private _processSizeParameter;
  20654. /**
  20655. * Define the number of samples to use in case of MSAA.
  20656. * It defaults to one meaning no MSAA has been enabled.
  20657. */
  20658. samples: number;
  20659. /**
  20660. * Resets the refresh counter of the texture and start bak from scratch.
  20661. * Could be useful to regenerate the texture if it is setup to render only once.
  20662. */
  20663. resetRefreshCounter(): void;
  20664. /**
  20665. * Define the refresh rate of the texture or the rendering frequency.
  20666. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20667. */
  20668. refreshRate: number;
  20669. /**
  20670. * Adds a post process to the render target rendering passes.
  20671. * @param postProcess define the post process to add
  20672. */
  20673. addPostProcess(postProcess: PostProcess): void;
  20674. /**
  20675. * Clear all the post processes attached to the render target
  20676. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20677. */
  20678. clearPostProcesses(dispose?: boolean): void;
  20679. /**
  20680. * Remove one of the post process from the list of attached post processes to the texture
  20681. * @param postProcess define the post process to remove from the list
  20682. */
  20683. removePostProcess(postProcess: PostProcess): void;
  20684. /** @hidden */
  20685. _shouldRender(): boolean;
  20686. /**
  20687. * Gets the actual render size of the texture.
  20688. * @returns the width of the render size
  20689. */
  20690. getRenderSize(): number;
  20691. /**
  20692. * Gets the actual render width of the texture.
  20693. * @returns the width of the render size
  20694. */
  20695. getRenderWidth(): number;
  20696. /**
  20697. * Gets the actual render height of the texture.
  20698. * @returns the height of the render size
  20699. */
  20700. getRenderHeight(): number;
  20701. /**
  20702. * Get if the texture can be rescaled or not.
  20703. */
  20704. readonly canRescale: boolean;
  20705. /**
  20706. * Resize the texture using a ratio.
  20707. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20708. */
  20709. scale(ratio: number): void;
  20710. /**
  20711. * Get the texture reflection matrix used to rotate/transform the reflection.
  20712. * @returns the reflection matrix
  20713. */
  20714. getReflectionTextureMatrix(): Matrix;
  20715. /**
  20716. * Resize the texture to a new desired size.
  20717. * Be carrefull as it will recreate all the data in the new texture.
  20718. * @param size Define the new size. It can be:
  20719. * - a number for squared texture,
  20720. * - an object containing { width: number, height: number }
  20721. * - or an object containing a ratio { ratio: number }
  20722. */
  20723. resize(size: number | {
  20724. width: number;
  20725. height: number;
  20726. } | {
  20727. ratio: number;
  20728. }): void;
  20729. /**
  20730. * Renders all the objects from the render list into the texture.
  20731. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20732. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20733. */
  20734. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20735. private _bestReflectionRenderTargetDimension;
  20736. /**
  20737. * @hidden
  20738. * @param faceIndex face index to bind to if this is a cubetexture
  20739. */
  20740. _bindFrameBuffer(faceIndex?: number): void;
  20741. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20742. private renderToTarget;
  20743. /**
  20744. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20745. * This allowed control for front to back rendering or reversly depending of the special needs.
  20746. *
  20747. * @param renderingGroupId The rendering group id corresponding to its index
  20748. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20749. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20750. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20751. */
  20752. 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;
  20753. /**
  20754. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20755. *
  20756. * @param renderingGroupId The rendering group id corresponding to its index
  20757. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20758. */
  20759. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20760. /**
  20761. * Clones the texture.
  20762. * @returns the cloned texture
  20763. */
  20764. clone(): RenderTargetTexture;
  20765. /**
  20766. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20767. * @returns The JSON representation of the texture
  20768. */
  20769. serialize(): any;
  20770. /**
  20771. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20772. */
  20773. disposeFramebufferObjects(): void;
  20774. /**
  20775. * Dispose the texture and release its associated resources.
  20776. */
  20777. dispose(): void;
  20778. /** @hidden */
  20779. _rebuild(): void;
  20780. /**
  20781. * Clear the info related to rendering groups preventing retention point in material dispose.
  20782. */
  20783. freeRenderingGroups(): void;
  20784. /**
  20785. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20786. * @returns the view count
  20787. */
  20788. getViewCount(): number;
  20789. }
  20790. }
  20791. declare module "babylonjs/Materials/material" {
  20792. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20793. import { SmartArray } from "babylonjs/Misc/smartArray";
  20794. import { Observable } from "babylonjs/Misc/observable";
  20795. import { Nullable } from "babylonjs/types";
  20796. import { Scene } from "babylonjs/scene";
  20797. import { Matrix } from "babylonjs/Maths/math.vector";
  20798. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20800. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20801. import { Effect } from "babylonjs/Materials/effect";
  20802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20803. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20804. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20805. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20806. import { Mesh } from "babylonjs/Meshes/mesh";
  20807. import { Animation } from "babylonjs/Animations/animation";
  20808. /**
  20809. * Base class for the main features of a material in Babylon.js
  20810. */
  20811. export class Material implements IAnimatable {
  20812. /**
  20813. * Returns the triangle fill mode
  20814. */
  20815. static readonly TriangleFillMode: number;
  20816. /**
  20817. * Returns the wireframe mode
  20818. */
  20819. static readonly WireFrameFillMode: number;
  20820. /**
  20821. * Returns the point fill mode
  20822. */
  20823. static readonly PointFillMode: number;
  20824. /**
  20825. * Returns the point list draw mode
  20826. */
  20827. static readonly PointListDrawMode: number;
  20828. /**
  20829. * Returns the line list draw mode
  20830. */
  20831. static readonly LineListDrawMode: number;
  20832. /**
  20833. * Returns the line loop draw mode
  20834. */
  20835. static readonly LineLoopDrawMode: number;
  20836. /**
  20837. * Returns the line strip draw mode
  20838. */
  20839. static readonly LineStripDrawMode: number;
  20840. /**
  20841. * Returns the triangle strip draw mode
  20842. */
  20843. static readonly TriangleStripDrawMode: number;
  20844. /**
  20845. * Returns the triangle fan draw mode
  20846. */
  20847. static readonly TriangleFanDrawMode: number;
  20848. /**
  20849. * Stores the clock-wise side orientation
  20850. */
  20851. static readonly ClockWiseSideOrientation: number;
  20852. /**
  20853. * Stores the counter clock-wise side orientation
  20854. */
  20855. static readonly CounterClockWiseSideOrientation: number;
  20856. /**
  20857. * The dirty texture flag value
  20858. */
  20859. static readonly TextureDirtyFlag: number;
  20860. /**
  20861. * The dirty light flag value
  20862. */
  20863. static readonly LightDirtyFlag: number;
  20864. /**
  20865. * The dirty fresnel flag value
  20866. */
  20867. static readonly FresnelDirtyFlag: number;
  20868. /**
  20869. * The dirty attribute flag value
  20870. */
  20871. static readonly AttributesDirtyFlag: number;
  20872. /**
  20873. * The dirty misc flag value
  20874. */
  20875. static readonly MiscDirtyFlag: number;
  20876. /**
  20877. * The all dirty flag value
  20878. */
  20879. static readonly AllDirtyFlag: number;
  20880. /**
  20881. * The ID of the material
  20882. */
  20883. id: string;
  20884. /**
  20885. * Gets or sets the unique id of the material
  20886. */
  20887. uniqueId: number;
  20888. /**
  20889. * The name of the material
  20890. */
  20891. name: string;
  20892. /**
  20893. * Gets or sets user defined metadata
  20894. */
  20895. metadata: any;
  20896. /**
  20897. * For internal use only. Please do not use.
  20898. */
  20899. reservedDataStore: any;
  20900. /**
  20901. * Specifies if the ready state should be checked on each call
  20902. */
  20903. checkReadyOnEveryCall: boolean;
  20904. /**
  20905. * Specifies if the ready state should be checked once
  20906. */
  20907. checkReadyOnlyOnce: boolean;
  20908. /**
  20909. * The state of the material
  20910. */
  20911. state: string;
  20912. /**
  20913. * The alpha value of the material
  20914. */
  20915. protected _alpha: number;
  20916. /**
  20917. * List of inspectable custom properties (used by the Inspector)
  20918. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20919. */
  20920. inspectableCustomProperties: IInspectable[];
  20921. /**
  20922. * Sets the alpha value of the material
  20923. */
  20924. /**
  20925. * Gets the alpha value of the material
  20926. */
  20927. alpha: number;
  20928. /**
  20929. * Specifies if back face culling is enabled
  20930. */
  20931. protected _backFaceCulling: boolean;
  20932. /**
  20933. * Sets the back-face culling state
  20934. */
  20935. /**
  20936. * Gets the back-face culling state
  20937. */
  20938. backFaceCulling: boolean;
  20939. /**
  20940. * Stores the value for side orientation
  20941. */
  20942. sideOrientation: number;
  20943. /**
  20944. * Callback triggered when the material is compiled
  20945. */
  20946. onCompiled: Nullable<(effect: Effect) => void>;
  20947. /**
  20948. * Callback triggered when an error occurs
  20949. */
  20950. onError: Nullable<(effect: Effect, errors: string) => void>;
  20951. /**
  20952. * Callback triggered to get the render target textures
  20953. */
  20954. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20955. /**
  20956. * Gets a boolean indicating that current material needs to register RTT
  20957. */
  20958. readonly hasRenderTargetTextures: boolean;
  20959. /**
  20960. * Specifies if the material should be serialized
  20961. */
  20962. doNotSerialize: boolean;
  20963. /**
  20964. * @hidden
  20965. */
  20966. _storeEffectOnSubMeshes: boolean;
  20967. /**
  20968. * Stores the animations for the material
  20969. */
  20970. animations: Nullable<Array<Animation>>;
  20971. /**
  20972. * An event triggered when the material is disposed
  20973. */
  20974. onDisposeObservable: Observable<Material>;
  20975. /**
  20976. * An observer which watches for dispose events
  20977. */
  20978. private _onDisposeObserver;
  20979. private _onUnBindObservable;
  20980. /**
  20981. * Called during a dispose event
  20982. */
  20983. onDispose: () => void;
  20984. private _onBindObservable;
  20985. /**
  20986. * An event triggered when the material is bound
  20987. */
  20988. readonly onBindObservable: Observable<AbstractMesh>;
  20989. /**
  20990. * An observer which watches for bind events
  20991. */
  20992. private _onBindObserver;
  20993. /**
  20994. * Called during a bind event
  20995. */
  20996. onBind: (Mesh: AbstractMesh) => void;
  20997. /**
  20998. * An event triggered when the material is unbound
  20999. */
  21000. readonly onUnBindObservable: Observable<Material>;
  21001. /**
  21002. * Stores the value of the alpha mode
  21003. */
  21004. private _alphaMode;
  21005. /**
  21006. * Sets the value of the alpha mode.
  21007. *
  21008. * | Value | Type | Description |
  21009. * | --- | --- | --- |
  21010. * | 0 | ALPHA_DISABLE | |
  21011. * | 1 | ALPHA_ADD | |
  21012. * | 2 | ALPHA_COMBINE | |
  21013. * | 3 | ALPHA_SUBTRACT | |
  21014. * | 4 | ALPHA_MULTIPLY | |
  21015. * | 5 | ALPHA_MAXIMIZED | |
  21016. * | 6 | ALPHA_ONEONE | |
  21017. * | 7 | ALPHA_PREMULTIPLIED | |
  21018. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21019. * | 9 | ALPHA_INTERPOLATE | |
  21020. * | 10 | ALPHA_SCREENMODE | |
  21021. *
  21022. */
  21023. /**
  21024. * Gets the value of the alpha mode
  21025. */
  21026. alphaMode: number;
  21027. /**
  21028. * Stores the state of the need depth pre-pass value
  21029. */
  21030. private _needDepthPrePass;
  21031. /**
  21032. * Sets the need depth pre-pass value
  21033. */
  21034. /**
  21035. * Gets the depth pre-pass value
  21036. */
  21037. needDepthPrePass: boolean;
  21038. /**
  21039. * Specifies if depth writing should be disabled
  21040. */
  21041. disableDepthWrite: boolean;
  21042. /**
  21043. * Specifies if depth writing should be forced
  21044. */
  21045. forceDepthWrite: boolean;
  21046. /**
  21047. * Specifies if there should be a separate pass for culling
  21048. */
  21049. separateCullingPass: boolean;
  21050. /**
  21051. * Stores the state specifing if fog should be enabled
  21052. */
  21053. private _fogEnabled;
  21054. /**
  21055. * Sets the state for enabling fog
  21056. */
  21057. /**
  21058. * Gets the value of the fog enabled state
  21059. */
  21060. fogEnabled: boolean;
  21061. /**
  21062. * Stores the size of points
  21063. */
  21064. pointSize: number;
  21065. /**
  21066. * Stores the z offset value
  21067. */
  21068. zOffset: number;
  21069. /**
  21070. * Gets a value specifying if wireframe mode is enabled
  21071. */
  21072. /**
  21073. * Sets the state of wireframe mode
  21074. */
  21075. wireframe: boolean;
  21076. /**
  21077. * Gets the value specifying if point clouds are enabled
  21078. */
  21079. /**
  21080. * Sets the state of point cloud mode
  21081. */
  21082. pointsCloud: boolean;
  21083. /**
  21084. * Gets the material fill mode
  21085. */
  21086. /**
  21087. * Sets the material fill mode
  21088. */
  21089. fillMode: number;
  21090. /**
  21091. * @hidden
  21092. * Stores the effects for the material
  21093. */
  21094. _effect: Nullable<Effect>;
  21095. /**
  21096. * @hidden
  21097. * Specifies if the material was previously ready
  21098. */
  21099. _wasPreviouslyReady: boolean;
  21100. /**
  21101. * Specifies if uniform buffers should be used
  21102. */
  21103. private _useUBO;
  21104. /**
  21105. * Stores a reference to the scene
  21106. */
  21107. private _scene;
  21108. /**
  21109. * Stores the fill mode state
  21110. */
  21111. private _fillMode;
  21112. /**
  21113. * Specifies if the depth write state should be cached
  21114. */
  21115. private _cachedDepthWriteState;
  21116. /**
  21117. * Stores the uniform buffer
  21118. */
  21119. protected _uniformBuffer: UniformBuffer;
  21120. /** @hidden */
  21121. _indexInSceneMaterialArray: number;
  21122. /** @hidden */
  21123. meshMap: Nullable<{
  21124. [id: string]: AbstractMesh | undefined;
  21125. }>;
  21126. /**
  21127. * Creates a material instance
  21128. * @param name defines the name of the material
  21129. * @param scene defines the scene to reference
  21130. * @param doNotAdd specifies if the material should be added to the scene
  21131. */
  21132. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21133. /**
  21134. * Returns a string representation of the current material
  21135. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21136. * @returns a string with material information
  21137. */
  21138. toString(fullDetails?: boolean): string;
  21139. /**
  21140. * Gets the class name of the material
  21141. * @returns a string with the class name of the material
  21142. */
  21143. getClassName(): string;
  21144. /**
  21145. * Specifies if updates for the material been locked
  21146. */
  21147. readonly isFrozen: boolean;
  21148. /**
  21149. * Locks updates for the material
  21150. */
  21151. freeze(): void;
  21152. /**
  21153. * Unlocks updates for the material
  21154. */
  21155. unfreeze(): void;
  21156. /**
  21157. * Specifies if the material is ready to be used
  21158. * @param mesh defines the mesh to check
  21159. * @param useInstances specifies if instances should be used
  21160. * @returns a boolean indicating if the material is ready to be used
  21161. */
  21162. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21163. /**
  21164. * Specifies that the submesh is ready to be used
  21165. * @param mesh defines the mesh to check
  21166. * @param subMesh defines which submesh to check
  21167. * @param useInstances specifies that instances should be used
  21168. * @returns a boolean indicating that the submesh is ready or not
  21169. */
  21170. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21171. /**
  21172. * Returns the material effect
  21173. * @returns the effect associated with the material
  21174. */
  21175. getEffect(): Nullable<Effect>;
  21176. /**
  21177. * Returns the current scene
  21178. * @returns a Scene
  21179. */
  21180. getScene(): Scene;
  21181. /**
  21182. * Specifies if the material will require alpha blending
  21183. * @returns a boolean specifying if alpha blending is needed
  21184. */
  21185. needAlphaBlending(): boolean;
  21186. /**
  21187. * Specifies if the mesh will require alpha blending
  21188. * @param mesh defines the mesh to check
  21189. * @returns a boolean specifying if alpha blending is needed for the mesh
  21190. */
  21191. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21192. /**
  21193. * Specifies if this material should be rendered in alpha test mode
  21194. * @returns a boolean specifying if an alpha test is needed.
  21195. */
  21196. needAlphaTesting(): boolean;
  21197. /**
  21198. * Gets the texture used for the alpha test
  21199. * @returns the texture to use for alpha testing
  21200. */
  21201. getAlphaTestTexture(): Nullable<BaseTexture>;
  21202. /**
  21203. * Marks the material to indicate that it needs to be re-calculated
  21204. */
  21205. markDirty(): void;
  21206. /** @hidden */
  21207. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21208. /**
  21209. * Binds the material to the mesh
  21210. * @param world defines the world transformation matrix
  21211. * @param mesh defines the mesh to bind the material to
  21212. */
  21213. bind(world: Matrix, mesh?: Mesh): void;
  21214. /**
  21215. * Binds the submesh to the material
  21216. * @param world defines the world transformation matrix
  21217. * @param mesh defines the mesh containing the submesh
  21218. * @param subMesh defines the submesh to bind the material to
  21219. */
  21220. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21221. /**
  21222. * Binds the world matrix to the material
  21223. * @param world defines the world transformation matrix
  21224. */
  21225. bindOnlyWorldMatrix(world: Matrix): void;
  21226. /**
  21227. * Binds the scene's uniform buffer to the effect.
  21228. * @param effect defines the effect to bind to the scene uniform buffer
  21229. * @param sceneUbo defines the uniform buffer storing scene data
  21230. */
  21231. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21232. /**
  21233. * Binds the view matrix to the effect
  21234. * @param effect defines the effect to bind the view matrix to
  21235. */
  21236. bindView(effect: Effect): void;
  21237. /**
  21238. * Binds the view projection matrix to the effect
  21239. * @param effect defines the effect to bind the view projection matrix to
  21240. */
  21241. bindViewProjection(effect: Effect): void;
  21242. /**
  21243. * Specifies if material alpha testing should be turned on for the mesh
  21244. * @param mesh defines the mesh to check
  21245. */
  21246. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21247. /**
  21248. * Processes to execute after binding the material to a mesh
  21249. * @param mesh defines the rendered mesh
  21250. */
  21251. protected _afterBind(mesh?: Mesh): void;
  21252. /**
  21253. * Unbinds the material from the mesh
  21254. */
  21255. unbind(): void;
  21256. /**
  21257. * Gets the active textures from the material
  21258. * @returns an array of textures
  21259. */
  21260. getActiveTextures(): BaseTexture[];
  21261. /**
  21262. * Specifies if the material uses a texture
  21263. * @param texture defines the texture to check against the material
  21264. * @returns a boolean specifying if the material uses the texture
  21265. */
  21266. hasTexture(texture: BaseTexture): boolean;
  21267. /**
  21268. * Makes a duplicate of the material, and gives it a new name
  21269. * @param name defines the new name for the duplicated material
  21270. * @returns the cloned material
  21271. */
  21272. clone(name: string): Nullable<Material>;
  21273. /**
  21274. * Gets the meshes bound to the material
  21275. * @returns an array of meshes bound to the material
  21276. */
  21277. getBindedMeshes(): AbstractMesh[];
  21278. /**
  21279. * Force shader compilation
  21280. * @param mesh defines the mesh associated with this material
  21281. * @param onCompiled defines a function to execute once the material is compiled
  21282. * @param options defines the options to configure the compilation
  21283. */
  21284. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21285. clipPlane: boolean;
  21286. }>): void;
  21287. /**
  21288. * Force shader compilation
  21289. * @param mesh defines the mesh that will use this material
  21290. * @param options defines additional options for compiling the shaders
  21291. * @returns a promise that resolves when the compilation completes
  21292. */
  21293. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21294. clipPlane: boolean;
  21295. }>): Promise<void>;
  21296. private static readonly _AllDirtyCallBack;
  21297. private static readonly _ImageProcessingDirtyCallBack;
  21298. private static readonly _TextureDirtyCallBack;
  21299. private static readonly _FresnelDirtyCallBack;
  21300. private static readonly _MiscDirtyCallBack;
  21301. private static readonly _LightsDirtyCallBack;
  21302. private static readonly _AttributeDirtyCallBack;
  21303. private static _FresnelAndMiscDirtyCallBack;
  21304. private static _TextureAndMiscDirtyCallBack;
  21305. private static readonly _DirtyCallbackArray;
  21306. private static readonly _RunDirtyCallBacks;
  21307. /**
  21308. * Marks a define in the material to indicate that it needs to be re-computed
  21309. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21310. */
  21311. markAsDirty(flag: number): void;
  21312. /**
  21313. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21314. * @param func defines a function which checks material defines against the submeshes
  21315. */
  21316. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21317. /**
  21318. * Indicates that we need to re-calculated for all submeshes
  21319. */
  21320. protected _markAllSubMeshesAsAllDirty(): void;
  21321. /**
  21322. * Indicates that image processing needs to be re-calculated for all submeshes
  21323. */
  21324. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21325. /**
  21326. * Indicates that textures need to be re-calculated for all submeshes
  21327. */
  21328. protected _markAllSubMeshesAsTexturesDirty(): void;
  21329. /**
  21330. * Indicates that fresnel needs to be re-calculated for all submeshes
  21331. */
  21332. protected _markAllSubMeshesAsFresnelDirty(): void;
  21333. /**
  21334. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21335. */
  21336. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21337. /**
  21338. * Indicates that lights need to be re-calculated for all submeshes
  21339. */
  21340. protected _markAllSubMeshesAsLightsDirty(): void;
  21341. /**
  21342. * Indicates that attributes need to be re-calculated for all submeshes
  21343. */
  21344. protected _markAllSubMeshesAsAttributesDirty(): void;
  21345. /**
  21346. * Indicates that misc needs to be re-calculated for all submeshes
  21347. */
  21348. protected _markAllSubMeshesAsMiscDirty(): void;
  21349. /**
  21350. * Indicates that textures and misc need to be re-calculated for all submeshes
  21351. */
  21352. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21353. /**
  21354. * Disposes the material
  21355. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21356. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21357. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21358. */
  21359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21360. /** @hidden */
  21361. private releaseVertexArrayObject;
  21362. /**
  21363. * Serializes this material
  21364. * @returns the serialized material object
  21365. */
  21366. serialize(): any;
  21367. /**
  21368. * Creates a material from parsed material data
  21369. * @param parsedMaterial defines parsed material data
  21370. * @param scene defines the hosting scene
  21371. * @param rootUrl defines the root URL to use to load textures
  21372. * @returns a new material
  21373. */
  21374. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21375. }
  21376. }
  21377. declare module "babylonjs/Materials/multiMaterial" {
  21378. import { Nullable } from "babylonjs/types";
  21379. import { Scene } from "babylonjs/scene";
  21380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21381. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21383. import { Material } from "babylonjs/Materials/material";
  21384. /**
  21385. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21386. * separate meshes. This can be use to improve performances.
  21387. * @see http://doc.babylonjs.com/how_to/multi_materials
  21388. */
  21389. export class MultiMaterial extends Material {
  21390. private _subMaterials;
  21391. /**
  21392. * Gets or Sets the list of Materials used within the multi material.
  21393. * They need to be ordered according to the submeshes order in the associated mesh
  21394. */
  21395. subMaterials: Nullable<Material>[];
  21396. /**
  21397. * Function used to align with Node.getChildren()
  21398. * @returns the list of Materials used within the multi material
  21399. */
  21400. getChildren(): Nullable<Material>[];
  21401. /**
  21402. * Instantiates a new Multi Material
  21403. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21404. * separate meshes. This can be use to improve performances.
  21405. * @see http://doc.babylonjs.com/how_to/multi_materials
  21406. * @param name Define the name in the scene
  21407. * @param scene Define the scene the material belongs to
  21408. */
  21409. constructor(name: string, scene: Scene);
  21410. private _hookArray;
  21411. /**
  21412. * Get one of the submaterial by its index in the submaterials array
  21413. * @param index The index to look the sub material at
  21414. * @returns The Material if the index has been defined
  21415. */
  21416. getSubMaterial(index: number): Nullable<Material>;
  21417. /**
  21418. * Get the list of active textures for the whole sub materials list.
  21419. * @returns All the textures that will be used during the rendering
  21420. */
  21421. getActiveTextures(): BaseTexture[];
  21422. /**
  21423. * Gets the current class name of the material e.g. "MultiMaterial"
  21424. * Mainly use in serialization.
  21425. * @returns the class name
  21426. */
  21427. getClassName(): string;
  21428. /**
  21429. * Checks if the material is ready to render the requested sub mesh
  21430. * @param mesh Define the mesh the submesh belongs to
  21431. * @param subMesh Define the sub mesh to look readyness for
  21432. * @param useInstances Define whether or not the material is used with instances
  21433. * @returns true if ready, otherwise false
  21434. */
  21435. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21436. /**
  21437. * Clones the current material and its related sub materials
  21438. * @param name Define the name of the newly cloned material
  21439. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21440. * @returns the cloned material
  21441. */
  21442. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21443. /**
  21444. * Serializes the materials into a JSON representation.
  21445. * @returns the JSON representation
  21446. */
  21447. serialize(): any;
  21448. /**
  21449. * Dispose the material and release its associated resources
  21450. * @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)
  21451. * @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)
  21452. * @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)
  21453. */
  21454. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21455. /**
  21456. * Creates a MultiMaterial from parsed MultiMaterial data.
  21457. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21458. * @param scene defines the hosting scene
  21459. * @returns a new MultiMaterial
  21460. */
  21461. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21462. }
  21463. }
  21464. declare module "babylonjs/Meshes/subMesh" {
  21465. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21466. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21467. import { Engine } from "babylonjs/Engines/engine";
  21468. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21469. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21470. import { Effect } from "babylonjs/Materials/effect";
  21471. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21472. import { Plane } from "babylonjs/Maths/math.plane";
  21473. import { Collider } from "babylonjs/Collisions/collider";
  21474. import { Material } from "babylonjs/Materials/material";
  21475. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21477. import { Mesh } from "babylonjs/Meshes/mesh";
  21478. import { Ray } from "babylonjs/Culling/ray";
  21479. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21480. /**
  21481. * Base class for submeshes
  21482. */
  21483. export class BaseSubMesh {
  21484. /** @hidden */
  21485. _materialDefines: Nullable<MaterialDefines>;
  21486. /** @hidden */
  21487. _materialEffect: Nullable<Effect>;
  21488. /**
  21489. * Gets associated effect
  21490. */
  21491. readonly effect: Nullable<Effect>;
  21492. /**
  21493. * Sets associated effect (effect used to render this submesh)
  21494. * @param effect defines the effect to associate with
  21495. * @param defines defines the set of defines used to compile this effect
  21496. */
  21497. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21498. }
  21499. /**
  21500. * Defines a subdivision inside a mesh
  21501. */
  21502. export class SubMesh extends BaseSubMesh implements ICullable {
  21503. /** the material index to use */
  21504. materialIndex: number;
  21505. /** vertex index start */
  21506. verticesStart: number;
  21507. /** vertices count */
  21508. verticesCount: number;
  21509. /** index start */
  21510. indexStart: number;
  21511. /** indices count */
  21512. indexCount: number;
  21513. /** @hidden */
  21514. _linesIndexCount: number;
  21515. private _mesh;
  21516. private _renderingMesh;
  21517. private _boundingInfo;
  21518. private _linesIndexBuffer;
  21519. /** @hidden */
  21520. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21521. /** @hidden */
  21522. _trianglePlanes: Plane[];
  21523. /** @hidden */
  21524. _lastColliderTransformMatrix: Nullable<Matrix>;
  21525. /** @hidden */
  21526. _renderId: number;
  21527. /** @hidden */
  21528. _alphaIndex: number;
  21529. /** @hidden */
  21530. _distanceToCamera: number;
  21531. /** @hidden */
  21532. _id: number;
  21533. private _currentMaterial;
  21534. /**
  21535. * Add a new submesh to a mesh
  21536. * @param materialIndex defines the material index to use
  21537. * @param verticesStart defines vertex index start
  21538. * @param verticesCount defines vertices count
  21539. * @param indexStart defines index start
  21540. * @param indexCount defines indices count
  21541. * @param mesh defines the parent mesh
  21542. * @param renderingMesh defines an optional rendering mesh
  21543. * @param createBoundingBox defines if bounding box should be created for this submesh
  21544. * @returns the new submesh
  21545. */
  21546. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21547. /**
  21548. * Creates a new submesh
  21549. * @param materialIndex defines the material index to use
  21550. * @param verticesStart defines vertex index start
  21551. * @param verticesCount defines vertices count
  21552. * @param indexStart defines index start
  21553. * @param indexCount defines indices count
  21554. * @param mesh defines the parent mesh
  21555. * @param renderingMesh defines an optional rendering mesh
  21556. * @param createBoundingBox defines if bounding box should be created for this submesh
  21557. */
  21558. constructor(
  21559. /** the material index to use */
  21560. materialIndex: number,
  21561. /** vertex index start */
  21562. verticesStart: number,
  21563. /** vertices count */
  21564. verticesCount: number,
  21565. /** index start */
  21566. indexStart: number,
  21567. /** indices count */
  21568. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21569. /**
  21570. * Returns true if this submesh covers the entire parent mesh
  21571. * @ignorenaming
  21572. */
  21573. readonly IsGlobal: boolean;
  21574. /**
  21575. * Returns the submesh BoudingInfo object
  21576. * @returns current bounding info (or mesh's one if the submesh is global)
  21577. */
  21578. getBoundingInfo(): BoundingInfo;
  21579. /**
  21580. * Sets the submesh BoundingInfo
  21581. * @param boundingInfo defines the new bounding info to use
  21582. * @returns the SubMesh
  21583. */
  21584. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21585. /**
  21586. * Returns the mesh of the current submesh
  21587. * @return the parent mesh
  21588. */
  21589. getMesh(): AbstractMesh;
  21590. /**
  21591. * Returns the rendering mesh of the submesh
  21592. * @returns the rendering mesh (could be different from parent mesh)
  21593. */
  21594. getRenderingMesh(): Mesh;
  21595. /**
  21596. * Returns the submesh material
  21597. * @returns null or the current material
  21598. */
  21599. getMaterial(): Nullable<Material>;
  21600. /**
  21601. * Sets a new updated BoundingInfo object to the submesh
  21602. * @param data defines an optional position array to use to determine the bounding info
  21603. * @returns the SubMesh
  21604. */
  21605. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21606. /** @hidden */
  21607. _checkCollision(collider: Collider): boolean;
  21608. /**
  21609. * Updates the submesh BoundingInfo
  21610. * @param world defines the world matrix to use to update the bounding info
  21611. * @returns the submesh
  21612. */
  21613. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21614. /**
  21615. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21616. * @param frustumPlanes defines the frustum planes
  21617. * @returns true if the submesh is intersecting with the frustum
  21618. */
  21619. isInFrustum(frustumPlanes: Plane[]): boolean;
  21620. /**
  21621. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21622. * @param frustumPlanes defines the frustum planes
  21623. * @returns true if the submesh is inside the frustum
  21624. */
  21625. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21626. /**
  21627. * Renders the submesh
  21628. * @param enableAlphaMode defines if alpha needs to be used
  21629. * @returns the submesh
  21630. */
  21631. render(enableAlphaMode: boolean): SubMesh;
  21632. /**
  21633. * @hidden
  21634. */
  21635. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21636. /**
  21637. * Checks if the submesh intersects with a ray
  21638. * @param ray defines the ray to test
  21639. * @returns true is the passed ray intersects the submesh bounding box
  21640. */
  21641. canIntersects(ray: Ray): boolean;
  21642. /**
  21643. * Intersects current submesh with a ray
  21644. * @param ray defines the ray to test
  21645. * @param positions defines mesh's positions array
  21646. * @param indices defines mesh's indices array
  21647. * @param fastCheck defines if only bounding info should be used
  21648. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21649. * @returns intersection info or null if no intersection
  21650. */
  21651. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21652. /** @hidden */
  21653. private _intersectLines;
  21654. /** @hidden */
  21655. private _intersectUnIndexedLines;
  21656. /** @hidden */
  21657. private _intersectTriangles;
  21658. /** @hidden */
  21659. private _intersectUnIndexedTriangles;
  21660. /** @hidden */
  21661. _rebuild(): void;
  21662. /**
  21663. * Creates a new submesh from the passed mesh
  21664. * @param newMesh defines the new hosting mesh
  21665. * @param newRenderingMesh defines an optional rendering mesh
  21666. * @returns the new submesh
  21667. */
  21668. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21669. /**
  21670. * Release associated resources
  21671. */
  21672. dispose(): void;
  21673. /**
  21674. * Gets the class name
  21675. * @returns the string "SubMesh".
  21676. */
  21677. getClassName(): string;
  21678. /**
  21679. * Creates a new submesh from indices data
  21680. * @param materialIndex the index of the main mesh material
  21681. * @param startIndex the index where to start the copy in the mesh indices array
  21682. * @param indexCount the number of indices to copy then from the startIndex
  21683. * @param mesh the main mesh to create the submesh from
  21684. * @param renderingMesh the optional rendering mesh
  21685. * @returns a new submesh
  21686. */
  21687. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21688. }
  21689. }
  21690. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21691. /**
  21692. * Class used to represent data loading progression
  21693. */
  21694. export class SceneLoaderFlags {
  21695. private static _ForceFullSceneLoadingForIncremental;
  21696. private static _ShowLoadingScreen;
  21697. private static _CleanBoneMatrixWeights;
  21698. private static _loggingLevel;
  21699. /**
  21700. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21701. */
  21702. static ForceFullSceneLoadingForIncremental: boolean;
  21703. /**
  21704. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21705. */
  21706. static ShowLoadingScreen: boolean;
  21707. /**
  21708. * Defines the current logging level (while loading the scene)
  21709. * @ignorenaming
  21710. */
  21711. static loggingLevel: number;
  21712. /**
  21713. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21714. */
  21715. static CleanBoneMatrixWeights: boolean;
  21716. }
  21717. }
  21718. declare module "babylonjs/Meshes/geometry" {
  21719. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21720. import { Scene } from "babylonjs/scene";
  21721. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21722. import { Engine } from "babylonjs/Engines/engine";
  21723. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21724. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21725. import { Effect } from "babylonjs/Materials/effect";
  21726. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21727. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21728. import { Mesh } from "babylonjs/Meshes/mesh";
  21729. /**
  21730. * Class used to store geometry data (vertex buffers + index buffer)
  21731. */
  21732. export class Geometry implements IGetSetVerticesData {
  21733. /**
  21734. * Gets or sets the ID of the geometry
  21735. */
  21736. id: string;
  21737. /**
  21738. * Gets or sets the unique ID of the geometry
  21739. */
  21740. uniqueId: number;
  21741. /**
  21742. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21743. */
  21744. delayLoadState: number;
  21745. /**
  21746. * Gets the file containing the data to load when running in delay load state
  21747. */
  21748. delayLoadingFile: Nullable<string>;
  21749. /**
  21750. * Callback called when the geometry is updated
  21751. */
  21752. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21753. private _scene;
  21754. private _engine;
  21755. private _meshes;
  21756. private _totalVertices;
  21757. /** @hidden */
  21758. _indices: IndicesArray;
  21759. /** @hidden */
  21760. _vertexBuffers: {
  21761. [key: string]: VertexBuffer;
  21762. };
  21763. private _isDisposed;
  21764. private _extend;
  21765. private _boundingBias;
  21766. /** @hidden */
  21767. _delayInfo: Array<string>;
  21768. private _indexBuffer;
  21769. private _indexBufferIsUpdatable;
  21770. /** @hidden */
  21771. _boundingInfo: Nullable<BoundingInfo>;
  21772. /** @hidden */
  21773. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21774. /** @hidden */
  21775. _softwareSkinningFrameId: number;
  21776. private _vertexArrayObjects;
  21777. private _updatable;
  21778. /** @hidden */
  21779. _positions: Nullable<Vector3[]>;
  21780. /**
  21781. * 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
  21782. */
  21783. /**
  21784. * 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
  21785. */
  21786. boundingBias: Vector2;
  21787. /**
  21788. * Static function used to attach a new empty geometry to a mesh
  21789. * @param mesh defines the mesh to attach the geometry to
  21790. * @returns the new Geometry
  21791. */
  21792. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21793. /**
  21794. * Creates a new geometry
  21795. * @param id defines the unique ID
  21796. * @param scene defines the hosting scene
  21797. * @param vertexData defines the VertexData used to get geometry data
  21798. * @param updatable defines if geometry must be updatable (false by default)
  21799. * @param mesh defines the mesh that will be associated with the geometry
  21800. */
  21801. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21802. /**
  21803. * Gets the current extend of the geometry
  21804. */
  21805. readonly extend: {
  21806. minimum: Vector3;
  21807. maximum: Vector3;
  21808. };
  21809. /**
  21810. * Gets the hosting scene
  21811. * @returns the hosting Scene
  21812. */
  21813. getScene(): Scene;
  21814. /**
  21815. * Gets the hosting engine
  21816. * @returns the hosting Engine
  21817. */
  21818. getEngine(): Engine;
  21819. /**
  21820. * Defines if the geometry is ready to use
  21821. * @returns true if the geometry is ready to be used
  21822. */
  21823. isReady(): boolean;
  21824. /**
  21825. * Gets a value indicating that the geometry should not be serialized
  21826. */
  21827. readonly doNotSerialize: boolean;
  21828. /** @hidden */
  21829. _rebuild(): void;
  21830. /**
  21831. * Affects all geometry data in one call
  21832. * @param vertexData defines the geometry data
  21833. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21834. */
  21835. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21836. /**
  21837. * Set specific vertex data
  21838. * @param kind defines the data kind (Position, normal, etc...)
  21839. * @param data defines the vertex data to use
  21840. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21841. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21842. */
  21843. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21844. /**
  21845. * Removes a specific vertex data
  21846. * @param kind defines the data kind (Position, normal, etc...)
  21847. */
  21848. removeVerticesData(kind: string): void;
  21849. /**
  21850. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21851. * @param buffer defines the vertex buffer to use
  21852. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21853. */
  21854. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21855. /**
  21856. * Update a specific vertex buffer
  21857. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21858. * It will do nothing if the buffer is not updatable
  21859. * @param kind defines the data kind (Position, normal, etc...)
  21860. * @param data defines the data to use
  21861. * @param offset defines the offset in the target buffer where to store the data
  21862. * @param useBytes set to true if the offset is in bytes
  21863. */
  21864. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21865. /**
  21866. * Update a specific vertex buffer
  21867. * This function will create a new buffer if the current one is not updatable
  21868. * @param kind defines the data kind (Position, normal, etc...)
  21869. * @param data defines the data to use
  21870. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21871. */
  21872. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21873. private _updateBoundingInfo;
  21874. /** @hidden */
  21875. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21876. /**
  21877. * Gets total number of vertices
  21878. * @returns the total number of vertices
  21879. */
  21880. getTotalVertices(): number;
  21881. /**
  21882. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21883. * @param kind defines the data kind (Position, normal, etc...)
  21884. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21885. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21886. * @returns a float array containing vertex data
  21887. */
  21888. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21889. /**
  21890. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21891. * @param kind defines the data kind (Position, normal, etc...)
  21892. * @returns true if the vertex buffer with the specified kind is updatable
  21893. */
  21894. isVertexBufferUpdatable(kind: string): boolean;
  21895. /**
  21896. * Gets a specific vertex buffer
  21897. * @param kind defines the data kind (Position, normal, etc...)
  21898. * @returns a VertexBuffer
  21899. */
  21900. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21901. /**
  21902. * Returns all vertex buffers
  21903. * @return an object holding all vertex buffers indexed by kind
  21904. */
  21905. getVertexBuffers(): Nullable<{
  21906. [key: string]: VertexBuffer;
  21907. }>;
  21908. /**
  21909. * Gets a boolean indicating if specific vertex buffer is present
  21910. * @param kind defines the data kind (Position, normal, etc...)
  21911. * @returns true if data is present
  21912. */
  21913. isVerticesDataPresent(kind: string): boolean;
  21914. /**
  21915. * Gets a list of all attached data kinds (Position, normal, etc...)
  21916. * @returns a list of string containing all kinds
  21917. */
  21918. getVerticesDataKinds(): string[];
  21919. /**
  21920. * Update index buffer
  21921. * @param indices defines the indices to store in the index buffer
  21922. * @param offset defines the offset in the target buffer where to store the data
  21923. * @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)
  21924. */
  21925. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21926. /**
  21927. * Creates a new index buffer
  21928. * @param indices defines the indices to store in the index buffer
  21929. * @param totalVertices defines the total number of vertices (could be null)
  21930. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21931. */
  21932. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21933. /**
  21934. * Return the total number of indices
  21935. * @returns the total number of indices
  21936. */
  21937. getTotalIndices(): number;
  21938. /**
  21939. * Gets the index buffer array
  21940. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21941. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21942. * @returns the index buffer array
  21943. */
  21944. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21945. /**
  21946. * Gets the index buffer
  21947. * @return the index buffer
  21948. */
  21949. getIndexBuffer(): Nullable<DataBuffer>;
  21950. /** @hidden */
  21951. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21952. /**
  21953. * Release the associated resources for a specific mesh
  21954. * @param mesh defines the source mesh
  21955. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21956. */
  21957. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21958. /**
  21959. * Apply current geometry to a given mesh
  21960. * @param mesh defines the mesh to apply geometry to
  21961. */
  21962. applyToMesh(mesh: Mesh): void;
  21963. private _updateExtend;
  21964. private _applyToMesh;
  21965. private notifyUpdate;
  21966. /**
  21967. * Load the geometry if it was flagged as delay loaded
  21968. * @param scene defines the hosting scene
  21969. * @param onLoaded defines a callback called when the geometry is loaded
  21970. */
  21971. load(scene: Scene, onLoaded?: () => void): void;
  21972. private _queueLoad;
  21973. /**
  21974. * Invert the geometry to move from a right handed system to a left handed one.
  21975. */
  21976. toLeftHanded(): void;
  21977. /** @hidden */
  21978. _resetPointsArrayCache(): void;
  21979. /** @hidden */
  21980. _generatePointsArray(): boolean;
  21981. /**
  21982. * Gets a value indicating if the geometry is disposed
  21983. * @returns true if the geometry was disposed
  21984. */
  21985. isDisposed(): boolean;
  21986. private _disposeVertexArrayObjects;
  21987. /**
  21988. * Free all associated resources
  21989. */
  21990. dispose(): void;
  21991. /**
  21992. * Clone the current geometry into a new geometry
  21993. * @param id defines the unique ID of the new geometry
  21994. * @returns a new geometry object
  21995. */
  21996. copy(id: string): Geometry;
  21997. /**
  21998. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21999. * @return a JSON representation of the current geometry data (without the vertices data)
  22000. */
  22001. serialize(): any;
  22002. private toNumberArray;
  22003. /**
  22004. * Serialize all vertices data into a JSON oject
  22005. * @returns a JSON representation of the current geometry data
  22006. */
  22007. serializeVerticeData(): any;
  22008. /**
  22009. * Extracts a clone of a mesh geometry
  22010. * @param mesh defines the source mesh
  22011. * @param id defines the unique ID of the new geometry object
  22012. * @returns the new geometry object
  22013. */
  22014. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22015. /**
  22016. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22017. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22018. * Be aware Math.random() could cause collisions, but:
  22019. * "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"
  22020. * @returns a string containing a new GUID
  22021. */
  22022. static RandomId(): string;
  22023. /** @hidden */
  22024. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22025. private static _CleanMatricesWeights;
  22026. /**
  22027. * Create a new geometry from persisted data (Using .babylon file format)
  22028. * @param parsedVertexData defines the persisted data
  22029. * @param scene defines the hosting scene
  22030. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22031. * @returns the new geometry object
  22032. */
  22033. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22034. }
  22035. }
  22036. declare module "babylonjs/Meshes/mesh.vertexData" {
  22037. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22038. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22039. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22040. import { Geometry } from "babylonjs/Meshes/geometry";
  22041. import { Mesh } from "babylonjs/Meshes/mesh";
  22042. /**
  22043. * Define an interface for all classes that will get and set the data on vertices
  22044. */
  22045. export interface IGetSetVerticesData {
  22046. /**
  22047. * Gets a boolean indicating if specific vertex data is present
  22048. * @param kind defines the vertex data kind to use
  22049. * @returns true is data kind is present
  22050. */
  22051. isVerticesDataPresent(kind: string): boolean;
  22052. /**
  22053. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22054. * @param kind defines the data kind (Position, normal, etc...)
  22055. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22056. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22057. * @returns a float array containing vertex data
  22058. */
  22059. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22060. /**
  22061. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22062. * @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.
  22063. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22064. * @returns the indices array or an empty array if the mesh has no geometry
  22065. */
  22066. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22067. /**
  22068. * Set specific vertex data
  22069. * @param kind defines the data kind (Position, normal, etc...)
  22070. * @param data defines the vertex data to use
  22071. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22072. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22073. */
  22074. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22075. /**
  22076. * Update a specific associated vertex buffer
  22077. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22078. * - VertexBuffer.PositionKind
  22079. * - VertexBuffer.UVKind
  22080. * - VertexBuffer.UV2Kind
  22081. * - VertexBuffer.UV3Kind
  22082. * - VertexBuffer.UV4Kind
  22083. * - VertexBuffer.UV5Kind
  22084. * - VertexBuffer.UV6Kind
  22085. * - VertexBuffer.ColorKind
  22086. * - VertexBuffer.MatricesIndicesKind
  22087. * - VertexBuffer.MatricesIndicesExtraKind
  22088. * - VertexBuffer.MatricesWeightsKind
  22089. * - VertexBuffer.MatricesWeightsExtraKind
  22090. * @param data defines the data source
  22091. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22092. * @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)
  22093. */
  22094. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22095. /**
  22096. * Creates a new index buffer
  22097. * @param indices defines the indices to store in the index buffer
  22098. * @param totalVertices defines the total number of vertices (could be null)
  22099. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22100. */
  22101. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22102. }
  22103. /**
  22104. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22105. */
  22106. export class VertexData {
  22107. /**
  22108. * Mesh side orientation : usually the external or front surface
  22109. */
  22110. static readonly FRONTSIDE: number;
  22111. /**
  22112. * Mesh side orientation : usually the internal or back surface
  22113. */
  22114. static readonly BACKSIDE: number;
  22115. /**
  22116. * Mesh side orientation : both internal and external or front and back surfaces
  22117. */
  22118. static readonly DOUBLESIDE: number;
  22119. /**
  22120. * Mesh side orientation : by default, `FRONTSIDE`
  22121. */
  22122. static readonly DEFAULTSIDE: number;
  22123. /**
  22124. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22125. */
  22126. positions: Nullable<FloatArray>;
  22127. /**
  22128. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22129. */
  22130. normals: Nullable<FloatArray>;
  22131. /**
  22132. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22133. */
  22134. tangents: Nullable<FloatArray>;
  22135. /**
  22136. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22137. */
  22138. uvs: Nullable<FloatArray>;
  22139. /**
  22140. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22141. */
  22142. uvs2: Nullable<FloatArray>;
  22143. /**
  22144. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22145. */
  22146. uvs3: Nullable<FloatArray>;
  22147. /**
  22148. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22149. */
  22150. uvs4: Nullable<FloatArray>;
  22151. /**
  22152. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22153. */
  22154. uvs5: Nullable<FloatArray>;
  22155. /**
  22156. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22157. */
  22158. uvs6: Nullable<FloatArray>;
  22159. /**
  22160. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22161. */
  22162. colors: Nullable<FloatArray>;
  22163. /**
  22164. * 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).
  22165. */
  22166. matricesIndices: Nullable<FloatArray>;
  22167. /**
  22168. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22169. */
  22170. matricesWeights: Nullable<FloatArray>;
  22171. /**
  22172. * An array extending the number of possible indices
  22173. */
  22174. matricesIndicesExtra: Nullable<FloatArray>;
  22175. /**
  22176. * An array extending the number of possible weights when the number of indices is extended
  22177. */
  22178. matricesWeightsExtra: Nullable<FloatArray>;
  22179. /**
  22180. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22181. */
  22182. indices: Nullable<IndicesArray>;
  22183. /**
  22184. * Uses the passed data array to set the set the values for the specified kind of data
  22185. * @param data a linear array of floating numbers
  22186. * @param kind the type of data that is being set, eg positions, colors etc
  22187. */
  22188. set(data: FloatArray, kind: string): void;
  22189. /**
  22190. * Associates the vertexData to the passed Mesh.
  22191. * Sets it as updatable or not (default `false`)
  22192. * @param mesh the mesh the vertexData is applied to
  22193. * @param updatable when used and having the value true allows new data to update the vertexData
  22194. * @returns the VertexData
  22195. */
  22196. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22197. /**
  22198. * Associates the vertexData to the passed Geometry.
  22199. * Sets it as updatable or not (default `false`)
  22200. * @param geometry the geometry the vertexData is applied to
  22201. * @param updatable when used and having the value true allows new data to update the vertexData
  22202. * @returns VertexData
  22203. */
  22204. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22205. /**
  22206. * Updates the associated mesh
  22207. * @param mesh the mesh to be updated
  22208. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22209. * @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
  22210. * @returns VertexData
  22211. */
  22212. updateMesh(mesh: Mesh): VertexData;
  22213. /**
  22214. * Updates the associated geometry
  22215. * @param geometry the geometry to be updated
  22216. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22217. * @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
  22218. * @returns VertexData.
  22219. */
  22220. updateGeometry(geometry: Geometry): VertexData;
  22221. private _applyTo;
  22222. private _update;
  22223. /**
  22224. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22225. * @param matrix the transforming matrix
  22226. * @returns the VertexData
  22227. */
  22228. transform(matrix: Matrix): VertexData;
  22229. /**
  22230. * Merges the passed VertexData into the current one
  22231. * @param other the VertexData to be merged into the current one
  22232. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22233. * @returns the modified VertexData
  22234. */
  22235. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22236. private _mergeElement;
  22237. private _validate;
  22238. /**
  22239. * Serializes the VertexData
  22240. * @returns a serialized object
  22241. */
  22242. serialize(): any;
  22243. /**
  22244. * Extracts the vertexData from a mesh
  22245. * @param mesh the mesh from which to extract the VertexData
  22246. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22247. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22248. * @returns the object VertexData associated to the passed mesh
  22249. */
  22250. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22251. /**
  22252. * Extracts the vertexData from the geometry
  22253. * @param geometry the geometry from which to extract the VertexData
  22254. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22255. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22256. * @returns the object VertexData associated to the passed mesh
  22257. */
  22258. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22259. private static _ExtractFrom;
  22260. /**
  22261. * Creates the VertexData for a Ribbon
  22262. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22263. * * pathArray array of paths, each of which an array of successive Vector3
  22264. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22265. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22266. * * 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
  22267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22268. * * 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)
  22269. * * 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)
  22270. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22271. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22272. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22273. * @returns the VertexData of the ribbon
  22274. */
  22275. static CreateRibbon(options: {
  22276. pathArray: Vector3[][];
  22277. closeArray?: boolean;
  22278. closePath?: boolean;
  22279. offset?: number;
  22280. sideOrientation?: number;
  22281. frontUVs?: Vector4;
  22282. backUVs?: Vector4;
  22283. invertUV?: boolean;
  22284. uvs?: Vector2[];
  22285. colors?: Color4[];
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for a box
  22289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22290. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22291. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22292. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22293. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22294. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22295. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22296. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22297. * * 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)
  22298. * * 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)
  22299. * @returns the VertexData of the box
  22300. */
  22301. static CreateBox(options: {
  22302. size?: number;
  22303. width?: number;
  22304. height?: number;
  22305. depth?: number;
  22306. faceUV?: Vector4[];
  22307. faceColors?: Color4[];
  22308. sideOrientation?: number;
  22309. frontUVs?: Vector4;
  22310. backUVs?: Vector4;
  22311. }): VertexData;
  22312. /**
  22313. * Creates the VertexData for a tiled box
  22314. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22315. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22316. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22317. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22318. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22319. * @returns the VertexData of the box
  22320. */
  22321. static CreateTiledBox(options: {
  22322. pattern?: number;
  22323. width?: number;
  22324. height?: number;
  22325. depth?: number;
  22326. tileSize?: number;
  22327. tileWidth?: number;
  22328. tileHeight?: number;
  22329. alignHorizontal?: number;
  22330. alignVertical?: number;
  22331. faceUV?: Vector4[];
  22332. faceColors?: Color4[];
  22333. sideOrientation?: number;
  22334. }): VertexData;
  22335. /**
  22336. * Creates the VertexData for a tiled plane
  22337. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22338. * * pattern a limited pattern arrangement depending on the number
  22339. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22340. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22341. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22342. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22343. * * 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)
  22344. * * 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)
  22345. * @returns the VertexData of the tiled plane
  22346. */
  22347. static CreateTiledPlane(options: {
  22348. pattern?: number;
  22349. tileSize?: number;
  22350. tileWidth?: number;
  22351. tileHeight?: number;
  22352. size?: number;
  22353. width?: number;
  22354. height?: number;
  22355. alignHorizontal?: number;
  22356. alignVertical?: number;
  22357. sideOrientation?: number;
  22358. frontUVs?: Vector4;
  22359. backUVs?: Vector4;
  22360. }): VertexData;
  22361. /**
  22362. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22363. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22364. * * segments sets the number of horizontal strips optional, default 32
  22365. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22366. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22367. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22368. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22369. * * 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
  22370. * * 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
  22371. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22372. * * 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)
  22373. * * 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)
  22374. * @returns the VertexData of the ellipsoid
  22375. */
  22376. static CreateSphere(options: {
  22377. segments?: number;
  22378. diameter?: number;
  22379. diameterX?: number;
  22380. diameterY?: number;
  22381. diameterZ?: number;
  22382. arc?: number;
  22383. slice?: number;
  22384. sideOrientation?: number;
  22385. frontUVs?: Vector4;
  22386. backUVs?: Vector4;
  22387. }): VertexData;
  22388. /**
  22389. * Creates the VertexData for a cylinder, cone or prism
  22390. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22391. * * height sets the height (y direction) of the cylinder, optional, default 2
  22392. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22393. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22394. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22395. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22396. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22397. * * 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
  22398. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22399. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22400. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22401. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22403. * * 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)
  22404. * * 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)
  22405. * @returns the VertexData of the cylinder, cone or prism
  22406. */
  22407. static CreateCylinder(options: {
  22408. height?: number;
  22409. diameterTop?: number;
  22410. diameterBottom?: number;
  22411. diameter?: number;
  22412. tessellation?: number;
  22413. subdivisions?: number;
  22414. arc?: number;
  22415. faceColors?: Color4[];
  22416. faceUV?: Vector4[];
  22417. hasRings?: boolean;
  22418. enclose?: boolean;
  22419. sideOrientation?: number;
  22420. frontUVs?: Vector4;
  22421. backUVs?: Vector4;
  22422. }): VertexData;
  22423. /**
  22424. * Creates the VertexData for a torus
  22425. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22426. * * diameter the diameter of the torus, optional default 1
  22427. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22428. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22430. * * 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)
  22431. * * 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)
  22432. * @returns the VertexData of the torus
  22433. */
  22434. static CreateTorus(options: {
  22435. diameter?: number;
  22436. thickness?: number;
  22437. tessellation?: number;
  22438. sideOrientation?: number;
  22439. frontUVs?: Vector4;
  22440. backUVs?: Vector4;
  22441. }): VertexData;
  22442. /**
  22443. * Creates the VertexData of the LineSystem
  22444. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22445. * - lines an array of lines, each line being an array of successive Vector3
  22446. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22447. * @returns the VertexData of the LineSystem
  22448. */
  22449. static CreateLineSystem(options: {
  22450. lines: Vector3[][];
  22451. colors?: Nullable<Color4[][]>;
  22452. }): VertexData;
  22453. /**
  22454. * Create the VertexData for a DashedLines
  22455. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22456. * - points an array successive Vector3
  22457. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22458. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22459. * - dashNb the intended total number of dashes, optional, default 200
  22460. * @returns the VertexData for the DashedLines
  22461. */
  22462. static CreateDashedLines(options: {
  22463. points: Vector3[];
  22464. dashSize?: number;
  22465. gapSize?: number;
  22466. dashNb?: number;
  22467. }): VertexData;
  22468. /**
  22469. * Creates the VertexData for a Ground
  22470. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22471. * - width the width (x direction) of the ground, optional, default 1
  22472. * - height the height (z direction) of the ground, optional, default 1
  22473. * - subdivisions the number of subdivisions per side, optional, default 1
  22474. * @returns the VertexData of the Ground
  22475. */
  22476. static CreateGround(options: {
  22477. width?: number;
  22478. height?: number;
  22479. subdivisions?: number;
  22480. subdivisionsX?: number;
  22481. subdivisionsY?: number;
  22482. }): VertexData;
  22483. /**
  22484. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22485. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22486. * * xmin the ground minimum X coordinate, optional, default -1
  22487. * * zmin the ground minimum Z coordinate, optional, default -1
  22488. * * xmax the ground maximum X coordinate, optional, default 1
  22489. * * zmax the ground maximum Z coordinate, optional, default 1
  22490. * * 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}
  22491. * * 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}
  22492. * @returns the VertexData of the TiledGround
  22493. */
  22494. static CreateTiledGround(options: {
  22495. xmin: number;
  22496. zmin: number;
  22497. xmax: number;
  22498. zmax: number;
  22499. subdivisions?: {
  22500. w: number;
  22501. h: number;
  22502. };
  22503. precision?: {
  22504. w: number;
  22505. h: number;
  22506. };
  22507. }): VertexData;
  22508. /**
  22509. * Creates the VertexData of the Ground designed from a heightmap
  22510. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22511. * * width the width (x direction) of the ground
  22512. * * height the height (z direction) of the ground
  22513. * * subdivisions the number of subdivisions per side
  22514. * * minHeight the minimum altitude on the ground, optional, default 0
  22515. * * maxHeight the maximum altitude on the ground, optional default 1
  22516. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22517. * * buffer the array holding the image color data
  22518. * * bufferWidth the width of image
  22519. * * bufferHeight the height of image
  22520. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22521. * @returns the VertexData of the Ground designed from a heightmap
  22522. */
  22523. static CreateGroundFromHeightMap(options: {
  22524. width: number;
  22525. height: number;
  22526. subdivisions: number;
  22527. minHeight: number;
  22528. maxHeight: number;
  22529. colorFilter: Color3;
  22530. buffer: Uint8Array;
  22531. bufferWidth: number;
  22532. bufferHeight: number;
  22533. alphaFilter: number;
  22534. }): VertexData;
  22535. /**
  22536. * Creates the VertexData for a Plane
  22537. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22538. * * size sets the width and height of the plane to the value of size, optional default 1
  22539. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22540. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22542. * * 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)
  22543. * * 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)
  22544. * @returns the VertexData of the box
  22545. */
  22546. static CreatePlane(options: {
  22547. size?: number;
  22548. width?: number;
  22549. height?: number;
  22550. sideOrientation?: number;
  22551. frontUVs?: Vector4;
  22552. backUVs?: Vector4;
  22553. }): VertexData;
  22554. /**
  22555. * Creates the VertexData of the Disc or regular Polygon
  22556. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22557. * * radius the radius of the disc, optional default 0.5
  22558. * * tessellation the number of polygon sides, optional, default 64
  22559. * * 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
  22560. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22561. * * 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)
  22562. * * 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)
  22563. * @returns the VertexData of the box
  22564. */
  22565. static CreateDisc(options: {
  22566. radius?: number;
  22567. tessellation?: number;
  22568. arc?: number;
  22569. sideOrientation?: number;
  22570. frontUVs?: Vector4;
  22571. backUVs?: Vector4;
  22572. }): VertexData;
  22573. /**
  22574. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22575. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22576. * @param polygon a mesh built from polygonTriangulation.build()
  22577. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22578. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22579. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22580. * @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)
  22581. * @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)
  22582. * @returns the VertexData of the Polygon
  22583. */
  22584. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22585. /**
  22586. * Creates the VertexData of the IcoSphere
  22587. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22588. * * radius the radius of the IcoSphere, optional default 1
  22589. * * radiusX allows stretching in the x direction, optional, default radius
  22590. * * radiusY allows stretching in the y direction, optional, default radius
  22591. * * radiusZ allows stretching in the z direction, optional, default radius
  22592. * * flat when true creates a flat shaded mesh, optional, default true
  22593. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22595. * * 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)
  22596. * * 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)
  22597. * @returns the VertexData of the IcoSphere
  22598. */
  22599. static CreateIcoSphere(options: {
  22600. radius?: number;
  22601. radiusX?: number;
  22602. radiusY?: number;
  22603. radiusZ?: number;
  22604. flat?: boolean;
  22605. subdivisions?: number;
  22606. sideOrientation?: number;
  22607. frontUVs?: Vector4;
  22608. backUVs?: Vector4;
  22609. }): VertexData;
  22610. /**
  22611. * Creates the VertexData for a Polyhedron
  22612. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22613. * * type provided types are:
  22614. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22615. * * 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)
  22616. * * size the size of the IcoSphere, optional default 1
  22617. * * sizeX allows stretching in the x direction, optional, default size
  22618. * * sizeY allows stretching in the y direction, optional, default size
  22619. * * sizeZ allows stretching in the z direction, optional, default size
  22620. * * 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
  22621. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22622. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22623. * * flat when true creates a flat shaded mesh, optional, default true
  22624. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22625. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22626. * * 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)
  22627. * * 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)
  22628. * @returns the VertexData of the Polyhedron
  22629. */
  22630. static CreatePolyhedron(options: {
  22631. type?: number;
  22632. size?: number;
  22633. sizeX?: number;
  22634. sizeY?: number;
  22635. sizeZ?: number;
  22636. custom?: any;
  22637. faceUV?: Vector4[];
  22638. faceColors?: Color4[];
  22639. flat?: boolean;
  22640. sideOrientation?: number;
  22641. frontUVs?: Vector4;
  22642. backUVs?: Vector4;
  22643. }): VertexData;
  22644. /**
  22645. * Creates the VertexData for a TorusKnot
  22646. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22647. * * radius the radius of the torus knot, optional, default 2
  22648. * * tube the thickness of the tube, optional, default 0.5
  22649. * * radialSegments the number of sides on each tube segments, optional, default 32
  22650. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22651. * * p the number of windings around the z axis, optional, default 2
  22652. * * q the number of windings around the x axis, optional, default 3
  22653. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22654. * * 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)
  22655. * * 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)
  22656. * @returns the VertexData of the Torus Knot
  22657. */
  22658. static CreateTorusKnot(options: {
  22659. radius?: number;
  22660. tube?: number;
  22661. radialSegments?: number;
  22662. tubularSegments?: number;
  22663. p?: number;
  22664. q?: number;
  22665. sideOrientation?: number;
  22666. frontUVs?: Vector4;
  22667. backUVs?: Vector4;
  22668. }): VertexData;
  22669. /**
  22670. * Compute normals for given positions and indices
  22671. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22672. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22673. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22674. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22675. * * facetNormals : optional array of facet normals (vector3)
  22676. * * facetPositions : optional array of facet positions (vector3)
  22677. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22678. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22679. * * bInfo : optional bounding info, required for facetPartitioning computation
  22680. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22681. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22682. * * useRightHandedSystem: optional boolean to for right handed system computation
  22683. * * depthSort : optional boolean to enable the facet depth sort computation
  22684. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22685. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22686. */
  22687. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22688. facetNormals?: any;
  22689. facetPositions?: any;
  22690. facetPartitioning?: any;
  22691. ratio?: number;
  22692. bInfo?: any;
  22693. bbSize?: Vector3;
  22694. subDiv?: any;
  22695. useRightHandedSystem?: boolean;
  22696. depthSort?: boolean;
  22697. distanceTo?: Vector3;
  22698. depthSortedFacets?: any;
  22699. }): void;
  22700. /** @hidden */
  22701. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22702. /**
  22703. * Applies VertexData created from the imported parameters to the geometry
  22704. * @param parsedVertexData the parsed data from an imported file
  22705. * @param geometry the geometry to apply the VertexData to
  22706. */
  22707. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22708. }
  22709. }
  22710. declare module "babylonjs/Morph/morphTarget" {
  22711. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22712. import { Observable } from "babylonjs/Misc/observable";
  22713. import { Nullable, FloatArray } from "babylonjs/types";
  22714. import { Scene } from "babylonjs/scene";
  22715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22716. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22717. /**
  22718. * Defines a target to use with MorphTargetManager
  22719. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22720. */
  22721. export class MorphTarget implements IAnimatable {
  22722. /** defines the name of the target */
  22723. name: string;
  22724. /**
  22725. * Gets or sets the list of animations
  22726. */
  22727. animations: import("babylonjs/Animations/animation").Animation[];
  22728. private _scene;
  22729. private _positions;
  22730. private _normals;
  22731. private _tangents;
  22732. private _uvs;
  22733. private _influence;
  22734. /**
  22735. * Observable raised when the influence changes
  22736. */
  22737. onInfluenceChanged: Observable<boolean>;
  22738. /** @hidden */
  22739. _onDataLayoutChanged: Observable<void>;
  22740. /**
  22741. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22742. */
  22743. influence: number;
  22744. /**
  22745. * Gets or sets the id of the morph Target
  22746. */
  22747. id: string;
  22748. private _animationPropertiesOverride;
  22749. /**
  22750. * Gets or sets the animation properties override
  22751. */
  22752. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22753. /**
  22754. * Creates a new MorphTarget
  22755. * @param name defines the name of the target
  22756. * @param influence defines the influence to use
  22757. * @param scene defines the scene the morphtarget belongs to
  22758. */
  22759. constructor(
  22760. /** defines the name of the target */
  22761. name: string, influence?: number, scene?: Nullable<Scene>);
  22762. /**
  22763. * Gets a boolean defining if the target contains position data
  22764. */
  22765. readonly hasPositions: boolean;
  22766. /**
  22767. * Gets a boolean defining if the target contains normal data
  22768. */
  22769. readonly hasNormals: boolean;
  22770. /**
  22771. * Gets a boolean defining if the target contains tangent data
  22772. */
  22773. readonly hasTangents: boolean;
  22774. /**
  22775. * Gets a boolean defining if the target contains texture coordinates data
  22776. */
  22777. readonly hasUVs: boolean;
  22778. /**
  22779. * Affects position data to this target
  22780. * @param data defines the position data to use
  22781. */
  22782. setPositions(data: Nullable<FloatArray>): void;
  22783. /**
  22784. * Gets the position data stored in this target
  22785. * @returns a FloatArray containing the position data (or null if not present)
  22786. */
  22787. getPositions(): Nullable<FloatArray>;
  22788. /**
  22789. * Affects normal data to this target
  22790. * @param data defines the normal data to use
  22791. */
  22792. setNormals(data: Nullable<FloatArray>): void;
  22793. /**
  22794. * Gets the normal data stored in this target
  22795. * @returns a FloatArray containing the normal data (or null if not present)
  22796. */
  22797. getNormals(): Nullable<FloatArray>;
  22798. /**
  22799. * Affects tangent data to this target
  22800. * @param data defines the tangent data to use
  22801. */
  22802. setTangents(data: Nullable<FloatArray>): void;
  22803. /**
  22804. * Gets the tangent data stored in this target
  22805. * @returns a FloatArray containing the tangent data (or null if not present)
  22806. */
  22807. getTangents(): Nullable<FloatArray>;
  22808. /**
  22809. * Affects texture coordinates data to this target
  22810. * @param data defines the texture coordinates data to use
  22811. */
  22812. setUVs(data: Nullable<FloatArray>): void;
  22813. /**
  22814. * Gets the texture coordinates data stored in this target
  22815. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22816. */
  22817. getUVs(): Nullable<FloatArray>;
  22818. /**
  22819. * Serializes the current target into a Serialization object
  22820. * @returns the serialized object
  22821. */
  22822. serialize(): any;
  22823. /**
  22824. * Returns the string "MorphTarget"
  22825. * @returns "MorphTarget"
  22826. */
  22827. getClassName(): string;
  22828. /**
  22829. * Creates a new target from serialized data
  22830. * @param serializationObject defines the serialized data to use
  22831. * @returns a new MorphTarget
  22832. */
  22833. static Parse(serializationObject: any): MorphTarget;
  22834. /**
  22835. * Creates a MorphTarget from mesh data
  22836. * @param mesh defines the source mesh
  22837. * @param name defines the name to use for the new target
  22838. * @param influence defines the influence to attach to the target
  22839. * @returns a new MorphTarget
  22840. */
  22841. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22842. }
  22843. }
  22844. declare module "babylonjs/Morph/morphTargetManager" {
  22845. import { Nullable } from "babylonjs/types";
  22846. import { Scene } from "babylonjs/scene";
  22847. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22848. /**
  22849. * This class is used to deform meshes using morphing between different targets
  22850. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22851. */
  22852. export class MorphTargetManager {
  22853. private _targets;
  22854. private _targetInfluenceChangedObservers;
  22855. private _targetDataLayoutChangedObservers;
  22856. private _activeTargets;
  22857. private _scene;
  22858. private _influences;
  22859. private _supportsNormals;
  22860. private _supportsTangents;
  22861. private _supportsUVs;
  22862. private _vertexCount;
  22863. private _uniqueId;
  22864. private _tempInfluences;
  22865. /**
  22866. * Gets or sets a boolean indicating if normals must be morphed
  22867. */
  22868. enableNormalMorphing: boolean;
  22869. /**
  22870. * Gets or sets a boolean indicating if tangents must be morphed
  22871. */
  22872. enableTangentMorphing: boolean;
  22873. /**
  22874. * Gets or sets a boolean indicating if UV must be morphed
  22875. */
  22876. enableUVMorphing: boolean;
  22877. /**
  22878. * Creates a new MorphTargetManager
  22879. * @param scene defines the current scene
  22880. */
  22881. constructor(scene?: Nullable<Scene>);
  22882. /**
  22883. * Gets the unique ID of this manager
  22884. */
  22885. readonly uniqueId: number;
  22886. /**
  22887. * Gets the number of vertices handled by this manager
  22888. */
  22889. readonly vertexCount: number;
  22890. /**
  22891. * Gets a boolean indicating if this manager supports morphing of normals
  22892. */
  22893. readonly supportsNormals: boolean;
  22894. /**
  22895. * Gets a boolean indicating if this manager supports morphing of tangents
  22896. */
  22897. readonly supportsTangents: boolean;
  22898. /**
  22899. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22900. */
  22901. readonly supportsUVs: boolean;
  22902. /**
  22903. * Gets the number of targets stored in this manager
  22904. */
  22905. readonly numTargets: number;
  22906. /**
  22907. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22908. */
  22909. readonly numInfluencers: number;
  22910. /**
  22911. * Gets the list of influences (one per target)
  22912. */
  22913. readonly influences: Float32Array;
  22914. /**
  22915. * Gets the active target at specified index. An active target is a target with an influence > 0
  22916. * @param index defines the index to check
  22917. * @returns the requested target
  22918. */
  22919. getActiveTarget(index: number): MorphTarget;
  22920. /**
  22921. * Gets the target at specified index
  22922. * @param index defines the index to check
  22923. * @returns the requested target
  22924. */
  22925. getTarget(index: number): MorphTarget;
  22926. /**
  22927. * Add a new target to this manager
  22928. * @param target defines the target to add
  22929. */
  22930. addTarget(target: MorphTarget): void;
  22931. /**
  22932. * Removes a target from the manager
  22933. * @param target defines the target to remove
  22934. */
  22935. removeTarget(target: MorphTarget): void;
  22936. /**
  22937. * Serializes the current manager into a Serialization object
  22938. * @returns the serialized object
  22939. */
  22940. serialize(): any;
  22941. private _syncActiveTargets;
  22942. /**
  22943. * Syncrhonize the targets with all the meshes using this morph target manager
  22944. */
  22945. synchronize(): void;
  22946. /**
  22947. * Creates a new MorphTargetManager from serialized data
  22948. * @param serializationObject defines the serialized data
  22949. * @param scene defines the hosting scene
  22950. * @returns the new MorphTargetManager
  22951. */
  22952. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22953. }
  22954. }
  22955. declare module "babylonjs/Meshes/meshLODLevel" {
  22956. import { Mesh } from "babylonjs/Meshes/mesh";
  22957. import { Nullable } from "babylonjs/types";
  22958. /**
  22959. * Class used to represent a specific level of detail of a mesh
  22960. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22961. */
  22962. export class MeshLODLevel {
  22963. /** Defines the distance where this level should start being displayed */
  22964. distance: number;
  22965. /** Defines the mesh to use to render this level */
  22966. mesh: Nullable<Mesh>;
  22967. /**
  22968. * Creates a new LOD level
  22969. * @param distance defines the distance where this level should star being displayed
  22970. * @param mesh defines the mesh to use to render this level
  22971. */
  22972. constructor(
  22973. /** Defines the distance where this level should start being displayed */
  22974. distance: number,
  22975. /** Defines the mesh to use to render this level */
  22976. mesh: Nullable<Mesh>);
  22977. }
  22978. }
  22979. declare module "babylonjs/Meshes/groundMesh" {
  22980. import { Scene } from "babylonjs/scene";
  22981. import { Vector3 } from "babylonjs/Maths/math.vector";
  22982. import { Mesh } from "babylonjs/Meshes/mesh";
  22983. /**
  22984. * Mesh representing the gorund
  22985. */
  22986. export class GroundMesh extends Mesh {
  22987. /** If octree should be generated */
  22988. generateOctree: boolean;
  22989. private _heightQuads;
  22990. /** @hidden */
  22991. _subdivisionsX: number;
  22992. /** @hidden */
  22993. _subdivisionsY: number;
  22994. /** @hidden */
  22995. _width: number;
  22996. /** @hidden */
  22997. _height: number;
  22998. /** @hidden */
  22999. _minX: number;
  23000. /** @hidden */
  23001. _maxX: number;
  23002. /** @hidden */
  23003. _minZ: number;
  23004. /** @hidden */
  23005. _maxZ: number;
  23006. constructor(name: string, scene: Scene);
  23007. /**
  23008. * "GroundMesh"
  23009. * @returns "GroundMesh"
  23010. */
  23011. getClassName(): string;
  23012. /**
  23013. * The minimum of x and y subdivisions
  23014. */
  23015. readonly subdivisions: number;
  23016. /**
  23017. * X subdivisions
  23018. */
  23019. readonly subdivisionsX: number;
  23020. /**
  23021. * Y subdivisions
  23022. */
  23023. readonly subdivisionsY: number;
  23024. /**
  23025. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23026. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23027. * @param chunksCount the number of subdivisions for x and y
  23028. * @param octreeBlocksSize (Default: 32)
  23029. */
  23030. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23031. /**
  23032. * Returns a height (y) value in the Worl system :
  23033. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23034. * @param x x coordinate
  23035. * @param z z coordinate
  23036. * @returns the ground y position if (x, z) are outside the ground surface.
  23037. */
  23038. getHeightAtCoordinates(x: number, z: number): number;
  23039. /**
  23040. * Returns a normalized vector (Vector3) orthogonal to the ground
  23041. * at the ground coordinates (x, z) expressed in the World system.
  23042. * @param x x coordinate
  23043. * @param z z coordinate
  23044. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23045. */
  23046. getNormalAtCoordinates(x: number, z: number): Vector3;
  23047. /**
  23048. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23049. * at the ground coordinates (x, z) expressed in the World system.
  23050. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23051. * @param x x coordinate
  23052. * @param z z coordinate
  23053. * @param ref vector to store the result
  23054. * @returns the GroundMesh.
  23055. */
  23056. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23057. /**
  23058. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23059. * if the ground has been updated.
  23060. * This can be used in the render loop.
  23061. * @returns the GroundMesh.
  23062. */
  23063. updateCoordinateHeights(): GroundMesh;
  23064. private _getFacetAt;
  23065. private _initHeightQuads;
  23066. private _computeHeightQuads;
  23067. /**
  23068. * Serializes this ground mesh
  23069. * @param serializationObject object to write serialization to
  23070. */
  23071. serialize(serializationObject: any): void;
  23072. /**
  23073. * Parses a serialized ground mesh
  23074. * @param parsedMesh the serialized mesh
  23075. * @param scene the scene to create the ground mesh in
  23076. * @returns the created ground mesh
  23077. */
  23078. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23079. }
  23080. }
  23081. declare module "babylonjs/Physics/physicsJoint" {
  23082. import { Vector3 } from "babylonjs/Maths/math.vector";
  23083. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23084. /**
  23085. * Interface for Physics-Joint data
  23086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23087. */
  23088. export interface PhysicsJointData {
  23089. /**
  23090. * The main pivot of the joint
  23091. */
  23092. mainPivot?: Vector3;
  23093. /**
  23094. * The connected pivot of the joint
  23095. */
  23096. connectedPivot?: Vector3;
  23097. /**
  23098. * The main axis of the joint
  23099. */
  23100. mainAxis?: Vector3;
  23101. /**
  23102. * The connected axis of the joint
  23103. */
  23104. connectedAxis?: Vector3;
  23105. /**
  23106. * The collision of the joint
  23107. */
  23108. collision?: boolean;
  23109. /**
  23110. * Native Oimo/Cannon/Energy data
  23111. */
  23112. nativeParams?: any;
  23113. }
  23114. /**
  23115. * This is a holder class for the physics joint created by the physics plugin
  23116. * It holds a set of functions to control the underlying joint
  23117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23118. */
  23119. export class PhysicsJoint {
  23120. /**
  23121. * The type of the physics joint
  23122. */
  23123. type: number;
  23124. /**
  23125. * The data for the physics joint
  23126. */
  23127. jointData: PhysicsJointData;
  23128. private _physicsJoint;
  23129. protected _physicsPlugin: IPhysicsEnginePlugin;
  23130. /**
  23131. * Initializes the physics joint
  23132. * @param type The type of the physics joint
  23133. * @param jointData The data for the physics joint
  23134. */
  23135. constructor(
  23136. /**
  23137. * The type of the physics joint
  23138. */
  23139. type: number,
  23140. /**
  23141. * The data for the physics joint
  23142. */
  23143. jointData: PhysicsJointData);
  23144. /**
  23145. * Gets the physics joint
  23146. */
  23147. /**
  23148. * Sets the physics joint
  23149. */
  23150. physicsJoint: any;
  23151. /**
  23152. * Sets the physics plugin
  23153. */
  23154. physicsPlugin: IPhysicsEnginePlugin;
  23155. /**
  23156. * Execute a function that is physics-plugin specific.
  23157. * @param {Function} func the function that will be executed.
  23158. * It accepts two parameters: the physics world and the physics joint
  23159. */
  23160. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23161. /**
  23162. * Distance-Joint type
  23163. */
  23164. static DistanceJoint: number;
  23165. /**
  23166. * Hinge-Joint type
  23167. */
  23168. static HingeJoint: number;
  23169. /**
  23170. * Ball-and-Socket joint type
  23171. */
  23172. static BallAndSocketJoint: number;
  23173. /**
  23174. * Wheel-Joint type
  23175. */
  23176. static WheelJoint: number;
  23177. /**
  23178. * Slider-Joint type
  23179. */
  23180. static SliderJoint: number;
  23181. /**
  23182. * Prismatic-Joint type
  23183. */
  23184. static PrismaticJoint: number;
  23185. /**
  23186. * Universal-Joint type
  23187. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23188. */
  23189. static UniversalJoint: number;
  23190. /**
  23191. * Hinge-Joint 2 type
  23192. */
  23193. static Hinge2Joint: number;
  23194. /**
  23195. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23196. */
  23197. static PointToPointJoint: number;
  23198. /**
  23199. * Spring-Joint type
  23200. */
  23201. static SpringJoint: number;
  23202. /**
  23203. * Lock-Joint type
  23204. */
  23205. static LockJoint: number;
  23206. }
  23207. /**
  23208. * A class representing a physics distance joint
  23209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23210. */
  23211. export class DistanceJoint extends PhysicsJoint {
  23212. /**
  23213. *
  23214. * @param jointData The data for the Distance-Joint
  23215. */
  23216. constructor(jointData: DistanceJointData);
  23217. /**
  23218. * Update the predefined distance.
  23219. * @param maxDistance The maximum preferred distance
  23220. * @param minDistance The minimum preferred distance
  23221. */
  23222. updateDistance(maxDistance: number, minDistance?: number): void;
  23223. }
  23224. /**
  23225. * Represents a Motor-Enabled Joint
  23226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23227. */
  23228. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23229. /**
  23230. * Initializes the Motor-Enabled Joint
  23231. * @param type The type of the joint
  23232. * @param jointData The physica joint data for the joint
  23233. */
  23234. constructor(type: number, jointData: PhysicsJointData);
  23235. /**
  23236. * Set the motor values.
  23237. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23238. * @param force the force to apply
  23239. * @param maxForce max force for this motor.
  23240. */
  23241. setMotor(force?: number, maxForce?: number): void;
  23242. /**
  23243. * Set the motor's limits.
  23244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23245. * @param upperLimit The upper limit of the motor
  23246. * @param lowerLimit The lower limit of the motor
  23247. */
  23248. setLimit(upperLimit: number, lowerLimit?: number): void;
  23249. }
  23250. /**
  23251. * This class represents a single physics Hinge-Joint
  23252. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23253. */
  23254. export class HingeJoint extends MotorEnabledJoint {
  23255. /**
  23256. * Initializes the Hinge-Joint
  23257. * @param jointData The joint data for the Hinge-Joint
  23258. */
  23259. constructor(jointData: PhysicsJointData);
  23260. /**
  23261. * Set the motor values.
  23262. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23263. * @param {number} force the force to apply
  23264. * @param {number} maxForce max force for this motor.
  23265. */
  23266. setMotor(force?: number, maxForce?: number): void;
  23267. /**
  23268. * Set the motor's limits.
  23269. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23270. * @param upperLimit The upper limit of the motor
  23271. * @param lowerLimit The lower limit of the motor
  23272. */
  23273. setLimit(upperLimit: number, lowerLimit?: number): void;
  23274. }
  23275. /**
  23276. * This class represents a dual hinge physics joint (same as wheel joint)
  23277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23278. */
  23279. export class Hinge2Joint extends MotorEnabledJoint {
  23280. /**
  23281. * Initializes the Hinge2-Joint
  23282. * @param jointData The joint data for the Hinge2-Joint
  23283. */
  23284. constructor(jointData: PhysicsJointData);
  23285. /**
  23286. * Set the motor values.
  23287. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23288. * @param {number} targetSpeed the speed the motor is to reach
  23289. * @param {number} maxForce max force for this motor.
  23290. * @param {motorIndex} the motor's index, 0 or 1.
  23291. */
  23292. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23293. /**
  23294. * Set the motor limits.
  23295. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23296. * @param {number} upperLimit the upper limit
  23297. * @param {number} lowerLimit lower limit
  23298. * @param {motorIndex} the motor's index, 0 or 1.
  23299. */
  23300. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23301. }
  23302. /**
  23303. * Interface for a motor enabled joint
  23304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23305. */
  23306. export interface IMotorEnabledJoint {
  23307. /**
  23308. * Physics joint
  23309. */
  23310. physicsJoint: any;
  23311. /**
  23312. * Sets the motor of the motor-enabled joint
  23313. * @param force The force of the motor
  23314. * @param maxForce The maximum force of the motor
  23315. * @param motorIndex The index of the motor
  23316. */
  23317. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23318. /**
  23319. * Sets the limit of the motor
  23320. * @param upperLimit The upper limit of the motor
  23321. * @param lowerLimit The lower limit of the motor
  23322. * @param motorIndex The index of the motor
  23323. */
  23324. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23325. }
  23326. /**
  23327. * Joint data for a Distance-Joint
  23328. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23329. */
  23330. export interface DistanceJointData extends PhysicsJointData {
  23331. /**
  23332. * Max distance the 2 joint objects can be apart
  23333. */
  23334. maxDistance: number;
  23335. }
  23336. /**
  23337. * Joint data from a spring joint
  23338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23339. */
  23340. export interface SpringJointData extends PhysicsJointData {
  23341. /**
  23342. * Length of the spring
  23343. */
  23344. length: number;
  23345. /**
  23346. * Stiffness of the spring
  23347. */
  23348. stiffness: number;
  23349. /**
  23350. * Damping of the spring
  23351. */
  23352. damping: number;
  23353. /** this callback will be called when applying the force to the impostors. */
  23354. forceApplicationCallback: () => void;
  23355. }
  23356. }
  23357. declare module "babylonjs/Physics/physicsRaycastResult" {
  23358. import { Vector3 } from "babylonjs/Maths/math.vector";
  23359. /**
  23360. * Holds the data for the raycast result
  23361. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23362. */
  23363. export class PhysicsRaycastResult {
  23364. private _hasHit;
  23365. private _hitDistance;
  23366. private _hitNormalWorld;
  23367. private _hitPointWorld;
  23368. private _rayFromWorld;
  23369. private _rayToWorld;
  23370. /**
  23371. * Gets if there was a hit
  23372. */
  23373. readonly hasHit: boolean;
  23374. /**
  23375. * Gets the distance from the hit
  23376. */
  23377. readonly hitDistance: number;
  23378. /**
  23379. * Gets the hit normal/direction in the world
  23380. */
  23381. readonly hitNormalWorld: Vector3;
  23382. /**
  23383. * Gets the hit point in the world
  23384. */
  23385. readonly hitPointWorld: Vector3;
  23386. /**
  23387. * Gets the ray "start point" of the ray in the world
  23388. */
  23389. readonly rayFromWorld: Vector3;
  23390. /**
  23391. * Gets the ray "end point" of the ray in the world
  23392. */
  23393. readonly rayToWorld: Vector3;
  23394. /**
  23395. * Sets the hit data (normal & point in world space)
  23396. * @param hitNormalWorld defines the normal in world space
  23397. * @param hitPointWorld defines the point in world space
  23398. */
  23399. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23400. /**
  23401. * Sets the distance from the start point to the hit point
  23402. * @param distance
  23403. */
  23404. setHitDistance(distance: number): void;
  23405. /**
  23406. * Calculates the distance manually
  23407. */
  23408. calculateHitDistance(): void;
  23409. /**
  23410. * Resets all the values to default
  23411. * @param from The from point on world space
  23412. * @param to The to point on world space
  23413. */
  23414. reset(from?: Vector3, to?: Vector3): void;
  23415. }
  23416. /**
  23417. * Interface for the size containing width and height
  23418. */
  23419. interface IXYZ {
  23420. /**
  23421. * X
  23422. */
  23423. x: number;
  23424. /**
  23425. * Y
  23426. */
  23427. y: number;
  23428. /**
  23429. * Z
  23430. */
  23431. z: number;
  23432. }
  23433. }
  23434. declare module "babylonjs/Physics/IPhysicsEngine" {
  23435. import { Nullable } from "babylonjs/types";
  23436. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23437. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23438. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23439. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23440. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23441. /**
  23442. * Interface used to describe a physics joint
  23443. */
  23444. export interface PhysicsImpostorJoint {
  23445. /** Defines the main impostor to which the joint is linked */
  23446. mainImpostor: PhysicsImpostor;
  23447. /** Defines the impostor that is connected to the main impostor using this joint */
  23448. connectedImpostor: PhysicsImpostor;
  23449. /** Defines the joint itself */
  23450. joint: PhysicsJoint;
  23451. }
  23452. /** @hidden */
  23453. export interface IPhysicsEnginePlugin {
  23454. world: any;
  23455. name: string;
  23456. setGravity(gravity: Vector3): void;
  23457. setTimeStep(timeStep: number): void;
  23458. getTimeStep(): number;
  23459. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23460. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23461. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23462. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23463. removePhysicsBody(impostor: PhysicsImpostor): void;
  23464. generateJoint(joint: PhysicsImpostorJoint): void;
  23465. removeJoint(joint: PhysicsImpostorJoint): void;
  23466. isSupported(): boolean;
  23467. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23468. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23469. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23470. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23471. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23472. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23473. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23474. getBodyMass(impostor: PhysicsImpostor): number;
  23475. getBodyFriction(impostor: PhysicsImpostor): number;
  23476. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23477. getBodyRestitution(impostor: PhysicsImpostor): number;
  23478. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23479. getBodyPressure?(impostor: PhysicsImpostor): number;
  23480. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23481. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23482. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23483. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23484. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23485. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23486. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23487. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23488. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23489. sleepBody(impostor: PhysicsImpostor): void;
  23490. wakeUpBody(impostor: PhysicsImpostor): void;
  23491. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23492. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23493. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23494. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23495. getRadius(impostor: PhysicsImpostor): number;
  23496. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23497. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23498. dispose(): void;
  23499. }
  23500. /**
  23501. * Interface used to define a physics engine
  23502. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23503. */
  23504. export interface IPhysicsEngine {
  23505. /**
  23506. * Gets the gravity vector used by the simulation
  23507. */
  23508. gravity: Vector3;
  23509. /**
  23510. * Sets the gravity vector used by the simulation
  23511. * @param gravity defines the gravity vector to use
  23512. */
  23513. setGravity(gravity: Vector3): void;
  23514. /**
  23515. * Set the time step of the physics engine.
  23516. * Default is 1/60.
  23517. * To slow it down, enter 1/600 for example.
  23518. * To speed it up, 1/30
  23519. * @param newTimeStep the new timestep to apply to this world.
  23520. */
  23521. setTimeStep(newTimeStep: number): void;
  23522. /**
  23523. * Get the time step of the physics engine.
  23524. * @returns the current time step
  23525. */
  23526. getTimeStep(): number;
  23527. /**
  23528. * Release all resources
  23529. */
  23530. dispose(): void;
  23531. /**
  23532. * Gets the name of the current physics plugin
  23533. * @returns the name of the plugin
  23534. */
  23535. getPhysicsPluginName(): string;
  23536. /**
  23537. * Adding a new impostor for the impostor tracking.
  23538. * This will be done by the impostor itself.
  23539. * @param impostor the impostor to add
  23540. */
  23541. addImpostor(impostor: PhysicsImpostor): void;
  23542. /**
  23543. * Remove an impostor from the engine.
  23544. * This impostor and its mesh will not longer be updated by the physics engine.
  23545. * @param impostor the impostor to remove
  23546. */
  23547. removeImpostor(impostor: PhysicsImpostor): void;
  23548. /**
  23549. * Add a joint to the physics engine
  23550. * @param mainImpostor defines the main impostor to which the joint is added.
  23551. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23552. * @param joint defines the joint that will connect both impostors.
  23553. */
  23554. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23555. /**
  23556. * Removes a joint from the simulation
  23557. * @param mainImpostor defines the impostor used with the joint
  23558. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23559. * @param joint defines the joint to remove
  23560. */
  23561. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23562. /**
  23563. * Gets the current plugin used to run the simulation
  23564. * @returns current plugin
  23565. */
  23566. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23567. /**
  23568. * Gets the list of physic impostors
  23569. * @returns an array of PhysicsImpostor
  23570. */
  23571. getImpostors(): Array<PhysicsImpostor>;
  23572. /**
  23573. * Gets the impostor for a physics enabled object
  23574. * @param object defines the object impersonated by the impostor
  23575. * @returns the PhysicsImpostor or null if not found
  23576. */
  23577. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23578. /**
  23579. * Gets the impostor for a physics body object
  23580. * @param body defines physics body used by the impostor
  23581. * @returns the PhysicsImpostor or null if not found
  23582. */
  23583. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23584. /**
  23585. * Does a raycast in the physics world
  23586. * @param from when should the ray start?
  23587. * @param to when should the ray end?
  23588. * @returns PhysicsRaycastResult
  23589. */
  23590. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23591. /**
  23592. * Called by the scene. No need to call it.
  23593. * @param delta defines the timespam between frames
  23594. */
  23595. _step(delta: number): void;
  23596. }
  23597. }
  23598. declare module "babylonjs/Physics/physicsImpostor" {
  23599. import { Nullable, IndicesArray } from "babylonjs/types";
  23600. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23601. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23603. import { Scene } from "babylonjs/scene";
  23604. import { Bone } from "babylonjs/Bones/bone";
  23605. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23606. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23607. import { Space } from "babylonjs/Maths/math.axis";
  23608. /**
  23609. * The interface for the physics imposter parameters
  23610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23611. */
  23612. export interface PhysicsImpostorParameters {
  23613. /**
  23614. * The mass of the physics imposter
  23615. */
  23616. mass: number;
  23617. /**
  23618. * The friction of the physics imposter
  23619. */
  23620. friction?: number;
  23621. /**
  23622. * The coefficient of restitution of the physics imposter
  23623. */
  23624. restitution?: number;
  23625. /**
  23626. * The native options of the physics imposter
  23627. */
  23628. nativeOptions?: any;
  23629. /**
  23630. * Specifies if the parent should be ignored
  23631. */
  23632. ignoreParent?: boolean;
  23633. /**
  23634. * Specifies if bi-directional transformations should be disabled
  23635. */
  23636. disableBidirectionalTransformation?: boolean;
  23637. /**
  23638. * The pressure inside the physics imposter, soft object only
  23639. */
  23640. pressure?: number;
  23641. /**
  23642. * The stiffness the physics imposter, soft object only
  23643. */
  23644. stiffness?: number;
  23645. /**
  23646. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23647. */
  23648. velocityIterations?: number;
  23649. /**
  23650. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23651. */
  23652. positionIterations?: number;
  23653. /**
  23654. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23655. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23656. * Add to fix multiple points
  23657. */
  23658. fixedPoints?: number;
  23659. /**
  23660. * The collision margin around a soft object
  23661. */
  23662. margin?: number;
  23663. /**
  23664. * The collision margin around a soft object
  23665. */
  23666. damping?: number;
  23667. /**
  23668. * The path for a rope based on an extrusion
  23669. */
  23670. path?: any;
  23671. /**
  23672. * The shape of an extrusion used for a rope based on an extrusion
  23673. */
  23674. shape?: any;
  23675. }
  23676. /**
  23677. * Interface for a physics-enabled object
  23678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23679. */
  23680. export interface IPhysicsEnabledObject {
  23681. /**
  23682. * The position of the physics-enabled object
  23683. */
  23684. position: Vector3;
  23685. /**
  23686. * The rotation of the physics-enabled object
  23687. */
  23688. rotationQuaternion: Nullable<Quaternion>;
  23689. /**
  23690. * The scale of the physics-enabled object
  23691. */
  23692. scaling: Vector3;
  23693. /**
  23694. * The rotation of the physics-enabled object
  23695. */
  23696. rotation?: Vector3;
  23697. /**
  23698. * The parent of the physics-enabled object
  23699. */
  23700. parent?: any;
  23701. /**
  23702. * The bounding info of the physics-enabled object
  23703. * @returns The bounding info of the physics-enabled object
  23704. */
  23705. getBoundingInfo(): BoundingInfo;
  23706. /**
  23707. * Computes the world matrix
  23708. * @param force Specifies if the world matrix should be computed by force
  23709. * @returns A world matrix
  23710. */
  23711. computeWorldMatrix(force: boolean): Matrix;
  23712. /**
  23713. * Gets the world matrix
  23714. * @returns A world matrix
  23715. */
  23716. getWorldMatrix?(): Matrix;
  23717. /**
  23718. * Gets the child meshes
  23719. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23720. * @returns An array of abstract meshes
  23721. */
  23722. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23723. /**
  23724. * Gets the vertex data
  23725. * @param kind The type of vertex data
  23726. * @returns A nullable array of numbers, or a float32 array
  23727. */
  23728. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23729. /**
  23730. * Gets the indices from the mesh
  23731. * @returns A nullable array of index arrays
  23732. */
  23733. getIndices?(): Nullable<IndicesArray>;
  23734. /**
  23735. * Gets the scene from the mesh
  23736. * @returns the indices array or null
  23737. */
  23738. getScene?(): Scene;
  23739. /**
  23740. * Gets the absolute position from the mesh
  23741. * @returns the absolute position
  23742. */
  23743. getAbsolutePosition(): Vector3;
  23744. /**
  23745. * Gets the absolute pivot point from the mesh
  23746. * @returns the absolute pivot point
  23747. */
  23748. getAbsolutePivotPoint(): Vector3;
  23749. /**
  23750. * Rotates the mesh
  23751. * @param axis The axis of rotation
  23752. * @param amount The amount of rotation
  23753. * @param space The space of the rotation
  23754. * @returns The rotation transform node
  23755. */
  23756. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23757. /**
  23758. * Translates the mesh
  23759. * @param axis The axis of translation
  23760. * @param distance The distance of translation
  23761. * @param space The space of the translation
  23762. * @returns The transform node
  23763. */
  23764. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23765. /**
  23766. * Sets the absolute position of the mesh
  23767. * @param absolutePosition The absolute position of the mesh
  23768. * @returns The transform node
  23769. */
  23770. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23771. /**
  23772. * Gets the class name of the mesh
  23773. * @returns The class name
  23774. */
  23775. getClassName(): string;
  23776. }
  23777. /**
  23778. * Represents a physics imposter
  23779. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23780. */
  23781. export class PhysicsImpostor {
  23782. /**
  23783. * The physics-enabled object used as the physics imposter
  23784. */
  23785. object: IPhysicsEnabledObject;
  23786. /**
  23787. * The type of the physics imposter
  23788. */
  23789. type: number;
  23790. private _options;
  23791. private _scene?;
  23792. /**
  23793. * The default object size of the imposter
  23794. */
  23795. static DEFAULT_OBJECT_SIZE: Vector3;
  23796. /**
  23797. * The identity quaternion of the imposter
  23798. */
  23799. static IDENTITY_QUATERNION: Quaternion;
  23800. /** @hidden */
  23801. _pluginData: any;
  23802. private _physicsEngine;
  23803. private _physicsBody;
  23804. private _bodyUpdateRequired;
  23805. private _onBeforePhysicsStepCallbacks;
  23806. private _onAfterPhysicsStepCallbacks;
  23807. /** @hidden */
  23808. _onPhysicsCollideCallbacks: Array<{
  23809. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23810. otherImpostors: Array<PhysicsImpostor>;
  23811. }>;
  23812. private _deltaPosition;
  23813. private _deltaRotation;
  23814. private _deltaRotationConjugated;
  23815. /** @hidden */
  23816. _isFromLine: boolean;
  23817. private _parent;
  23818. private _isDisposed;
  23819. private static _tmpVecs;
  23820. private static _tmpQuat;
  23821. /**
  23822. * Specifies if the physics imposter is disposed
  23823. */
  23824. readonly isDisposed: boolean;
  23825. /**
  23826. * Gets the mass of the physics imposter
  23827. */
  23828. mass: number;
  23829. /**
  23830. * Gets the coefficient of friction
  23831. */
  23832. /**
  23833. * Sets the coefficient of friction
  23834. */
  23835. friction: number;
  23836. /**
  23837. * Gets the coefficient of restitution
  23838. */
  23839. /**
  23840. * Sets the coefficient of restitution
  23841. */
  23842. restitution: number;
  23843. /**
  23844. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23845. */
  23846. /**
  23847. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23848. */
  23849. pressure: number;
  23850. /**
  23851. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23852. */
  23853. /**
  23854. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23855. */
  23856. stiffness: number;
  23857. /**
  23858. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23859. */
  23860. /**
  23861. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23862. */
  23863. velocityIterations: number;
  23864. /**
  23865. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23866. */
  23867. /**
  23868. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23869. */
  23870. positionIterations: number;
  23871. /**
  23872. * The unique id of the physics imposter
  23873. * set by the physics engine when adding this impostor to the array
  23874. */
  23875. uniqueId: number;
  23876. /**
  23877. * @hidden
  23878. */
  23879. soft: boolean;
  23880. /**
  23881. * @hidden
  23882. */
  23883. segments: number;
  23884. private _joints;
  23885. /**
  23886. * Initializes the physics imposter
  23887. * @param object The physics-enabled object used as the physics imposter
  23888. * @param type The type of the physics imposter
  23889. * @param _options The options for the physics imposter
  23890. * @param _scene The Babylon scene
  23891. */
  23892. constructor(
  23893. /**
  23894. * The physics-enabled object used as the physics imposter
  23895. */
  23896. object: IPhysicsEnabledObject,
  23897. /**
  23898. * The type of the physics imposter
  23899. */
  23900. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23901. /**
  23902. * This function will completly initialize this impostor.
  23903. * It will create a new body - but only if this mesh has no parent.
  23904. * If it has, this impostor will not be used other than to define the impostor
  23905. * of the child mesh.
  23906. * @hidden
  23907. */
  23908. _init(): void;
  23909. private _getPhysicsParent;
  23910. /**
  23911. * Should a new body be generated.
  23912. * @returns boolean specifying if body initialization is required
  23913. */
  23914. isBodyInitRequired(): boolean;
  23915. /**
  23916. * Sets the updated scaling
  23917. * @param updated Specifies if the scaling is updated
  23918. */
  23919. setScalingUpdated(): void;
  23920. /**
  23921. * Force a regeneration of this or the parent's impostor's body.
  23922. * Use under cautious - This will remove all joints already implemented.
  23923. */
  23924. forceUpdate(): void;
  23925. /**
  23926. * Gets the body that holds this impostor. Either its own, or its parent.
  23927. */
  23928. /**
  23929. * Set the physics body. Used mainly by the physics engine/plugin
  23930. */
  23931. physicsBody: any;
  23932. /**
  23933. * Get the parent of the physics imposter
  23934. * @returns Physics imposter or null
  23935. */
  23936. /**
  23937. * Sets the parent of the physics imposter
  23938. */
  23939. parent: Nullable<PhysicsImpostor>;
  23940. /**
  23941. * Resets the update flags
  23942. */
  23943. resetUpdateFlags(): void;
  23944. /**
  23945. * Gets the object extend size
  23946. * @returns the object extend size
  23947. */
  23948. getObjectExtendSize(): Vector3;
  23949. /**
  23950. * Gets the object center
  23951. * @returns The object center
  23952. */
  23953. getObjectCenter(): Vector3;
  23954. /**
  23955. * Get a specific parametes from the options parameter
  23956. * @param paramName The object parameter name
  23957. * @returns The object parameter
  23958. */
  23959. getParam(paramName: string): any;
  23960. /**
  23961. * Sets a specific parameter in the options given to the physics plugin
  23962. * @param paramName The parameter name
  23963. * @param value The value of the parameter
  23964. */
  23965. setParam(paramName: string, value: number): void;
  23966. /**
  23967. * Specifically change the body's mass option. Won't recreate the physics body object
  23968. * @param mass The mass of the physics imposter
  23969. */
  23970. setMass(mass: number): void;
  23971. /**
  23972. * Gets the linear velocity
  23973. * @returns linear velocity or null
  23974. */
  23975. getLinearVelocity(): Nullable<Vector3>;
  23976. /**
  23977. * Sets the linear velocity
  23978. * @param velocity linear velocity or null
  23979. */
  23980. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23981. /**
  23982. * Gets the angular velocity
  23983. * @returns angular velocity or null
  23984. */
  23985. getAngularVelocity(): Nullable<Vector3>;
  23986. /**
  23987. * Sets the angular velocity
  23988. * @param velocity The velocity or null
  23989. */
  23990. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23991. /**
  23992. * Execute a function with the physics plugin native code
  23993. * Provide a function the will have two variables - the world object and the physics body object
  23994. * @param func The function to execute with the physics plugin native code
  23995. */
  23996. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23997. /**
  23998. * Register a function that will be executed before the physics world is stepping forward
  23999. * @param func The function to execute before the physics world is stepped forward
  24000. */
  24001. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24002. /**
  24003. * Unregister a function that will be executed before the physics world is stepping forward
  24004. * @param func The function to execute before the physics world is stepped forward
  24005. */
  24006. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24007. /**
  24008. * Register a function that will be executed after the physics step
  24009. * @param func The function to execute after physics step
  24010. */
  24011. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24012. /**
  24013. * Unregisters a function that will be executed after the physics step
  24014. * @param func The function to execute after physics step
  24015. */
  24016. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24017. /**
  24018. * register a function that will be executed when this impostor collides against a different body
  24019. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24020. * @param func Callback that is executed on collision
  24021. */
  24022. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24023. /**
  24024. * Unregisters the physics imposter on contact
  24025. * @param collideAgainst The physics object to collide against
  24026. * @param func Callback to execute on collision
  24027. */
  24028. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24029. private _tmpQuat;
  24030. private _tmpQuat2;
  24031. /**
  24032. * Get the parent rotation
  24033. * @returns The parent rotation
  24034. */
  24035. getParentsRotation(): Quaternion;
  24036. /**
  24037. * this function is executed by the physics engine.
  24038. */
  24039. beforeStep: () => void;
  24040. /**
  24041. * this function is executed by the physics engine
  24042. */
  24043. afterStep: () => void;
  24044. /**
  24045. * Legacy collision detection event support
  24046. */
  24047. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24048. /**
  24049. * event and body object due to cannon's event-based architecture.
  24050. */
  24051. onCollide: (e: {
  24052. body: any;
  24053. }) => void;
  24054. /**
  24055. * Apply a force
  24056. * @param force The force to apply
  24057. * @param contactPoint The contact point for the force
  24058. * @returns The physics imposter
  24059. */
  24060. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24061. /**
  24062. * Apply an impulse
  24063. * @param force The impulse force
  24064. * @param contactPoint The contact point for the impulse force
  24065. * @returns The physics imposter
  24066. */
  24067. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24068. /**
  24069. * A help function to create a joint
  24070. * @param otherImpostor A physics imposter used to create a joint
  24071. * @param jointType The type of joint
  24072. * @param jointData The data for the joint
  24073. * @returns The physics imposter
  24074. */
  24075. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24076. /**
  24077. * Add a joint to this impostor with a different impostor
  24078. * @param otherImpostor A physics imposter used to add a joint
  24079. * @param joint The joint to add
  24080. * @returns The physics imposter
  24081. */
  24082. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24083. /**
  24084. * Add an anchor to a cloth impostor
  24085. * @param otherImpostor rigid impostor to anchor to
  24086. * @param width ratio across width from 0 to 1
  24087. * @param height ratio up height from 0 to 1
  24088. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24089. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24090. * @returns impostor the soft imposter
  24091. */
  24092. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24093. /**
  24094. * Add a hook to a rope impostor
  24095. * @param otherImpostor rigid impostor to anchor to
  24096. * @param length ratio across rope from 0 to 1
  24097. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24098. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24099. * @returns impostor the rope imposter
  24100. */
  24101. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24102. /**
  24103. * Will keep this body still, in a sleep mode.
  24104. * @returns the physics imposter
  24105. */
  24106. sleep(): PhysicsImpostor;
  24107. /**
  24108. * Wake the body up.
  24109. * @returns The physics imposter
  24110. */
  24111. wakeUp(): PhysicsImpostor;
  24112. /**
  24113. * Clones the physics imposter
  24114. * @param newObject The physics imposter clones to this physics-enabled object
  24115. * @returns A nullable physics imposter
  24116. */
  24117. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24118. /**
  24119. * Disposes the physics imposter
  24120. */
  24121. dispose(): void;
  24122. /**
  24123. * Sets the delta position
  24124. * @param position The delta position amount
  24125. */
  24126. setDeltaPosition(position: Vector3): void;
  24127. /**
  24128. * Sets the delta rotation
  24129. * @param rotation The delta rotation amount
  24130. */
  24131. setDeltaRotation(rotation: Quaternion): void;
  24132. /**
  24133. * Gets the box size of the physics imposter and stores the result in the input parameter
  24134. * @param result Stores the box size
  24135. * @returns The physics imposter
  24136. */
  24137. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24138. /**
  24139. * Gets the radius of the physics imposter
  24140. * @returns Radius of the physics imposter
  24141. */
  24142. getRadius(): number;
  24143. /**
  24144. * Sync a bone with this impostor
  24145. * @param bone The bone to sync to the impostor.
  24146. * @param boneMesh The mesh that the bone is influencing.
  24147. * @param jointPivot The pivot of the joint / bone in local space.
  24148. * @param distToJoint Optional distance from the impostor to the joint.
  24149. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24150. */
  24151. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24152. /**
  24153. * Sync impostor to a bone
  24154. * @param bone The bone that the impostor will be synced to.
  24155. * @param boneMesh The mesh that the bone is influencing.
  24156. * @param jointPivot The pivot of the joint / bone in local space.
  24157. * @param distToJoint Optional distance from the impostor to the joint.
  24158. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24159. * @param boneAxis Optional vector3 axis the bone is aligned with
  24160. */
  24161. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24162. /**
  24163. * No-Imposter type
  24164. */
  24165. static NoImpostor: number;
  24166. /**
  24167. * Sphere-Imposter type
  24168. */
  24169. static SphereImpostor: number;
  24170. /**
  24171. * Box-Imposter type
  24172. */
  24173. static BoxImpostor: number;
  24174. /**
  24175. * Plane-Imposter type
  24176. */
  24177. static PlaneImpostor: number;
  24178. /**
  24179. * Mesh-imposter type
  24180. */
  24181. static MeshImpostor: number;
  24182. /**
  24183. * Capsule-Impostor type (Ammo.js plugin only)
  24184. */
  24185. static CapsuleImpostor: number;
  24186. /**
  24187. * Cylinder-Imposter type
  24188. */
  24189. static CylinderImpostor: number;
  24190. /**
  24191. * Particle-Imposter type
  24192. */
  24193. static ParticleImpostor: number;
  24194. /**
  24195. * Heightmap-Imposter type
  24196. */
  24197. static HeightmapImpostor: number;
  24198. /**
  24199. * ConvexHull-Impostor type (Ammo.js plugin only)
  24200. */
  24201. static ConvexHullImpostor: number;
  24202. /**
  24203. * Rope-Imposter type
  24204. */
  24205. static RopeImpostor: number;
  24206. /**
  24207. * Cloth-Imposter type
  24208. */
  24209. static ClothImpostor: number;
  24210. /**
  24211. * Softbody-Imposter type
  24212. */
  24213. static SoftbodyImpostor: number;
  24214. }
  24215. }
  24216. declare module "babylonjs/Meshes/mesh" {
  24217. import { Observable } from "babylonjs/Misc/observable";
  24218. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24219. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24220. import { Camera } from "babylonjs/Cameras/camera";
  24221. import { Scene } from "babylonjs/scene";
  24222. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24223. import { Color4 } from "babylonjs/Maths/math.color";
  24224. import { Engine } from "babylonjs/Engines/engine";
  24225. import { Node } from "babylonjs/node";
  24226. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24227. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24228. import { Buffer } from "babylonjs/Meshes/buffer";
  24229. import { Geometry } from "babylonjs/Meshes/geometry";
  24230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24231. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24232. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24233. import { Effect } from "babylonjs/Materials/effect";
  24234. import { Material } from "babylonjs/Materials/material";
  24235. import { Skeleton } from "babylonjs/Bones/skeleton";
  24236. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24237. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24238. import { Path3D } from "babylonjs/Maths/math.path";
  24239. import { Plane } from "babylonjs/Maths/math.plane";
  24240. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24241. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24242. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24243. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24244. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24245. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24246. /**
  24247. * @hidden
  24248. **/
  24249. export class _CreationDataStorage {
  24250. closePath?: boolean;
  24251. closeArray?: boolean;
  24252. idx: number[];
  24253. dashSize: number;
  24254. gapSize: number;
  24255. path3D: Path3D;
  24256. pathArray: Vector3[][];
  24257. arc: number;
  24258. radius: number;
  24259. cap: number;
  24260. tessellation: number;
  24261. }
  24262. /**
  24263. * @hidden
  24264. **/
  24265. class _InstanceDataStorage {
  24266. visibleInstances: any;
  24267. batchCache: _InstancesBatch;
  24268. instancesBufferSize: number;
  24269. instancesBuffer: Nullable<Buffer>;
  24270. instancesData: Float32Array;
  24271. overridenInstanceCount: number;
  24272. isFrozen: boolean;
  24273. previousBatch: Nullable<_InstancesBatch>;
  24274. hardwareInstancedRendering: boolean;
  24275. sideOrientation: number;
  24276. }
  24277. /**
  24278. * @hidden
  24279. **/
  24280. export class _InstancesBatch {
  24281. mustReturn: boolean;
  24282. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24283. renderSelf: boolean[];
  24284. hardwareInstancedRendering: boolean[];
  24285. }
  24286. /**
  24287. * Class used to represent renderable models
  24288. */
  24289. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24290. /**
  24291. * Mesh side orientation : usually the external or front surface
  24292. */
  24293. static readonly FRONTSIDE: number;
  24294. /**
  24295. * Mesh side orientation : usually the internal or back surface
  24296. */
  24297. static readonly BACKSIDE: number;
  24298. /**
  24299. * Mesh side orientation : both internal and external or front and back surfaces
  24300. */
  24301. static readonly DOUBLESIDE: number;
  24302. /**
  24303. * Mesh side orientation : by default, `FRONTSIDE`
  24304. */
  24305. static readonly DEFAULTSIDE: number;
  24306. /**
  24307. * Mesh cap setting : no cap
  24308. */
  24309. static readonly NO_CAP: number;
  24310. /**
  24311. * Mesh cap setting : one cap at the beginning of the mesh
  24312. */
  24313. static readonly CAP_START: number;
  24314. /**
  24315. * Mesh cap setting : one cap at the end of the mesh
  24316. */
  24317. static readonly CAP_END: number;
  24318. /**
  24319. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24320. */
  24321. static readonly CAP_ALL: number;
  24322. /**
  24323. * Mesh pattern setting : no flip or rotate
  24324. */
  24325. static readonly NO_FLIP: number;
  24326. /**
  24327. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24328. */
  24329. static readonly FLIP_TILE: number;
  24330. /**
  24331. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24332. */
  24333. static readonly ROTATE_TILE: number;
  24334. /**
  24335. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24336. */
  24337. static readonly FLIP_ROW: number;
  24338. /**
  24339. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24340. */
  24341. static readonly ROTATE_ROW: number;
  24342. /**
  24343. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24344. */
  24345. static readonly FLIP_N_ROTATE_TILE: number;
  24346. /**
  24347. * Mesh pattern setting : rotate pattern and rotate
  24348. */
  24349. static readonly FLIP_N_ROTATE_ROW: number;
  24350. /**
  24351. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24352. */
  24353. static readonly CENTER: number;
  24354. /**
  24355. * Mesh tile positioning : part tiles on left
  24356. */
  24357. static readonly LEFT: number;
  24358. /**
  24359. * Mesh tile positioning : part tiles on right
  24360. */
  24361. static readonly RIGHT: number;
  24362. /**
  24363. * Mesh tile positioning : part tiles on top
  24364. */
  24365. static readonly TOP: number;
  24366. /**
  24367. * Mesh tile positioning : part tiles on bottom
  24368. */
  24369. static readonly BOTTOM: number;
  24370. /**
  24371. * Gets the default side orientation.
  24372. * @param orientation the orientation to value to attempt to get
  24373. * @returns the default orientation
  24374. * @hidden
  24375. */
  24376. static _GetDefaultSideOrientation(orientation?: number): number;
  24377. private _internalMeshDataInfo;
  24378. /**
  24379. * An event triggered before rendering the mesh
  24380. */
  24381. readonly onBeforeRenderObservable: Observable<Mesh>;
  24382. /**
  24383. * An event triggered before binding the mesh
  24384. */
  24385. readonly onBeforeBindObservable: Observable<Mesh>;
  24386. /**
  24387. * An event triggered after rendering the mesh
  24388. */
  24389. readonly onAfterRenderObservable: Observable<Mesh>;
  24390. /**
  24391. * An event triggered before drawing the mesh
  24392. */
  24393. readonly onBeforeDrawObservable: Observable<Mesh>;
  24394. private _onBeforeDrawObserver;
  24395. /**
  24396. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24397. */
  24398. onBeforeDraw: () => void;
  24399. readonly hasInstances: boolean;
  24400. /**
  24401. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24402. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24403. */
  24404. delayLoadState: number;
  24405. /**
  24406. * Gets the list of instances created from this mesh
  24407. * it is not supposed to be modified manually.
  24408. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24409. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24410. */
  24411. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24412. /**
  24413. * Gets the file containing delay loading data for this mesh
  24414. */
  24415. delayLoadingFile: string;
  24416. /** @hidden */
  24417. _binaryInfo: any;
  24418. /**
  24419. * User defined function used to change how LOD level selection is done
  24420. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24421. */
  24422. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24423. /**
  24424. * Gets or sets the morph target manager
  24425. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24426. */
  24427. morphTargetManager: Nullable<MorphTargetManager>;
  24428. /** @hidden */
  24429. _creationDataStorage: Nullable<_CreationDataStorage>;
  24430. /** @hidden */
  24431. _geometry: Nullable<Geometry>;
  24432. /** @hidden */
  24433. _delayInfo: Array<string>;
  24434. /** @hidden */
  24435. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24436. /** @hidden */
  24437. _instanceDataStorage: _InstanceDataStorage;
  24438. private _effectiveMaterial;
  24439. /** @hidden */
  24440. _shouldGenerateFlatShading: boolean;
  24441. /** @hidden */
  24442. _originalBuilderSideOrientation: number;
  24443. /**
  24444. * Use this property to change the original side orientation defined at construction time
  24445. */
  24446. overrideMaterialSideOrientation: Nullable<number>;
  24447. /**
  24448. * Gets the source mesh (the one used to clone this one from)
  24449. */
  24450. readonly source: Nullable<Mesh>;
  24451. /**
  24452. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24453. */
  24454. isUnIndexed: boolean;
  24455. /**
  24456. * @constructor
  24457. * @param name The value used by scene.getMeshByName() to do a lookup.
  24458. * @param scene The scene to add this mesh to.
  24459. * @param parent The parent of this mesh, if it has one
  24460. * @param source An optional Mesh from which geometry is shared, cloned.
  24461. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24462. * When false, achieved by calling a clone(), also passing False.
  24463. * This will make creation of children, recursive.
  24464. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24465. */
  24466. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24467. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24468. /**
  24469. * Gets the class name
  24470. * @returns the string "Mesh".
  24471. */
  24472. getClassName(): string;
  24473. /** @hidden */
  24474. readonly _isMesh: boolean;
  24475. /**
  24476. * Returns a description of this mesh
  24477. * @param fullDetails define if full details about this mesh must be used
  24478. * @returns a descriptive string representing this mesh
  24479. */
  24480. toString(fullDetails?: boolean): string;
  24481. /** @hidden */
  24482. _unBindEffect(): void;
  24483. /**
  24484. * Gets a boolean indicating if this mesh has LOD
  24485. */
  24486. readonly hasLODLevels: boolean;
  24487. /**
  24488. * Gets the list of MeshLODLevel associated with the current mesh
  24489. * @returns an array of MeshLODLevel
  24490. */
  24491. getLODLevels(): MeshLODLevel[];
  24492. private _sortLODLevels;
  24493. /**
  24494. * Add a mesh as LOD level triggered at the given distance.
  24495. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24496. * @param distance The distance from the center of the object to show this level
  24497. * @param mesh The mesh to be added as LOD level (can be null)
  24498. * @return This mesh (for chaining)
  24499. */
  24500. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24501. /**
  24502. * Returns the LOD level mesh at the passed distance or null if not found.
  24503. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24504. * @param distance The distance from the center of the object to show this level
  24505. * @returns a Mesh or `null`
  24506. */
  24507. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24508. /**
  24509. * Remove a mesh from the LOD array
  24510. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24511. * @param mesh defines the mesh to be removed
  24512. * @return This mesh (for chaining)
  24513. */
  24514. removeLODLevel(mesh: Mesh): Mesh;
  24515. /**
  24516. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24517. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24518. * @param camera defines the camera to use to compute distance
  24519. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24520. * @return This mesh (for chaining)
  24521. */
  24522. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24523. /**
  24524. * Gets the mesh internal Geometry object
  24525. */
  24526. readonly geometry: Nullable<Geometry>;
  24527. /**
  24528. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24529. * @returns the total number of vertices
  24530. */
  24531. getTotalVertices(): number;
  24532. /**
  24533. * Returns the content of an associated vertex buffer
  24534. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24535. * - VertexBuffer.PositionKind
  24536. * - VertexBuffer.UVKind
  24537. * - VertexBuffer.UV2Kind
  24538. * - VertexBuffer.UV3Kind
  24539. * - VertexBuffer.UV4Kind
  24540. * - VertexBuffer.UV5Kind
  24541. * - VertexBuffer.UV6Kind
  24542. * - VertexBuffer.ColorKind
  24543. * - VertexBuffer.MatricesIndicesKind
  24544. * - VertexBuffer.MatricesIndicesExtraKind
  24545. * - VertexBuffer.MatricesWeightsKind
  24546. * - VertexBuffer.MatricesWeightsExtraKind
  24547. * @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
  24548. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24549. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24550. */
  24551. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24552. /**
  24553. * Returns the mesh VertexBuffer object from the requested `kind`
  24554. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24555. * - VertexBuffer.PositionKind
  24556. * - VertexBuffer.NormalKind
  24557. * - VertexBuffer.UVKind
  24558. * - VertexBuffer.UV2Kind
  24559. * - VertexBuffer.UV3Kind
  24560. * - VertexBuffer.UV4Kind
  24561. * - VertexBuffer.UV5Kind
  24562. * - VertexBuffer.UV6Kind
  24563. * - VertexBuffer.ColorKind
  24564. * - VertexBuffer.MatricesIndicesKind
  24565. * - VertexBuffer.MatricesIndicesExtraKind
  24566. * - VertexBuffer.MatricesWeightsKind
  24567. * - VertexBuffer.MatricesWeightsExtraKind
  24568. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24569. */
  24570. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24571. /**
  24572. * Tests if a specific vertex buffer is associated with this mesh
  24573. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24574. * - VertexBuffer.PositionKind
  24575. * - VertexBuffer.NormalKind
  24576. * - VertexBuffer.UVKind
  24577. * - VertexBuffer.UV2Kind
  24578. * - VertexBuffer.UV3Kind
  24579. * - VertexBuffer.UV4Kind
  24580. * - VertexBuffer.UV5Kind
  24581. * - VertexBuffer.UV6Kind
  24582. * - VertexBuffer.ColorKind
  24583. * - VertexBuffer.MatricesIndicesKind
  24584. * - VertexBuffer.MatricesIndicesExtraKind
  24585. * - VertexBuffer.MatricesWeightsKind
  24586. * - VertexBuffer.MatricesWeightsExtraKind
  24587. * @returns a boolean
  24588. */
  24589. isVerticesDataPresent(kind: string): boolean;
  24590. /**
  24591. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24592. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24593. * - VertexBuffer.PositionKind
  24594. * - VertexBuffer.UVKind
  24595. * - VertexBuffer.UV2Kind
  24596. * - VertexBuffer.UV3Kind
  24597. * - VertexBuffer.UV4Kind
  24598. * - VertexBuffer.UV5Kind
  24599. * - VertexBuffer.UV6Kind
  24600. * - VertexBuffer.ColorKind
  24601. * - VertexBuffer.MatricesIndicesKind
  24602. * - VertexBuffer.MatricesIndicesExtraKind
  24603. * - VertexBuffer.MatricesWeightsKind
  24604. * - VertexBuffer.MatricesWeightsExtraKind
  24605. * @returns a boolean
  24606. */
  24607. isVertexBufferUpdatable(kind: string): boolean;
  24608. /**
  24609. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24610. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24611. * - VertexBuffer.PositionKind
  24612. * - VertexBuffer.NormalKind
  24613. * - VertexBuffer.UVKind
  24614. * - VertexBuffer.UV2Kind
  24615. * - VertexBuffer.UV3Kind
  24616. * - VertexBuffer.UV4Kind
  24617. * - VertexBuffer.UV5Kind
  24618. * - VertexBuffer.UV6Kind
  24619. * - VertexBuffer.ColorKind
  24620. * - VertexBuffer.MatricesIndicesKind
  24621. * - VertexBuffer.MatricesIndicesExtraKind
  24622. * - VertexBuffer.MatricesWeightsKind
  24623. * - VertexBuffer.MatricesWeightsExtraKind
  24624. * @returns an array of strings
  24625. */
  24626. getVerticesDataKinds(): string[];
  24627. /**
  24628. * Returns a positive integer : the total number of indices in this mesh geometry.
  24629. * @returns the numner of indices or zero if the mesh has no geometry.
  24630. */
  24631. getTotalIndices(): number;
  24632. /**
  24633. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24634. * @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.
  24635. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24636. * @returns the indices array or an empty array if the mesh has no geometry
  24637. */
  24638. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24639. readonly isBlocked: boolean;
  24640. /**
  24641. * Determine if the current mesh is ready to be rendered
  24642. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24643. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24644. * @returns true if all associated assets are ready (material, textures, shaders)
  24645. */
  24646. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24647. /**
  24648. * 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.
  24649. */
  24650. readonly areNormalsFrozen: boolean;
  24651. /**
  24652. * 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.
  24653. * @returns the current mesh
  24654. */
  24655. freezeNormals(): Mesh;
  24656. /**
  24657. * 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
  24658. * @returns the current mesh
  24659. */
  24660. unfreezeNormals(): Mesh;
  24661. /**
  24662. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24663. */
  24664. overridenInstanceCount: number;
  24665. /** @hidden */
  24666. _preActivate(): Mesh;
  24667. /** @hidden */
  24668. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24669. /** @hidden */
  24670. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24671. /**
  24672. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24673. * This means the mesh underlying bounding box and sphere are recomputed.
  24674. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24675. * @returns the current mesh
  24676. */
  24677. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24678. /** @hidden */
  24679. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24680. /**
  24681. * This function will subdivide the mesh into multiple submeshes
  24682. * @param count defines the expected number of submeshes
  24683. */
  24684. subdivide(count: number): void;
  24685. /**
  24686. * Copy a FloatArray into a specific associated vertex buffer
  24687. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24688. * - VertexBuffer.PositionKind
  24689. * - VertexBuffer.UVKind
  24690. * - VertexBuffer.UV2Kind
  24691. * - VertexBuffer.UV3Kind
  24692. * - VertexBuffer.UV4Kind
  24693. * - VertexBuffer.UV5Kind
  24694. * - VertexBuffer.UV6Kind
  24695. * - VertexBuffer.ColorKind
  24696. * - VertexBuffer.MatricesIndicesKind
  24697. * - VertexBuffer.MatricesIndicesExtraKind
  24698. * - VertexBuffer.MatricesWeightsKind
  24699. * - VertexBuffer.MatricesWeightsExtraKind
  24700. * @param data defines the data source
  24701. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24702. * @param stride defines the data stride size (can be null)
  24703. * @returns the current mesh
  24704. */
  24705. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24706. /**
  24707. * Flags an associated vertex buffer as updatable
  24708. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24709. * - VertexBuffer.PositionKind
  24710. * - VertexBuffer.UVKind
  24711. * - VertexBuffer.UV2Kind
  24712. * - VertexBuffer.UV3Kind
  24713. * - VertexBuffer.UV4Kind
  24714. * - VertexBuffer.UV5Kind
  24715. * - VertexBuffer.UV6Kind
  24716. * - VertexBuffer.ColorKind
  24717. * - VertexBuffer.MatricesIndicesKind
  24718. * - VertexBuffer.MatricesIndicesExtraKind
  24719. * - VertexBuffer.MatricesWeightsKind
  24720. * - VertexBuffer.MatricesWeightsExtraKind
  24721. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24722. */
  24723. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24724. /**
  24725. * Sets the mesh global Vertex Buffer
  24726. * @param buffer defines the buffer to use
  24727. * @returns the current mesh
  24728. */
  24729. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24730. /**
  24731. * Update a specific associated vertex buffer
  24732. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24733. * - VertexBuffer.PositionKind
  24734. * - VertexBuffer.UVKind
  24735. * - VertexBuffer.UV2Kind
  24736. * - VertexBuffer.UV3Kind
  24737. * - VertexBuffer.UV4Kind
  24738. * - VertexBuffer.UV5Kind
  24739. * - VertexBuffer.UV6Kind
  24740. * - VertexBuffer.ColorKind
  24741. * - VertexBuffer.MatricesIndicesKind
  24742. * - VertexBuffer.MatricesIndicesExtraKind
  24743. * - VertexBuffer.MatricesWeightsKind
  24744. * - VertexBuffer.MatricesWeightsExtraKind
  24745. * @param data defines the data source
  24746. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24747. * @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)
  24748. * @returns the current mesh
  24749. */
  24750. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24751. /**
  24752. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24753. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24754. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24755. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24756. * @returns the current mesh
  24757. */
  24758. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24759. /**
  24760. * Creates a un-shared specific occurence of the geometry for the mesh.
  24761. * @returns the current mesh
  24762. */
  24763. makeGeometryUnique(): Mesh;
  24764. /**
  24765. * Set the index buffer of this mesh
  24766. * @param indices defines the source data
  24767. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24768. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24769. * @returns the current mesh
  24770. */
  24771. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24772. /**
  24773. * Update the current index buffer
  24774. * @param indices defines the source data
  24775. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24776. * @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)
  24777. * @returns the current mesh
  24778. */
  24779. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24780. /**
  24781. * Invert the geometry to move from a right handed system to a left handed one.
  24782. * @returns the current mesh
  24783. */
  24784. toLeftHanded(): Mesh;
  24785. /** @hidden */
  24786. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24787. /** @hidden */
  24788. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24789. /**
  24790. * Registers for this mesh a javascript function called just before the rendering process
  24791. * @param func defines the function to call before rendering this mesh
  24792. * @returns the current mesh
  24793. */
  24794. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24795. /**
  24796. * Disposes a previously registered javascript function called before the rendering
  24797. * @param func defines the function to remove
  24798. * @returns the current mesh
  24799. */
  24800. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24801. /**
  24802. * Registers for this mesh a javascript function called just after the rendering is complete
  24803. * @param func defines the function to call after rendering this mesh
  24804. * @returns the current mesh
  24805. */
  24806. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24807. /**
  24808. * Disposes a previously registered javascript function called after the rendering.
  24809. * @param func defines the function to remove
  24810. * @returns the current mesh
  24811. */
  24812. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24813. /** @hidden */
  24814. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24815. /** @hidden */
  24816. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24817. /** @hidden */
  24818. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24819. /** @hidden */
  24820. _rebuild(): void;
  24821. /** @hidden */
  24822. _freeze(): void;
  24823. /** @hidden */
  24824. _unFreeze(): void;
  24825. /**
  24826. * 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
  24827. * @param subMesh defines the subMesh to render
  24828. * @param enableAlphaMode defines if alpha mode can be changed
  24829. * @returns the current mesh
  24830. */
  24831. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24832. private _onBeforeDraw;
  24833. /**
  24834. * Renormalize the mesh and patch it up if there are no weights
  24835. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24836. * However in the case of zero weights then we set just a single influence to 1.
  24837. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24838. */
  24839. cleanMatrixWeights(): void;
  24840. private normalizeSkinFourWeights;
  24841. private normalizeSkinWeightsAndExtra;
  24842. /**
  24843. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24844. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24845. * the user know there was an issue with importing the mesh
  24846. * @returns a validation object with skinned, valid and report string
  24847. */
  24848. validateSkinning(): {
  24849. skinned: boolean;
  24850. valid: boolean;
  24851. report: string;
  24852. };
  24853. /** @hidden */
  24854. _checkDelayState(): Mesh;
  24855. private _queueLoad;
  24856. /**
  24857. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24858. * A mesh is in the frustum if its bounding box intersects the frustum
  24859. * @param frustumPlanes defines the frustum to test
  24860. * @returns true if the mesh is in the frustum planes
  24861. */
  24862. isInFrustum(frustumPlanes: Plane[]): boolean;
  24863. /**
  24864. * Sets the mesh material by the material or multiMaterial `id` property
  24865. * @param id is a string identifying the material or the multiMaterial
  24866. * @returns the current mesh
  24867. */
  24868. setMaterialByID(id: string): Mesh;
  24869. /**
  24870. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24871. * @returns an array of IAnimatable
  24872. */
  24873. getAnimatables(): IAnimatable[];
  24874. /**
  24875. * Modifies the mesh geometry according to the passed transformation matrix.
  24876. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24877. * The mesh normals are modified using the same transformation.
  24878. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24879. * @param transform defines the transform matrix to use
  24880. * @see http://doc.babylonjs.com/resources/baking_transformations
  24881. * @returns the current mesh
  24882. */
  24883. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24884. /**
  24885. * Modifies the mesh geometry according to its own current World Matrix.
  24886. * The mesh World Matrix is then reset.
  24887. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24888. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24889. * @see http://doc.babylonjs.com/resources/baking_transformations
  24890. * @returns the current mesh
  24891. */
  24892. bakeCurrentTransformIntoVertices(): Mesh;
  24893. /** @hidden */
  24894. readonly _positions: Nullable<Vector3[]>;
  24895. /** @hidden */
  24896. _resetPointsArrayCache(): Mesh;
  24897. /** @hidden */
  24898. _generatePointsArray(): boolean;
  24899. /**
  24900. * Returns a new Mesh object generated from the current mesh properties.
  24901. * This method must not get confused with createInstance()
  24902. * @param name is a string, the name given to the new mesh
  24903. * @param newParent can be any Node object (default `null`)
  24904. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24905. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24906. * @returns a new mesh
  24907. */
  24908. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24909. /**
  24910. * Releases resources associated with this mesh.
  24911. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24912. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24913. */
  24914. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24915. /**
  24916. * Modifies the mesh geometry according to a displacement map.
  24917. * 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.
  24918. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24919. * @param url is a string, the URL from the image file is to be downloaded.
  24920. * @param minHeight is the lower limit of the displacement.
  24921. * @param maxHeight is the upper limit of the displacement.
  24922. * @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.
  24923. * @param uvOffset is an optional vector2 used to offset UV.
  24924. * @param uvScale is an optional vector2 used to scale UV.
  24925. * @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.
  24926. * @returns the Mesh.
  24927. */
  24928. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24929. /**
  24930. * Modifies the mesh geometry according to a displacementMap buffer.
  24931. * 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.
  24932. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24933. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24934. * @param heightMapWidth is the width of the buffer image.
  24935. * @param heightMapHeight is the height of the buffer image.
  24936. * @param minHeight is the lower limit of the displacement.
  24937. * @param maxHeight is the upper limit of the displacement.
  24938. * @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.
  24939. * @param uvOffset is an optional vector2 used to offset UV.
  24940. * @param uvScale is an optional vector2 used to scale UV.
  24941. * @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.
  24942. * @returns the Mesh.
  24943. */
  24944. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24945. /**
  24946. * Modify the mesh to get a flat shading rendering.
  24947. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24948. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24949. * @returns current mesh
  24950. */
  24951. convertToFlatShadedMesh(): Mesh;
  24952. /**
  24953. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24954. * In other words, more vertices, no more indices and a single bigger VBO.
  24955. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24956. * @returns current mesh
  24957. */
  24958. convertToUnIndexedMesh(): Mesh;
  24959. /**
  24960. * Inverses facet orientations.
  24961. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24962. * @param flipNormals will also inverts the normals
  24963. * @returns current mesh
  24964. */
  24965. flipFaces(flipNormals?: boolean): Mesh;
  24966. /**
  24967. * Increase the number of facets and hence vertices in a mesh
  24968. * Vertex normals are interpolated from existing vertex normals
  24969. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24970. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24971. */
  24972. increaseVertices(numberPerEdge: number): void;
  24973. /**
  24974. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24975. * This will undo any application of covertToFlatShadedMesh
  24976. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24977. */
  24978. forceSharedVertices(): void;
  24979. /** @hidden */
  24980. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24981. /** @hidden */
  24982. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24983. /**
  24984. * Creates a new InstancedMesh object from the mesh model.
  24985. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24986. * @param name defines the name of the new instance
  24987. * @returns a new InstancedMesh
  24988. */
  24989. createInstance(name: string): InstancedMesh;
  24990. /**
  24991. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24992. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24993. * @returns the current mesh
  24994. */
  24995. synchronizeInstances(): Mesh;
  24996. /**
  24997. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24998. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24999. * This should be used together with the simplification to avoid disappearing triangles.
  25000. * @param successCallback an optional success callback to be called after the optimization finished.
  25001. * @returns the current mesh
  25002. */
  25003. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25004. /**
  25005. * Serialize current mesh
  25006. * @param serializationObject defines the object which will receive the serialization data
  25007. */
  25008. serialize(serializationObject: any): void;
  25009. /** @hidden */
  25010. _syncGeometryWithMorphTargetManager(): void;
  25011. /** @hidden */
  25012. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25013. /**
  25014. * Returns a new Mesh object parsed from the source provided.
  25015. * @param parsedMesh is the source
  25016. * @param scene defines the hosting scene
  25017. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25018. * @returns a new Mesh
  25019. */
  25020. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25021. /**
  25022. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25023. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25024. * @param name defines the name of the mesh to create
  25025. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25026. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25027. * @param closePath creates a seam between the first and the last points of each path of the path array
  25028. * @param offset is taken in account only if the `pathArray` is containing a single path
  25029. * @param scene defines the hosting scene
  25030. * @param updatable defines if the mesh must be flagged as updatable
  25031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25032. * @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)
  25033. * @returns a new Mesh
  25034. */
  25035. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25036. /**
  25037. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25038. * @param name defines the name of the mesh to create
  25039. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25040. * @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
  25041. * @param scene defines the hosting scene
  25042. * @param updatable defines if the mesh must be flagged as updatable
  25043. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25044. * @returns a new Mesh
  25045. */
  25046. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25047. /**
  25048. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25049. * @param name defines the name of the mesh to create
  25050. * @param size sets the size (float) of each box side (default 1)
  25051. * @param scene defines the hosting scene
  25052. * @param updatable defines if the mesh must be flagged as updatable
  25053. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25054. * @returns a new Mesh
  25055. */
  25056. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25057. /**
  25058. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25059. * @param name defines the name of the mesh to create
  25060. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25061. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25062. * @param scene defines the hosting scene
  25063. * @param updatable defines if the mesh must be flagged as updatable
  25064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25065. * @returns a new Mesh
  25066. */
  25067. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25068. /**
  25069. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25070. * @param name defines the name of the mesh to create
  25071. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25072. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25073. * @param scene defines the hosting scene
  25074. * @returns a new Mesh
  25075. */
  25076. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25077. /**
  25078. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25079. * @param name defines the name of the mesh to create
  25080. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25081. * @param diameterTop set the top cap diameter (floats, default 1)
  25082. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25083. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25084. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25085. * @param scene defines the hosting scene
  25086. * @param updatable defines if the mesh must be flagged as updatable
  25087. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25088. * @returns a new Mesh
  25089. */
  25090. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25091. /**
  25092. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25093. * @param name defines the name of the mesh to create
  25094. * @param diameter sets the diameter size (float) of the torus (default 1)
  25095. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25096. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25097. * @param scene defines the hosting scene
  25098. * @param updatable defines if the mesh must be flagged as updatable
  25099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25100. * @returns a new Mesh
  25101. */
  25102. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25103. /**
  25104. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25105. * @param name defines the name of the mesh to create
  25106. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25107. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25108. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25109. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25110. * @param p the number of windings on X axis (positive integers, default 2)
  25111. * @param q the number of windings on Y axis (positive integers, default 3)
  25112. * @param scene defines the hosting scene
  25113. * @param updatable defines if the mesh must be flagged as updatable
  25114. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25115. * @returns a new Mesh
  25116. */
  25117. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25118. /**
  25119. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25120. * @param name defines the name of the mesh to create
  25121. * @param points is an array successive Vector3
  25122. * @param scene defines the hosting scene
  25123. * @param updatable defines if the mesh must be flagged as updatable
  25124. * @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).
  25125. * @returns a new Mesh
  25126. */
  25127. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25128. /**
  25129. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25130. * @param name defines the name of the mesh to create
  25131. * @param points is an array successive Vector3
  25132. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25133. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25134. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25135. * @param scene defines the hosting scene
  25136. * @param updatable defines if the mesh must be flagged as updatable
  25137. * @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)
  25138. * @returns a new Mesh
  25139. */
  25140. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25141. /**
  25142. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25143. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25144. * 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.
  25145. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25146. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25147. * Remember you can only change the shape positions, not their number when updating a polygon.
  25148. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25149. * @param name defines the name of the mesh to create
  25150. * @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
  25151. * @param scene defines the hosting scene
  25152. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25153. * @param updatable defines if the mesh must be flagged as updatable
  25154. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25155. * @param earcutInjection can be used to inject your own earcut reference
  25156. * @returns a new Mesh
  25157. */
  25158. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25159. /**
  25160. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25161. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25162. * @param name defines the name of the mesh to create
  25163. * @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
  25164. * @param depth defines the height of extrusion
  25165. * @param scene defines the hosting scene
  25166. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25167. * @param updatable defines if the mesh must be flagged as updatable
  25168. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25169. * @param earcutInjection can be used to inject your own earcut reference
  25170. * @returns a new Mesh
  25171. */
  25172. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25173. /**
  25174. * Creates an extruded shape mesh.
  25175. * 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
  25176. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25177. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25178. * @param name defines the name of the mesh to create
  25179. * @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
  25180. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25181. * @param scale is the value to scale the shape
  25182. * @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
  25183. * @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
  25184. * @param scene defines the hosting scene
  25185. * @param updatable defines if the mesh must be flagged as updatable
  25186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25187. * @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)
  25188. * @returns a new Mesh
  25189. */
  25190. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25191. /**
  25192. * Creates an custom extruded shape mesh.
  25193. * The custom extrusion is a parametric shape.
  25194. * It has no predefined shape. Its final shape will depend on the input parameters.
  25195. * Please consider using the same method from the MeshBuilder class instead
  25196. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25197. * @param name defines the name of the mesh to create
  25198. * @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
  25199. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25200. * @param scaleFunction is a custom Javascript function called on each path point
  25201. * @param rotationFunction is a custom Javascript function called on each path point
  25202. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25203. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25204. * @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
  25205. * @param scene defines the hosting scene
  25206. * @param updatable defines if the mesh must be flagged as updatable
  25207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25208. * @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)
  25209. * @returns a new Mesh
  25210. */
  25211. 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;
  25212. /**
  25213. * Creates lathe mesh.
  25214. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25215. * Please consider using the same method from the MeshBuilder class instead
  25216. * @param name defines the name of the mesh to create
  25217. * @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
  25218. * @param radius is the radius value of the lathe
  25219. * @param tessellation is the side number of the lathe.
  25220. * @param scene defines the hosting scene
  25221. * @param updatable defines if the mesh must be flagged as updatable
  25222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25223. * @returns a new Mesh
  25224. */
  25225. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25226. /**
  25227. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25228. * @param name defines the name of the mesh to create
  25229. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25230. * @param scene defines the hosting scene
  25231. * @param updatable defines if the mesh must be flagged as updatable
  25232. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25233. * @returns a new Mesh
  25234. */
  25235. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25236. /**
  25237. * Creates a ground mesh.
  25238. * Please consider using the same method from the MeshBuilder class instead
  25239. * @param name defines the name of the mesh to create
  25240. * @param width set the width of the ground
  25241. * @param height set the height of the ground
  25242. * @param subdivisions sets the number of subdivisions per side
  25243. * @param scene defines the hosting scene
  25244. * @param updatable defines if the mesh must be flagged as updatable
  25245. * @returns a new Mesh
  25246. */
  25247. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25248. /**
  25249. * Creates a tiled ground mesh.
  25250. * Please consider using the same method from the MeshBuilder class instead
  25251. * @param name defines the name of the mesh to create
  25252. * @param xmin set the ground minimum X coordinate
  25253. * @param zmin set the ground minimum Y coordinate
  25254. * @param xmax set the ground maximum X coordinate
  25255. * @param zmax set the ground maximum Z coordinate
  25256. * @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
  25257. * @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
  25258. * @param scene defines the hosting scene
  25259. * @param updatable defines if the mesh must be flagged as updatable
  25260. * @returns a new Mesh
  25261. */
  25262. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25263. w: number;
  25264. h: number;
  25265. }, precision: {
  25266. w: number;
  25267. h: number;
  25268. }, scene: Scene, updatable?: boolean): Mesh;
  25269. /**
  25270. * Creates a ground mesh from a height map.
  25271. * Please consider using the same method from the MeshBuilder class instead
  25272. * @see http://doc.babylonjs.com/babylon101/height_map
  25273. * @param name defines the name of the mesh to create
  25274. * @param url sets the URL of the height map image resource
  25275. * @param width set the ground width size
  25276. * @param height set the ground height size
  25277. * @param subdivisions sets the number of subdivision per side
  25278. * @param minHeight is the minimum altitude on the ground
  25279. * @param maxHeight is the maximum altitude on the ground
  25280. * @param scene defines the hosting scene
  25281. * @param updatable defines if the mesh must be flagged as updatable
  25282. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25283. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25284. * @returns a new Mesh
  25285. */
  25286. 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;
  25287. /**
  25288. * Creates a tube mesh.
  25289. * The tube is a parametric shape.
  25290. * It has no predefined shape. Its final shape will depend on the input parameters.
  25291. * Please consider using the same method from the MeshBuilder class instead
  25292. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25293. * @param name defines the name of the mesh to create
  25294. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25295. * @param radius sets the tube radius size
  25296. * @param tessellation is the number of sides on the tubular surface
  25297. * @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
  25298. * @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
  25299. * @param scene defines the hosting scene
  25300. * @param updatable defines if the mesh must be flagged as updatable
  25301. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25302. * @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)
  25303. * @returns a new Mesh
  25304. */
  25305. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25306. (i: number, distance: number): number;
  25307. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25308. /**
  25309. * Creates a polyhedron mesh.
  25310. * Please consider using the same method from the MeshBuilder class instead.
  25311. * * 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
  25312. * * The parameter `size` (positive float, default 1) sets the polygon size
  25313. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25314. * * 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`
  25315. * * 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
  25316. * * 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)`)
  25317. * * 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
  25318. * * 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
  25319. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25320. * * If you create a double-sided mesh, you can choose what parts of 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
  25321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25322. * @param name defines the name of the mesh to create
  25323. * @param options defines the options used to create the mesh
  25324. * @param scene defines the hosting scene
  25325. * @returns a new Mesh
  25326. */
  25327. static CreatePolyhedron(name: string, options: {
  25328. type?: number;
  25329. size?: number;
  25330. sizeX?: number;
  25331. sizeY?: number;
  25332. sizeZ?: number;
  25333. custom?: any;
  25334. faceUV?: Vector4[];
  25335. faceColors?: Color4[];
  25336. updatable?: boolean;
  25337. sideOrientation?: number;
  25338. }, scene: Scene): Mesh;
  25339. /**
  25340. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25341. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25342. * * 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`)
  25343. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25344. * * 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
  25345. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25346. * * If you create a double-sided mesh, you can choose what parts of 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
  25347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25348. * @param name defines the name of the mesh
  25349. * @param options defines the options used to create the mesh
  25350. * @param scene defines the hosting scene
  25351. * @returns a new Mesh
  25352. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25353. */
  25354. static CreateIcoSphere(name: string, options: {
  25355. radius?: number;
  25356. flat?: boolean;
  25357. subdivisions?: number;
  25358. sideOrientation?: number;
  25359. updatable?: boolean;
  25360. }, scene: Scene): Mesh;
  25361. /**
  25362. * Creates a decal mesh.
  25363. * Please consider using the same method from the MeshBuilder class instead.
  25364. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25365. * @param name defines the name of the mesh
  25366. * @param sourceMesh defines the mesh receiving the decal
  25367. * @param position sets the position of the decal in world coordinates
  25368. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25369. * @param size sets the decal scaling
  25370. * @param angle sets the angle to rotate the decal
  25371. * @returns a new Mesh
  25372. */
  25373. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25374. /**
  25375. * Prepare internal position array for software CPU skinning
  25376. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25377. */
  25378. setPositionsForCPUSkinning(): Float32Array;
  25379. /**
  25380. * Prepare internal normal array for software CPU skinning
  25381. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25382. */
  25383. setNormalsForCPUSkinning(): Float32Array;
  25384. /**
  25385. * Updates the vertex buffer by applying transformation from the bones
  25386. * @param skeleton defines the skeleton to apply to current mesh
  25387. * @returns the current mesh
  25388. */
  25389. applySkeleton(skeleton: Skeleton): Mesh;
  25390. /**
  25391. * 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
  25392. * @param meshes defines the list of meshes to scan
  25393. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25394. */
  25395. static MinMax(meshes: AbstractMesh[]): {
  25396. min: Vector3;
  25397. max: Vector3;
  25398. };
  25399. /**
  25400. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25401. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25402. * @returns a vector3
  25403. */
  25404. static Center(meshesOrMinMaxVector: {
  25405. min: Vector3;
  25406. max: Vector3;
  25407. } | AbstractMesh[]): Vector3;
  25408. /**
  25409. * Merge the array of meshes into a single mesh for performance reasons.
  25410. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25411. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25412. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25413. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25414. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25415. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25416. * @returns a new mesh
  25417. */
  25418. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25419. /** @hidden */
  25420. addInstance(instance: InstancedMesh): void;
  25421. /** @hidden */
  25422. removeInstance(instance: InstancedMesh): void;
  25423. }
  25424. }
  25425. declare module "babylonjs/Cameras/camera" {
  25426. import { SmartArray } from "babylonjs/Misc/smartArray";
  25427. import { Observable } from "babylonjs/Misc/observable";
  25428. import { Nullable } from "babylonjs/types";
  25429. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25430. import { Scene } from "babylonjs/scene";
  25431. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25432. import { Node } from "babylonjs/node";
  25433. import { Mesh } from "babylonjs/Meshes/mesh";
  25434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25435. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25436. import { Viewport } from "babylonjs/Maths/math.viewport";
  25437. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25438. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25439. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25440. import { Ray } from "babylonjs/Culling/ray";
  25441. /**
  25442. * This is the base class of all the camera used in the application.
  25443. * @see http://doc.babylonjs.com/features/cameras
  25444. */
  25445. export class Camera extends Node {
  25446. /** @hidden */
  25447. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25448. /**
  25449. * This is the default projection mode used by the cameras.
  25450. * It helps recreating a feeling of perspective and better appreciate depth.
  25451. * This is the best way to simulate real life cameras.
  25452. */
  25453. static readonly PERSPECTIVE_CAMERA: number;
  25454. /**
  25455. * This helps creating camera with an orthographic mode.
  25456. * 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.
  25457. */
  25458. static readonly ORTHOGRAPHIC_CAMERA: number;
  25459. /**
  25460. * This is the default FOV mode for perspective cameras.
  25461. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25462. */
  25463. static readonly FOVMODE_VERTICAL_FIXED: number;
  25464. /**
  25465. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25466. */
  25467. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25468. /**
  25469. * This specifies ther is no need for a camera rig.
  25470. * Basically only one eye is rendered corresponding to the camera.
  25471. */
  25472. static readonly RIG_MODE_NONE: number;
  25473. /**
  25474. * Simulates a camera Rig with one blue eye and one red eye.
  25475. * This can be use with 3d blue and red glasses.
  25476. */
  25477. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25478. /**
  25479. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25480. */
  25481. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25482. /**
  25483. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25484. */
  25485. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25486. /**
  25487. * Defines that both eyes of the camera will be rendered over under each other.
  25488. */
  25489. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25490. /**
  25491. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25492. */
  25493. static readonly RIG_MODE_VR: number;
  25494. /**
  25495. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25496. */
  25497. static readonly RIG_MODE_WEBVR: number;
  25498. /**
  25499. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25500. */
  25501. static readonly RIG_MODE_CUSTOM: number;
  25502. /**
  25503. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25504. */
  25505. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25506. /**
  25507. * Define the input manager associated with the camera.
  25508. */
  25509. inputs: CameraInputsManager<Camera>;
  25510. /** @hidden */
  25511. _position: Vector3;
  25512. /**
  25513. * Define the current local position of the camera in the scene
  25514. */
  25515. position: Vector3;
  25516. /**
  25517. * The vector the camera should consider as up.
  25518. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25519. */
  25520. upVector: Vector3;
  25521. /**
  25522. * Define the current limit on the left side for an orthographic camera
  25523. * In scene unit
  25524. */
  25525. orthoLeft: Nullable<number>;
  25526. /**
  25527. * Define the current limit on the right side for an orthographic camera
  25528. * In scene unit
  25529. */
  25530. orthoRight: Nullable<number>;
  25531. /**
  25532. * Define the current limit on the bottom side for an orthographic camera
  25533. * In scene unit
  25534. */
  25535. orthoBottom: Nullable<number>;
  25536. /**
  25537. * Define the current limit on the top side for an orthographic camera
  25538. * In scene unit
  25539. */
  25540. orthoTop: Nullable<number>;
  25541. /**
  25542. * Field Of View is set in Radians. (default is 0.8)
  25543. */
  25544. fov: number;
  25545. /**
  25546. * Define the minimum distance the camera can see from.
  25547. * This is important to note that the depth buffer are not infinite and the closer it starts
  25548. * the more your scene might encounter depth fighting issue.
  25549. */
  25550. minZ: number;
  25551. /**
  25552. * Define the maximum distance the camera can see to.
  25553. * This is important to note that the depth buffer are not infinite and the further it end
  25554. * the more your scene might encounter depth fighting issue.
  25555. */
  25556. maxZ: number;
  25557. /**
  25558. * Define the default inertia of the camera.
  25559. * This helps giving a smooth feeling to the camera movement.
  25560. */
  25561. inertia: number;
  25562. /**
  25563. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25564. */
  25565. mode: number;
  25566. /**
  25567. * Define wether the camera is intermediate.
  25568. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25569. */
  25570. isIntermediate: boolean;
  25571. /**
  25572. * Define the viewport of the camera.
  25573. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25574. */
  25575. viewport: Viewport;
  25576. /**
  25577. * Restricts the camera to viewing objects with the same layerMask.
  25578. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25579. */
  25580. layerMask: number;
  25581. /**
  25582. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25583. */
  25584. fovMode: number;
  25585. /**
  25586. * Rig mode of the camera.
  25587. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25588. * This is normally controlled byt the camera themselves as internal use.
  25589. */
  25590. cameraRigMode: number;
  25591. /**
  25592. * Defines the distance between both "eyes" in case of a RIG
  25593. */
  25594. interaxialDistance: number;
  25595. /**
  25596. * Defines if stereoscopic rendering is done side by side or over under.
  25597. */
  25598. isStereoscopicSideBySide: boolean;
  25599. /**
  25600. * 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
  25601. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25602. * else in the scene. (Eg. security camera)
  25603. *
  25604. * 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)
  25605. */
  25606. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25607. /**
  25608. * When set, the camera will render to this render target instead of the default canvas
  25609. *
  25610. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25611. */
  25612. outputRenderTarget: Nullable<RenderTargetTexture>;
  25613. /**
  25614. * Observable triggered when the camera view matrix has changed.
  25615. */
  25616. onViewMatrixChangedObservable: Observable<Camera>;
  25617. /**
  25618. * Observable triggered when the camera Projection matrix has changed.
  25619. */
  25620. onProjectionMatrixChangedObservable: Observable<Camera>;
  25621. /**
  25622. * Observable triggered when the inputs have been processed.
  25623. */
  25624. onAfterCheckInputsObservable: Observable<Camera>;
  25625. /**
  25626. * Observable triggered when reset has been called and applied to the camera.
  25627. */
  25628. onRestoreStateObservable: Observable<Camera>;
  25629. /** @hidden */
  25630. _cameraRigParams: any;
  25631. /** @hidden */
  25632. _rigCameras: Camera[];
  25633. /** @hidden */
  25634. _rigPostProcess: Nullable<PostProcess>;
  25635. protected _webvrViewMatrix: Matrix;
  25636. /** @hidden */
  25637. _skipRendering: boolean;
  25638. /** @hidden */
  25639. _projectionMatrix: Matrix;
  25640. /** @hidden */
  25641. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25642. /** @hidden */
  25643. _activeMeshes: SmartArray<AbstractMesh>;
  25644. protected _globalPosition: Vector3;
  25645. /** @hidden */
  25646. _computedViewMatrix: Matrix;
  25647. private _doNotComputeProjectionMatrix;
  25648. private _transformMatrix;
  25649. private _frustumPlanes;
  25650. private _refreshFrustumPlanes;
  25651. private _storedFov;
  25652. private _stateStored;
  25653. /**
  25654. * Instantiates a new camera object.
  25655. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25656. * @see http://doc.babylonjs.com/features/cameras
  25657. * @param name Defines the name of the camera in the scene
  25658. * @param position Defines the position of the camera
  25659. * @param scene Defines the scene the camera belongs too
  25660. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25661. */
  25662. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25663. /**
  25664. * Store current camera state (fov, position, etc..)
  25665. * @returns the camera
  25666. */
  25667. storeState(): Camera;
  25668. /**
  25669. * Restores the camera state values if it has been stored. You must call storeState() first
  25670. */
  25671. protected _restoreStateValues(): boolean;
  25672. /**
  25673. * Restored camera state. You must call storeState() first.
  25674. * @returns true if restored and false otherwise
  25675. */
  25676. restoreState(): boolean;
  25677. /**
  25678. * Gets the class name of the camera.
  25679. * @returns the class name
  25680. */
  25681. getClassName(): string;
  25682. /** @hidden */
  25683. readonly _isCamera: boolean;
  25684. /**
  25685. * Gets a string representation of the camera useful for debug purpose.
  25686. * @param fullDetails Defines that a more verboe level of logging is required
  25687. * @returns the string representation
  25688. */
  25689. toString(fullDetails?: boolean): string;
  25690. /**
  25691. * Gets the current world space position of the camera.
  25692. */
  25693. readonly globalPosition: Vector3;
  25694. /**
  25695. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25696. * @returns the active meshe list
  25697. */
  25698. getActiveMeshes(): SmartArray<AbstractMesh>;
  25699. /**
  25700. * Check wether a mesh is part of the current active mesh list of the camera
  25701. * @param mesh Defines the mesh to check
  25702. * @returns true if active, false otherwise
  25703. */
  25704. isActiveMesh(mesh: Mesh): boolean;
  25705. /**
  25706. * Is this camera ready to be used/rendered
  25707. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25708. * @return true if the camera is ready
  25709. */
  25710. isReady(completeCheck?: boolean): boolean;
  25711. /** @hidden */
  25712. _initCache(): void;
  25713. /** @hidden */
  25714. _updateCache(ignoreParentClass?: boolean): void;
  25715. /** @hidden */
  25716. _isSynchronized(): boolean;
  25717. /** @hidden */
  25718. _isSynchronizedViewMatrix(): boolean;
  25719. /** @hidden */
  25720. _isSynchronizedProjectionMatrix(): boolean;
  25721. /**
  25722. * Attach the input controls to a specific dom element to get the input from.
  25723. * @param element Defines the element the controls should be listened from
  25724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25725. */
  25726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25727. /**
  25728. * Detach the current controls from the specified dom element.
  25729. * @param element Defines the element to stop listening the inputs from
  25730. */
  25731. detachControl(element: HTMLElement): void;
  25732. /**
  25733. * Update the camera state according to the different inputs gathered during the frame.
  25734. */
  25735. update(): void;
  25736. /** @hidden */
  25737. _checkInputs(): void;
  25738. /** @hidden */
  25739. readonly rigCameras: Camera[];
  25740. /**
  25741. * Gets the post process used by the rig cameras
  25742. */
  25743. readonly rigPostProcess: Nullable<PostProcess>;
  25744. /**
  25745. * Internal, gets the first post proces.
  25746. * @returns the first post process to be run on this camera.
  25747. */
  25748. _getFirstPostProcess(): Nullable<PostProcess>;
  25749. private _cascadePostProcessesToRigCams;
  25750. /**
  25751. * Attach a post process to the camera.
  25752. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25753. * @param postProcess The post process to attach to the camera
  25754. * @param insertAt The position of the post process in case several of them are in use in the scene
  25755. * @returns the position the post process has been inserted at
  25756. */
  25757. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25758. /**
  25759. * Detach a post process to the camera.
  25760. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25761. * @param postProcess The post process to detach from the camera
  25762. */
  25763. detachPostProcess(postProcess: PostProcess): void;
  25764. /**
  25765. * Gets the current world matrix of the camera
  25766. */
  25767. getWorldMatrix(): Matrix;
  25768. /** @hidden */
  25769. _getViewMatrix(): Matrix;
  25770. /**
  25771. * Gets the current view matrix of the camera.
  25772. * @param force forces the camera to recompute the matrix without looking at the cached state
  25773. * @returns the view matrix
  25774. */
  25775. getViewMatrix(force?: boolean): Matrix;
  25776. /**
  25777. * Freeze the projection matrix.
  25778. * It will prevent the cache check of the camera projection compute and can speed up perf
  25779. * if no parameter of the camera are meant to change
  25780. * @param projection Defines manually a projection if necessary
  25781. */
  25782. freezeProjectionMatrix(projection?: Matrix): void;
  25783. /**
  25784. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25785. */
  25786. unfreezeProjectionMatrix(): void;
  25787. /**
  25788. * Gets the current projection matrix of the camera.
  25789. * @param force forces the camera to recompute the matrix without looking at the cached state
  25790. * @returns the projection matrix
  25791. */
  25792. getProjectionMatrix(force?: boolean): Matrix;
  25793. /**
  25794. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25795. * @returns a Matrix
  25796. */
  25797. getTransformationMatrix(): Matrix;
  25798. private _updateFrustumPlanes;
  25799. /**
  25800. * Checks if a cullable object (mesh...) is in the camera frustum
  25801. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25802. * @param target The object to check
  25803. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25804. * @returns true if the object is in frustum otherwise false
  25805. */
  25806. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25807. /**
  25808. * Checks if a cullable object (mesh...) is in the camera frustum
  25809. * Unlike isInFrustum this cheks the full bounding box
  25810. * @param target The object to check
  25811. * @returns true if the object is in frustum otherwise false
  25812. */
  25813. isCompletelyInFrustum(target: ICullable): boolean;
  25814. /**
  25815. * Gets a ray in the forward direction from the camera.
  25816. * @param length Defines the length of the ray to create
  25817. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25818. * @param origin Defines the start point of the ray which defaults to the camera position
  25819. * @returns the forward ray
  25820. */
  25821. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25822. /**
  25823. * Releases resources associated with this node.
  25824. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25825. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25826. */
  25827. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25828. /** @hidden */
  25829. _isLeftCamera: boolean;
  25830. /**
  25831. * Gets the left camera of a rig setup in case of Rigged Camera
  25832. */
  25833. readonly isLeftCamera: boolean;
  25834. /** @hidden */
  25835. _isRightCamera: boolean;
  25836. /**
  25837. * Gets the right camera of a rig setup in case of Rigged Camera
  25838. */
  25839. readonly isRightCamera: boolean;
  25840. /**
  25841. * Gets the left camera of a rig setup in case of Rigged Camera
  25842. */
  25843. readonly leftCamera: Nullable<FreeCamera>;
  25844. /**
  25845. * Gets the right camera of a rig setup in case of Rigged Camera
  25846. */
  25847. readonly rightCamera: Nullable<FreeCamera>;
  25848. /**
  25849. * Gets the left camera target of a rig setup in case of Rigged Camera
  25850. * @returns the target position
  25851. */
  25852. getLeftTarget(): Nullable<Vector3>;
  25853. /**
  25854. * Gets the right camera target of a rig setup in case of Rigged Camera
  25855. * @returns the target position
  25856. */
  25857. getRightTarget(): Nullable<Vector3>;
  25858. /**
  25859. * @hidden
  25860. */
  25861. setCameraRigMode(mode: number, rigParams: any): void;
  25862. /** @hidden */
  25863. static _setStereoscopicRigMode(camera: Camera): void;
  25864. /** @hidden */
  25865. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25866. /** @hidden */
  25867. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25868. /** @hidden */
  25869. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25870. /** @hidden */
  25871. _getVRProjectionMatrix(): Matrix;
  25872. protected _updateCameraRotationMatrix(): void;
  25873. protected _updateWebVRCameraRotationMatrix(): void;
  25874. /**
  25875. * This function MUST be overwritten by the different WebVR cameras available.
  25876. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25877. * @hidden
  25878. */
  25879. _getWebVRProjectionMatrix(): Matrix;
  25880. /**
  25881. * This function MUST be overwritten by the different WebVR cameras available.
  25882. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25883. * @hidden
  25884. */
  25885. _getWebVRViewMatrix(): Matrix;
  25886. /** @hidden */
  25887. setCameraRigParameter(name: string, value: any): void;
  25888. /**
  25889. * needs to be overridden by children so sub has required properties to be copied
  25890. * @hidden
  25891. */
  25892. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25893. /**
  25894. * May need to be overridden by children
  25895. * @hidden
  25896. */
  25897. _updateRigCameras(): void;
  25898. /** @hidden */
  25899. _setupInputs(): void;
  25900. /**
  25901. * Serialiaze the camera setup to a json represention
  25902. * @returns the JSON representation
  25903. */
  25904. serialize(): any;
  25905. /**
  25906. * Clones the current camera.
  25907. * @param name The cloned camera name
  25908. * @returns the cloned camera
  25909. */
  25910. clone(name: string): Camera;
  25911. /**
  25912. * Gets the direction of the camera relative to a given local axis.
  25913. * @param localAxis Defines the reference axis to provide a relative direction.
  25914. * @return the direction
  25915. */
  25916. getDirection(localAxis: Vector3): Vector3;
  25917. /**
  25918. * Returns the current camera absolute rotation
  25919. */
  25920. readonly absoluteRotation: Quaternion;
  25921. /**
  25922. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25923. * @param localAxis Defines the reference axis to provide a relative direction.
  25924. * @param result Defines the vector to store the result in
  25925. */
  25926. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25927. /**
  25928. * Gets a camera constructor for a given camera type
  25929. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25930. * @param name The name of the camera the result will be able to instantiate
  25931. * @param scene The scene the result will construct the camera in
  25932. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25933. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25934. * @returns a factory method to construc the camera
  25935. */
  25936. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25937. /**
  25938. * Compute the world matrix of the camera.
  25939. * @returns the camera workd matrix
  25940. */
  25941. computeWorldMatrix(): Matrix;
  25942. /**
  25943. * Parse a JSON and creates the camera from the parsed information
  25944. * @param parsedCamera The JSON to parse
  25945. * @param scene The scene to instantiate the camera in
  25946. * @returns the newly constructed camera
  25947. */
  25948. static Parse(parsedCamera: any, scene: Scene): Camera;
  25949. }
  25950. }
  25951. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25952. import { Nullable } from "babylonjs/types";
  25953. import { Scene } from "babylonjs/scene";
  25954. import { Vector4 } from "babylonjs/Maths/math.vector";
  25955. import { Mesh } from "babylonjs/Meshes/mesh";
  25956. /**
  25957. * Class containing static functions to help procedurally build meshes
  25958. */
  25959. export class DiscBuilder {
  25960. /**
  25961. * Creates a plane polygonal mesh. By default, this is a disc
  25962. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25963. * * 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
  25964. * * 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
  25965. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25966. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25967. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25968. * @param name defines the name of the mesh
  25969. * @param options defines the options used to create the mesh
  25970. * @param scene defines the hosting scene
  25971. * @returns the plane polygonal mesh
  25972. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25973. */
  25974. static CreateDisc(name: string, options: {
  25975. radius?: number;
  25976. tessellation?: number;
  25977. arc?: number;
  25978. updatable?: boolean;
  25979. sideOrientation?: number;
  25980. frontUVs?: Vector4;
  25981. backUVs?: Vector4;
  25982. }, scene?: Nullable<Scene>): Mesh;
  25983. }
  25984. }
  25985. declare module "babylonjs/Particles/solidParticleSystem" {
  25986. import { Vector3 } from "babylonjs/Maths/math.vector";
  25987. import { Mesh } from "babylonjs/Meshes/mesh";
  25988. import { Scene, IDisposable } from "babylonjs/scene";
  25989. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25990. /**
  25991. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25992. *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.
  25993. * The SPS is also a particle system. It provides some methods to manage the particles.
  25994. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25995. *
  25996. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25997. */
  25998. export class SolidParticleSystem implements IDisposable {
  25999. /**
  26000. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26001. * Example : var p = SPS.particles[i];
  26002. */
  26003. particles: SolidParticle[];
  26004. /**
  26005. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26006. */
  26007. nbParticles: number;
  26008. /**
  26009. * If the particles must ever face the camera (default false). Useful for planar particles.
  26010. */
  26011. billboard: boolean;
  26012. /**
  26013. * Recompute normals when adding a shape
  26014. */
  26015. recomputeNormals: boolean;
  26016. /**
  26017. * This a counter ofr your own usage. It's not set by any SPS functions.
  26018. */
  26019. counter: number;
  26020. /**
  26021. * The SPS name. This name is also given to the underlying mesh.
  26022. */
  26023. name: string;
  26024. /**
  26025. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26026. */
  26027. mesh: Mesh;
  26028. /**
  26029. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26030. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26031. */
  26032. vars: any;
  26033. /**
  26034. * This array is populated when the SPS is set as 'pickable'.
  26035. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26036. * Each element of this array is an object `{idx: int, faceId: int}`.
  26037. * `idx` is the picked particle index in the `SPS.particles` array
  26038. * `faceId` is the picked face index counted within this particle.
  26039. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26040. */
  26041. pickedParticles: {
  26042. idx: number;
  26043. faceId: number;
  26044. }[];
  26045. /**
  26046. * This array is populated when `enableDepthSort` is set to true.
  26047. * Each element of this array is an instance of the class DepthSortedParticle.
  26048. */
  26049. depthSortedParticles: DepthSortedParticle[];
  26050. /**
  26051. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26052. * @hidden
  26053. */
  26054. _bSphereOnly: boolean;
  26055. /**
  26056. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26057. * @hidden
  26058. */
  26059. _bSphereRadiusFactor: number;
  26060. private _scene;
  26061. private _positions;
  26062. private _indices;
  26063. private _normals;
  26064. private _colors;
  26065. private _uvs;
  26066. private _indices32;
  26067. private _positions32;
  26068. private _normals32;
  26069. private _fixedNormal32;
  26070. private _colors32;
  26071. private _uvs32;
  26072. private _index;
  26073. private _updatable;
  26074. private _pickable;
  26075. private _isVisibilityBoxLocked;
  26076. private _alwaysVisible;
  26077. private _depthSort;
  26078. private _shapeCounter;
  26079. private _copy;
  26080. private _color;
  26081. private _computeParticleColor;
  26082. private _computeParticleTexture;
  26083. private _computeParticleRotation;
  26084. private _computeParticleVertex;
  26085. private _computeBoundingBox;
  26086. private _depthSortParticles;
  26087. private _camera;
  26088. private _mustUnrotateFixedNormals;
  26089. private _particlesIntersect;
  26090. private _needs32Bits;
  26091. /**
  26092. * Creates a SPS (Solid Particle System) object.
  26093. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26094. * @param scene (Scene) is the scene in which the SPS is added.
  26095. * @param options defines the options of the sps e.g.
  26096. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26097. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26098. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26099. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26100. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26101. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26102. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26103. */
  26104. constructor(name: string, scene: Scene, options?: {
  26105. updatable?: boolean;
  26106. isPickable?: boolean;
  26107. enableDepthSort?: boolean;
  26108. particleIntersection?: boolean;
  26109. boundingSphereOnly?: boolean;
  26110. bSphereRadiusFactor?: number;
  26111. });
  26112. /**
  26113. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26114. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26115. * @returns the created mesh
  26116. */
  26117. buildMesh(): Mesh;
  26118. /**
  26119. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26120. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26121. * Thus the particles generated from `digest()` have their property `position` set yet.
  26122. * @param mesh ( Mesh ) is the mesh to be digested
  26123. * @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
  26124. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26125. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26126. * @returns the current SPS
  26127. */
  26128. digest(mesh: Mesh, options?: {
  26129. facetNb?: number;
  26130. number?: number;
  26131. delta?: number;
  26132. }): SolidParticleSystem;
  26133. private _unrotateFixedNormals;
  26134. private _resetCopy;
  26135. private _meshBuilder;
  26136. private _posToShape;
  26137. private _uvsToShapeUV;
  26138. private _addParticle;
  26139. /**
  26140. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26141. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26142. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26143. * @param nb (positive integer) the number of particles to be created from this model
  26144. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26145. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26146. * @returns the number of shapes in the system
  26147. */
  26148. addShape(mesh: Mesh, nb: number, options?: {
  26149. positionFunction?: any;
  26150. vertexFunction?: any;
  26151. }): number;
  26152. private _rebuildParticle;
  26153. /**
  26154. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26155. * @returns the SPS.
  26156. */
  26157. rebuildMesh(): SolidParticleSystem;
  26158. /**
  26159. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26160. * This method calls `updateParticle()` for each particle of the SPS.
  26161. * For an animated SPS, it is usually called within the render loop.
  26162. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26163. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26164. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26165. * @returns the SPS.
  26166. */
  26167. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26168. /**
  26169. * Disposes the SPS.
  26170. */
  26171. dispose(): void;
  26172. /**
  26173. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26174. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26175. * @returns the SPS.
  26176. */
  26177. refreshVisibleSize(): SolidParticleSystem;
  26178. /**
  26179. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26180. * @param size the size (float) of the visibility box
  26181. * note : this doesn't lock the SPS mesh bounding box.
  26182. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26183. */
  26184. setVisibilityBox(size: number): void;
  26185. /**
  26186. * Gets whether the SPS as always visible or not
  26187. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26188. */
  26189. /**
  26190. * Sets the SPS as always visible or not
  26191. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26192. */
  26193. isAlwaysVisible: boolean;
  26194. /**
  26195. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26196. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26197. */
  26198. /**
  26199. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26200. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26201. */
  26202. isVisibilityBoxLocked: boolean;
  26203. /**
  26204. * Tells to `setParticles()` to compute the particle rotations or not.
  26205. * Default value : true. The SPS is faster when it's set to false.
  26206. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26207. */
  26208. /**
  26209. * Gets if `setParticles()` computes the particle rotations or not.
  26210. * Default value : true. The SPS is faster when it's set to false.
  26211. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26212. */
  26213. computeParticleRotation: boolean;
  26214. /**
  26215. * Tells to `setParticles()` to compute the particle colors or not.
  26216. * Default value : true. The SPS is faster when it's set to false.
  26217. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26218. */
  26219. /**
  26220. * Gets if `setParticles()` computes the particle colors or not.
  26221. * Default value : true. The SPS is faster when it's set to false.
  26222. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26223. */
  26224. computeParticleColor: boolean;
  26225. /**
  26226. * Gets if `setParticles()` computes the particle textures or not.
  26227. * Default value : true. The SPS is faster when it's set to false.
  26228. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26229. */
  26230. computeParticleTexture: boolean;
  26231. /**
  26232. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26233. * Default value : false. The SPS is faster when it's set to false.
  26234. * Note : the particle custom vertex positions aren't stored values.
  26235. */
  26236. /**
  26237. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26238. * Default value : false. The SPS is faster when it's set to false.
  26239. * Note : the particle custom vertex positions aren't stored values.
  26240. */
  26241. computeParticleVertex: boolean;
  26242. /**
  26243. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26244. */
  26245. /**
  26246. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26247. */
  26248. computeBoundingBox: boolean;
  26249. /**
  26250. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26251. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26252. * Default : `true`
  26253. */
  26254. /**
  26255. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26256. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26257. * Default : `true`
  26258. */
  26259. depthSortParticles: boolean;
  26260. /**
  26261. * This function does nothing. It may be overwritten to set all the particle first values.
  26262. * The SPS doesn't call this function, you may have to call it by your own.
  26263. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26264. */
  26265. initParticles(): void;
  26266. /**
  26267. * This function does nothing. It may be overwritten to recycle a particle.
  26268. * The SPS doesn't call this function, you may have to call it by your own.
  26269. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26270. * @param particle The particle to recycle
  26271. * @returns the recycled particle
  26272. */
  26273. recycleParticle(particle: SolidParticle): SolidParticle;
  26274. /**
  26275. * Updates a particle : this function should be overwritten by the user.
  26276. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26277. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26278. * @example : just set a particle position or velocity and recycle conditions
  26279. * @param particle The particle to update
  26280. * @returns the updated particle
  26281. */
  26282. updateParticle(particle: SolidParticle): SolidParticle;
  26283. /**
  26284. * Updates a vertex of a particle : it can be overwritten by the user.
  26285. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26286. * @param particle the current particle
  26287. * @param vertex the current index of the current particle
  26288. * @param pt the index of the current vertex in the particle shape
  26289. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26290. * @example : just set a vertex particle position
  26291. * @returns the updated vertex
  26292. */
  26293. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26294. /**
  26295. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26296. * This does nothing and may be overwritten by the user.
  26297. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26298. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26299. * @param update the boolean update value actually passed to setParticles()
  26300. */
  26301. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26302. /**
  26303. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26304. * This will be passed three parameters.
  26305. * This does nothing and may be overwritten by the user.
  26306. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26307. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26308. * @param update the boolean update value actually passed to setParticles()
  26309. */
  26310. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26311. }
  26312. }
  26313. declare module "babylonjs/Particles/solidParticle" {
  26314. import { Nullable } from "babylonjs/types";
  26315. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26316. import { Color4 } from "babylonjs/Maths/math.color";
  26317. import { Mesh } from "babylonjs/Meshes/mesh";
  26318. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26319. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26320. import { Plane } from "babylonjs/Maths/math.plane";
  26321. /**
  26322. * Represents one particle of a solid particle system.
  26323. */
  26324. export class SolidParticle {
  26325. /**
  26326. * particle global index
  26327. */
  26328. idx: number;
  26329. /**
  26330. * The color of the particle
  26331. */
  26332. color: Nullable<Color4>;
  26333. /**
  26334. * The world space position of the particle.
  26335. */
  26336. position: Vector3;
  26337. /**
  26338. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26339. */
  26340. rotation: Vector3;
  26341. /**
  26342. * The world space rotation quaternion of the particle.
  26343. */
  26344. rotationQuaternion: Nullable<Quaternion>;
  26345. /**
  26346. * The scaling of the particle.
  26347. */
  26348. scaling: Vector3;
  26349. /**
  26350. * The uvs of the particle.
  26351. */
  26352. uvs: Vector4;
  26353. /**
  26354. * The current speed of the particle.
  26355. */
  26356. velocity: Vector3;
  26357. /**
  26358. * The pivot point in the particle local space.
  26359. */
  26360. pivot: Vector3;
  26361. /**
  26362. * Must the particle be translated from its pivot point in its local space ?
  26363. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26364. * Default : false
  26365. */
  26366. translateFromPivot: boolean;
  26367. /**
  26368. * Is the particle active or not ?
  26369. */
  26370. alive: boolean;
  26371. /**
  26372. * Is the particle visible or not ?
  26373. */
  26374. isVisible: boolean;
  26375. /**
  26376. * Index of this particle in the global "positions" array (Internal use)
  26377. * @hidden
  26378. */
  26379. _pos: number;
  26380. /**
  26381. * @hidden Index of this particle in the global "indices" array (Internal use)
  26382. */
  26383. _ind: number;
  26384. /**
  26385. * @hidden ModelShape of this particle (Internal use)
  26386. */
  26387. _model: ModelShape;
  26388. /**
  26389. * ModelShape id of this particle
  26390. */
  26391. shapeId: number;
  26392. /**
  26393. * Index of the particle in its shape id
  26394. */
  26395. idxInShape: number;
  26396. /**
  26397. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26398. */
  26399. _modelBoundingInfo: BoundingInfo;
  26400. /**
  26401. * @hidden Particle BoundingInfo object (Internal use)
  26402. */
  26403. _boundingInfo: BoundingInfo;
  26404. /**
  26405. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26406. */
  26407. _sps: SolidParticleSystem;
  26408. /**
  26409. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26410. */
  26411. _stillInvisible: boolean;
  26412. /**
  26413. * @hidden Last computed particle rotation matrix
  26414. */
  26415. _rotationMatrix: number[];
  26416. /**
  26417. * Parent particle Id, if any.
  26418. * Default null.
  26419. */
  26420. parentId: Nullable<number>;
  26421. /**
  26422. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26423. * The possible values are :
  26424. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26425. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26426. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26427. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26428. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26429. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26430. * */
  26431. cullingStrategy: number;
  26432. /**
  26433. * @hidden Internal global position in the SPS.
  26434. */
  26435. _globalPosition: Vector3;
  26436. /**
  26437. * Creates a Solid Particle object.
  26438. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26439. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26440. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26441. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26442. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26443. * @param shapeId (integer) is the model shape identifier in the SPS.
  26444. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26445. * @param sps defines the sps it is associated to
  26446. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26447. */
  26448. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26449. /**
  26450. * Legacy support, changed scale to scaling
  26451. */
  26452. /**
  26453. * Legacy support, changed scale to scaling
  26454. */
  26455. scale: Vector3;
  26456. /**
  26457. * Legacy support, changed quaternion to rotationQuaternion
  26458. */
  26459. /**
  26460. * Legacy support, changed quaternion to rotationQuaternion
  26461. */
  26462. quaternion: Nullable<Quaternion>;
  26463. /**
  26464. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26465. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26466. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26467. * @returns true if it intersects
  26468. */
  26469. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26470. /**
  26471. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26472. * A particle is in the frustum if its bounding box intersects the frustum
  26473. * @param frustumPlanes defines the frustum to test
  26474. * @returns true if the particle is in the frustum planes
  26475. */
  26476. isInFrustum(frustumPlanes: Plane[]): boolean;
  26477. /**
  26478. * get the rotation matrix of the particle
  26479. * @hidden
  26480. */
  26481. getRotationMatrix(m: Matrix): void;
  26482. }
  26483. /**
  26484. * Represents the shape of the model used by one particle of a solid particle system.
  26485. * SPS internal tool, don't use it manually.
  26486. */
  26487. export class ModelShape {
  26488. /**
  26489. * The shape id
  26490. * @hidden
  26491. */
  26492. shapeID: number;
  26493. /**
  26494. * flat array of model positions (internal use)
  26495. * @hidden
  26496. */
  26497. _shape: Vector3[];
  26498. /**
  26499. * flat array of model UVs (internal use)
  26500. * @hidden
  26501. */
  26502. _shapeUV: number[];
  26503. /**
  26504. * length of the shape in the model indices array (internal use)
  26505. * @hidden
  26506. */
  26507. _indicesLength: number;
  26508. /**
  26509. * Custom position function (internal use)
  26510. * @hidden
  26511. */
  26512. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26513. /**
  26514. * Custom vertex function (internal use)
  26515. * @hidden
  26516. */
  26517. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26518. /**
  26519. * 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.
  26520. * SPS internal tool, don't use it manually.
  26521. * @hidden
  26522. */
  26523. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26524. }
  26525. /**
  26526. * Represents a Depth Sorted Particle in the solid particle system.
  26527. */
  26528. export class DepthSortedParticle {
  26529. /**
  26530. * Index of the particle in the "indices" array
  26531. */
  26532. ind: number;
  26533. /**
  26534. * Length of the particle shape in the "indices" array
  26535. */
  26536. indicesLength: number;
  26537. /**
  26538. * Squared distance from the particle to the camera
  26539. */
  26540. sqDistance: number;
  26541. }
  26542. }
  26543. declare module "babylonjs/Collisions/meshCollisionData" {
  26544. import { Collider } from "babylonjs/Collisions/collider";
  26545. import { Vector3 } from "babylonjs/Maths/math.vector";
  26546. import { Nullable } from "babylonjs/types";
  26547. import { Observer } from "babylonjs/Misc/observable";
  26548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26549. /**
  26550. * @hidden
  26551. */
  26552. export class _MeshCollisionData {
  26553. _checkCollisions: boolean;
  26554. _collisionMask: number;
  26555. _collisionGroup: number;
  26556. _collider: Nullable<Collider>;
  26557. _oldPositionForCollisions: Vector3;
  26558. _diffPositionForCollisions: Vector3;
  26559. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26560. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26561. }
  26562. }
  26563. declare module "babylonjs/Meshes/abstractMesh" {
  26564. import { Observable } from "babylonjs/Misc/observable";
  26565. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26566. import { Camera } from "babylonjs/Cameras/camera";
  26567. import { Scene, IDisposable } from "babylonjs/scene";
  26568. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26569. import { Node } from "babylonjs/node";
  26570. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26571. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26572. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26573. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26574. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26575. import { Material } from "babylonjs/Materials/material";
  26576. import { Light } from "babylonjs/Lights/light";
  26577. import { Skeleton } from "babylonjs/Bones/skeleton";
  26578. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26579. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26580. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26581. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26582. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26583. import { Plane } from "babylonjs/Maths/math.plane";
  26584. import { Ray } from "babylonjs/Culling/ray";
  26585. import { Collider } from "babylonjs/Collisions/collider";
  26586. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26587. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26588. /** @hidden */
  26589. class _FacetDataStorage {
  26590. facetPositions: Vector3[];
  26591. facetNormals: Vector3[];
  26592. facetPartitioning: number[][];
  26593. facetNb: number;
  26594. partitioningSubdivisions: number;
  26595. partitioningBBoxRatio: number;
  26596. facetDataEnabled: boolean;
  26597. facetParameters: any;
  26598. bbSize: Vector3;
  26599. subDiv: {
  26600. max: number;
  26601. X: number;
  26602. Y: number;
  26603. Z: number;
  26604. };
  26605. facetDepthSort: boolean;
  26606. facetDepthSortEnabled: boolean;
  26607. depthSortedIndices: IndicesArray;
  26608. depthSortedFacets: {
  26609. ind: number;
  26610. sqDistance: number;
  26611. }[];
  26612. facetDepthSortFunction: (f1: {
  26613. ind: number;
  26614. sqDistance: number;
  26615. }, f2: {
  26616. ind: number;
  26617. sqDistance: number;
  26618. }) => number;
  26619. facetDepthSortFrom: Vector3;
  26620. facetDepthSortOrigin: Vector3;
  26621. invertedMatrix: Matrix;
  26622. }
  26623. /**
  26624. * @hidden
  26625. **/
  26626. class _InternalAbstractMeshDataInfo {
  26627. _hasVertexAlpha: boolean;
  26628. _useVertexColors: boolean;
  26629. _numBoneInfluencers: number;
  26630. _applyFog: boolean;
  26631. _receiveShadows: boolean;
  26632. _facetData: _FacetDataStorage;
  26633. _visibility: number;
  26634. _skeleton: Nullable<Skeleton>;
  26635. _layerMask: number;
  26636. _computeBonesUsingShaders: boolean;
  26637. _isActive: boolean;
  26638. _onlyForInstances: boolean;
  26639. _isActiveIntermediate: boolean;
  26640. _onlyForInstancesIntermediate: boolean;
  26641. }
  26642. /**
  26643. * Class used to store all common mesh properties
  26644. */
  26645. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26646. /** No occlusion */
  26647. static OCCLUSION_TYPE_NONE: number;
  26648. /** Occlusion set to optimisitic */
  26649. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26650. /** Occlusion set to strict */
  26651. static OCCLUSION_TYPE_STRICT: number;
  26652. /** Use an accurante occlusion algorithm */
  26653. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26654. /** Use a conservative occlusion algorithm */
  26655. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26656. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26657. * Test order :
  26658. * Is the bounding sphere outside the frustum ?
  26659. * If not, are the bounding box vertices outside the frustum ?
  26660. * It not, then the cullable object is in the frustum.
  26661. */
  26662. static readonly CULLINGSTRATEGY_STANDARD: number;
  26663. /** Culling strategy : Bounding Sphere Only.
  26664. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26665. * It's also less accurate than the standard because some not visible objects can still be selected.
  26666. * Test : is the bounding sphere outside the frustum ?
  26667. * If not, then the cullable object is in the frustum.
  26668. */
  26669. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26670. /** Culling strategy : Optimistic Inclusion.
  26671. * This in an inclusion test first, then the standard exclusion test.
  26672. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26673. * 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.
  26674. * Anyway, it's as accurate as the standard strategy.
  26675. * Test :
  26676. * Is the cullable object bounding sphere center in the frustum ?
  26677. * If not, apply the default culling strategy.
  26678. */
  26679. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26680. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26681. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26682. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26683. * 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.
  26684. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26685. * Test :
  26686. * Is the cullable object bounding sphere center in the frustum ?
  26687. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26688. */
  26689. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26690. /**
  26691. * No billboard
  26692. */
  26693. static readonly BILLBOARDMODE_NONE: number;
  26694. /** Billboard on X axis */
  26695. static readonly BILLBOARDMODE_X: number;
  26696. /** Billboard on Y axis */
  26697. static readonly BILLBOARDMODE_Y: number;
  26698. /** Billboard on Z axis */
  26699. static readonly BILLBOARDMODE_Z: number;
  26700. /** Billboard on all axes */
  26701. static readonly BILLBOARDMODE_ALL: number;
  26702. /** Billboard on using position instead of orientation */
  26703. static readonly BILLBOARDMODE_USE_POSITION: number;
  26704. /** @hidden */
  26705. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26706. /**
  26707. * The culling strategy to use to check whether the mesh must be rendered or not.
  26708. * This value can be changed at any time and will be used on the next render mesh selection.
  26709. * The possible values are :
  26710. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26711. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26712. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26713. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26714. * Please read each static variable documentation to get details about the culling process.
  26715. * */
  26716. cullingStrategy: number;
  26717. /**
  26718. * Gets the number of facets in the mesh
  26719. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26720. */
  26721. readonly facetNb: number;
  26722. /**
  26723. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26725. */
  26726. partitioningSubdivisions: number;
  26727. /**
  26728. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26729. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26730. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26731. */
  26732. partitioningBBoxRatio: number;
  26733. /**
  26734. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26735. * Works only for updatable meshes.
  26736. * Doesn't work with multi-materials
  26737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26738. */
  26739. mustDepthSortFacets: boolean;
  26740. /**
  26741. * The location (Vector3) where the facet depth sort must be computed from.
  26742. * By default, the active camera position.
  26743. * Used only when facet depth sort is enabled
  26744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26745. */
  26746. facetDepthSortFrom: Vector3;
  26747. /**
  26748. * gets a boolean indicating if facetData is enabled
  26749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26750. */
  26751. readonly isFacetDataEnabled: boolean;
  26752. /** @hidden */
  26753. _updateNonUniformScalingState(value: boolean): boolean;
  26754. /**
  26755. * An event triggered when this mesh collides with another one
  26756. */
  26757. onCollideObservable: Observable<AbstractMesh>;
  26758. /** Set a function to call when this mesh collides with another one */
  26759. onCollide: () => void;
  26760. /**
  26761. * An event triggered when the collision's position changes
  26762. */
  26763. onCollisionPositionChangeObservable: Observable<Vector3>;
  26764. /** Set a function to call when the collision's position changes */
  26765. onCollisionPositionChange: () => void;
  26766. /**
  26767. * An event triggered when material is changed
  26768. */
  26769. onMaterialChangedObservable: Observable<AbstractMesh>;
  26770. /**
  26771. * Gets or sets the orientation for POV movement & rotation
  26772. */
  26773. definedFacingForward: boolean;
  26774. /** @hidden */
  26775. _occlusionQuery: Nullable<WebGLQuery>;
  26776. /** @hidden */
  26777. _renderingGroup: Nullable<RenderingGroup>;
  26778. /**
  26779. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26780. */
  26781. /**
  26782. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26783. */
  26784. visibility: number;
  26785. /** Gets or sets the alpha index used to sort transparent meshes
  26786. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26787. */
  26788. alphaIndex: number;
  26789. /**
  26790. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26791. */
  26792. isVisible: boolean;
  26793. /**
  26794. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26795. */
  26796. isPickable: boolean;
  26797. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26798. showSubMeshesBoundingBox: boolean;
  26799. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26800. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26801. */
  26802. isBlocker: boolean;
  26803. /**
  26804. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26805. */
  26806. enablePointerMoveEvents: boolean;
  26807. /**
  26808. * Specifies the rendering group id for this mesh (0 by default)
  26809. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26810. */
  26811. renderingGroupId: number;
  26812. private _material;
  26813. /** Gets or sets current material */
  26814. material: Nullable<Material>;
  26815. /**
  26816. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26817. * @see http://doc.babylonjs.com/babylon101/shadows
  26818. */
  26819. receiveShadows: boolean;
  26820. /** Defines color to use when rendering outline */
  26821. outlineColor: Color3;
  26822. /** Define width to use when rendering outline */
  26823. outlineWidth: number;
  26824. /** Defines color to use when rendering overlay */
  26825. overlayColor: Color3;
  26826. /** Defines alpha to use when rendering overlay */
  26827. overlayAlpha: number;
  26828. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26829. hasVertexAlpha: boolean;
  26830. /** 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) */
  26831. useVertexColors: boolean;
  26832. /**
  26833. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26834. */
  26835. computeBonesUsingShaders: boolean;
  26836. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26837. numBoneInfluencers: number;
  26838. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26839. applyFog: boolean;
  26840. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26841. useOctreeForRenderingSelection: boolean;
  26842. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26843. useOctreeForPicking: boolean;
  26844. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26845. useOctreeForCollisions: boolean;
  26846. /**
  26847. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26848. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26849. */
  26850. layerMask: number;
  26851. /**
  26852. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26853. */
  26854. alwaysSelectAsActiveMesh: boolean;
  26855. /**
  26856. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26857. */
  26858. doNotSyncBoundingInfo: boolean;
  26859. /**
  26860. * Gets or sets the current action manager
  26861. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26862. */
  26863. actionManager: Nullable<AbstractActionManager>;
  26864. private _meshCollisionData;
  26865. /**
  26866. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26867. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26868. */
  26869. ellipsoid: Vector3;
  26870. /**
  26871. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26872. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26873. */
  26874. ellipsoidOffset: Vector3;
  26875. /**
  26876. * Gets or sets a collision mask used to mask collisions (default is -1).
  26877. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26878. */
  26879. collisionMask: number;
  26880. /**
  26881. * Gets or sets the current collision group mask (-1 by default).
  26882. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26883. */
  26884. collisionGroup: number;
  26885. /**
  26886. * Defines edge width used when edgesRenderer is enabled
  26887. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26888. */
  26889. edgesWidth: number;
  26890. /**
  26891. * Defines edge color used when edgesRenderer is enabled
  26892. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26893. */
  26894. edgesColor: Color4;
  26895. /** @hidden */
  26896. _edgesRenderer: Nullable<IEdgesRenderer>;
  26897. /** @hidden */
  26898. _masterMesh: Nullable<AbstractMesh>;
  26899. /** @hidden */
  26900. _boundingInfo: Nullable<BoundingInfo>;
  26901. /** @hidden */
  26902. _renderId: number;
  26903. /**
  26904. * Gets or sets the list of subMeshes
  26905. * @see http://doc.babylonjs.com/how_to/multi_materials
  26906. */
  26907. subMeshes: SubMesh[];
  26908. /** @hidden */
  26909. _intersectionsInProgress: AbstractMesh[];
  26910. /** @hidden */
  26911. _unIndexed: boolean;
  26912. /** @hidden */
  26913. _lightSources: Light[];
  26914. /** Gets the list of lights affecting that mesh */
  26915. readonly lightSources: Light[];
  26916. /** @hidden */
  26917. readonly _positions: Nullable<Vector3[]>;
  26918. /** @hidden */
  26919. _waitingData: {
  26920. lods: Nullable<any>;
  26921. actions: Nullable<any>;
  26922. freezeWorldMatrix: Nullable<boolean>;
  26923. };
  26924. /** @hidden */
  26925. _bonesTransformMatrices: Nullable<Float32Array>;
  26926. /** @hidden */
  26927. _transformMatrixTexture: Nullable<RawTexture>;
  26928. /**
  26929. * Gets or sets a skeleton to apply skining transformations
  26930. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26931. */
  26932. skeleton: Nullable<Skeleton>;
  26933. /**
  26934. * An event triggered when the mesh is rebuilt.
  26935. */
  26936. onRebuildObservable: Observable<AbstractMesh>;
  26937. /**
  26938. * Creates a new AbstractMesh
  26939. * @param name defines the name of the mesh
  26940. * @param scene defines the hosting scene
  26941. */
  26942. constructor(name: string, scene?: Nullable<Scene>);
  26943. /**
  26944. * Returns the string "AbstractMesh"
  26945. * @returns "AbstractMesh"
  26946. */
  26947. getClassName(): string;
  26948. /**
  26949. * Gets a string representation of the current mesh
  26950. * @param fullDetails defines a boolean indicating if full details must be included
  26951. * @returns a string representation of the current mesh
  26952. */
  26953. toString(fullDetails?: boolean): string;
  26954. /**
  26955. * @hidden
  26956. */
  26957. protected _getEffectiveParent(): Nullable<Node>;
  26958. /** @hidden */
  26959. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26960. /** @hidden */
  26961. _rebuild(): void;
  26962. /** @hidden */
  26963. _resyncLightSources(): void;
  26964. /** @hidden */
  26965. _resyncLighSource(light: Light): void;
  26966. /** @hidden */
  26967. _unBindEffect(): void;
  26968. /** @hidden */
  26969. _removeLightSource(light: Light, dispose: boolean): void;
  26970. private _markSubMeshesAsDirty;
  26971. /** @hidden */
  26972. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26973. /** @hidden */
  26974. _markSubMeshesAsAttributesDirty(): void;
  26975. /** @hidden */
  26976. _markSubMeshesAsMiscDirty(): void;
  26977. /**
  26978. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26979. */
  26980. scaling: Vector3;
  26981. /**
  26982. * Returns true if the mesh is blocked. Implemented by child classes
  26983. */
  26984. readonly isBlocked: boolean;
  26985. /**
  26986. * Returns the mesh itself by default. Implemented by child classes
  26987. * @param camera defines the camera to use to pick the right LOD level
  26988. * @returns the currentAbstractMesh
  26989. */
  26990. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26991. /**
  26992. * Returns 0 by default. Implemented by child classes
  26993. * @returns an integer
  26994. */
  26995. getTotalVertices(): number;
  26996. /**
  26997. * Returns a positive integer : the total number of indices in this mesh geometry.
  26998. * @returns the numner of indices or zero if the mesh has no geometry.
  26999. */
  27000. getTotalIndices(): number;
  27001. /**
  27002. * Returns null by default. Implemented by child classes
  27003. * @returns null
  27004. */
  27005. getIndices(): Nullable<IndicesArray>;
  27006. /**
  27007. * Returns the array of the requested vertex data kind. Implemented by child classes
  27008. * @param kind defines the vertex data kind to use
  27009. * @returns null
  27010. */
  27011. getVerticesData(kind: string): Nullable<FloatArray>;
  27012. /**
  27013. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27014. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27015. * Note that a new underlying VertexBuffer object is created each call.
  27016. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27017. * @param kind defines vertex data kind:
  27018. * * VertexBuffer.PositionKind
  27019. * * VertexBuffer.UVKind
  27020. * * VertexBuffer.UV2Kind
  27021. * * VertexBuffer.UV3Kind
  27022. * * VertexBuffer.UV4Kind
  27023. * * VertexBuffer.UV5Kind
  27024. * * VertexBuffer.UV6Kind
  27025. * * VertexBuffer.ColorKind
  27026. * * VertexBuffer.MatricesIndicesKind
  27027. * * VertexBuffer.MatricesIndicesExtraKind
  27028. * * VertexBuffer.MatricesWeightsKind
  27029. * * VertexBuffer.MatricesWeightsExtraKind
  27030. * @param data defines the data source
  27031. * @param updatable defines if the data must be flagged as updatable (or static)
  27032. * @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
  27033. * @returns the current mesh
  27034. */
  27035. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27036. /**
  27037. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27038. * If the mesh has no geometry, it is simply returned as it is.
  27039. * @param kind defines vertex data kind:
  27040. * * VertexBuffer.PositionKind
  27041. * * VertexBuffer.UVKind
  27042. * * VertexBuffer.UV2Kind
  27043. * * VertexBuffer.UV3Kind
  27044. * * VertexBuffer.UV4Kind
  27045. * * VertexBuffer.UV5Kind
  27046. * * VertexBuffer.UV6Kind
  27047. * * VertexBuffer.ColorKind
  27048. * * VertexBuffer.MatricesIndicesKind
  27049. * * VertexBuffer.MatricesIndicesExtraKind
  27050. * * VertexBuffer.MatricesWeightsKind
  27051. * * VertexBuffer.MatricesWeightsExtraKind
  27052. * @param data defines the data source
  27053. * @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
  27054. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27055. * @returns the current mesh
  27056. */
  27057. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27058. /**
  27059. * Sets the mesh indices,
  27060. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27061. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27062. * @param totalVertices Defines the total number of vertices
  27063. * @returns the current mesh
  27064. */
  27065. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27066. /**
  27067. * Gets a boolean indicating if specific vertex data is present
  27068. * @param kind defines the vertex data kind to use
  27069. * @returns true is data kind is present
  27070. */
  27071. isVerticesDataPresent(kind: string): boolean;
  27072. /**
  27073. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27074. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27075. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27076. * @returns a BoundingInfo
  27077. */
  27078. getBoundingInfo(): BoundingInfo;
  27079. /**
  27080. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27081. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27082. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27083. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27084. * @returns the current mesh
  27085. */
  27086. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27087. /**
  27088. * Overwrite the current bounding info
  27089. * @param boundingInfo defines the new bounding info
  27090. * @returns the current mesh
  27091. */
  27092. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27093. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27094. readonly useBones: boolean;
  27095. /** @hidden */
  27096. _preActivate(): void;
  27097. /** @hidden */
  27098. _preActivateForIntermediateRendering(renderId: number): void;
  27099. /** @hidden */
  27100. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27101. /** @hidden */
  27102. _postActivate(): void;
  27103. /** @hidden */
  27104. _freeze(): void;
  27105. /** @hidden */
  27106. _unFreeze(): void;
  27107. /**
  27108. * Gets the current world matrix
  27109. * @returns a Matrix
  27110. */
  27111. getWorldMatrix(): Matrix;
  27112. /** @hidden */
  27113. _getWorldMatrixDeterminant(): number;
  27114. /**
  27115. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27116. */
  27117. readonly isAnInstance: boolean;
  27118. /**
  27119. * Gets a boolean indicating if this mesh has instances
  27120. */
  27121. readonly hasInstances: boolean;
  27122. /**
  27123. * Perform relative position change from the point of view of behind the front of the mesh.
  27124. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27125. * Supports definition of mesh facing forward or backward
  27126. * @param amountRight defines the distance on the right axis
  27127. * @param amountUp defines the distance on the up axis
  27128. * @param amountForward defines the distance on the forward axis
  27129. * @returns the current mesh
  27130. */
  27131. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27132. /**
  27133. * Calculate relative position change from the point of view of behind the front of the mesh.
  27134. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27135. * Supports definition of mesh facing forward or backward
  27136. * @param amountRight defines the distance on the right axis
  27137. * @param amountUp defines the distance on the up axis
  27138. * @param amountForward defines the distance on the forward axis
  27139. * @returns the new displacement vector
  27140. */
  27141. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27142. /**
  27143. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27144. * Supports definition of mesh facing forward or backward
  27145. * @param flipBack defines the flip
  27146. * @param twirlClockwise defines the twirl
  27147. * @param tiltRight defines the tilt
  27148. * @returns the current mesh
  27149. */
  27150. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27151. /**
  27152. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27153. * Supports definition of mesh facing forward or backward.
  27154. * @param flipBack defines the flip
  27155. * @param twirlClockwise defines the twirl
  27156. * @param tiltRight defines the tilt
  27157. * @returns the new rotation vector
  27158. */
  27159. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27160. /**
  27161. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27162. * This means the mesh underlying bounding box and sphere are recomputed.
  27163. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27164. * @returns the current mesh
  27165. */
  27166. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27167. /** @hidden */
  27168. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27169. /** @hidden */
  27170. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27171. /** @hidden */
  27172. _updateBoundingInfo(): AbstractMesh;
  27173. /** @hidden */
  27174. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27175. /** @hidden */
  27176. protected _afterComputeWorldMatrix(): void;
  27177. /** @hidden */
  27178. readonly _effectiveMesh: AbstractMesh;
  27179. /**
  27180. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27181. * A mesh is in the frustum if its bounding box intersects the frustum
  27182. * @param frustumPlanes defines the frustum to test
  27183. * @returns true if the mesh is in the frustum planes
  27184. */
  27185. isInFrustum(frustumPlanes: Plane[]): boolean;
  27186. /**
  27187. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27188. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27189. * @param frustumPlanes defines the frustum to test
  27190. * @returns true if the mesh is completely in the frustum planes
  27191. */
  27192. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27193. /**
  27194. * True if the mesh intersects another mesh or a SolidParticle object
  27195. * @param mesh defines a target mesh or SolidParticle to test
  27196. * @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)
  27197. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27198. * @returns true if there is an intersection
  27199. */
  27200. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27201. /**
  27202. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27203. * @param point defines the point to test
  27204. * @returns true if there is an intersection
  27205. */
  27206. intersectsPoint(point: Vector3): boolean;
  27207. /**
  27208. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27209. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27210. */
  27211. checkCollisions: boolean;
  27212. /**
  27213. * Gets Collider object used to compute collisions (not physics)
  27214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27215. */
  27216. readonly collider: Nullable<Collider>;
  27217. /**
  27218. * Move the mesh using collision engine
  27219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27220. * @param displacement defines the requested displacement vector
  27221. * @returns the current mesh
  27222. */
  27223. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27224. private _onCollisionPositionChange;
  27225. /** @hidden */
  27226. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27227. /** @hidden */
  27228. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27229. /** @hidden */
  27230. _checkCollision(collider: Collider): AbstractMesh;
  27231. /** @hidden */
  27232. _generatePointsArray(): boolean;
  27233. /**
  27234. * Checks if the passed Ray intersects with the mesh
  27235. * @param ray defines the ray to use
  27236. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27237. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27238. * @returns the picking info
  27239. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27240. */
  27241. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27242. /**
  27243. * Clones the current mesh
  27244. * @param name defines the mesh name
  27245. * @param newParent defines the new mesh parent
  27246. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27247. * @returns the new mesh
  27248. */
  27249. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27250. /**
  27251. * Disposes all the submeshes of the current meshnp
  27252. * @returns the current mesh
  27253. */
  27254. releaseSubMeshes(): AbstractMesh;
  27255. /**
  27256. * Releases resources associated with this abstract mesh.
  27257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27259. */
  27260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27261. /**
  27262. * Adds the passed mesh as a child to the current mesh
  27263. * @param mesh defines the child mesh
  27264. * @returns the current mesh
  27265. */
  27266. addChild(mesh: AbstractMesh): AbstractMesh;
  27267. /**
  27268. * Removes the passed mesh from the current mesh children list
  27269. * @param mesh defines the child mesh
  27270. * @returns the current mesh
  27271. */
  27272. removeChild(mesh: AbstractMesh): AbstractMesh;
  27273. /** @hidden */
  27274. private _initFacetData;
  27275. /**
  27276. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27277. * This method can be called within the render loop.
  27278. * 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
  27279. * @returns the current mesh
  27280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27281. */
  27282. updateFacetData(): AbstractMesh;
  27283. /**
  27284. * Returns the facetLocalNormals array.
  27285. * The normals are expressed in the mesh local spac
  27286. * @returns an array of Vector3
  27287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27288. */
  27289. getFacetLocalNormals(): Vector3[];
  27290. /**
  27291. * Returns the facetLocalPositions array.
  27292. * The facet positions are expressed in the mesh local space
  27293. * @returns an array of Vector3
  27294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27295. */
  27296. getFacetLocalPositions(): Vector3[];
  27297. /**
  27298. * Returns the facetLocalPartioning array
  27299. * @returns an array of array of numbers
  27300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27301. */
  27302. getFacetLocalPartitioning(): number[][];
  27303. /**
  27304. * Returns the i-th facet position in the world system.
  27305. * This method allocates a new Vector3 per call
  27306. * @param i defines the facet index
  27307. * @returns a new Vector3
  27308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27309. */
  27310. getFacetPosition(i: number): Vector3;
  27311. /**
  27312. * Sets the reference Vector3 with the i-th facet position in the world system
  27313. * @param i defines the facet index
  27314. * @param ref defines the target vector
  27315. * @returns the current mesh
  27316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27317. */
  27318. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27319. /**
  27320. * Returns the i-th facet normal in the world system.
  27321. * This method allocates a new Vector3 per call
  27322. * @param i defines the facet index
  27323. * @returns a new Vector3
  27324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27325. */
  27326. getFacetNormal(i: number): Vector3;
  27327. /**
  27328. * Sets the reference Vector3 with the i-th facet normal in the world system
  27329. * @param i defines the facet index
  27330. * @param ref defines the target vector
  27331. * @returns the current mesh
  27332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27333. */
  27334. getFacetNormalToRef(i: number, ref: Vector3): this;
  27335. /**
  27336. * 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)
  27337. * @param x defines x coordinate
  27338. * @param y defines y coordinate
  27339. * @param z defines z coordinate
  27340. * @returns the array of facet indexes
  27341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27342. */
  27343. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27344. /**
  27345. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27346. * @param projected sets as the (x,y,z) world projection on the facet
  27347. * @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
  27348. * @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
  27349. * @param x defines x coordinate
  27350. * @param y defines y coordinate
  27351. * @param z defines z coordinate
  27352. * @returns the face index if found (or null instead)
  27353. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27354. */
  27355. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27356. /**
  27357. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27358. * @param projected sets as the (x,y,z) local projection on the facet
  27359. * @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
  27360. * @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
  27361. * @param x defines x coordinate
  27362. * @param y defines y coordinate
  27363. * @param z defines z coordinate
  27364. * @returns the face index if found (or null instead)
  27365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27366. */
  27367. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27368. /**
  27369. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27370. * @returns the parameters
  27371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27372. */
  27373. getFacetDataParameters(): any;
  27374. /**
  27375. * Disables the feature FacetData and frees the related memory
  27376. * @returns the current mesh
  27377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27378. */
  27379. disableFacetData(): AbstractMesh;
  27380. /**
  27381. * Updates the AbstractMesh indices array
  27382. * @param indices defines the data source
  27383. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27384. * @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)
  27385. * @returns the current mesh
  27386. */
  27387. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27388. /**
  27389. * Creates new normals data for the mesh
  27390. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27391. * @returns the current mesh
  27392. */
  27393. createNormals(updatable: boolean): AbstractMesh;
  27394. /**
  27395. * Align the mesh with a normal
  27396. * @param normal defines the normal to use
  27397. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27398. * @returns the current mesh
  27399. */
  27400. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27401. /** @hidden */
  27402. _checkOcclusionQuery(): boolean;
  27403. /**
  27404. * Disables the mesh edge rendering mode
  27405. * @returns the currentAbstractMesh
  27406. */
  27407. disableEdgesRendering(): AbstractMesh;
  27408. /**
  27409. * Enables the edge rendering mode on the mesh.
  27410. * This mode makes the mesh edges visible
  27411. * @param epsilon defines the maximal distance between two angles to detect a face
  27412. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27413. * @returns the currentAbstractMesh
  27414. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27415. */
  27416. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27417. }
  27418. }
  27419. declare module "babylonjs/Actions/actionEvent" {
  27420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27421. import { Nullable } from "babylonjs/types";
  27422. import { Sprite } from "babylonjs/Sprites/sprite";
  27423. import { Scene } from "babylonjs/scene";
  27424. import { Vector2 } from "babylonjs/Maths/math.vector";
  27425. /**
  27426. * Interface used to define ActionEvent
  27427. */
  27428. export interface IActionEvent {
  27429. /** The mesh or sprite that triggered the action */
  27430. source: any;
  27431. /** The X mouse cursor position at the time of the event */
  27432. pointerX: number;
  27433. /** The Y mouse cursor position at the time of the event */
  27434. pointerY: number;
  27435. /** The mesh that is currently pointed at (can be null) */
  27436. meshUnderPointer: Nullable<AbstractMesh>;
  27437. /** the original (browser) event that triggered the ActionEvent */
  27438. sourceEvent?: any;
  27439. /** additional data for the event */
  27440. additionalData?: any;
  27441. }
  27442. /**
  27443. * ActionEvent is the event being sent when an action is triggered.
  27444. */
  27445. export class ActionEvent implements IActionEvent {
  27446. /** The mesh or sprite that triggered the action */
  27447. source: any;
  27448. /** The X mouse cursor position at the time of the event */
  27449. pointerX: number;
  27450. /** The Y mouse cursor position at the time of the event */
  27451. pointerY: number;
  27452. /** The mesh that is currently pointed at (can be null) */
  27453. meshUnderPointer: Nullable<AbstractMesh>;
  27454. /** the original (browser) event that triggered the ActionEvent */
  27455. sourceEvent?: any;
  27456. /** additional data for the event */
  27457. additionalData?: any;
  27458. /**
  27459. * Creates a new ActionEvent
  27460. * @param source The mesh or sprite that triggered the action
  27461. * @param pointerX The X mouse cursor position at the time of the event
  27462. * @param pointerY The Y mouse cursor position at the time of the event
  27463. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27464. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27465. * @param additionalData additional data for the event
  27466. */
  27467. constructor(
  27468. /** The mesh or sprite that triggered the action */
  27469. source: any,
  27470. /** The X mouse cursor position at the time of the event */
  27471. pointerX: number,
  27472. /** The Y mouse cursor position at the time of the event */
  27473. pointerY: number,
  27474. /** The mesh that is currently pointed at (can be null) */
  27475. meshUnderPointer: Nullable<AbstractMesh>,
  27476. /** the original (browser) event that triggered the ActionEvent */
  27477. sourceEvent?: any,
  27478. /** additional data for the event */
  27479. additionalData?: any);
  27480. /**
  27481. * Helper function to auto-create an ActionEvent from a source mesh.
  27482. * @param source The source mesh that triggered the event
  27483. * @param evt The original (browser) event
  27484. * @param additionalData additional data for the event
  27485. * @returns the new ActionEvent
  27486. */
  27487. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27488. /**
  27489. * Helper function to auto-create an ActionEvent from a source sprite
  27490. * @param source The source sprite that triggered the event
  27491. * @param scene Scene associated with the sprite
  27492. * @param evt The original (browser) event
  27493. * @param additionalData additional data for the event
  27494. * @returns the new ActionEvent
  27495. */
  27496. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27497. /**
  27498. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27499. * @param scene the scene where the event occurred
  27500. * @param evt The original (browser) event
  27501. * @returns the new ActionEvent
  27502. */
  27503. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27504. /**
  27505. * Helper function to auto-create an ActionEvent from a primitive
  27506. * @param prim defines the target primitive
  27507. * @param pointerPos defines the pointer position
  27508. * @param evt The original (browser) event
  27509. * @param additionalData additional data for the event
  27510. * @returns the new ActionEvent
  27511. */
  27512. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27513. }
  27514. }
  27515. declare module "babylonjs/Actions/abstractActionManager" {
  27516. import { IDisposable } from "babylonjs/scene";
  27517. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27518. import { IAction } from "babylonjs/Actions/action";
  27519. import { Nullable } from "babylonjs/types";
  27520. /**
  27521. * Abstract class used to decouple action Manager from scene and meshes.
  27522. * Do not instantiate.
  27523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27524. */
  27525. export abstract class AbstractActionManager implements IDisposable {
  27526. /** Gets the list of active triggers */
  27527. static Triggers: {
  27528. [key: string]: number;
  27529. };
  27530. /** Gets the cursor to use when hovering items */
  27531. hoverCursor: string;
  27532. /** Gets the list of actions */
  27533. actions: IAction[];
  27534. /**
  27535. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27536. */
  27537. isRecursive: boolean;
  27538. /**
  27539. * Releases all associated resources
  27540. */
  27541. abstract dispose(): void;
  27542. /**
  27543. * Does this action manager has pointer triggers
  27544. */
  27545. abstract readonly hasPointerTriggers: boolean;
  27546. /**
  27547. * Does this action manager has pick triggers
  27548. */
  27549. abstract readonly hasPickTriggers: boolean;
  27550. /**
  27551. * Process a specific trigger
  27552. * @param trigger defines the trigger to process
  27553. * @param evt defines the event details to be processed
  27554. */
  27555. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27556. /**
  27557. * Does this action manager handles actions of any of the given triggers
  27558. * @param triggers defines the triggers to be tested
  27559. * @return a boolean indicating whether one (or more) of the triggers is handled
  27560. */
  27561. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27562. /**
  27563. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27564. * speed.
  27565. * @param triggerA defines the trigger to be tested
  27566. * @param triggerB defines the trigger to be tested
  27567. * @return a boolean indicating whether one (or more) of the triggers is handled
  27568. */
  27569. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27570. /**
  27571. * Does this action manager handles actions of a given trigger
  27572. * @param trigger defines the trigger to be tested
  27573. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27574. * @return whether the trigger is handled
  27575. */
  27576. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27577. /**
  27578. * Serialize this manager to a JSON object
  27579. * @param name defines the property name to store this manager
  27580. * @returns a JSON representation of this manager
  27581. */
  27582. abstract serialize(name: string): any;
  27583. /**
  27584. * Registers an action to this action manager
  27585. * @param action defines the action to be registered
  27586. * @return the action amended (prepared) after registration
  27587. */
  27588. abstract registerAction(action: IAction): Nullable<IAction>;
  27589. /**
  27590. * Unregisters an action to this action manager
  27591. * @param action defines the action to be unregistered
  27592. * @return a boolean indicating whether the action has been unregistered
  27593. */
  27594. abstract unregisterAction(action: IAction): Boolean;
  27595. /**
  27596. * Does exist one action manager with at least one trigger
  27597. **/
  27598. static readonly HasTriggers: boolean;
  27599. /**
  27600. * Does exist one action manager with at least one pick trigger
  27601. **/
  27602. static readonly HasPickTriggers: boolean;
  27603. /**
  27604. * Does exist one action manager that handles actions of a given trigger
  27605. * @param trigger defines the trigger to be tested
  27606. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27607. **/
  27608. static HasSpecificTrigger(trigger: number): boolean;
  27609. }
  27610. }
  27611. declare module "babylonjs/node" {
  27612. import { Scene } from "babylonjs/scene";
  27613. import { Nullable } from "babylonjs/types";
  27614. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27615. import { Engine } from "babylonjs/Engines/engine";
  27616. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27617. import { Observable } from "babylonjs/Misc/observable";
  27618. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27619. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27620. import { Animatable } from "babylonjs/Animations/animatable";
  27621. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27622. import { Animation } from "babylonjs/Animations/animation";
  27623. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27625. /**
  27626. * Defines how a node can be built from a string name.
  27627. */
  27628. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27629. /**
  27630. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27631. */
  27632. export class Node implements IBehaviorAware<Node> {
  27633. /** @hidden */
  27634. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27635. private static _NodeConstructors;
  27636. /**
  27637. * Add a new node constructor
  27638. * @param type defines the type name of the node to construct
  27639. * @param constructorFunc defines the constructor function
  27640. */
  27641. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27642. /**
  27643. * Returns a node constructor based on type name
  27644. * @param type defines the type name
  27645. * @param name defines the new node name
  27646. * @param scene defines the hosting scene
  27647. * @param options defines optional options to transmit to constructors
  27648. * @returns the new constructor or null
  27649. */
  27650. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27651. /**
  27652. * Gets or sets the name of the node
  27653. */
  27654. name: string;
  27655. /**
  27656. * Gets or sets the id of the node
  27657. */
  27658. id: string;
  27659. /**
  27660. * Gets or sets the unique id of the node
  27661. */
  27662. uniqueId: number;
  27663. /**
  27664. * Gets or sets a string used to store user defined state for the node
  27665. */
  27666. state: string;
  27667. /**
  27668. * Gets or sets an object used to store user defined information for the node
  27669. */
  27670. metadata: any;
  27671. /**
  27672. * For internal use only. Please do not use.
  27673. */
  27674. reservedDataStore: any;
  27675. /**
  27676. * List of inspectable custom properties (used by the Inspector)
  27677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27678. */
  27679. inspectableCustomProperties: IInspectable[];
  27680. /**
  27681. * Gets or sets a boolean used to define if the node must be serialized
  27682. */
  27683. doNotSerialize: boolean;
  27684. /** @hidden */
  27685. _isDisposed: boolean;
  27686. /**
  27687. * Gets a list of Animations associated with the node
  27688. */
  27689. animations: import("babylonjs/Animations/animation").Animation[];
  27690. protected _ranges: {
  27691. [name: string]: Nullable<AnimationRange>;
  27692. };
  27693. /**
  27694. * Callback raised when the node is ready to be used
  27695. */
  27696. onReady: Nullable<(node: Node) => void>;
  27697. private _isEnabled;
  27698. private _isParentEnabled;
  27699. private _isReady;
  27700. /** @hidden */
  27701. _currentRenderId: number;
  27702. private _parentUpdateId;
  27703. /** @hidden */
  27704. _childUpdateId: number;
  27705. /** @hidden */
  27706. _waitingParentId: Nullable<string>;
  27707. /** @hidden */
  27708. _scene: Scene;
  27709. /** @hidden */
  27710. _cache: any;
  27711. private _parentNode;
  27712. private _children;
  27713. /** @hidden */
  27714. _worldMatrix: Matrix;
  27715. /** @hidden */
  27716. _worldMatrixDeterminant: number;
  27717. /** @hidden */
  27718. _worldMatrixDeterminantIsDirty: boolean;
  27719. /** @hidden */
  27720. private _sceneRootNodesIndex;
  27721. /**
  27722. * Gets a boolean indicating if the node has been disposed
  27723. * @returns true if the node was disposed
  27724. */
  27725. isDisposed(): boolean;
  27726. /**
  27727. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27728. * @see https://doc.babylonjs.com/how_to/parenting
  27729. */
  27730. parent: Nullable<Node>;
  27731. private addToSceneRootNodes;
  27732. private removeFromSceneRootNodes;
  27733. private _animationPropertiesOverride;
  27734. /**
  27735. * Gets or sets the animation properties override
  27736. */
  27737. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27738. /**
  27739. * Gets a string idenfifying the name of the class
  27740. * @returns "Node" string
  27741. */
  27742. getClassName(): string;
  27743. /** @hidden */
  27744. readonly _isNode: boolean;
  27745. /**
  27746. * An event triggered when the mesh is disposed
  27747. */
  27748. onDisposeObservable: Observable<Node>;
  27749. private _onDisposeObserver;
  27750. /**
  27751. * Sets a callback that will be raised when the node will be disposed
  27752. */
  27753. onDispose: () => void;
  27754. /**
  27755. * Creates a new Node
  27756. * @param name the name and id to be given to this node
  27757. * @param scene the scene this node will be added to
  27758. * @param addToRootNodes the node will be added to scene.rootNodes
  27759. */
  27760. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27761. /**
  27762. * Gets the scene of the node
  27763. * @returns a scene
  27764. */
  27765. getScene(): Scene;
  27766. /**
  27767. * Gets the engine of the node
  27768. * @returns a Engine
  27769. */
  27770. getEngine(): Engine;
  27771. private _behaviors;
  27772. /**
  27773. * Attach a behavior to the node
  27774. * @see http://doc.babylonjs.com/features/behaviour
  27775. * @param behavior defines the behavior to attach
  27776. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27777. * @returns the current Node
  27778. */
  27779. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27780. /**
  27781. * Remove an attached behavior
  27782. * @see http://doc.babylonjs.com/features/behaviour
  27783. * @param behavior defines the behavior to attach
  27784. * @returns the current Node
  27785. */
  27786. removeBehavior(behavior: Behavior<Node>): Node;
  27787. /**
  27788. * Gets the list of attached behaviors
  27789. * @see http://doc.babylonjs.com/features/behaviour
  27790. */
  27791. readonly behaviors: Behavior<Node>[];
  27792. /**
  27793. * Gets an attached behavior by name
  27794. * @param name defines the name of the behavior to look for
  27795. * @see http://doc.babylonjs.com/features/behaviour
  27796. * @returns null if behavior was not found else the requested behavior
  27797. */
  27798. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27799. /**
  27800. * Returns the latest update of the World matrix
  27801. * @returns a Matrix
  27802. */
  27803. getWorldMatrix(): Matrix;
  27804. /** @hidden */
  27805. _getWorldMatrixDeterminant(): number;
  27806. /**
  27807. * Returns directly the latest state of the mesh World matrix.
  27808. * A Matrix is returned.
  27809. */
  27810. readonly worldMatrixFromCache: Matrix;
  27811. /** @hidden */
  27812. _initCache(): void;
  27813. /** @hidden */
  27814. updateCache(force?: boolean): void;
  27815. /** @hidden */
  27816. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27817. /** @hidden */
  27818. _updateCache(ignoreParentClass?: boolean): void;
  27819. /** @hidden */
  27820. _isSynchronized(): boolean;
  27821. /** @hidden */
  27822. _markSyncedWithParent(): void;
  27823. /** @hidden */
  27824. isSynchronizedWithParent(): boolean;
  27825. /** @hidden */
  27826. isSynchronized(): boolean;
  27827. /**
  27828. * Is this node ready to be used/rendered
  27829. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27830. * @return true if the node is ready
  27831. */
  27832. isReady(completeCheck?: boolean): boolean;
  27833. /**
  27834. * Is this node enabled?
  27835. * 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
  27836. * @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
  27837. * @return whether this node (and its parent) is enabled
  27838. */
  27839. isEnabled(checkAncestors?: boolean): boolean;
  27840. /** @hidden */
  27841. protected _syncParentEnabledState(): void;
  27842. /**
  27843. * Set the enabled state of this node
  27844. * @param value defines the new enabled state
  27845. */
  27846. setEnabled(value: boolean): void;
  27847. /**
  27848. * Is this node a descendant of the given node?
  27849. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27850. * @param ancestor defines the parent node to inspect
  27851. * @returns a boolean indicating if this node is a descendant of the given node
  27852. */
  27853. isDescendantOf(ancestor: Node): boolean;
  27854. /** @hidden */
  27855. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27856. /**
  27857. * Will return all nodes that have this node as ascendant
  27858. * @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
  27859. * @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
  27860. * @return all children nodes of all types
  27861. */
  27862. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27863. /**
  27864. * Get all child-meshes of this node
  27865. * @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)
  27866. * @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
  27867. * @returns an array of AbstractMesh
  27868. */
  27869. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27870. /**
  27871. * Get all direct children of this node
  27872. * @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
  27873. * @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)
  27874. * @returns an array of Node
  27875. */
  27876. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27877. /** @hidden */
  27878. _setReady(state: boolean): void;
  27879. /**
  27880. * Get an animation by name
  27881. * @param name defines the name of the animation to look for
  27882. * @returns null if not found else the requested animation
  27883. */
  27884. getAnimationByName(name: string): Nullable<Animation>;
  27885. /**
  27886. * Creates an animation range for this node
  27887. * @param name defines the name of the range
  27888. * @param from defines the starting key
  27889. * @param to defines the end key
  27890. */
  27891. createAnimationRange(name: string, from: number, to: number): void;
  27892. /**
  27893. * Delete a specific animation range
  27894. * @param name defines the name of the range to delete
  27895. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27896. */
  27897. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27898. /**
  27899. * Get an animation range by name
  27900. * @param name defines the name of the animation range to look for
  27901. * @returns null if not found else the requested animation range
  27902. */
  27903. getAnimationRange(name: string): Nullable<AnimationRange>;
  27904. /**
  27905. * Gets the list of all animation ranges defined on this node
  27906. * @returns an array
  27907. */
  27908. getAnimationRanges(): Nullable<AnimationRange>[];
  27909. /**
  27910. * Will start the animation sequence
  27911. * @param name defines the range frames for animation sequence
  27912. * @param loop defines if the animation should loop (false by default)
  27913. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27914. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27915. * @returns the object created for this animation. If range does not exist, it will return null
  27916. */
  27917. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27918. /**
  27919. * Serialize animation ranges into a JSON compatible object
  27920. * @returns serialization object
  27921. */
  27922. serializeAnimationRanges(): any;
  27923. /**
  27924. * Computes the world matrix of the node
  27925. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27926. * @returns the world matrix
  27927. */
  27928. computeWorldMatrix(force?: boolean): Matrix;
  27929. /**
  27930. * Releases resources associated with this node.
  27931. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27932. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27933. */
  27934. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27935. /**
  27936. * Parse animation range data from a serialization object and store them into a given node
  27937. * @param node defines where to store the animation ranges
  27938. * @param parsedNode defines the serialization object to read data from
  27939. * @param scene defines the hosting scene
  27940. */
  27941. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27942. /**
  27943. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27944. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27945. * @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
  27946. * @returns the new bounding vectors
  27947. */
  27948. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27949. min: Vector3;
  27950. max: Vector3;
  27951. };
  27952. }
  27953. }
  27954. declare module "babylonjs/Animations/animation" {
  27955. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27956. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27957. import { Color3 } from "babylonjs/Maths/math.color";
  27958. import { Nullable } from "babylonjs/types";
  27959. import { Scene } from "babylonjs/scene";
  27960. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27961. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27962. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27963. import { Node } from "babylonjs/node";
  27964. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27965. import { Size } from "babylonjs/Maths/math.size";
  27966. import { Animatable } from "babylonjs/Animations/animatable";
  27967. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27968. /**
  27969. * @hidden
  27970. */
  27971. export class _IAnimationState {
  27972. key: number;
  27973. repeatCount: number;
  27974. workValue?: any;
  27975. loopMode?: number;
  27976. offsetValue?: any;
  27977. highLimitValue?: any;
  27978. }
  27979. /**
  27980. * Class used to store any kind of animation
  27981. */
  27982. export class Animation {
  27983. /**Name of the animation */
  27984. name: string;
  27985. /**Property to animate */
  27986. targetProperty: string;
  27987. /**The frames per second of the animation */
  27988. framePerSecond: number;
  27989. /**The data type of the animation */
  27990. dataType: number;
  27991. /**The loop mode of the animation */
  27992. loopMode?: number | undefined;
  27993. /**Specifies if blending should be enabled */
  27994. enableBlending?: boolean | undefined;
  27995. /**
  27996. * Use matrix interpolation instead of using direct key value when animating matrices
  27997. */
  27998. static AllowMatricesInterpolation: boolean;
  27999. /**
  28000. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28001. */
  28002. static AllowMatrixDecomposeForInterpolation: boolean;
  28003. /**
  28004. * Stores the key frames of the animation
  28005. */
  28006. private _keys;
  28007. /**
  28008. * Stores the easing function of the animation
  28009. */
  28010. private _easingFunction;
  28011. /**
  28012. * @hidden Internal use only
  28013. */
  28014. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28015. /**
  28016. * The set of event that will be linked to this animation
  28017. */
  28018. private _events;
  28019. /**
  28020. * Stores an array of target property paths
  28021. */
  28022. targetPropertyPath: string[];
  28023. /**
  28024. * Stores the blending speed of the animation
  28025. */
  28026. blendingSpeed: number;
  28027. /**
  28028. * Stores the animation ranges for the animation
  28029. */
  28030. private _ranges;
  28031. /**
  28032. * @hidden Internal use
  28033. */
  28034. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28035. /**
  28036. * Sets up an animation
  28037. * @param property The property to animate
  28038. * @param animationType The animation type to apply
  28039. * @param framePerSecond The frames per second of the animation
  28040. * @param easingFunction The easing function used in the animation
  28041. * @returns The created animation
  28042. */
  28043. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28044. /**
  28045. * Create and start an animation on a node
  28046. * @param name defines the name of the global animation that will be run on all nodes
  28047. * @param node defines the root node where the animation will take place
  28048. * @param targetProperty defines property to animate
  28049. * @param framePerSecond defines the number of frame per second yo use
  28050. * @param totalFrame defines the number of frames in total
  28051. * @param from defines the initial value
  28052. * @param to defines the final value
  28053. * @param loopMode defines which loop mode you want to use (off by default)
  28054. * @param easingFunction defines the easing function to use (linear by default)
  28055. * @param onAnimationEnd defines the callback to call when animation end
  28056. * @returns the animatable created for this animation
  28057. */
  28058. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28059. /**
  28060. * Create and start an animation on a node and its descendants
  28061. * @param name defines the name of the global animation that will be run on all nodes
  28062. * @param node defines the root node where the animation will take place
  28063. * @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
  28064. * @param targetProperty defines property to animate
  28065. * @param framePerSecond defines the number of frame per second to use
  28066. * @param totalFrame defines the number of frames in total
  28067. * @param from defines the initial value
  28068. * @param to defines the final value
  28069. * @param loopMode defines which loop mode you want to use (off by default)
  28070. * @param easingFunction defines the easing function to use (linear by default)
  28071. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28072. * @returns the list of animatables created for all nodes
  28073. * @example https://www.babylonjs-playground.com/#MH0VLI
  28074. */
  28075. 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[]>;
  28076. /**
  28077. * Creates a new animation, merges it with the existing animations and starts it
  28078. * @param name Name of the animation
  28079. * @param node Node which contains the scene that begins the animations
  28080. * @param targetProperty Specifies which property to animate
  28081. * @param framePerSecond The frames per second of the animation
  28082. * @param totalFrame The total number of frames
  28083. * @param from The frame at the beginning of the animation
  28084. * @param to The frame at the end of the animation
  28085. * @param loopMode Specifies the loop mode of the animation
  28086. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28087. * @param onAnimationEnd Callback to run once the animation is complete
  28088. * @returns Nullable animation
  28089. */
  28090. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28091. /**
  28092. * Transition property of an host to the target Value
  28093. * @param property The property to transition
  28094. * @param targetValue The target Value of the property
  28095. * @param host The object where the property to animate belongs
  28096. * @param scene Scene used to run the animation
  28097. * @param frameRate Framerate (in frame/s) to use
  28098. * @param transition The transition type we want to use
  28099. * @param duration The duration of the animation, in milliseconds
  28100. * @param onAnimationEnd Callback trigger at the end of the animation
  28101. * @returns Nullable animation
  28102. */
  28103. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28104. /**
  28105. * Return the array of runtime animations currently using this animation
  28106. */
  28107. readonly runtimeAnimations: RuntimeAnimation[];
  28108. /**
  28109. * Specifies if any of the runtime animations are currently running
  28110. */
  28111. readonly hasRunningRuntimeAnimations: boolean;
  28112. /**
  28113. * Initializes the animation
  28114. * @param name Name of the animation
  28115. * @param targetProperty Property to animate
  28116. * @param framePerSecond The frames per second of the animation
  28117. * @param dataType The data type of the animation
  28118. * @param loopMode The loop mode of the animation
  28119. * @param enableBlending Specifies if blending should be enabled
  28120. */
  28121. constructor(
  28122. /**Name of the animation */
  28123. name: string,
  28124. /**Property to animate */
  28125. targetProperty: string,
  28126. /**The frames per second of the animation */
  28127. framePerSecond: number,
  28128. /**The data type of the animation */
  28129. dataType: number,
  28130. /**The loop mode of the animation */
  28131. loopMode?: number | undefined,
  28132. /**Specifies if blending should be enabled */
  28133. enableBlending?: boolean | undefined);
  28134. /**
  28135. * Converts the animation to a string
  28136. * @param fullDetails support for multiple levels of logging within scene loading
  28137. * @returns String form of the animation
  28138. */
  28139. toString(fullDetails?: boolean): string;
  28140. /**
  28141. * Add an event to this animation
  28142. * @param event Event to add
  28143. */
  28144. addEvent(event: AnimationEvent): void;
  28145. /**
  28146. * Remove all events found at the given frame
  28147. * @param frame The frame to remove events from
  28148. */
  28149. removeEvents(frame: number): void;
  28150. /**
  28151. * Retrieves all the events from the animation
  28152. * @returns Events from the animation
  28153. */
  28154. getEvents(): AnimationEvent[];
  28155. /**
  28156. * Creates an animation range
  28157. * @param name Name of the animation range
  28158. * @param from Starting frame of the animation range
  28159. * @param to Ending frame of the animation
  28160. */
  28161. createRange(name: string, from: number, to: number): void;
  28162. /**
  28163. * Deletes an animation range by name
  28164. * @param name Name of the animation range to delete
  28165. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28166. */
  28167. deleteRange(name: string, deleteFrames?: boolean): void;
  28168. /**
  28169. * Gets the animation range by name, or null if not defined
  28170. * @param name Name of the animation range
  28171. * @returns Nullable animation range
  28172. */
  28173. getRange(name: string): Nullable<AnimationRange>;
  28174. /**
  28175. * Gets the key frames from the animation
  28176. * @returns The key frames of the animation
  28177. */
  28178. getKeys(): Array<IAnimationKey>;
  28179. /**
  28180. * Gets the highest frame rate of the animation
  28181. * @returns Highest frame rate of the animation
  28182. */
  28183. getHighestFrame(): number;
  28184. /**
  28185. * Gets the easing function of the animation
  28186. * @returns Easing function of the animation
  28187. */
  28188. getEasingFunction(): IEasingFunction;
  28189. /**
  28190. * Sets the easing function of the animation
  28191. * @param easingFunction A custom mathematical formula for animation
  28192. */
  28193. setEasingFunction(easingFunction: EasingFunction): void;
  28194. /**
  28195. * Interpolates a scalar linearly
  28196. * @param startValue Start value of the animation curve
  28197. * @param endValue End value of the animation curve
  28198. * @param gradient Scalar amount to interpolate
  28199. * @returns Interpolated scalar value
  28200. */
  28201. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28202. /**
  28203. * Interpolates a scalar cubically
  28204. * @param startValue Start value of the animation curve
  28205. * @param outTangent End tangent of the animation
  28206. * @param endValue End value of the animation curve
  28207. * @param inTangent Start tangent of the animation curve
  28208. * @param gradient Scalar amount to interpolate
  28209. * @returns Interpolated scalar value
  28210. */
  28211. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28212. /**
  28213. * Interpolates a quaternion using a spherical linear interpolation
  28214. * @param startValue Start value of the animation curve
  28215. * @param endValue End value of the animation curve
  28216. * @param gradient Scalar amount to interpolate
  28217. * @returns Interpolated quaternion value
  28218. */
  28219. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28220. /**
  28221. * Interpolates a quaternion cubically
  28222. * @param startValue Start value of the animation curve
  28223. * @param outTangent End tangent of the animation curve
  28224. * @param endValue End value of the animation curve
  28225. * @param inTangent Start tangent of the animation curve
  28226. * @param gradient Scalar amount to interpolate
  28227. * @returns Interpolated quaternion value
  28228. */
  28229. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28230. /**
  28231. * Interpolates a Vector3 linearl
  28232. * @param startValue Start value of the animation curve
  28233. * @param endValue End value of the animation curve
  28234. * @param gradient Scalar amount to interpolate
  28235. * @returns Interpolated scalar value
  28236. */
  28237. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28238. /**
  28239. * Interpolates a Vector3 cubically
  28240. * @param startValue Start value of the animation curve
  28241. * @param outTangent End tangent of the animation
  28242. * @param endValue End value of the animation curve
  28243. * @param inTangent Start tangent of the animation curve
  28244. * @param gradient Scalar amount to interpolate
  28245. * @returns InterpolatedVector3 value
  28246. */
  28247. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28248. /**
  28249. * Interpolates a Vector2 linearly
  28250. * @param startValue Start value of the animation curve
  28251. * @param endValue End value of the animation curve
  28252. * @param gradient Scalar amount to interpolate
  28253. * @returns Interpolated Vector2 value
  28254. */
  28255. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28256. /**
  28257. * Interpolates a Vector2 cubically
  28258. * @param startValue Start value of the animation curve
  28259. * @param outTangent End tangent of the animation
  28260. * @param endValue End value of the animation curve
  28261. * @param inTangent Start tangent of the animation curve
  28262. * @param gradient Scalar amount to interpolate
  28263. * @returns Interpolated Vector2 value
  28264. */
  28265. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28266. /**
  28267. * Interpolates a size linearly
  28268. * @param startValue Start value of the animation curve
  28269. * @param endValue End value of the animation curve
  28270. * @param gradient Scalar amount to interpolate
  28271. * @returns Interpolated Size value
  28272. */
  28273. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28274. /**
  28275. * Interpolates a Color3 linearly
  28276. * @param startValue Start value of the animation curve
  28277. * @param endValue End value of the animation curve
  28278. * @param gradient Scalar amount to interpolate
  28279. * @returns Interpolated Color3 value
  28280. */
  28281. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28282. /**
  28283. * @hidden Internal use only
  28284. */
  28285. _getKeyValue(value: any): any;
  28286. /**
  28287. * @hidden Internal use only
  28288. */
  28289. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28290. /**
  28291. * Defines the function to use to interpolate matrices
  28292. * @param startValue defines the start matrix
  28293. * @param endValue defines the end matrix
  28294. * @param gradient defines the gradient between both matrices
  28295. * @param result defines an optional target matrix where to store the interpolation
  28296. * @returns the interpolated matrix
  28297. */
  28298. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28299. /**
  28300. * Makes a copy of the animation
  28301. * @returns Cloned animation
  28302. */
  28303. clone(): Animation;
  28304. /**
  28305. * Sets the key frames of the animation
  28306. * @param values The animation key frames to set
  28307. */
  28308. setKeys(values: Array<IAnimationKey>): void;
  28309. /**
  28310. * Serializes the animation to an object
  28311. * @returns Serialized object
  28312. */
  28313. serialize(): any;
  28314. /**
  28315. * Float animation type
  28316. */
  28317. private static _ANIMATIONTYPE_FLOAT;
  28318. /**
  28319. * Vector3 animation type
  28320. */
  28321. private static _ANIMATIONTYPE_VECTOR3;
  28322. /**
  28323. * Quaternion animation type
  28324. */
  28325. private static _ANIMATIONTYPE_QUATERNION;
  28326. /**
  28327. * Matrix animation type
  28328. */
  28329. private static _ANIMATIONTYPE_MATRIX;
  28330. /**
  28331. * Color3 animation type
  28332. */
  28333. private static _ANIMATIONTYPE_COLOR3;
  28334. /**
  28335. * Vector2 animation type
  28336. */
  28337. private static _ANIMATIONTYPE_VECTOR2;
  28338. /**
  28339. * Size animation type
  28340. */
  28341. private static _ANIMATIONTYPE_SIZE;
  28342. /**
  28343. * Relative Loop Mode
  28344. */
  28345. private static _ANIMATIONLOOPMODE_RELATIVE;
  28346. /**
  28347. * Cycle Loop Mode
  28348. */
  28349. private static _ANIMATIONLOOPMODE_CYCLE;
  28350. /**
  28351. * Constant Loop Mode
  28352. */
  28353. private static _ANIMATIONLOOPMODE_CONSTANT;
  28354. /**
  28355. * Get the float animation type
  28356. */
  28357. static readonly ANIMATIONTYPE_FLOAT: number;
  28358. /**
  28359. * Get the Vector3 animation type
  28360. */
  28361. static readonly ANIMATIONTYPE_VECTOR3: number;
  28362. /**
  28363. * Get the Vector2 animation type
  28364. */
  28365. static readonly ANIMATIONTYPE_VECTOR2: number;
  28366. /**
  28367. * Get the Size animation type
  28368. */
  28369. static readonly ANIMATIONTYPE_SIZE: number;
  28370. /**
  28371. * Get the Quaternion animation type
  28372. */
  28373. static readonly ANIMATIONTYPE_QUATERNION: number;
  28374. /**
  28375. * Get the Matrix animation type
  28376. */
  28377. static readonly ANIMATIONTYPE_MATRIX: number;
  28378. /**
  28379. * Get the Color3 animation type
  28380. */
  28381. static readonly ANIMATIONTYPE_COLOR3: number;
  28382. /**
  28383. * Get the Relative Loop Mode
  28384. */
  28385. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28386. /**
  28387. * Get the Cycle Loop Mode
  28388. */
  28389. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28390. /**
  28391. * Get the Constant Loop Mode
  28392. */
  28393. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28394. /** @hidden */
  28395. static _UniversalLerp(left: any, right: any, amount: number): any;
  28396. /**
  28397. * Parses an animation object and creates an animation
  28398. * @param parsedAnimation Parsed animation object
  28399. * @returns Animation object
  28400. */
  28401. static Parse(parsedAnimation: any): Animation;
  28402. /**
  28403. * Appends the serialized animations from the source animations
  28404. * @param source Source containing the animations
  28405. * @param destination Target to store the animations
  28406. */
  28407. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28408. }
  28409. }
  28410. declare module "babylonjs/Animations/animatable.interface" {
  28411. import { Nullable } from "babylonjs/types";
  28412. import { Animation } from "babylonjs/Animations/animation";
  28413. /**
  28414. * Interface containing an array of animations
  28415. */
  28416. export interface IAnimatable {
  28417. /**
  28418. * Array of animations
  28419. */
  28420. animations: Nullable<Array<Animation>>;
  28421. }
  28422. }
  28423. declare module "babylonjs/Materials/fresnelParameters" {
  28424. import { Color3 } from "babylonjs/Maths/math.color";
  28425. /**
  28426. * This represents all the required information to add a fresnel effect on a material:
  28427. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28428. */
  28429. export class FresnelParameters {
  28430. private _isEnabled;
  28431. /**
  28432. * Define if the fresnel effect is enable or not.
  28433. */
  28434. isEnabled: boolean;
  28435. /**
  28436. * Define the color used on edges (grazing angle)
  28437. */
  28438. leftColor: Color3;
  28439. /**
  28440. * Define the color used on center
  28441. */
  28442. rightColor: Color3;
  28443. /**
  28444. * Define bias applied to computed fresnel term
  28445. */
  28446. bias: number;
  28447. /**
  28448. * Defined the power exponent applied to fresnel term
  28449. */
  28450. power: number;
  28451. /**
  28452. * Clones the current fresnel and its valuues
  28453. * @returns a clone fresnel configuration
  28454. */
  28455. clone(): FresnelParameters;
  28456. /**
  28457. * Serializes the current fresnel parameters to a JSON representation.
  28458. * @return the JSON serialization
  28459. */
  28460. serialize(): any;
  28461. /**
  28462. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28463. * @param parsedFresnelParameters Define the JSON representation
  28464. * @returns the parsed parameters
  28465. */
  28466. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28467. }
  28468. }
  28469. declare module "babylonjs/Misc/decorators" {
  28470. import { Nullable } from "babylonjs/types";
  28471. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28472. import { Scene } from "babylonjs/scene";
  28473. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28474. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28475. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28476. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28477. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28478. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28479. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28480. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28481. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28482. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28483. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28484. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28485. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28486. /**
  28487. * Decorator used to define property that can be serialized as reference to a camera
  28488. * @param sourceName defines the name of the property to decorate
  28489. */
  28490. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28491. /**
  28492. * Class used to help serialization objects
  28493. */
  28494. export class SerializationHelper {
  28495. /** @hidden */
  28496. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28497. /** @hidden */
  28498. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28499. /** @hidden */
  28500. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28501. /** @hidden */
  28502. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28503. /**
  28504. * Appends the serialized animations from the source animations
  28505. * @param source Source containing the animations
  28506. * @param destination Target to store the animations
  28507. */
  28508. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28509. /**
  28510. * Static function used to serialized a specific entity
  28511. * @param entity defines the entity to serialize
  28512. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28513. * @returns a JSON compatible object representing the serialization of the entity
  28514. */
  28515. static Serialize<T>(entity: T, serializationObject?: any): any;
  28516. /**
  28517. * Creates a new entity from a serialization data object
  28518. * @param creationFunction defines a function used to instanciated the new entity
  28519. * @param source defines the source serialization data
  28520. * @param scene defines the hosting scene
  28521. * @param rootUrl defines the root url for resources
  28522. * @returns a new entity
  28523. */
  28524. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28525. /**
  28526. * Clones an object
  28527. * @param creationFunction defines the function used to instanciate the new object
  28528. * @param source defines the source object
  28529. * @returns the cloned object
  28530. */
  28531. static Clone<T>(creationFunction: () => T, source: T): T;
  28532. /**
  28533. * Instanciates a new object based on a source one (some data will be shared between both object)
  28534. * @param creationFunction defines the function used to instanciate the new object
  28535. * @param source defines the source object
  28536. * @returns the new object
  28537. */
  28538. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28539. }
  28540. }
  28541. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28542. import { Nullable } from "babylonjs/types";
  28543. /**
  28544. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28545. */
  28546. export interface CubeMapInfo {
  28547. /**
  28548. * The pixel array for the front face.
  28549. * This is stored in format, left to right, up to down format.
  28550. */
  28551. front: Nullable<ArrayBufferView>;
  28552. /**
  28553. * The pixel array for the back face.
  28554. * This is stored in format, left to right, up to down format.
  28555. */
  28556. back: Nullable<ArrayBufferView>;
  28557. /**
  28558. * The pixel array for the left face.
  28559. * This is stored in format, left to right, up to down format.
  28560. */
  28561. left: Nullable<ArrayBufferView>;
  28562. /**
  28563. * The pixel array for the right face.
  28564. * This is stored in format, left to right, up to down format.
  28565. */
  28566. right: Nullable<ArrayBufferView>;
  28567. /**
  28568. * The pixel array for the up face.
  28569. * This is stored in format, left to right, up to down format.
  28570. */
  28571. up: Nullable<ArrayBufferView>;
  28572. /**
  28573. * The pixel array for the down face.
  28574. * This is stored in format, left to right, up to down format.
  28575. */
  28576. down: Nullable<ArrayBufferView>;
  28577. /**
  28578. * The size of the cubemap stored.
  28579. *
  28580. * Each faces will be size * size pixels.
  28581. */
  28582. size: number;
  28583. /**
  28584. * The format of the texture.
  28585. *
  28586. * RGBA, RGB.
  28587. */
  28588. format: number;
  28589. /**
  28590. * The type of the texture data.
  28591. *
  28592. * UNSIGNED_INT, FLOAT.
  28593. */
  28594. type: number;
  28595. /**
  28596. * Specifies whether the texture is in gamma space.
  28597. */
  28598. gammaSpace: boolean;
  28599. }
  28600. /**
  28601. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28602. */
  28603. export class PanoramaToCubeMapTools {
  28604. private static FACE_FRONT;
  28605. private static FACE_BACK;
  28606. private static FACE_RIGHT;
  28607. private static FACE_LEFT;
  28608. private static FACE_DOWN;
  28609. private static FACE_UP;
  28610. /**
  28611. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28612. *
  28613. * @param float32Array The source data.
  28614. * @param inputWidth The width of the input panorama.
  28615. * @param inputHeight The height of the input panorama.
  28616. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28617. * @return The cubemap data
  28618. */
  28619. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28620. private static CreateCubemapTexture;
  28621. private static CalcProjectionSpherical;
  28622. }
  28623. }
  28624. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28625. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28626. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28627. import { Nullable } from "babylonjs/types";
  28628. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28629. /**
  28630. * Helper class dealing with the extraction of spherical polynomial dataArray
  28631. * from a cube map.
  28632. */
  28633. export class CubeMapToSphericalPolynomialTools {
  28634. private static FileFaces;
  28635. /**
  28636. * Converts a texture to the according Spherical Polynomial data.
  28637. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28638. *
  28639. * @param texture The texture to extract the information from.
  28640. * @return The Spherical Polynomial data.
  28641. */
  28642. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28643. /**
  28644. * Converts a cubemap to the according Spherical Polynomial data.
  28645. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28646. *
  28647. * @param cubeInfo The Cube map to extract the information from.
  28648. * @return The Spherical Polynomial data.
  28649. */
  28650. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28651. }
  28652. }
  28653. declare module "babylonjs/Misc/guid" {
  28654. /**
  28655. * Class used to manipulate GUIDs
  28656. */
  28657. export class GUID {
  28658. /**
  28659. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28660. * Be aware Math.random() could cause collisions, but:
  28661. * "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"
  28662. * @returns a pseudo random id
  28663. */
  28664. static RandomId(): string;
  28665. }
  28666. }
  28667. declare module "babylonjs/Materials/Textures/baseTexture" {
  28668. import { Observable } from "babylonjs/Misc/observable";
  28669. import { Nullable } from "babylonjs/types";
  28670. import { Scene } from "babylonjs/scene";
  28671. import { Matrix } from "babylonjs/Maths/math.vector";
  28672. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28673. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28674. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28675. import { ISize } from "babylonjs/Maths/math.size";
  28676. /**
  28677. * Base class of all the textures in babylon.
  28678. * It groups all the common properties the materials, post process, lights... might need
  28679. * in order to make a correct use of the texture.
  28680. */
  28681. export class BaseTexture implements IAnimatable {
  28682. /**
  28683. * Default anisotropic filtering level for the application.
  28684. * It is set to 4 as a good tradeoff between perf and quality.
  28685. */
  28686. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28687. /**
  28688. * Gets or sets the unique id of the texture
  28689. */
  28690. uniqueId: number;
  28691. /**
  28692. * Define the name of the texture.
  28693. */
  28694. name: string;
  28695. /**
  28696. * Gets or sets an object used to store user defined information.
  28697. */
  28698. metadata: any;
  28699. /**
  28700. * For internal use only. Please do not use.
  28701. */
  28702. reservedDataStore: any;
  28703. private _hasAlpha;
  28704. /**
  28705. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28706. */
  28707. hasAlpha: boolean;
  28708. /**
  28709. * Defines if the alpha value should be determined via the rgb values.
  28710. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28711. */
  28712. getAlphaFromRGB: boolean;
  28713. /**
  28714. * Intensity or strength of the texture.
  28715. * It is commonly used by materials to fine tune the intensity of the texture
  28716. */
  28717. level: number;
  28718. /**
  28719. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28720. * This is part of the texture as textures usually maps to one uv set.
  28721. */
  28722. coordinatesIndex: number;
  28723. private _coordinatesMode;
  28724. /**
  28725. * How a texture is mapped.
  28726. *
  28727. * | Value | Type | Description |
  28728. * | ----- | ----------------------------------- | ----------- |
  28729. * | 0 | EXPLICIT_MODE | |
  28730. * | 1 | SPHERICAL_MODE | |
  28731. * | 2 | PLANAR_MODE | |
  28732. * | 3 | CUBIC_MODE | |
  28733. * | 4 | PROJECTION_MODE | |
  28734. * | 5 | SKYBOX_MODE | |
  28735. * | 6 | INVCUBIC_MODE | |
  28736. * | 7 | EQUIRECTANGULAR_MODE | |
  28737. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28738. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28739. */
  28740. coordinatesMode: number;
  28741. /**
  28742. * | Value | Type | Description |
  28743. * | ----- | ------------------ | ----------- |
  28744. * | 0 | CLAMP_ADDRESSMODE | |
  28745. * | 1 | WRAP_ADDRESSMODE | |
  28746. * | 2 | MIRROR_ADDRESSMODE | |
  28747. */
  28748. wrapU: number;
  28749. /**
  28750. * | Value | Type | Description |
  28751. * | ----- | ------------------ | ----------- |
  28752. * | 0 | CLAMP_ADDRESSMODE | |
  28753. * | 1 | WRAP_ADDRESSMODE | |
  28754. * | 2 | MIRROR_ADDRESSMODE | |
  28755. */
  28756. wrapV: number;
  28757. /**
  28758. * | Value | Type | Description |
  28759. * | ----- | ------------------ | ----------- |
  28760. * | 0 | CLAMP_ADDRESSMODE | |
  28761. * | 1 | WRAP_ADDRESSMODE | |
  28762. * | 2 | MIRROR_ADDRESSMODE | |
  28763. */
  28764. wrapR: number;
  28765. /**
  28766. * With compliant hardware and browser (supporting anisotropic filtering)
  28767. * this defines the level of anisotropic filtering in the texture.
  28768. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28769. */
  28770. anisotropicFilteringLevel: number;
  28771. /**
  28772. * Define if the texture is a cube texture or if false a 2d texture.
  28773. */
  28774. isCube: boolean;
  28775. /**
  28776. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28777. */
  28778. is3D: boolean;
  28779. /**
  28780. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28781. * HDR texture are usually stored in linear space.
  28782. * This only impacts the PBR and Background materials
  28783. */
  28784. gammaSpace: boolean;
  28785. /**
  28786. * Gets or sets whether or not the texture contains RGBD data.
  28787. */
  28788. isRGBD: boolean;
  28789. /**
  28790. * Is Z inverted in the texture (useful in a cube texture).
  28791. */
  28792. invertZ: boolean;
  28793. /**
  28794. * Are mip maps generated for this texture or not.
  28795. */
  28796. readonly noMipmap: boolean;
  28797. /**
  28798. * @hidden
  28799. */
  28800. lodLevelInAlpha: boolean;
  28801. /**
  28802. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28803. */
  28804. lodGenerationOffset: number;
  28805. /**
  28806. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28807. */
  28808. lodGenerationScale: number;
  28809. /**
  28810. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28811. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28812. * average roughness values.
  28813. */
  28814. linearSpecularLOD: boolean;
  28815. /**
  28816. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28817. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28818. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28819. */
  28820. irradianceTexture: Nullable<BaseTexture>;
  28821. /**
  28822. * Define if the texture is a render target.
  28823. */
  28824. isRenderTarget: boolean;
  28825. /**
  28826. * Define the unique id of the texture in the scene.
  28827. */
  28828. readonly uid: string;
  28829. /**
  28830. * Return a string representation of the texture.
  28831. * @returns the texture as a string
  28832. */
  28833. toString(): string;
  28834. /**
  28835. * Get the class name of the texture.
  28836. * @returns "BaseTexture"
  28837. */
  28838. getClassName(): string;
  28839. /**
  28840. * Define the list of animation attached to the texture.
  28841. */
  28842. animations: import("babylonjs/Animations/animation").Animation[];
  28843. /**
  28844. * An event triggered when the texture is disposed.
  28845. */
  28846. onDisposeObservable: Observable<BaseTexture>;
  28847. private _onDisposeObserver;
  28848. /**
  28849. * Callback triggered when the texture has been disposed.
  28850. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28851. */
  28852. onDispose: () => void;
  28853. /**
  28854. * Define the current state of the loading sequence when in delayed load mode.
  28855. */
  28856. delayLoadState: number;
  28857. private _scene;
  28858. /** @hidden */
  28859. _texture: Nullable<InternalTexture>;
  28860. private _uid;
  28861. /**
  28862. * Define if the texture is preventinga material to render or not.
  28863. * If not and the texture is not ready, the engine will use a default black texture instead.
  28864. */
  28865. readonly isBlocking: boolean;
  28866. /**
  28867. * Instantiates a new BaseTexture.
  28868. * Base class of all the textures in babylon.
  28869. * It groups all the common properties the materials, post process, lights... might need
  28870. * in order to make a correct use of the texture.
  28871. * @param scene Define the scene the texture blongs to
  28872. */
  28873. constructor(scene: Nullable<Scene>);
  28874. /**
  28875. * Get the scene the texture belongs to.
  28876. * @returns the scene or null if undefined
  28877. */
  28878. getScene(): Nullable<Scene>;
  28879. /**
  28880. * Get the texture transform matrix used to offset tile the texture for istance.
  28881. * @returns the transformation matrix
  28882. */
  28883. getTextureMatrix(): Matrix;
  28884. /**
  28885. * Get the texture reflection matrix used to rotate/transform the reflection.
  28886. * @returns the reflection matrix
  28887. */
  28888. getReflectionTextureMatrix(): Matrix;
  28889. /**
  28890. * Get the underlying lower level texture from Babylon.
  28891. * @returns the insternal texture
  28892. */
  28893. getInternalTexture(): Nullable<InternalTexture>;
  28894. /**
  28895. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28896. * @returns true if ready or not blocking
  28897. */
  28898. isReadyOrNotBlocking(): boolean;
  28899. /**
  28900. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28901. * @returns true if fully ready
  28902. */
  28903. isReady(): boolean;
  28904. private _cachedSize;
  28905. /**
  28906. * Get the size of the texture.
  28907. * @returns the texture size.
  28908. */
  28909. getSize(): ISize;
  28910. /**
  28911. * Get the base size of the texture.
  28912. * It can be different from the size if the texture has been resized for POT for instance
  28913. * @returns the base size
  28914. */
  28915. getBaseSize(): ISize;
  28916. /**
  28917. * Update the sampling mode of the texture.
  28918. * Default is Trilinear mode.
  28919. *
  28920. * | Value | Type | Description |
  28921. * | ----- | ------------------ | ----------- |
  28922. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28923. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28924. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28925. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28926. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28927. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28928. * | 7 | NEAREST_LINEAR | |
  28929. * | 8 | NEAREST_NEAREST | |
  28930. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28931. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28932. * | 11 | LINEAR_LINEAR | |
  28933. * | 12 | LINEAR_NEAREST | |
  28934. *
  28935. * > _mag_: magnification filter (close to the viewer)
  28936. * > _min_: minification filter (far from the viewer)
  28937. * > _mip_: filter used between mip map levels
  28938. *@param samplingMode Define the new sampling mode of the texture
  28939. */
  28940. updateSamplingMode(samplingMode: number): void;
  28941. /**
  28942. * Scales the texture if is `canRescale()`
  28943. * @param ratio the resize factor we want to use to rescale
  28944. */
  28945. scale(ratio: number): void;
  28946. /**
  28947. * Get if the texture can rescale.
  28948. */
  28949. readonly canRescale: boolean;
  28950. /** @hidden */
  28951. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28952. /** @hidden */
  28953. _rebuild(): void;
  28954. /**
  28955. * Triggers the load sequence in delayed load mode.
  28956. */
  28957. delayLoad(): void;
  28958. /**
  28959. * Clones the texture.
  28960. * @returns the cloned texture
  28961. */
  28962. clone(): Nullable<BaseTexture>;
  28963. /**
  28964. * Get the texture underlying type (INT, FLOAT...)
  28965. */
  28966. readonly textureType: number;
  28967. /**
  28968. * Get the texture underlying format (RGB, RGBA...)
  28969. */
  28970. readonly textureFormat: number;
  28971. /**
  28972. * Indicates that textures need to be re-calculated for all materials
  28973. */
  28974. protected _markAllSubMeshesAsTexturesDirty(): void;
  28975. /**
  28976. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28977. * This will returns an RGBA array buffer containing either in values (0-255) or
  28978. * float values (0-1) depending of the underlying buffer type.
  28979. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28980. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28981. * @param buffer defines a user defined buffer to fill with data (can be null)
  28982. * @returns The Array buffer containing the pixels data.
  28983. */
  28984. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28985. /**
  28986. * Release and destroy the underlying lower level texture aka internalTexture.
  28987. */
  28988. releaseInternalTexture(): void;
  28989. /**
  28990. * Get the polynomial representation of the texture data.
  28991. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28992. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28993. */
  28994. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28995. /** @hidden */
  28996. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28997. /** @hidden */
  28998. readonly _lodTextureMid: Nullable<BaseTexture>;
  28999. /** @hidden */
  29000. readonly _lodTextureLow: Nullable<BaseTexture>;
  29001. /**
  29002. * Dispose the texture and release its associated resources.
  29003. */
  29004. dispose(): void;
  29005. /**
  29006. * Serialize the texture into a JSON representation that can be parsed later on.
  29007. * @returns the JSON representation of the texture
  29008. */
  29009. serialize(): any;
  29010. /**
  29011. * Helper function to be called back once a list of texture contains only ready textures.
  29012. * @param textures Define the list of textures to wait for
  29013. * @param callback Define the callback triggered once the entire list will be ready
  29014. */
  29015. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29016. }
  29017. }
  29018. declare module "babylonjs/Materials/effect" {
  29019. import { Observable } from "babylonjs/Misc/observable";
  29020. import { Nullable } from "babylonjs/types";
  29021. import { IDisposable } from "babylonjs/scene";
  29022. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29023. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29024. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29025. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29026. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29027. import { Engine } from "babylonjs/Engines/engine";
  29028. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29029. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29030. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29031. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29032. /**
  29033. * Options to be used when creating an effect.
  29034. */
  29035. export class EffectCreationOptions {
  29036. /**
  29037. * Atrributes that will be used in the shader.
  29038. */
  29039. attributes: string[];
  29040. /**
  29041. * Uniform varible names that will be set in the shader.
  29042. */
  29043. uniformsNames: string[];
  29044. /**
  29045. * Uniform buffer varible names that will be set in the shader.
  29046. */
  29047. uniformBuffersNames: string[];
  29048. /**
  29049. * Sampler texture variable names that will be set in the shader.
  29050. */
  29051. samplers: string[];
  29052. /**
  29053. * Define statements that will be set in the shader.
  29054. */
  29055. defines: any;
  29056. /**
  29057. * Possible fallbacks for this effect to improve performance when needed.
  29058. */
  29059. fallbacks: Nullable<IEffectFallbacks>;
  29060. /**
  29061. * Callback that will be called when the shader is compiled.
  29062. */
  29063. onCompiled: Nullable<(effect: Effect) => void>;
  29064. /**
  29065. * Callback that will be called if an error occurs during shader compilation.
  29066. */
  29067. onError: Nullable<(effect: Effect, errors: string) => void>;
  29068. /**
  29069. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29070. */
  29071. indexParameters?: any;
  29072. /**
  29073. * Max number of lights that can be used in the shader.
  29074. */
  29075. maxSimultaneousLights?: number;
  29076. /**
  29077. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29078. */
  29079. transformFeedbackVaryings?: Nullable<string[]>;
  29080. }
  29081. /**
  29082. * Effect containing vertex and fragment shader that can be executed on an object.
  29083. */
  29084. export class Effect implements IDisposable {
  29085. /**
  29086. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29087. */
  29088. static ShadersRepository: string;
  29089. /**
  29090. * Name of the effect.
  29091. */
  29092. name: any;
  29093. /**
  29094. * String container all the define statements that should be set on the shader.
  29095. */
  29096. defines: string;
  29097. /**
  29098. * Callback that will be called when the shader is compiled.
  29099. */
  29100. onCompiled: Nullable<(effect: Effect) => void>;
  29101. /**
  29102. * Callback that will be called if an error occurs during shader compilation.
  29103. */
  29104. onError: Nullable<(effect: Effect, errors: string) => void>;
  29105. /**
  29106. * Callback that will be called when effect is bound.
  29107. */
  29108. onBind: Nullable<(effect: Effect) => void>;
  29109. /**
  29110. * Unique ID of the effect.
  29111. */
  29112. uniqueId: number;
  29113. /**
  29114. * Observable that will be called when the shader is compiled.
  29115. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29116. */
  29117. onCompileObservable: Observable<Effect>;
  29118. /**
  29119. * Observable that will be called if an error occurs during shader compilation.
  29120. */
  29121. onErrorObservable: Observable<Effect>;
  29122. /** @hidden */
  29123. _onBindObservable: Nullable<Observable<Effect>>;
  29124. /**
  29125. * Observable that will be called when effect is bound.
  29126. */
  29127. readonly onBindObservable: Observable<Effect>;
  29128. /** @hidden */
  29129. _bonesComputationForcedToCPU: boolean;
  29130. private static _uniqueIdSeed;
  29131. private _engine;
  29132. private _uniformBuffersNames;
  29133. private _uniformsNames;
  29134. private _samplerList;
  29135. private _samplers;
  29136. private _isReady;
  29137. private _compilationError;
  29138. private _attributesNames;
  29139. private _attributes;
  29140. private _uniforms;
  29141. /**
  29142. * Key for the effect.
  29143. * @hidden
  29144. */
  29145. _key: string;
  29146. private _indexParameters;
  29147. private _fallbacks;
  29148. private _vertexSourceCode;
  29149. private _fragmentSourceCode;
  29150. private _vertexSourceCodeOverride;
  29151. private _fragmentSourceCodeOverride;
  29152. private _transformFeedbackVaryings;
  29153. /**
  29154. * Compiled shader to webGL program.
  29155. * @hidden
  29156. */
  29157. _pipelineContext: Nullable<IPipelineContext>;
  29158. private _valueCache;
  29159. private static _baseCache;
  29160. /**
  29161. * Instantiates an effect.
  29162. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29163. * @param baseName Name of the effect.
  29164. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29165. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29166. * @param samplers List of sampler variables that will be passed to the shader.
  29167. * @param engine Engine to be used to render the effect
  29168. * @param defines Define statements to be added to the shader.
  29169. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29170. * @param onCompiled Callback that will be called when the shader is compiled.
  29171. * @param onError Callback that will be called if an error occurs during shader compilation.
  29172. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29173. */
  29174. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  29175. private _useFinalCode;
  29176. /**
  29177. * Unique key for this effect
  29178. */
  29179. readonly key: string;
  29180. /**
  29181. * If the effect has been compiled and prepared.
  29182. * @returns if the effect is compiled and prepared.
  29183. */
  29184. isReady(): boolean;
  29185. private _isReadyInternal;
  29186. /**
  29187. * The engine the effect was initialized with.
  29188. * @returns the engine.
  29189. */
  29190. getEngine(): Engine;
  29191. /**
  29192. * The pipeline context for this effect
  29193. * @returns the associated pipeline context
  29194. */
  29195. getPipelineContext(): Nullable<IPipelineContext>;
  29196. /**
  29197. * The set of names of attribute variables for the shader.
  29198. * @returns An array of attribute names.
  29199. */
  29200. getAttributesNames(): string[];
  29201. /**
  29202. * Returns the attribute at the given index.
  29203. * @param index The index of the attribute.
  29204. * @returns The location of the attribute.
  29205. */
  29206. getAttributeLocation(index: number): number;
  29207. /**
  29208. * Returns the attribute based on the name of the variable.
  29209. * @param name of the attribute to look up.
  29210. * @returns the attribute location.
  29211. */
  29212. getAttributeLocationByName(name: string): number;
  29213. /**
  29214. * The number of attributes.
  29215. * @returns the numnber of attributes.
  29216. */
  29217. getAttributesCount(): number;
  29218. /**
  29219. * Gets the index of a uniform variable.
  29220. * @param uniformName of the uniform to look up.
  29221. * @returns the index.
  29222. */
  29223. getUniformIndex(uniformName: string): number;
  29224. /**
  29225. * Returns the attribute based on the name of the variable.
  29226. * @param uniformName of the uniform to look up.
  29227. * @returns the location of the uniform.
  29228. */
  29229. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29230. /**
  29231. * Returns an array of sampler variable names
  29232. * @returns The array of sampler variable neames.
  29233. */
  29234. getSamplers(): string[];
  29235. /**
  29236. * The error from the last compilation.
  29237. * @returns the error string.
  29238. */
  29239. getCompilationError(): string;
  29240. /**
  29241. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29242. * @param func The callback to be used.
  29243. */
  29244. executeWhenCompiled(func: (effect: Effect) => void): void;
  29245. private _checkIsReady;
  29246. /** @hidden */
  29247. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29248. /** @hidden */
  29249. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29250. /** @hidden */
  29251. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29252. /**
  29253. * Recompiles the webGL program
  29254. * @param vertexSourceCode The source code for the vertex shader.
  29255. * @param fragmentSourceCode The source code for the fragment shader.
  29256. * @param onCompiled Callback called when completed.
  29257. * @param onError Callback called on error.
  29258. * @hidden
  29259. */
  29260. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29261. /**
  29262. * Prepares the effect
  29263. * @hidden
  29264. */
  29265. _prepareEffect(): void;
  29266. private _processCompilationErrors;
  29267. /**
  29268. * Checks if the effect is supported. (Must be called after compilation)
  29269. */
  29270. readonly isSupported: boolean;
  29271. /**
  29272. * Binds a texture to the engine to be used as output of the shader.
  29273. * @param channel Name of the output variable.
  29274. * @param texture Texture to bind.
  29275. * @hidden
  29276. */
  29277. _bindTexture(channel: string, texture: InternalTexture): void;
  29278. /**
  29279. * Sets a texture on the engine to be used in the shader.
  29280. * @param channel Name of the sampler variable.
  29281. * @param texture Texture to set.
  29282. */
  29283. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29284. /**
  29285. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29286. * @param channel Name of the sampler variable.
  29287. * @param texture Texture to set.
  29288. */
  29289. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29290. /**
  29291. * Sets an array of textures on the engine to be used in the shader.
  29292. * @param channel Name of the variable.
  29293. * @param textures Textures to set.
  29294. */
  29295. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29296. /**
  29297. * 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)
  29298. * @param channel Name of the sampler variable.
  29299. * @param postProcess Post process to get the input texture from.
  29300. */
  29301. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29302. /**
  29303. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29304. * 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)
  29305. * @param channel Name of the sampler variable.
  29306. * @param postProcess Post process to get the output texture from.
  29307. */
  29308. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29309. /** @hidden */
  29310. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29311. /** @hidden */
  29312. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29313. /** @hidden */
  29314. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29315. /** @hidden */
  29316. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29317. /**
  29318. * Binds a buffer to a uniform.
  29319. * @param buffer Buffer to bind.
  29320. * @param name Name of the uniform variable to bind to.
  29321. */
  29322. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29323. /**
  29324. * Binds block to a uniform.
  29325. * @param blockName Name of the block to bind.
  29326. * @param index Index to bind.
  29327. */
  29328. bindUniformBlock(blockName: string, index: number): void;
  29329. /**
  29330. * Sets an interger value on a uniform variable.
  29331. * @param uniformName Name of the variable.
  29332. * @param value Value to be set.
  29333. * @returns this effect.
  29334. */
  29335. setInt(uniformName: string, value: number): Effect;
  29336. /**
  29337. * Sets an int array on a uniform variable.
  29338. * @param uniformName Name of the variable.
  29339. * @param array array to be set.
  29340. * @returns this effect.
  29341. */
  29342. setIntArray(uniformName: string, array: Int32Array): Effect;
  29343. /**
  29344. * 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)
  29345. * @param uniformName Name of the variable.
  29346. * @param array array to be set.
  29347. * @returns this effect.
  29348. */
  29349. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29350. /**
  29351. * 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)
  29352. * @param uniformName Name of the variable.
  29353. * @param array array to be set.
  29354. * @returns this effect.
  29355. */
  29356. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29357. /**
  29358. * 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)
  29359. * @param uniformName Name of the variable.
  29360. * @param array array to be set.
  29361. * @returns this effect.
  29362. */
  29363. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29364. /**
  29365. * Sets an float array on a uniform variable.
  29366. * @param uniformName Name of the variable.
  29367. * @param array array to be set.
  29368. * @returns this effect.
  29369. */
  29370. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29371. /**
  29372. * 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)
  29373. * @param uniformName Name of the variable.
  29374. * @param array array to be set.
  29375. * @returns this effect.
  29376. */
  29377. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29378. /**
  29379. * 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)
  29380. * @param uniformName Name of the variable.
  29381. * @param array array to be set.
  29382. * @returns this effect.
  29383. */
  29384. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29385. /**
  29386. * 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)
  29387. * @param uniformName Name of the variable.
  29388. * @param array array to be set.
  29389. * @returns this effect.
  29390. */
  29391. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29392. /**
  29393. * Sets an array on a uniform variable.
  29394. * @param uniformName Name of the variable.
  29395. * @param array array to be set.
  29396. * @returns this effect.
  29397. */
  29398. setArray(uniformName: string, array: number[]): Effect;
  29399. /**
  29400. * 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)
  29401. * @param uniformName Name of the variable.
  29402. * @param array array to be set.
  29403. * @returns this effect.
  29404. */
  29405. setArray2(uniformName: string, array: number[]): Effect;
  29406. /**
  29407. * 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)
  29408. * @param uniformName Name of the variable.
  29409. * @param array array to be set.
  29410. * @returns this effect.
  29411. */
  29412. setArray3(uniformName: string, array: number[]): Effect;
  29413. /**
  29414. * 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)
  29415. * @param uniformName Name of the variable.
  29416. * @param array array to be set.
  29417. * @returns this effect.
  29418. */
  29419. setArray4(uniformName: string, array: number[]): Effect;
  29420. /**
  29421. * Sets matrices on a uniform variable.
  29422. * @param uniformName Name of the variable.
  29423. * @param matrices matrices to be set.
  29424. * @returns this effect.
  29425. */
  29426. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29427. /**
  29428. * Sets matrix on a uniform variable.
  29429. * @param uniformName Name of the variable.
  29430. * @param matrix matrix to be set.
  29431. * @returns this effect.
  29432. */
  29433. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29434. /**
  29435. * 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)
  29436. * @param uniformName Name of the variable.
  29437. * @param matrix matrix to be set.
  29438. * @returns this effect.
  29439. */
  29440. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29441. /**
  29442. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29443. * @param uniformName Name of the variable.
  29444. * @param matrix matrix to be set.
  29445. * @returns this effect.
  29446. */
  29447. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29448. /**
  29449. * Sets a float on a uniform variable.
  29450. * @param uniformName Name of the variable.
  29451. * @param value value to be set.
  29452. * @returns this effect.
  29453. */
  29454. setFloat(uniformName: string, value: number): Effect;
  29455. /**
  29456. * Sets a boolean on a uniform variable.
  29457. * @param uniformName Name of the variable.
  29458. * @param bool value to be set.
  29459. * @returns this effect.
  29460. */
  29461. setBool(uniformName: string, bool: boolean): Effect;
  29462. /**
  29463. * Sets a Vector2 on a uniform variable.
  29464. * @param uniformName Name of the variable.
  29465. * @param vector2 vector2 to be set.
  29466. * @returns this effect.
  29467. */
  29468. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29469. /**
  29470. * Sets a float2 on a uniform variable.
  29471. * @param uniformName Name of the variable.
  29472. * @param x First float in float2.
  29473. * @param y Second float in float2.
  29474. * @returns this effect.
  29475. */
  29476. setFloat2(uniformName: string, x: number, y: number): Effect;
  29477. /**
  29478. * Sets a Vector3 on a uniform variable.
  29479. * @param uniformName Name of the variable.
  29480. * @param vector3 Value to be set.
  29481. * @returns this effect.
  29482. */
  29483. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29484. /**
  29485. * Sets a float3 on a uniform variable.
  29486. * @param uniformName Name of the variable.
  29487. * @param x First float in float3.
  29488. * @param y Second float in float3.
  29489. * @param z Third float in float3.
  29490. * @returns this effect.
  29491. */
  29492. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29493. /**
  29494. * Sets a Vector4 on a uniform variable.
  29495. * @param uniformName Name of the variable.
  29496. * @param vector4 Value to be set.
  29497. * @returns this effect.
  29498. */
  29499. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29500. /**
  29501. * Sets a float4 on a uniform variable.
  29502. * @param uniformName Name of the variable.
  29503. * @param x First float in float4.
  29504. * @param y Second float in float4.
  29505. * @param z Third float in float4.
  29506. * @param w Fourth float in float4.
  29507. * @returns this effect.
  29508. */
  29509. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29510. /**
  29511. * Sets a Color3 on a uniform variable.
  29512. * @param uniformName Name of the variable.
  29513. * @param color3 Value to be set.
  29514. * @returns this effect.
  29515. */
  29516. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29517. /**
  29518. * Sets a Color4 on a uniform variable.
  29519. * @param uniformName Name of the variable.
  29520. * @param color3 Value to be set.
  29521. * @param alpha Alpha value to be set.
  29522. * @returns this effect.
  29523. */
  29524. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29525. /**
  29526. * Sets a Color4 on a uniform variable
  29527. * @param uniformName defines the name of the variable
  29528. * @param color4 defines the value to be set
  29529. * @returns this effect.
  29530. */
  29531. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29532. /** Release all associated resources */
  29533. dispose(): void;
  29534. /**
  29535. * This function will add a new shader to the shader store
  29536. * @param name the name of the shader
  29537. * @param pixelShader optional pixel shader content
  29538. * @param vertexShader optional vertex shader content
  29539. */
  29540. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29541. /**
  29542. * Store of each shader (The can be looked up using effect.key)
  29543. */
  29544. static ShadersStore: {
  29545. [key: string]: string;
  29546. };
  29547. /**
  29548. * Store of each included file for a shader (The can be looked up using effect.key)
  29549. */
  29550. static IncludesShadersStore: {
  29551. [key: string]: string;
  29552. };
  29553. /**
  29554. * Resets the cache of effects.
  29555. */
  29556. static ResetCache(): void;
  29557. }
  29558. }
  29559. declare module "babylonjs/Engines/engineCapabilities" {
  29560. import { Nullable } from "babylonjs/types";
  29561. /**
  29562. * Class used to describe the capabilities of the engine relatively to the current browser
  29563. */
  29564. export class EngineCapabilities {
  29565. /** Maximum textures units per fragment shader */
  29566. maxTexturesImageUnits: number;
  29567. /** Maximum texture units per vertex shader */
  29568. maxVertexTextureImageUnits: number;
  29569. /** Maximum textures units in the entire pipeline */
  29570. maxCombinedTexturesImageUnits: number;
  29571. /** Maximum texture size */
  29572. maxTextureSize: number;
  29573. /** Maximum cube texture size */
  29574. maxCubemapTextureSize: number;
  29575. /** Maximum render texture size */
  29576. maxRenderTextureSize: number;
  29577. /** Maximum number of vertex attributes */
  29578. maxVertexAttribs: number;
  29579. /** Maximum number of varyings */
  29580. maxVaryingVectors: number;
  29581. /** Maximum number of uniforms per vertex shader */
  29582. maxVertexUniformVectors: number;
  29583. /** Maximum number of uniforms per fragment shader */
  29584. maxFragmentUniformVectors: number;
  29585. /** Defines if standard derivates (dx/dy) are supported */
  29586. standardDerivatives: boolean;
  29587. /** Defines if s3tc texture compression is supported */
  29588. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29589. /** Defines if pvrtc texture compression is supported */
  29590. pvrtc: any;
  29591. /** Defines if etc1 texture compression is supported */
  29592. etc1: any;
  29593. /** Defines if etc2 texture compression is supported */
  29594. etc2: any;
  29595. /** Defines if astc texture compression is supported */
  29596. astc: any;
  29597. /** Defines if float textures are supported */
  29598. textureFloat: boolean;
  29599. /** Defines if vertex array objects are supported */
  29600. vertexArrayObject: boolean;
  29601. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29602. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29603. /** Gets the maximum level of anisotropy supported */
  29604. maxAnisotropy: number;
  29605. /** Defines if instancing is supported */
  29606. instancedArrays: boolean;
  29607. /** Defines if 32 bits indices are supported */
  29608. uintIndices: boolean;
  29609. /** Defines if high precision shaders are supported */
  29610. highPrecisionShaderSupported: boolean;
  29611. /** Defines if depth reading in the fragment shader is supported */
  29612. fragmentDepthSupported: boolean;
  29613. /** Defines if float texture linear filtering is supported*/
  29614. textureFloatLinearFiltering: boolean;
  29615. /** Defines if rendering to float textures is supported */
  29616. textureFloatRender: boolean;
  29617. /** Defines if half float textures are supported*/
  29618. textureHalfFloat: boolean;
  29619. /** Defines if half float texture linear filtering is supported*/
  29620. textureHalfFloatLinearFiltering: boolean;
  29621. /** Defines if rendering to half float textures is supported */
  29622. textureHalfFloatRender: boolean;
  29623. /** Defines if textureLOD shader command is supported */
  29624. textureLOD: boolean;
  29625. /** Defines if draw buffers extension is supported */
  29626. drawBuffersExtension: boolean;
  29627. /** Defines if depth textures are supported */
  29628. depthTextureExtension: boolean;
  29629. /** Defines if float color buffer are supported */
  29630. colorBufferFloat: boolean;
  29631. /** Gets disjoint timer query extension (null if not supported) */
  29632. timerQuery: EXT_disjoint_timer_query;
  29633. /** Defines if timestamp can be used with timer query */
  29634. canUseTimestampForTimerQuery: boolean;
  29635. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29636. multiview: any;
  29637. /** Function used to let the system compiles shaders in background */
  29638. parallelShaderCompile: {
  29639. COMPLETION_STATUS_KHR: number;
  29640. };
  29641. /** Max number of texture samples for MSAA */
  29642. maxMSAASamples: number;
  29643. /** Defines if the blend min max extension is supported */
  29644. blendMinMax: boolean;
  29645. }
  29646. }
  29647. declare module "babylonjs/Misc/perfCounter" {
  29648. /**
  29649. * This class is used to track a performance counter which is number based.
  29650. * The user has access to many properties which give statistics of different nature.
  29651. *
  29652. * The implementer can track two kinds of Performance Counter: time and count.
  29653. * 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.
  29654. * 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.
  29655. */
  29656. export class PerfCounter {
  29657. /**
  29658. * Gets or sets a global boolean to turn on and off all the counters
  29659. */
  29660. static Enabled: boolean;
  29661. /**
  29662. * Returns the smallest value ever
  29663. */
  29664. readonly min: number;
  29665. /**
  29666. * Returns the biggest value ever
  29667. */
  29668. readonly max: number;
  29669. /**
  29670. * Returns the average value since the performance counter is running
  29671. */
  29672. readonly average: number;
  29673. /**
  29674. * Returns the average value of the last second the counter was monitored
  29675. */
  29676. readonly lastSecAverage: number;
  29677. /**
  29678. * Returns the current value
  29679. */
  29680. readonly current: number;
  29681. /**
  29682. * Gets the accumulated total
  29683. */
  29684. readonly total: number;
  29685. /**
  29686. * Gets the total value count
  29687. */
  29688. readonly count: number;
  29689. /**
  29690. * Creates a new counter
  29691. */
  29692. constructor();
  29693. /**
  29694. * Call this method to start monitoring a new frame.
  29695. * 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.
  29696. */
  29697. fetchNewFrame(): void;
  29698. /**
  29699. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  29700. * @param newCount the count value to add to the monitored count
  29701. * @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.
  29702. */
  29703. addCount(newCount: number, fetchResult: boolean): void;
  29704. /**
  29705. * Start monitoring this performance counter
  29706. */
  29707. beginMonitoring(): void;
  29708. /**
  29709. * Compute the time lapsed since the previous beginMonitoring() call.
  29710. * @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
  29711. */
  29712. endMonitoring(newFrame?: boolean): void;
  29713. private _fetchResult;
  29714. private _startMonitoringTime;
  29715. private _min;
  29716. private _max;
  29717. private _average;
  29718. private _current;
  29719. private _totalValueCount;
  29720. private _totalAccumulated;
  29721. private _lastSecAverage;
  29722. private _lastSecAccumulated;
  29723. private _lastSecTime;
  29724. private _lastSecValueCount;
  29725. }
  29726. }
  29727. declare module "babylonjs/States/depthCullingState" {
  29728. import { Nullable } from "babylonjs/types";
  29729. /**
  29730. * @hidden
  29731. **/
  29732. export class DepthCullingState {
  29733. private _isDepthTestDirty;
  29734. private _isDepthMaskDirty;
  29735. private _isDepthFuncDirty;
  29736. private _isCullFaceDirty;
  29737. private _isCullDirty;
  29738. private _isZOffsetDirty;
  29739. private _isFrontFaceDirty;
  29740. private _depthTest;
  29741. private _depthMask;
  29742. private _depthFunc;
  29743. private _cull;
  29744. private _cullFace;
  29745. private _zOffset;
  29746. private _frontFace;
  29747. /**
  29748. * Initializes the state.
  29749. */
  29750. constructor();
  29751. readonly isDirty: boolean;
  29752. zOffset: number;
  29753. cullFace: Nullable<number>;
  29754. cull: Nullable<boolean>;
  29755. depthFunc: Nullable<number>;
  29756. depthMask: boolean;
  29757. depthTest: boolean;
  29758. frontFace: Nullable<number>;
  29759. reset(): void;
  29760. apply(gl: WebGLRenderingContext): void;
  29761. }
  29762. }
  29763. declare module "babylonjs/States/stencilState" {
  29764. /**
  29765. * @hidden
  29766. **/
  29767. export class StencilState {
  29768. /** 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 */
  29769. static readonly ALWAYS: number;
  29770. /** Passed to stencilOperation to specify that stencil value must be kept */
  29771. static readonly KEEP: number;
  29772. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29773. static readonly REPLACE: number;
  29774. private _isStencilTestDirty;
  29775. private _isStencilMaskDirty;
  29776. private _isStencilFuncDirty;
  29777. private _isStencilOpDirty;
  29778. private _stencilTest;
  29779. private _stencilMask;
  29780. private _stencilFunc;
  29781. private _stencilFuncRef;
  29782. private _stencilFuncMask;
  29783. private _stencilOpStencilFail;
  29784. private _stencilOpDepthFail;
  29785. private _stencilOpStencilDepthPass;
  29786. readonly isDirty: boolean;
  29787. stencilFunc: number;
  29788. stencilFuncRef: number;
  29789. stencilFuncMask: number;
  29790. stencilOpStencilFail: number;
  29791. stencilOpDepthFail: number;
  29792. stencilOpStencilDepthPass: number;
  29793. stencilMask: number;
  29794. stencilTest: boolean;
  29795. constructor();
  29796. reset(): void;
  29797. apply(gl: WebGLRenderingContext): void;
  29798. }
  29799. }
  29800. declare module "babylonjs/States/alphaCullingState" {
  29801. /**
  29802. * @hidden
  29803. **/
  29804. export class AlphaState {
  29805. private _isAlphaBlendDirty;
  29806. private _isBlendFunctionParametersDirty;
  29807. private _isBlendEquationParametersDirty;
  29808. private _isBlendConstantsDirty;
  29809. private _alphaBlend;
  29810. private _blendFunctionParameters;
  29811. private _blendEquationParameters;
  29812. private _blendConstants;
  29813. /**
  29814. * Initializes the state.
  29815. */
  29816. constructor();
  29817. readonly isDirty: boolean;
  29818. alphaBlend: boolean;
  29819. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29820. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29821. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29822. reset(): void;
  29823. apply(gl: WebGLRenderingContext): void;
  29824. }
  29825. }
  29826. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29827. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29828. /** @hidden */
  29829. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29830. attributeProcessor(attribute: string): string;
  29831. varyingProcessor(varying: string, isFragment: boolean): string;
  29832. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29833. }
  29834. }
  29835. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29836. /**
  29837. * Interface for attribute information associated with buffer instanciation
  29838. */
  29839. export class InstancingAttributeInfo {
  29840. /**
  29841. * Index/offset of the attribute in the vertex shader
  29842. */
  29843. index: number;
  29844. /**
  29845. * size of the attribute, 1, 2, 3 or 4
  29846. */
  29847. attributeSize: number;
  29848. /**
  29849. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29850. * default is FLOAT
  29851. */
  29852. attribyteType: number;
  29853. /**
  29854. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29855. */
  29856. normalized: boolean;
  29857. /**
  29858. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29859. */
  29860. offset: number;
  29861. /**
  29862. * Name of the GLSL attribute, for debugging purpose only
  29863. */
  29864. attributeName: string;
  29865. }
  29866. }
  29867. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29868. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29869. import { Nullable } from "babylonjs/types";
  29870. module "babylonjs/Engines/thinEngine" {
  29871. interface ThinEngine {
  29872. /**
  29873. * Update a video texture
  29874. * @param texture defines the texture to update
  29875. * @param video defines the video element to use
  29876. * @param invertY defines if data must be stored with Y axis inverted
  29877. */
  29878. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29879. }
  29880. }
  29881. }
  29882. declare module "babylonjs/Materials/Textures/videoTexture" {
  29883. import { Observable } from "babylonjs/Misc/observable";
  29884. import { Nullable } from "babylonjs/types";
  29885. import { Scene } from "babylonjs/scene";
  29886. import { Texture } from "babylonjs/Materials/Textures/texture";
  29887. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29888. /**
  29889. * Settings for finer control over video usage
  29890. */
  29891. export interface VideoTextureSettings {
  29892. /**
  29893. * Applies `autoplay` to video, if specified
  29894. */
  29895. autoPlay?: boolean;
  29896. /**
  29897. * Applies `loop` to video, if specified
  29898. */
  29899. loop?: boolean;
  29900. /**
  29901. * Automatically updates internal texture from video at every frame in the render loop
  29902. */
  29903. autoUpdateTexture: boolean;
  29904. /**
  29905. * Image src displayed during the video loading or until the user interacts with the video.
  29906. */
  29907. poster?: string;
  29908. }
  29909. /**
  29910. * If you want to display a video in your scene, this is the special texture for that.
  29911. * This special texture works similar to other textures, with the exception of a few parameters.
  29912. * @see https://doc.babylonjs.com/how_to/video_texture
  29913. */
  29914. export class VideoTexture extends Texture {
  29915. /**
  29916. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29917. */
  29918. readonly autoUpdateTexture: boolean;
  29919. /**
  29920. * The video instance used by the texture internally
  29921. */
  29922. readonly video: HTMLVideoElement;
  29923. private _onUserActionRequestedObservable;
  29924. /**
  29925. * Event triggerd when a dom action is required by the user to play the video.
  29926. * This happens due to recent changes in browser policies preventing video to auto start.
  29927. */
  29928. readonly onUserActionRequestedObservable: Observable<Texture>;
  29929. private _generateMipMaps;
  29930. private _engine;
  29931. private _stillImageCaptured;
  29932. private _displayingPosterTexture;
  29933. private _settings;
  29934. private _createInternalTextureOnEvent;
  29935. private _frameId;
  29936. /**
  29937. * Creates a video texture.
  29938. * If you want to display a video in your scene, this is the special texture for that.
  29939. * This special texture works similar to other textures, with the exception of a few parameters.
  29940. * @see https://doc.babylonjs.com/how_to/video_texture
  29941. * @param name optional name, will detect from video source, if not defined
  29942. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29943. * @param scene is obviously the current scene.
  29944. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29945. * @param invertY is false by default but can be used to invert video on Y axis
  29946. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29947. * @param settings allows finer control over video usage
  29948. */
  29949. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29950. private _getName;
  29951. private _getVideo;
  29952. private _createInternalTexture;
  29953. private reset;
  29954. /**
  29955. * @hidden Internal method to initiate `update`.
  29956. */
  29957. _rebuild(): void;
  29958. /**
  29959. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29960. */
  29961. update(): void;
  29962. /**
  29963. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29964. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29965. */
  29966. updateTexture(isVisible: boolean): void;
  29967. protected _updateInternalTexture: () => void;
  29968. /**
  29969. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29970. * @param url New url.
  29971. */
  29972. updateURL(url: string): void;
  29973. /**
  29974. * Dispose the texture and release its associated resources.
  29975. */
  29976. dispose(): void;
  29977. /**
  29978. * Creates a video texture straight from a stream.
  29979. * @param scene Define the scene the texture should be created in
  29980. * @param stream Define the stream the texture should be created from
  29981. * @returns The created video texture as a promise
  29982. */
  29983. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29984. /**
  29985. * Creates a video texture straight from your WebCam video feed.
  29986. * @param scene Define the scene the texture should be created in
  29987. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29988. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29989. * @returns The created video texture as a promise
  29990. */
  29991. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29992. minWidth: number;
  29993. maxWidth: number;
  29994. minHeight: number;
  29995. maxHeight: number;
  29996. deviceId: string;
  29997. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29998. /**
  29999. * Creates a video texture straight from your WebCam video feed.
  30000. * @param scene Define the scene the texture should be created in
  30001. * @param onReady Define a callback to triggered once the texture will be ready
  30002. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30003. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30004. */
  30005. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30006. minWidth: number;
  30007. maxWidth: number;
  30008. minHeight: number;
  30009. maxHeight: number;
  30010. deviceId: string;
  30011. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30012. }
  30013. }
  30014. declare module "babylonjs/Engines/thinEngine" {
  30015. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30016. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  30017. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30018. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30019. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  30020. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  30021. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30022. import { Observable } from "babylonjs/Misc/observable";
  30023. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  30024. import { StencilState } from "babylonjs/States/stencilState";
  30025. import { AlphaState } from "babylonjs/States/alphaCullingState";
  30026. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30027. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30028. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30029. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30030. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30031. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30032. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30033. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  30034. import { WebRequest } from "babylonjs/Misc/webRequest";
  30035. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  30036. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30037. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30038. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30039. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30040. /**
  30041. * Defines the interface used by objects working like Scene
  30042. * @hidden
  30043. */
  30044. interface ISceneLike {
  30045. _addPendingData(data: any): void;
  30046. _removePendingData(data: any): void;
  30047. offlineProvider: IOfflineProvider;
  30048. }
  30049. /** Interface defining initialization parameters for Engine class */
  30050. export interface EngineOptions extends WebGLContextAttributes {
  30051. /**
  30052. * Defines if the engine should no exceed a specified device ratio
  30053. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30054. */
  30055. limitDeviceRatio?: number;
  30056. /**
  30057. * Defines if webvr should be enabled automatically
  30058. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30059. */
  30060. autoEnableWebVR?: boolean;
  30061. /**
  30062. * Defines if webgl2 should be turned off even if supported
  30063. * @see http://doc.babylonjs.com/features/webgl2
  30064. */
  30065. disableWebGL2Support?: boolean;
  30066. /**
  30067. * Defines if webaudio should be initialized as well
  30068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30069. */
  30070. audioEngine?: boolean;
  30071. /**
  30072. * Defines if animations should run using a deterministic lock step
  30073. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30074. */
  30075. deterministicLockstep?: boolean;
  30076. /** Defines the maximum steps to use with deterministic lock step mode */
  30077. lockstepMaxSteps?: number;
  30078. /**
  30079. * Defines that engine should ignore context lost events
  30080. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30081. */
  30082. doNotHandleContextLost?: boolean;
  30083. /**
  30084. * Defines that engine should ignore modifying touch action attribute and style
  30085. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30086. */
  30087. doNotHandleTouchAction?: boolean;
  30088. /**
  30089. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30090. */
  30091. useHighPrecisionFloats?: boolean;
  30092. }
  30093. /**
  30094. * The base engine class (root of all engines)
  30095. */
  30096. export class ThinEngine {
  30097. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30098. static ExceptionList: ({
  30099. key: string;
  30100. capture: string;
  30101. captureConstraint: number;
  30102. targets: string[];
  30103. } | {
  30104. key: string;
  30105. capture: null;
  30106. captureConstraint: null;
  30107. targets: string[];
  30108. })[];
  30109. /** @hidden */
  30110. static _TextureLoaders: IInternalTextureLoader[];
  30111. /**
  30112. * Returns the current npm package of the sdk
  30113. */
  30114. static readonly NpmPackage: string;
  30115. /**
  30116. * Returns the current version of the framework
  30117. */
  30118. static readonly Version: string;
  30119. /**
  30120. * Returns a string describing the current engine
  30121. */
  30122. readonly description: string;
  30123. /**
  30124. * Gets or sets the epsilon value used by collision engine
  30125. */
  30126. static CollisionsEpsilon: number;
  30127. /**
  30128. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30129. */
  30130. static ShadersRepository: string;
  30131. /** @hidden */
  30132. _shaderProcessor: IShaderProcessor;
  30133. /**
  30134. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30135. */
  30136. forcePOTTextures: boolean;
  30137. /**
  30138. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30139. */
  30140. isFullscreen: boolean;
  30141. /**
  30142. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30143. */
  30144. cullBackFaces: boolean;
  30145. /**
  30146. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30147. */
  30148. renderEvenInBackground: boolean;
  30149. /**
  30150. * Gets or sets a boolean indicating that cache can be kept between frames
  30151. */
  30152. preventCacheWipeBetweenFrames: boolean;
  30153. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30154. validateShaderPrograms: boolean;
  30155. /**
  30156. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30157. */
  30158. disableUniformBuffers: boolean;
  30159. /** @hidden */
  30160. _uniformBuffers: UniformBuffer[];
  30161. /**
  30162. * Gets a boolean indicating that the engine supports uniform buffers
  30163. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30164. */
  30165. readonly supportsUniformBuffers: boolean;
  30166. /** @hidden */
  30167. _gl: WebGLRenderingContext;
  30168. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30169. protected _windowIsBackground: boolean;
  30170. protected _webGLVersion: number;
  30171. protected _highPrecisionShadersAllowed: boolean;
  30172. /** @hidden */
  30173. readonly _shouldUseHighPrecisionShader: boolean;
  30174. /**
  30175. * Gets a boolean indicating that only power of 2 textures are supported
  30176. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30177. */
  30178. readonly needPOTTextures: boolean;
  30179. /** @hidden */
  30180. _badOS: boolean;
  30181. /** @hidden */
  30182. _badDesktopOS: boolean;
  30183. private _hardwareScalingLevel;
  30184. /** @hidden */
  30185. _caps: EngineCapabilities;
  30186. private _isStencilEnable;
  30187. protected _colorWrite: boolean;
  30188. /** @hidden */
  30189. _drawCalls: PerfCounter;
  30190. private _glVersion;
  30191. private _glRenderer;
  30192. private _glVendor;
  30193. /** @hidden */
  30194. _videoTextureSupported: boolean;
  30195. protected _renderingQueueLaunched: boolean;
  30196. protected _activeRenderLoops: (() => void)[];
  30197. /**
  30198. * Observable signaled when a context lost event is raised
  30199. */
  30200. onContextLostObservable: Observable<ThinEngine>;
  30201. /**
  30202. * Observable signaled when a context restored event is raised
  30203. */
  30204. onContextRestoredObservable: Observable<ThinEngine>;
  30205. private _onContextLost;
  30206. private _onContextRestored;
  30207. protected _contextWasLost: boolean;
  30208. /** @hidden */
  30209. _doNotHandleContextLost: boolean;
  30210. /**
  30211. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30213. */
  30214. doNotHandleContextLost: boolean;
  30215. /**
  30216. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30217. */
  30218. disableVertexArrayObjects: boolean;
  30219. /** @hidden */
  30220. protected _depthCullingState: DepthCullingState;
  30221. /** @hidden */
  30222. protected _stencilState: StencilState;
  30223. /** @hidden */
  30224. protected _alphaState: AlphaState;
  30225. /** @hidden */
  30226. _internalTexturesCache: InternalTexture[];
  30227. /** @hidden */
  30228. protected _activeChannel: number;
  30229. private _currentTextureChannel;
  30230. /** @hidden */
  30231. protected _boundTexturesCache: {
  30232. [key: string]: Nullable<InternalTexture>;
  30233. };
  30234. /** @hidden */
  30235. protected _currentEffect: Nullable<Effect>;
  30236. /** @hidden */
  30237. protected _currentProgram: Nullable<WebGLProgram>;
  30238. private _compiledEffects;
  30239. private _vertexAttribArraysEnabled;
  30240. /** @hidden */
  30241. protected _cachedViewport: Nullable<IViewportLike>;
  30242. private _cachedVertexArrayObject;
  30243. /** @hidden */
  30244. protected _cachedVertexBuffers: any;
  30245. /** @hidden */
  30246. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30247. /** @hidden */
  30248. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30249. /** @hidden */
  30250. _currentRenderTarget: Nullable<InternalTexture>;
  30251. private _uintIndicesCurrentlySet;
  30252. private _currentBoundBuffer;
  30253. /** @hidden */
  30254. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30255. private _currentBufferPointers;
  30256. private _currentInstanceLocations;
  30257. private _currentInstanceBuffers;
  30258. private _textureUnits;
  30259. /** @hidden */
  30260. _workingCanvas: Nullable<HTMLCanvasElement>;
  30261. /** @hidden */
  30262. _workingContext: Nullable<CanvasRenderingContext2D>;
  30263. /** @hidden */
  30264. _bindedRenderFunction: any;
  30265. private _vaoRecordInProgress;
  30266. private _mustWipeVertexAttributes;
  30267. private _emptyTexture;
  30268. private _emptyCubeTexture;
  30269. private _emptyTexture3D;
  30270. /** @hidden */
  30271. _frameHandler: number;
  30272. private _nextFreeTextureSlots;
  30273. private _maxSimultaneousTextures;
  30274. private _activeRequests;
  30275. protected _texturesSupported: string[];
  30276. /** @hidden */
  30277. _textureFormatInUse: Nullable<string>;
  30278. protected readonly _supportsHardwareTextureRescaling: boolean;
  30279. /**
  30280. * Gets the list of texture formats supported
  30281. */
  30282. readonly texturesSupported: Array<string>;
  30283. /**
  30284. * Gets the list of texture formats in use
  30285. */
  30286. readonly textureFormatInUse: Nullable<string>;
  30287. /**
  30288. * Gets the current viewport
  30289. */
  30290. readonly currentViewport: Nullable<IViewportLike>;
  30291. /**
  30292. * Gets the default empty texture
  30293. */
  30294. readonly emptyTexture: InternalTexture;
  30295. /**
  30296. * Gets the default empty 3D texture
  30297. */
  30298. readonly emptyTexture3D: InternalTexture;
  30299. /**
  30300. * Gets the default empty cube texture
  30301. */
  30302. readonly emptyCubeTexture: InternalTexture;
  30303. /**
  30304. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30305. */
  30306. readonly premultipliedAlpha: boolean;
  30307. /**
  30308. * Creates a new engine
  30309. * @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
  30310. * @param antialias defines enable antialiasing (default: false)
  30311. * @param options defines further options to be sent to the getContext() function
  30312. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30313. */
  30314. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30315. private _rebuildInternalTextures;
  30316. private _rebuildEffects;
  30317. /**
  30318. * Gets a boolean indicating if all created effects are ready
  30319. * @returns true if all effects are ready
  30320. */
  30321. areAllEffectsReady(): boolean;
  30322. protected _rebuildBuffers(): void;
  30323. private _initGLContext;
  30324. /**
  30325. * Gets version of the current webGL context
  30326. */
  30327. readonly webGLVersion: number;
  30328. /**
  30329. * Gets a string idenfifying the name of the class
  30330. * @returns "Engine" string
  30331. */
  30332. getClassName(): string;
  30333. /**
  30334. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30335. */
  30336. readonly isStencilEnable: boolean;
  30337. /** @hidden */
  30338. _prepareWorkingCanvas(): void;
  30339. /**
  30340. * Reset the texture cache to empty state
  30341. */
  30342. resetTextureCache(): void;
  30343. /**
  30344. * Gets an object containing information about the current webGL context
  30345. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30346. */
  30347. getGlInfo(): {
  30348. vendor: string;
  30349. renderer: string;
  30350. version: string;
  30351. };
  30352. /**
  30353. * Defines the hardware scaling level.
  30354. * By default the hardware scaling level is computed from the window device ratio.
  30355. * 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.
  30356. * @param level defines the level to use
  30357. */
  30358. setHardwareScalingLevel(level: number): void;
  30359. /**
  30360. * Gets the current hardware scaling level.
  30361. * By default the hardware scaling level is computed from the window device ratio.
  30362. * 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.
  30363. * @returns a number indicating the current hardware scaling level
  30364. */
  30365. getHardwareScalingLevel(): number;
  30366. /**
  30367. * Gets the list of loaded textures
  30368. * @returns an array containing all loaded textures
  30369. */
  30370. getLoadedTexturesCache(): InternalTexture[];
  30371. /**
  30372. * Gets the object containing all engine capabilities
  30373. * @returns the EngineCapabilities object
  30374. */
  30375. getCaps(): EngineCapabilities;
  30376. /**
  30377. * stop executing a render loop function and remove it from the execution array
  30378. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30379. */
  30380. stopRenderLoop(renderFunction?: () => void): void;
  30381. /** @hidden */
  30382. _renderLoop(): void;
  30383. /**
  30384. * Gets the HTML canvas attached with the current webGL context
  30385. * @returns a HTML canvas
  30386. */
  30387. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30388. /**
  30389. * Gets host window
  30390. * @returns the host window object
  30391. */
  30392. getHostWindow(): Window;
  30393. /**
  30394. * Gets the current render width
  30395. * @param useScreen defines if screen size must be used (or the current render target if any)
  30396. * @returns a number defining the current render width
  30397. */
  30398. getRenderWidth(useScreen?: boolean): number;
  30399. /**
  30400. * Gets the current render height
  30401. * @param useScreen defines if screen size must be used (or the current render target if any)
  30402. * @returns a number defining the current render height
  30403. */
  30404. getRenderHeight(useScreen?: boolean): number;
  30405. /**
  30406. * Can be used to override the current requestAnimationFrame requester.
  30407. * @hidden
  30408. */
  30409. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30410. /**
  30411. * Register and execute a render loop. The engine can have more than one render function
  30412. * @param renderFunction defines the function to continuously execute
  30413. */
  30414. runRenderLoop(renderFunction: () => void): void;
  30415. /**
  30416. * Clear the current render buffer or the current render target (if any is set up)
  30417. * @param color defines the color to use
  30418. * @param backBuffer defines if the back buffer must be cleared
  30419. * @param depth defines if the depth buffer must be cleared
  30420. * @param stencil defines if the stencil buffer must be cleared
  30421. */
  30422. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30423. private _viewportCached;
  30424. /** @hidden */
  30425. _viewport(x: number, y: number, width: number, height: number): void;
  30426. /**
  30427. * Set the WebGL's viewport
  30428. * @param viewport defines the viewport element to be used
  30429. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30430. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30431. */
  30432. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30433. /**
  30434. * Begin a new frame
  30435. */
  30436. beginFrame(): void;
  30437. /**
  30438. * Enf the current frame
  30439. */
  30440. endFrame(): void;
  30441. /**
  30442. * Resize the view according to the canvas' size
  30443. */
  30444. resize(): void;
  30445. /**
  30446. * Force a specific size of the canvas
  30447. * @param width defines the new canvas' width
  30448. * @param height defines the new canvas' height
  30449. */
  30450. setSize(width: number, height: number): void;
  30451. /**
  30452. * Binds the frame buffer to the specified texture.
  30453. * @param texture The texture to render to or null for the default canvas
  30454. * @param faceIndex The face of the texture to render to in case of cube texture
  30455. * @param requiredWidth The width of the target to render to
  30456. * @param requiredHeight The height of the target to render to
  30457. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30458. * @param depthStencilTexture The depth stencil texture to use to render
  30459. * @param lodLevel defines le lod level to bind to the frame buffer
  30460. */
  30461. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30462. /** @hidden */
  30463. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30464. /**
  30465. * Unbind the current render target texture from the webGL context
  30466. * @param texture defines the render target texture to unbind
  30467. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30468. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30469. */
  30470. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30471. /**
  30472. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30473. */
  30474. flushFramebuffer(): void;
  30475. /**
  30476. * Unbind the current render target and bind the default framebuffer
  30477. */
  30478. restoreDefaultFramebuffer(): void;
  30479. private _resetVertexBufferBinding;
  30480. /**
  30481. * Creates a vertex buffer
  30482. * @param data the data for the vertex buffer
  30483. * @returns the new WebGL static buffer
  30484. */
  30485. createVertexBuffer(data: DataArray): DataBuffer;
  30486. private _createVertexBuffer;
  30487. /**
  30488. * Creates a dynamic vertex buffer
  30489. * @param data the data for the dynamic vertex buffer
  30490. * @returns the new WebGL dynamic buffer
  30491. */
  30492. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30493. /**
  30494. * Update a dynamic index buffer
  30495. * @param indexBuffer defines the target index buffer
  30496. * @param indices defines the data to update
  30497. * @param offset defines the offset in the target index buffer where update should start
  30498. */
  30499. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30500. /**
  30501. * Updates a dynamic vertex buffer.
  30502. * @param vertexBuffer the vertex buffer to update
  30503. * @param data the data used to update the vertex buffer
  30504. * @param byteOffset the byte offset of the data
  30505. * @param byteLength the byte length of the data
  30506. */
  30507. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30508. private _resetIndexBufferBinding;
  30509. /**
  30510. * Creates a new index buffer
  30511. * @param indices defines the content of the index buffer
  30512. * @param updatable defines if the index buffer must be updatable
  30513. * @returns a new webGL buffer
  30514. */
  30515. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30516. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30517. /**
  30518. * Bind a webGL buffer to the webGL context
  30519. * @param buffer defines the buffer to bind
  30520. */
  30521. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30522. private bindIndexBuffer;
  30523. private bindBuffer;
  30524. /**
  30525. * update the bound buffer with the given data
  30526. * @param data defines the data to update
  30527. */
  30528. updateArrayBuffer(data: Float32Array): void;
  30529. private _vertexAttribPointer;
  30530. private _bindIndexBufferWithCache;
  30531. private _bindVertexBuffersAttributes;
  30532. /**
  30533. * Records a vertex array object
  30534. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30535. * @param vertexBuffers defines the list of vertex buffers to store
  30536. * @param indexBuffer defines the index buffer to store
  30537. * @param effect defines the effect to store
  30538. * @returns the new vertex array object
  30539. */
  30540. recordVertexArrayObject(vertexBuffers: {
  30541. [key: string]: VertexBuffer;
  30542. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30543. /**
  30544. * Bind a specific vertex array object
  30545. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30546. * @param vertexArrayObject defines the vertex array object to bind
  30547. * @param indexBuffer defines the index buffer to bind
  30548. */
  30549. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30550. /**
  30551. * Bind webGl buffers directly to the webGL context
  30552. * @param vertexBuffer defines the vertex buffer to bind
  30553. * @param indexBuffer defines the index buffer to bind
  30554. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30555. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30556. * @param effect defines the effect associated with the vertex buffer
  30557. */
  30558. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30559. private _unbindVertexArrayObject;
  30560. /**
  30561. * Bind a list of vertex buffers to the webGL context
  30562. * @param vertexBuffers defines the list of vertex buffers to bind
  30563. * @param indexBuffer defines the index buffer to bind
  30564. * @param effect defines the effect associated with the vertex buffers
  30565. */
  30566. bindBuffers(vertexBuffers: {
  30567. [key: string]: Nullable<VertexBuffer>;
  30568. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30569. /**
  30570. * Unbind all instance attributes
  30571. */
  30572. unbindInstanceAttributes(): void;
  30573. /**
  30574. * Release and free the memory of a vertex array object
  30575. * @param vao defines the vertex array object to delete
  30576. */
  30577. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30578. /** @hidden */
  30579. _releaseBuffer(buffer: DataBuffer): boolean;
  30580. protected _deleteBuffer(buffer: DataBuffer): void;
  30581. /**
  30582. * Creates a webGL buffer to use with instanciation
  30583. * @param capacity defines the size of the buffer
  30584. * @returns the webGL buffer
  30585. */
  30586. createInstancesBuffer(capacity: number): DataBuffer;
  30587. /**
  30588. * Delete a webGL buffer used with instanciation
  30589. * @param buffer defines the webGL buffer to delete
  30590. */
  30591. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30592. /**
  30593. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30594. * @param instancesBuffer defines the webGL buffer to update and bind
  30595. * @param data defines the data to store in the buffer
  30596. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30597. */
  30598. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30599. /**
  30600. * Apply all cached states (depth, culling, stencil and alpha)
  30601. */
  30602. applyStates(): void;
  30603. /**
  30604. * Send a draw order
  30605. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30606. * @param indexStart defines the starting index
  30607. * @param indexCount defines the number of index to draw
  30608. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30609. */
  30610. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30611. /**
  30612. * Draw a list of points
  30613. * @param verticesStart defines the index of first vertex to draw
  30614. * @param verticesCount defines the count of vertices to draw
  30615. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30616. */
  30617. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30618. /**
  30619. * Draw a list of unindexed primitives
  30620. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30621. * @param verticesStart defines the index of first vertex to draw
  30622. * @param verticesCount defines the count of vertices to draw
  30623. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30624. */
  30625. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30626. /**
  30627. * Draw a list of indexed primitives
  30628. * @param fillMode defines the primitive to use
  30629. * @param indexStart defines the starting index
  30630. * @param indexCount defines the number of index to draw
  30631. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30632. */
  30633. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30634. /**
  30635. * Draw a list of unindexed primitives
  30636. * @param fillMode defines the primitive to use
  30637. * @param verticesStart defines the index of first vertex to draw
  30638. * @param verticesCount defines the count of vertices to draw
  30639. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30640. */
  30641. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30642. private _drawMode;
  30643. /** @hidden */
  30644. _releaseEffect(effect: Effect): void;
  30645. /** @hidden */
  30646. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30647. /**
  30648. * Create a new effect (used to store vertex/fragment shaders)
  30649. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30650. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30651. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30652. * @param samplers defines an array of string used to represent textures
  30653. * @param defines defines the string containing the defines to use to compile the shaders
  30654. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30655. * @param onCompiled defines a function to call when the effect creation is successful
  30656. * @param onError defines a function to call when the effect creation has failed
  30657. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30658. * @returns the new Effect
  30659. */
  30660. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30661. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30662. private _compileShader;
  30663. private _compileRawShader;
  30664. /**
  30665. * Directly creates a webGL program
  30666. * @param pipelineContext defines the pipeline context to attach to
  30667. * @param vertexCode defines the vertex shader code to use
  30668. * @param fragmentCode defines the fragment shader code to use
  30669. * @param context defines the webGL context to use (if not set, the current one will be used)
  30670. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30671. * @returns the new webGL program
  30672. */
  30673. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30674. /**
  30675. * Creates a webGL program
  30676. * @param pipelineContext defines the pipeline context to attach to
  30677. * @param vertexCode defines the vertex shader code to use
  30678. * @param fragmentCode defines the fragment shader code to use
  30679. * @param defines defines the string containing the defines to use to compile the shaders
  30680. * @param context defines the webGL context to use (if not set, the current one will be used)
  30681. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30682. * @returns the new webGL program
  30683. */
  30684. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30685. /**
  30686. * Creates a new pipeline context
  30687. * @returns the new pipeline
  30688. */
  30689. createPipelineContext(): IPipelineContext;
  30690. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30691. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30692. /** @hidden */
  30693. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30694. /** @hidden */
  30695. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30696. /** @hidden */
  30697. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30698. /**
  30699. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30700. * @param pipelineContext defines the pipeline context to use
  30701. * @param uniformsNames defines the list of uniform names
  30702. * @returns an array of webGL uniform locations
  30703. */
  30704. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30705. /**
  30706. * Gets the lsit of active attributes for a given webGL program
  30707. * @param pipelineContext defines the pipeline context to use
  30708. * @param attributesNames defines the list of attribute names to get
  30709. * @returns an array of indices indicating the offset of each attribute
  30710. */
  30711. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30712. /**
  30713. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30714. * @param effect defines the effect to activate
  30715. */
  30716. enableEffect(effect: Nullable<Effect>): void;
  30717. /**
  30718. * Set the value of an uniform to an array of int32
  30719. * @param uniform defines the webGL uniform location where to store the value
  30720. * @param array defines the array of int32 to store
  30721. */
  30722. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30723. /**
  30724. * Set the value of an uniform to an array of int32 (stored as vec2)
  30725. * @param uniform defines the webGL uniform location where to store the value
  30726. * @param array defines the array of int32 to store
  30727. */
  30728. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30729. /**
  30730. * Set the value of an uniform to an array of int32 (stored as vec3)
  30731. * @param uniform defines the webGL uniform location where to store the value
  30732. * @param array defines the array of int32 to store
  30733. */
  30734. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30735. /**
  30736. * Set the value of an uniform to an array of int32 (stored as vec4)
  30737. * @param uniform defines the webGL uniform location where to store the value
  30738. * @param array defines the array of int32 to store
  30739. */
  30740. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30741. /**
  30742. * Set the value of an uniform to an array of float32
  30743. * @param uniform defines the webGL uniform location where to store the value
  30744. * @param array defines the array of float32 to store
  30745. */
  30746. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30747. /**
  30748. * Set the value of an uniform to an array of float32 (stored as vec2)
  30749. * @param uniform defines the webGL uniform location where to store the value
  30750. * @param array defines the array of float32 to store
  30751. */
  30752. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30753. /**
  30754. * Set the value of an uniform to an array of float32 (stored as vec3)
  30755. * @param uniform defines the webGL uniform location where to store the value
  30756. * @param array defines the array of float32 to store
  30757. */
  30758. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30759. /**
  30760. * Set the value of an uniform to an array of float32 (stored as vec4)
  30761. * @param uniform defines the webGL uniform location where to store the value
  30762. * @param array defines the array of float32 to store
  30763. */
  30764. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30765. /**
  30766. * Set the value of an uniform to an array of number
  30767. * @param uniform defines the webGL uniform location where to store the value
  30768. * @param array defines the array of number to store
  30769. */
  30770. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30771. /**
  30772. * Set the value of an uniform to an array of number (stored as vec2)
  30773. * @param uniform defines the webGL uniform location where to store the value
  30774. * @param array defines the array of number to store
  30775. */
  30776. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30777. /**
  30778. * Set the value of an uniform to an array of number (stored as vec3)
  30779. * @param uniform defines the webGL uniform location where to store the value
  30780. * @param array defines the array of number to store
  30781. */
  30782. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30783. /**
  30784. * Set the value of an uniform to an array of number (stored as vec4)
  30785. * @param uniform defines the webGL uniform location where to store the value
  30786. * @param array defines the array of number to store
  30787. */
  30788. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30789. /**
  30790. * Set the value of an uniform to an array of float32 (stored as matrices)
  30791. * @param uniform defines the webGL uniform location where to store the value
  30792. * @param matrices defines the array of float32 to store
  30793. */
  30794. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30795. /**
  30796. * Set the value of an uniform to a matrix (3x3)
  30797. * @param uniform defines the webGL uniform location where to store the value
  30798. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30799. */
  30800. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30801. /**
  30802. * Set the value of an uniform to a matrix (2x2)
  30803. * @param uniform defines the webGL uniform location where to store the value
  30804. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30805. */
  30806. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30807. /**
  30808. * Set the value of an uniform to a number (int)
  30809. * @param uniform defines the webGL uniform location where to store the value
  30810. * @param value defines the int number to store
  30811. */
  30812. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30813. /**
  30814. * Set the value of an uniform to a number (float)
  30815. * @param uniform defines the webGL uniform location where to store the value
  30816. * @param value defines the float number to store
  30817. */
  30818. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30819. /**
  30820. * Set the value of an uniform to a vec2
  30821. * @param uniform defines the webGL uniform location where to store the value
  30822. * @param x defines the 1st component of the value
  30823. * @param y defines the 2nd component of the value
  30824. */
  30825. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30826. /**
  30827. * Set the value of an uniform to a vec3
  30828. * @param uniform defines the webGL uniform location where to store the value
  30829. * @param x defines the 1st component of the value
  30830. * @param y defines the 2nd component of the value
  30831. * @param z defines the 3rd component of the value
  30832. */
  30833. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30834. /**
  30835. * Set the value of an uniform to a boolean
  30836. * @param uniform defines the webGL uniform location where to store the value
  30837. * @param bool defines the boolean to store
  30838. */
  30839. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30840. /**
  30841. * Set the value of an uniform to a vec4
  30842. * @param uniform defines the webGL uniform location where to store the value
  30843. * @param x defines the 1st component of the value
  30844. * @param y defines the 2nd component of the value
  30845. * @param z defines the 3rd component of the value
  30846. * @param w defines the 4th component of the value
  30847. */
  30848. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30849. /**
  30850. * Sets a Color4 on a uniform variable
  30851. * @param uniform defines the uniform location
  30852. * @param color4 defines the value to be set
  30853. */
  30854. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30855. /**
  30856. * Gets the depth culling state manager
  30857. */
  30858. readonly depthCullingState: DepthCullingState;
  30859. /**
  30860. * Gets the alpha state manager
  30861. */
  30862. readonly alphaState: AlphaState;
  30863. /**
  30864. * Gets the stencil state manager
  30865. */
  30866. readonly stencilState: StencilState;
  30867. /**
  30868. * Clears the list of texture accessible through engine.
  30869. * This can help preventing texture load conflict due to name collision.
  30870. */
  30871. clearInternalTexturesCache(): void;
  30872. /**
  30873. * Force the entire cache to be cleared
  30874. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30875. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30876. */
  30877. wipeCaches(bruteForce?: boolean): void;
  30878. /** @hidden */
  30879. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30880. min: number;
  30881. mag: number;
  30882. };
  30883. /** @hidden */
  30884. _createTexture(): WebGLTexture;
  30885. /**
  30886. * Usually called from Texture.ts.
  30887. * Passed information to create a WebGLTexture
  30888. * @param urlArg defines a value which contains one of the following:
  30889. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30890. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30891. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30892. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30893. * @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)
  30894. * @param scene needed for loading to the correct scene
  30895. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30896. * @param onLoad optional callback to be called upon successful completion
  30897. * @param onError optional callback to be called upon failure
  30898. * @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
  30899. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30900. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30901. * @param forcedExtension defines the extension to use to pick the right loader
  30902. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30903. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30904. */
  30905. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30906. /**
  30907. * @hidden
  30908. */
  30909. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30910. /**
  30911. * Creates a raw texture
  30912. * @param data defines the data to store in the texture
  30913. * @param width defines the width of the texture
  30914. * @param height defines the height of the texture
  30915. * @param format defines the format of the data
  30916. * @param generateMipMaps defines if the engine should generate the mip levels
  30917. * @param invertY defines if data must be stored with Y axis inverted
  30918. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30919. * @param compression defines the compression used (null by default)
  30920. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30921. * @returns the raw texture inside an InternalTexture
  30922. */
  30923. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30924. /**
  30925. * Creates a new raw cube texture
  30926. * @param data defines the array of data to use to create each face
  30927. * @param size defines the size of the textures
  30928. * @param format defines the format of the data
  30929. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30930. * @param generateMipMaps defines if the engine should generate the mip levels
  30931. * @param invertY defines if data must be stored with Y axis inverted
  30932. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30933. * @param compression defines the compression used (null by default)
  30934. * @returns the cube texture as an InternalTexture
  30935. */
  30936. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30937. /**
  30938. * Creates a new raw 3D texture
  30939. * @param data defines the data used to create the texture
  30940. * @param width defines the width of the texture
  30941. * @param height defines the height of the texture
  30942. * @param depth defines the depth of the texture
  30943. * @param format defines the format of the texture
  30944. * @param generateMipMaps defines if the engine must generate mip levels
  30945. * @param invertY defines if data must be stored with Y axis inverted
  30946. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30947. * @param compression defines the compressed used (can be null)
  30948. * @param textureType defines the compressed used (can be null)
  30949. * @returns a new raw 3D texture (stored in an InternalTexture)
  30950. */
  30951. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30952. private _unpackFlipYCached;
  30953. /**
  30954. * In case you are sharing the context with other applications, it might
  30955. * be interested to not cache the unpack flip y state to ensure a consistent
  30956. * value would be set.
  30957. */
  30958. enableUnpackFlipYCached: boolean;
  30959. /** @hidden */
  30960. _unpackFlipY(value: boolean): void;
  30961. /** @hidden */
  30962. _getUnpackAlignement(): number;
  30963. /**
  30964. * Update the sampling mode of a given texture
  30965. * @param samplingMode defines the required sampling mode
  30966. * @param texture defines the texture to update
  30967. */
  30968. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30969. /**
  30970. * Updates a depth texture Comparison Mode and Function.
  30971. * If the comparison Function is equal to 0, the mode will be set to none.
  30972. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30973. * @param texture The texture to set the comparison function for
  30974. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30975. */
  30976. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30977. /** @hidden */
  30978. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30979. width: number;
  30980. height: number;
  30981. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30982. /**
  30983. * Creates a depth stencil texture.
  30984. * This is only available in WebGL 2 or with the depth texture extension available.
  30985. * @param size The size of face edge in the texture.
  30986. * @param options The options defining the texture.
  30987. * @returns The texture
  30988. */
  30989. createDepthStencilTexture(size: number | {
  30990. width: number;
  30991. height: number;
  30992. }, options: DepthTextureCreationOptions): InternalTexture;
  30993. /**
  30994. * Creates a depth stencil texture.
  30995. * This is only available in WebGL 2 or with the depth texture extension available.
  30996. * @param size The size of face edge in the texture.
  30997. * @param options The options defining the texture.
  30998. * @returns The texture
  30999. */
  31000. private _createDepthStencilTexture;
  31001. /**
  31002. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31003. * @param renderTarget The render target to set the frame buffer for
  31004. */
  31005. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  31006. /** @hidden */
  31007. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31008. /** @hidden */
  31009. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31010. /** @hidden */
  31011. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31012. /** @hidden */
  31013. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31014. /** @hidden */
  31015. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  31016. /**
  31017. * @hidden
  31018. */
  31019. _setCubeMapTextureParams(loadMipmap: boolean): void;
  31020. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31021. private _prepareWebGLTexture;
  31022. /** @hidden */
  31023. _releaseFramebufferObjects(texture: InternalTexture): void;
  31024. /** @hidden */
  31025. _releaseTexture(texture: InternalTexture): void;
  31026. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31027. protected _setProgram(program: WebGLProgram): void;
  31028. protected _boundUniforms: {
  31029. [key: number]: WebGLUniformLocation;
  31030. };
  31031. /**
  31032. * Binds an effect to the webGL context
  31033. * @param effect defines the effect to bind
  31034. */
  31035. bindSamplers(effect: Effect): void;
  31036. private _activateCurrentTexture;
  31037. /** @hidden */
  31038. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31039. /** @hidden */
  31040. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31041. /**
  31042. * Unbind all textures from the webGL context
  31043. */
  31044. unbindAllTextures(): void;
  31045. /**
  31046. * Sets a texture to the according uniform.
  31047. * @param channel The texture channel
  31048. * @param uniform The uniform to set
  31049. * @param texture The texture to apply
  31050. */
  31051. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31052. private _bindSamplerUniformToChannel;
  31053. private _getTextureWrapMode;
  31054. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31055. /**
  31056. * Sets an array of texture to the webGL context
  31057. * @param channel defines the channel where the texture array must be set
  31058. * @param uniform defines the associated uniform location
  31059. * @param textures defines the array of textures to bind
  31060. */
  31061. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31062. /** @hidden */
  31063. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  31064. private _setTextureParameterFloat;
  31065. private _setTextureParameterInteger;
  31066. /**
  31067. * Unbind all vertex attributes from the webGL context
  31068. */
  31069. unbindAllAttributes(): void;
  31070. /**
  31071. * 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
  31072. */
  31073. releaseEffects(): void;
  31074. /**
  31075. * Dispose and release all associated resources
  31076. */
  31077. dispose(): void;
  31078. /**
  31079. * Attach a new callback raised when context lost event is fired
  31080. * @param callback defines the callback to call
  31081. */
  31082. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31083. /**
  31084. * Attach a new callback raised when context restored event is fired
  31085. * @param callback defines the callback to call
  31086. */
  31087. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31088. /**
  31089. * Get the current error code of the webGL context
  31090. * @returns the error code
  31091. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31092. */
  31093. getError(): number;
  31094. private _canRenderToFloatFramebuffer;
  31095. private _canRenderToHalfFloatFramebuffer;
  31096. private _canRenderToFramebuffer;
  31097. /** @hidden */
  31098. _getWebGLTextureType(type: number): number;
  31099. /** @hidden */
  31100. _getInternalFormat(format: number): number;
  31101. /** @hidden */
  31102. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31103. /** @hidden */
  31104. _getRGBAMultiSampleBufferFormat(type: number): number;
  31105. /** @hidden */
  31106. _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;
  31107. /**
  31108. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31109. * @returns true if the engine can be created
  31110. * @ignorenaming
  31111. */
  31112. static isSupported(): boolean;
  31113. /**
  31114. * Find the next highest power of two.
  31115. * @param x Number to start search from.
  31116. * @return Next highest power of two.
  31117. */
  31118. static CeilingPOT(x: number): number;
  31119. /**
  31120. * Find the next lowest power of two.
  31121. * @param x Number to start search from.
  31122. * @return Next lowest power of two.
  31123. */
  31124. static FloorPOT(x: number): number;
  31125. /**
  31126. * Find the nearest power of two.
  31127. * @param x Number to start search from.
  31128. * @return Next nearest power of two.
  31129. */
  31130. static NearestPOT(x: number): number;
  31131. /**
  31132. * Get the closest exponent of two
  31133. * @param value defines the value to approximate
  31134. * @param max defines the maximum value to return
  31135. * @param mode defines how to define the closest value
  31136. * @returns closest exponent of two of the given value
  31137. */
  31138. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31139. /**
  31140. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31141. * @param func - the function to be called
  31142. * @param requester - the object that will request the next frame. Falls back to window.
  31143. * @returns frame number
  31144. */
  31145. static QueueNewFrame(func: () => void, requester?: any): number;
  31146. }
  31147. }
  31148. declare module "babylonjs/Materials/Textures/internalTexture" {
  31149. import { Observable } from "babylonjs/Misc/observable";
  31150. import { Nullable, int } from "babylonjs/types";
  31151. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31152. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31153. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31154. /**
  31155. * Class used to store data associated with WebGL texture data for the engine
  31156. * This class should not be used directly
  31157. */
  31158. export class InternalTexture {
  31159. /** @hidden */
  31160. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31161. /**
  31162. * The source of the texture data is unknown
  31163. */
  31164. static DATASOURCE_UNKNOWN: number;
  31165. /**
  31166. * Texture data comes from an URL
  31167. */
  31168. static DATASOURCE_URL: number;
  31169. /**
  31170. * Texture data is only used for temporary storage
  31171. */
  31172. static DATASOURCE_TEMP: number;
  31173. /**
  31174. * Texture data comes from raw data (ArrayBuffer)
  31175. */
  31176. static DATASOURCE_RAW: number;
  31177. /**
  31178. * Texture content is dynamic (video or dynamic texture)
  31179. */
  31180. static DATASOURCE_DYNAMIC: number;
  31181. /**
  31182. * Texture content is generated by rendering to it
  31183. */
  31184. static DATASOURCE_RENDERTARGET: number;
  31185. /**
  31186. * Texture content is part of a multi render target process
  31187. */
  31188. static DATASOURCE_MULTIRENDERTARGET: number;
  31189. /**
  31190. * Texture data comes from a cube data file
  31191. */
  31192. static DATASOURCE_CUBE: number;
  31193. /**
  31194. * Texture data comes from a raw cube data
  31195. */
  31196. static DATASOURCE_CUBERAW: number;
  31197. /**
  31198. * Texture data come from a prefiltered cube data file
  31199. */
  31200. static DATASOURCE_CUBEPREFILTERED: number;
  31201. /**
  31202. * Texture content is raw 3D data
  31203. */
  31204. static DATASOURCE_RAW3D: number;
  31205. /**
  31206. * Texture content is a depth texture
  31207. */
  31208. static DATASOURCE_DEPTHTEXTURE: number;
  31209. /**
  31210. * Texture data comes from a raw cube data encoded with RGBD
  31211. */
  31212. static DATASOURCE_CUBERAW_RGBD: number;
  31213. /**
  31214. * Defines if the texture is ready
  31215. */
  31216. isReady: boolean;
  31217. /**
  31218. * Defines if the texture is a cube texture
  31219. */
  31220. isCube: boolean;
  31221. /**
  31222. * Defines if the texture contains 3D data
  31223. */
  31224. is3D: boolean;
  31225. /**
  31226. * Defines if the texture contains multiview data
  31227. */
  31228. isMultiview: boolean;
  31229. /**
  31230. * Gets the URL used to load this texture
  31231. */
  31232. url: string;
  31233. /**
  31234. * Gets the sampling mode of the texture
  31235. */
  31236. samplingMode: number;
  31237. /**
  31238. * Gets a boolean indicating if the texture needs mipmaps generation
  31239. */
  31240. generateMipMaps: boolean;
  31241. /**
  31242. * Gets the number of samples used by the texture (WebGL2+ only)
  31243. */
  31244. samples: number;
  31245. /**
  31246. * Gets the type of the texture (int, float...)
  31247. */
  31248. type: number;
  31249. /**
  31250. * Gets the format of the texture (RGB, RGBA...)
  31251. */
  31252. format: number;
  31253. /**
  31254. * Observable called when the texture is loaded
  31255. */
  31256. onLoadedObservable: Observable<InternalTexture>;
  31257. /**
  31258. * Gets the width of the texture
  31259. */
  31260. width: number;
  31261. /**
  31262. * Gets the height of the texture
  31263. */
  31264. height: number;
  31265. /**
  31266. * Gets the depth of the texture
  31267. */
  31268. depth: number;
  31269. /**
  31270. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31271. */
  31272. baseWidth: number;
  31273. /**
  31274. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31275. */
  31276. baseHeight: number;
  31277. /**
  31278. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31279. */
  31280. baseDepth: number;
  31281. /**
  31282. * Gets a boolean indicating if the texture is inverted on Y axis
  31283. */
  31284. invertY: boolean;
  31285. /** @hidden */
  31286. _invertVScale: boolean;
  31287. /** @hidden */
  31288. _associatedChannel: number;
  31289. /** @hidden */
  31290. _dataSource: number;
  31291. /** @hidden */
  31292. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31293. /** @hidden */
  31294. _bufferView: Nullable<ArrayBufferView>;
  31295. /** @hidden */
  31296. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31297. /** @hidden */
  31298. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31299. /** @hidden */
  31300. _size: number;
  31301. /** @hidden */
  31302. _extension: string;
  31303. /** @hidden */
  31304. _files: Nullable<string[]>;
  31305. /** @hidden */
  31306. _workingCanvas: Nullable<HTMLCanvasElement>;
  31307. /** @hidden */
  31308. _workingContext: Nullable<CanvasRenderingContext2D>;
  31309. /** @hidden */
  31310. _framebuffer: Nullable<WebGLFramebuffer>;
  31311. /** @hidden */
  31312. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31313. /** @hidden */
  31314. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31315. /** @hidden */
  31316. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31317. /** @hidden */
  31318. _attachments: Nullable<number[]>;
  31319. /** @hidden */
  31320. _cachedCoordinatesMode: Nullable<number>;
  31321. /** @hidden */
  31322. _cachedWrapU: Nullable<number>;
  31323. /** @hidden */
  31324. _cachedWrapV: Nullable<number>;
  31325. /** @hidden */
  31326. _cachedWrapR: Nullable<number>;
  31327. /** @hidden */
  31328. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31329. /** @hidden */
  31330. _isDisabled: boolean;
  31331. /** @hidden */
  31332. _compression: Nullable<string>;
  31333. /** @hidden */
  31334. _generateStencilBuffer: boolean;
  31335. /** @hidden */
  31336. _generateDepthBuffer: boolean;
  31337. /** @hidden */
  31338. _comparisonFunction: number;
  31339. /** @hidden */
  31340. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31341. /** @hidden */
  31342. _lodGenerationScale: number;
  31343. /** @hidden */
  31344. _lodGenerationOffset: number;
  31345. /** @hidden */
  31346. _colorTextureArray: Nullable<WebGLTexture>;
  31347. /** @hidden */
  31348. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31349. /** @hidden */
  31350. _lodTextureHigh: Nullable<BaseTexture>;
  31351. /** @hidden */
  31352. _lodTextureMid: Nullable<BaseTexture>;
  31353. /** @hidden */
  31354. _lodTextureLow: Nullable<BaseTexture>;
  31355. /** @hidden */
  31356. _isRGBD: boolean;
  31357. /** @hidden */
  31358. _linearSpecularLOD: boolean;
  31359. /** @hidden */
  31360. _irradianceTexture: Nullable<BaseTexture>;
  31361. /** @hidden */
  31362. _webGLTexture: Nullable<WebGLTexture>;
  31363. /** @hidden */
  31364. _references: number;
  31365. private _engine;
  31366. /**
  31367. * Gets the Engine the texture belongs to.
  31368. * @returns The babylon engine
  31369. */
  31370. getEngine(): ThinEngine;
  31371. /**
  31372. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  31373. */
  31374. readonly dataSource: number;
  31375. /**
  31376. * Creates a new InternalTexture
  31377. * @param engine defines the engine to use
  31378. * @param dataSource defines the type of data that will be used
  31379. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31380. */
  31381. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  31382. /**
  31383. * Increments the number of references (ie. the number of Texture that point to it)
  31384. */
  31385. incrementReferences(): void;
  31386. /**
  31387. * Change the size of the texture (not the size of the content)
  31388. * @param width defines the new width
  31389. * @param height defines the new height
  31390. * @param depth defines the new depth (1 by default)
  31391. */
  31392. updateSize(width: int, height: int, depth?: int): void;
  31393. /** @hidden */
  31394. _rebuild(): void;
  31395. /** @hidden */
  31396. _swapAndDie(target: InternalTexture): void;
  31397. /**
  31398. * Dispose the current allocated resources
  31399. */
  31400. dispose(): void;
  31401. }
  31402. }
  31403. declare module "babylonjs/Audio/analyser" {
  31404. import { Scene } from "babylonjs/scene";
  31405. /**
  31406. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31408. */
  31409. export class Analyser {
  31410. /**
  31411. * Gets or sets the smoothing
  31412. * @ignorenaming
  31413. */
  31414. SMOOTHING: number;
  31415. /**
  31416. * Gets or sets the FFT table size
  31417. * @ignorenaming
  31418. */
  31419. FFT_SIZE: number;
  31420. /**
  31421. * Gets or sets the bar graph amplitude
  31422. * @ignorenaming
  31423. */
  31424. BARGRAPHAMPLITUDE: number;
  31425. /**
  31426. * Gets or sets the position of the debug canvas
  31427. * @ignorenaming
  31428. */
  31429. DEBUGCANVASPOS: {
  31430. x: number;
  31431. y: number;
  31432. };
  31433. /**
  31434. * Gets or sets the debug canvas size
  31435. * @ignorenaming
  31436. */
  31437. DEBUGCANVASSIZE: {
  31438. width: number;
  31439. height: number;
  31440. };
  31441. private _byteFreqs;
  31442. private _byteTime;
  31443. private _floatFreqs;
  31444. private _webAudioAnalyser;
  31445. private _debugCanvas;
  31446. private _debugCanvasContext;
  31447. private _scene;
  31448. private _registerFunc;
  31449. private _audioEngine;
  31450. /**
  31451. * Creates a new analyser
  31452. * @param scene defines hosting scene
  31453. */
  31454. constructor(scene: Scene);
  31455. /**
  31456. * Get the number of data values you will have to play with for the visualization
  31457. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31458. * @returns a number
  31459. */
  31460. getFrequencyBinCount(): number;
  31461. /**
  31462. * Gets the current frequency data as a byte array
  31463. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31464. * @returns a Uint8Array
  31465. */
  31466. getByteFrequencyData(): Uint8Array;
  31467. /**
  31468. * Gets the current waveform as a byte array
  31469. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31470. * @returns a Uint8Array
  31471. */
  31472. getByteTimeDomainData(): Uint8Array;
  31473. /**
  31474. * Gets the current frequency data as a float array
  31475. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31476. * @returns a Float32Array
  31477. */
  31478. getFloatFrequencyData(): Float32Array;
  31479. /**
  31480. * Renders the debug canvas
  31481. */
  31482. drawDebugCanvas(): void;
  31483. /**
  31484. * Stops rendering the debug canvas and removes it
  31485. */
  31486. stopDebugCanvas(): void;
  31487. /**
  31488. * Connects two audio nodes
  31489. * @param inputAudioNode defines first node to connect
  31490. * @param outputAudioNode defines second node to connect
  31491. */
  31492. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31493. /**
  31494. * Releases all associated resources
  31495. */
  31496. dispose(): void;
  31497. }
  31498. }
  31499. declare module "babylonjs/Audio/audioEngine" {
  31500. import { IDisposable } from "babylonjs/scene";
  31501. import { Analyser } from "babylonjs/Audio/analyser";
  31502. import { Nullable } from "babylonjs/types";
  31503. import { Observable } from "babylonjs/Misc/observable";
  31504. /**
  31505. * This represents an audio engine and it is responsible
  31506. * to play, synchronize and analyse sounds throughout the application.
  31507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31508. */
  31509. export interface IAudioEngine extends IDisposable {
  31510. /**
  31511. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31512. */
  31513. readonly canUseWebAudio: boolean;
  31514. /**
  31515. * Gets the current AudioContext if available.
  31516. */
  31517. readonly audioContext: Nullable<AudioContext>;
  31518. /**
  31519. * The master gain node defines the global audio volume of your audio engine.
  31520. */
  31521. readonly masterGain: GainNode;
  31522. /**
  31523. * Gets whether or not mp3 are supported by your browser.
  31524. */
  31525. readonly isMP3supported: boolean;
  31526. /**
  31527. * Gets whether or not ogg are supported by your browser.
  31528. */
  31529. readonly isOGGsupported: boolean;
  31530. /**
  31531. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31532. * @ignoreNaming
  31533. */
  31534. WarnedWebAudioUnsupported: boolean;
  31535. /**
  31536. * Defines if the audio engine relies on a custom unlocked button.
  31537. * In this case, the embedded button will not be displayed.
  31538. */
  31539. useCustomUnlockedButton: boolean;
  31540. /**
  31541. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31542. */
  31543. readonly unlocked: boolean;
  31544. /**
  31545. * Event raised when audio has been unlocked on the browser.
  31546. */
  31547. onAudioUnlockedObservable: Observable<AudioEngine>;
  31548. /**
  31549. * Event raised when audio has been locked on the browser.
  31550. */
  31551. onAudioLockedObservable: Observable<AudioEngine>;
  31552. /**
  31553. * Flags the audio engine in Locked state.
  31554. * This happens due to new browser policies preventing audio to autoplay.
  31555. */
  31556. lock(): void;
  31557. /**
  31558. * Unlocks the audio engine once a user action has been done on the dom.
  31559. * This is helpful to resume play once browser policies have been satisfied.
  31560. */
  31561. unlock(): void;
  31562. }
  31563. /**
  31564. * This represents the default audio engine used in babylon.
  31565. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31566. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31567. */
  31568. export class AudioEngine implements IAudioEngine {
  31569. private _audioContext;
  31570. private _audioContextInitialized;
  31571. private _muteButton;
  31572. private _hostElement;
  31573. /**
  31574. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31575. */
  31576. canUseWebAudio: boolean;
  31577. /**
  31578. * The master gain node defines the global audio volume of your audio engine.
  31579. */
  31580. masterGain: GainNode;
  31581. /**
  31582. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31583. * @ignoreNaming
  31584. */
  31585. WarnedWebAudioUnsupported: boolean;
  31586. /**
  31587. * Gets whether or not mp3 are supported by your browser.
  31588. */
  31589. isMP3supported: boolean;
  31590. /**
  31591. * Gets whether or not ogg are supported by your browser.
  31592. */
  31593. isOGGsupported: boolean;
  31594. /**
  31595. * Gets whether audio has been unlocked on the device.
  31596. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31597. * a user interaction has happened.
  31598. */
  31599. unlocked: boolean;
  31600. /**
  31601. * Defines if the audio engine relies on a custom unlocked button.
  31602. * In this case, the embedded button will not be displayed.
  31603. */
  31604. useCustomUnlockedButton: boolean;
  31605. /**
  31606. * Event raised when audio has been unlocked on the browser.
  31607. */
  31608. onAudioUnlockedObservable: Observable<AudioEngine>;
  31609. /**
  31610. * Event raised when audio has been locked on the browser.
  31611. */
  31612. onAudioLockedObservable: Observable<AudioEngine>;
  31613. /**
  31614. * Gets the current AudioContext if available.
  31615. */
  31616. readonly audioContext: Nullable<AudioContext>;
  31617. private _connectedAnalyser;
  31618. /**
  31619. * Instantiates a new audio engine.
  31620. *
  31621. * There should be only one per page as some browsers restrict the number
  31622. * of audio contexts you can create.
  31623. * @param hostElement defines the host element where to display the mute icon if necessary
  31624. */
  31625. constructor(hostElement?: Nullable<HTMLElement>);
  31626. /**
  31627. * Flags the audio engine in Locked state.
  31628. * This happens due to new browser policies preventing audio to autoplay.
  31629. */
  31630. lock(): void;
  31631. /**
  31632. * Unlocks the audio engine once a user action has been done on the dom.
  31633. * This is helpful to resume play once browser policies have been satisfied.
  31634. */
  31635. unlock(): void;
  31636. private _resumeAudioContext;
  31637. private _initializeAudioContext;
  31638. private _tryToRun;
  31639. private _triggerRunningState;
  31640. private _triggerSuspendedState;
  31641. private _displayMuteButton;
  31642. private _moveButtonToTopLeft;
  31643. private _onResize;
  31644. private _hideMuteButton;
  31645. /**
  31646. * Destroy and release the resources associated with the audio ccontext.
  31647. */
  31648. dispose(): void;
  31649. /**
  31650. * Gets the global volume sets on the master gain.
  31651. * @returns the global volume if set or -1 otherwise
  31652. */
  31653. getGlobalVolume(): number;
  31654. /**
  31655. * Sets the global volume of your experience (sets on the master gain).
  31656. * @param newVolume Defines the new global volume of the application
  31657. */
  31658. setGlobalVolume(newVolume: number): void;
  31659. /**
  31660. * Connect the audio engine to an audio analyser allowing some amazing
  31661. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31663. * @param analyser The analyser to connect to the engine
  31664. */
  31665. connectToAnalyser(analyser: Analyser): void;
  31666. }
  31667. }
  31668. declare module "babylonjs/Loading/loadingScreen" {
  31669. /**
  31670. * Interface used to present a loading screen while loading a scene
  31671. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31672. */
  31673. export interface ILoadingScreen {
  31674. /**
  31675. * Function called to display the loading screen
  31676. */
  31677. displayLoadingUI: () => void;
  31678. /**
  31679. * Function called to hide the loading screen
  31680. */
  31681. hideLoadingUI: () => void;
  31682. /**
  31683. * Gets or sets the color to use for the background
  31684. */
  31685. loadingUIBackgroundColor: string;
  31686. /**
  31687. * Gets or sets the text to display while loading
  31688. */
  31689. loadingUIText: string;
  31690. }
  31691. /**
  31692. * Class used for the default loading screen
  31693. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31694. */
  31695. export class DefaultLoadingScreen implements ILoadingScreen {
  31696. private _renderingCanvas;
  31697. private _loadingText;
  31698. private _loadingDivBackgroundColor;
  31699. private _loadingDiv;
  31700. private _loadingTextDiv;
  31701. /** Gets or sets the logo url to use for the default loading screen */
  31702. static DefaultLogoUrl: string;
  31703. /** Gets or sets the spinner url to use for the default loading screen */
  31704. static DefaultSpinnerUrl: string;
  31705. /**
  31706. * Creates a new default loading screen
  31707. * @param _renderingCanvas defines the canvas used to render the scene
  31708. * @param _loadingText defines the default text to display
  31709. * @param _loadingDivBackgroundColor defines the default background color
  31710. */
  31711. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31712. /**
  31713. * Function called to display the loading screen
  31714. */
  31715. displayLoadingUI(): void;
  31716. /**
  31717. * Function called to hide the loading screen
  31718. */
  31719. hideLoadingUI(): void;
  31720. /**
  31721. * Gets or sets the text to display while loading
  31722. */
  31723. loadingUIText: string;
  31724. /**
  31725. * Gets or sets the color to use for the background
  31726. */
  31727. loadingUIBackgroundColor: string;
  31728. private _resizeLoadingUI;
  31729. }
  31730. }
  31731. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31732. /**
  31733. * Interface for any object that can request an animation frame
  31734. */
  31735. export interface ICustomAnimationFrameRequester {
  31736. /**
  31737. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31738. */
  31739. renderFunction?: Function;
  31740. /**
  31741. * Called to request the next frame to render to
  31742. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31743. */
  31744. requestAnimationFrame: Function;
  31745. /**
  31746. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31747. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31748. */
  31749. requestID?: number;
  31750. }
  31751. }
  31752. declare module "babylonjs/Misc/performanceMonitor" {
  31753. /**
  31754. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31755. */
  31756. export class PerformanceMonitor {
  31757. private _enabled;
  31758. private _rollingFrameTime;
  31759. private _lastFrameTimeMs;
  31760. /**
  31761. * constructor
  31762. * @param frameSampleSize The number of samples required to saturate the sliding window
  31763. */
  31764. constructor(frameSampleSize?: number);
  31765. /**
  31766. * Samples current frame
  31767. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31768. */
  31769. sampleFrame(timeMs?: number): void;
  31770. /**
  31771. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31772. */
  31773. readonly averageFrameTime: number;
  31774. /**
  31775. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31776. */
  31777. readonly averageFrameTimeVariance: number;
  31778. /**
  31779. * Returns the frame time of the most recent frame
  31780. */
  31781. readonly instantaneousFrameTime: number;
  31782. /**
  31783. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31784. */
  31785. readonly averageFPS: number;
  31786. /**
  31787. * Returns the average framerate in frames per second using the most recent frame time
  31788. */
  31789. readonly instantaneousFPS: number;
  31790. /**
  31791. * Returns true if enough samples have been taken to completely fill the sliding window
  31792. */
  31793. readonly isSaturated: boolean;
  31794. /**
  31795. * Enables contributions to the sliding window sample set
  31796. */
  31797. enable(): void;
  31798. /**
  31799. * Disables contributions to the sliding window sample set
  31800. * Samples will not be interpolated over the disabled period
  31801. */
  31802. disable(): void;
  31803. /**
  31804. * Returns true if sampling is enabled
  31805. */
  31806. readonly isEnabled: boolean;
  31807. /**
  31808. * Resets performance monitor
  31809. */
  31810. reset(): void;
  31811. }
  31812. /**
  31813. * RollingAverage
  31814. *
  31815. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31816. */
  31817. export class RollingAverage {
  31818. /**
  31819. * Current average
  31820. */
  31821. average: number;
  31822. /**
  31823. * Current variance
  31824. */
  31825. variance: number;
  31826. protected _samples: Array<number>;
  31827. protected _sampleCount: number;
  31828. protected _pos: number;
  31829. protected _m2: number;
  31830. /**
  31831. * constructor
  31832. * @param length The number of samples required to saturate the sliding window
  31833. */
  31834. constructor(length: number);
  31835. /**
  31836. * Adds a sample to the sample set
  31837. * @param v The sample value
  31838. */
  31839. add(v: number): void;
  31840. /**
  31841. * Returns previously added values or null if outside of history or outside the sliding window domain
  31842. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31843. * @return Value previously recorded with add() or null if outside of range
  31844. */
  31845. history(i: number): number;
  31846. /**
  31847. * Returns true if enough samples have been taken to completely fill the sliding window
  31848. * @return true if sample-set saturated
  31849. */
  31850. isSaturated(): boolean;
  31851. /**
  31852. * Resets the rolling average (equivalent to 0 samples taken so far)
  31853. */
  31854. reset(): void;
  31855. /**
  31856. * Wraps a value around the sample range boundaries
  31857. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31858. * @return Wrapped position in sample range
  31859. */
  31860. protected _wrapPosition(i: number): number;
  31861. }
  31862. }
  31863. declare module "babylonjs/Engines/engine" {
  31864. import { Observable } from "babylonjs/Misc/observable";
  31865. import { Nullable } from "babylonjs/types";
  31866. import { Scene } from "babylonjs/scene";
  31867. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31868. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31869. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31870. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31871. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31872. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31873. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31874. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31875. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31876. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  31877. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31878. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31879. import { Material } from "babylonjs/Materials/material";
  31880. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31881. /**
  31882. * Defines the interface used by display changed events
  31883. */
  31884. export interface IDisplayChangedEventArgs {
  31885. /** Gets the vrDisplay object (if any) */
  31886. vrDisplay: Nullable<any>;
  31887. /** Gets a boolean indicating if webVR is supported */
  31888. vrSupported: boolean;
  31889. }
  31890. /**
  31891. * Defines the interface used by objects containing a viewport (like a camera)
  31892. */
  31893. interface IViewportOwnerLike {
  31894. /**
  31895. * Gets or sets the viewport
  31896. */
  31897. viewport: IViewportLike;
  31898. }
  31899. /**
  31900. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31901. */
  31902. export class Engine extends ThinEngine {
  31903. /** Defines that alpha blending is disabled */
  31904. static readonly ALPHA_DISABLE: number;
  31905. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31906. static readonly ALPHA_ADD: number;
  31907. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31908. static readonly ALPHA_COMBINE: number;
  31909. /** Defines that alpha blending to DEST - SRC * DEST */
  31910. static readonly ALPHA_SUBTRACT: number;
  31911. /** Defines that alpha blending to SRC * DEST */
  31912. static readonly ALPHA_MULTIPLY: number;
  31913. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31914. static readonly ALPHA_MAXIMIZED: number;
  31915. /** Defines that alpha blending to SRC + DEST */
  31916. static readonly ALPHA_ONEONE: number;
  31917. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31918. static readonly ALPHA_PREMULTIPLIED: number;
  31919. /**
  31920. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31921. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31922. */
  31923. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31924. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31925. static readonly ALPHA_INTERPOLATE: number;
  31926. /**
  31927. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31928. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31929. */
  31930. static readonly ALPHA_SCREENMODE: number;
  31931. /** Defines that the ressource is not delayed*/
  31932. static readonly DELAYLOADSTATE_NONE: number;
  31933. /** Defines that the ressource was successfully delay loaded */
  31934. static readonly DELAYLOADSTATE_LOADED: number;
  31935. /** Defines that the ressource is currently delay loading */
  31936. static readonly DELAYLOADSTATE_LOADING: number;
  31937. /** Defines that the ressource is delayed and has not started loading */
  31938. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31939. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31940. static readonly NEVER: number;
  31941. /** 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 */
  31942. static readonly ALWAYS: number;
  31943. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31944. static readonly LESS: number;
  31945. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31946. static readonly EQUAL: number;
  31947. /** 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 */
  31948. static readonly LEQUAL: number;
  31949. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31950. static readonly GREATER: number;
  31951. /** 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 */
  31952. static readonly GEQUAL: number;
  31953. /** 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 */
  31954. static readonly NOTEQUAL: number;
  31955. /** Passed to stencilOperation to specify that stencil value must be kept */
  31956. static readonly KEEP: number;
  31957. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31958. static readonly REPLACE: number;
  31959. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31960. static readonly INCR: number;
  31961. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31962. static readonly DECR: number;
  31963. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31964. static readonly INVERT: number;
  31965. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31966. static readonly INCR_WRAP: number;
  31967. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31968. static readonly DECR_WRAP: number;
  31969. /** Texture is not repeating outside of 0..1 UVs */
  31970. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31971. /** Texture is repeating outside of 0..1 UVs */
  31972. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31973. /** Texture is repeating and mirrored */
  31974. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31975. /** ALPHA */
  31976. static readonly TEXTUREFORMAT_ALPHA: number;
  31977. /** LUMINANCE */
  31978. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31979. /** LUMINANCE_ALPHA */
  31980. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31981. /** RGB */
  31982. static readonly TEXTUREFORMAT_RGB: number;
  31983. /** RGBA */
  31984. static readonly TEXTUREFORMAT_RGBA: number;
  31985. /** RED */
  31986. static readonly TEXTUREFORMAT_RED: number;
  31987. /** RED (2nd reference) */
  31988. static readonly TEXTUREFORMAT_R: number;
  31989. /** RG */
  31990. static readonly TEXTUREFORMAT_RG: number;
  31991. /** RED_INTEGER */
  31992. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31993. /** RED_INTEGER (2nd reference) */
  31994. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31995. /** RG_INTEGER */
  31996. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31997. /** RGB_INTEGER */
  31998. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31999. /** RGBA_INTEGER */
  32000. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32001. /** UNSIGNED_BYTE */
  32002. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32003. /** UNSIGNED_BYTE (2nd reference) */
  32004. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32005. /** FLOAT */
  32006. static readonly TEXTURETYPE_FLOAT: number;
  32007. /** HALF_FLOAT */
  32008. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32009. /** BYTE */
  32010. static readonly TEXTURETYPE_BYTE: number;
  32011. /** SHORT */
  32012. static readonly TEXTURETYPE_SHORT: number;
  32013. /** UNSIGNED_SHORT */
  32014. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32015. /** INT */
  32016. static readonly TEXTURETYPE_INT: number;
  32017. /** UNSIGNED_INT */
  32018. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32019. /** UNSIGNED_SHORT_4_4_4_4 */
  32020. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32021. /** UNSIGNED_SHORT_5_5_5_1 */
  32022. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32023. /** UNSIGNED_SHORT_5_6_5 */
  32024. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32025. /** UNSIGNED_INT_2_10_10_10_REV */
  32026. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32027. /** UNSIGNED_INT_24_8 */
  32028. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32029. /** UNSIGNED_INT_10F_11F_11F_REV */
  32030. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32031. /** UNSIGNED_INT_5_9_9_9_REV */
  32032. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32033. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32034. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32035. /** nearest is mag = nearest and min = nearest and mip = linear */
  32036. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32037. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32038. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32039. /** Trilinear is mag = linear and min = linear and mip = linear */
  32040. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32041. /** nearest is mag = nearest and min = nearest and mip = linear */
  32042. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32043. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32044. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32045. /** Trilinear is mag = linear and min = linear and mip = linear */
  32046. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32047. /** mag = nearest and min = nearest and mip = nearest */
  32048. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32049. /** mag = nearest and min = linear and mip = nearest */
  32050. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32051. /** mag = nearest and min = linear and mip = linear */
  32052. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32053. /** mag = nearest and min = linear and mip = none */
  32054. static readonly TEXTURE_NEAREST_LINEAR: number;
  32055. /** mag = nearest and min = nearest and mip = none */
  32056. static readonly TEXTURE_NEAREST_NEAREST: number;
  32057. /** mag = linear and min = nearest and mip = nearest */
  32058. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32059. /** mag = linear and min = nearest and mip = linear */
  32060. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32061. /** mag = linear and min = linear and mip = none */
  32062. static readonly TEXTURE_LINEAR_LINEAR: number;
  32063. /** mag = linear and min = nearest and mip = none */
  32064. static readonly TEXTURE_LINEAR_NEAREST: number;
  32065. /** Explicit coordinates mode */
  32066. static readonly TEXTURE_EXPLICIT_MODE: number;
  32067. /** Spherical coordinates mode */
  32068. static readonly TEXTURE_SPHERICAL_MODE: number;
  32069. /** Planar coordinates mode */
  32070. static readonly TEXTURE_PLANAR_MODE: number;
  32071. /** Cubic coordinates mode */
  32072. static readonly TEXTURE_CUBIC_MODE: number;
  32073. /** Projection coordinates mode */
  32074. static readonly TEXTURE_PROJECTION_MODE: number;
  32075. /** Skybox coordinates mode */
  32076. static readonly TEXTURE_SKYBOX_MODE: number;
  32077. /** Inverse Cubic coordinates mode */
  32078. static readonly TEXTURE_INVCUBIC_MODE: number;
  32079. /** Equirectangular coordinates mode */
  32080. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32081. /** Equirectangular Fixed coordinates mode */
  32082. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32083. /** Equirectangular Fixed Mirrored coordinates mode */
  32084. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32085. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32086. static readonly SCALEMODE_FLOOR: number;
  32087. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32088. static readonly SCALEMODE_NEAREST: number;
  32089. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32090. static readonly SCALEMODE_CEILING: number;
  32091. /**
  32092. * Returns the current npm package of the sdk
  32093. */
  32094. static readonly NpmPackage: string;
  32095. /**
  32096. * Returns the current version of the framework
  32097. */
  32098. static readonly Version: string;
  32099. /** Gets the list of created engines */
  32100. static readonly Instances: Engine[];
  32101. /**
  32102. * Gets the latest created engine
  32103. */
  32104. static readonly LastCreatedEngine: Nullable<Engine>;
  32105. /**
  32106. * Gets the latest created scene
  32107. */
  32108. static readonly LastCreatedScene: Nullable<Scene>;
  32109. /**
  32110. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32111. * @param flag defines which part of the materials must be marked as dirty
  32112. * @param predicate defines a predicate used to filter which materials should be affected
  32113. */
  32114. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32115. /**
  32116. * Method called to create the default loading screen.
  32117. * This can be overriden in your own app.
  32118. * @param canvas The rendering canvas element
  32119. * @returns The loading screen
  32120. */
  32121. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32122. /**
  32123. * Method called to create the default rescale post process on each engine.
  32124. */
  32125. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32126. /**
  32127. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32128. **/
  32129. enableOfflineSupport: boolean;
  32130. /**
  32131. * 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)
  32132. **/
  32133. disableManifestCheck: boolean;
  32134. /**
  32135. * Gets the list of created scenes
  32136. */
  32137. scenes: Scene[];
  32138. /**
  32139. * Event raised when a new scene is created
  32140. */
  32141. onNewSceneAddedObservable: Observable<Scene>;
  32142. /**
  32143. * Gets the list of created postprocesses
  32144. */
  32145. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32146. /**
  32147. * Gets a boolean indicating if the pointer is currently locked
  32148. */
  32149. isPointerLock: boolean;
  32150. /**
  32151. * Observable event triggered each time the rendering canvas is resized
  32152. */
  32153. onResizeObservable: Observable<Engine>;
  32154. /**
  32155. * Observable event triggered each time the canvas loses focus
  32156. */
  32157. onCanvasBlurObservable: Observable<Engine>;
  32158. /**
  32159. * Observable event triggered each time the canvas gains focus
  32160. */
  32161. onCanvasFocusObservable: Observable<Engine>;
  32162. /**
  32163. * Observable event triggered each time the canvas receives pointerout event
  32164. */
  32165. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32166. /**
  32167. * Observable event triggered before each texture is initialized
  32168. */
  32169. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32170. /**
  32171. * Observable raised when the engine begins a new frame
  32172. */
  32173. onBeginFrameObservable: Observable<Engine>;
  32174. /**
  32175. * If set, will be used to request the next animation frame for the render loop
  32176. */
  32177. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32178. /**
  32179. * Observable raised when the engine ends the current frame
  32180. */
  32181. onEndFrameObservable: Observable<Engine>;
  32182. /**
  32183. * Observable raised when the engine is about to compile a shader
  32184. */
  32185. onBeforeShaderCompilationObservable: Observable<Engine>;
  32186. /**
  32187. * Observable raised when the engine has jsut compiled a shader
  32188. */
  32189. onAfterShaderCompilationObservable: Observable<Engine>;
  32190. /**
  32191. * Gets the audio engine
  32192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32193. * @ignorenaming
  32194. */
  32195. static audioEngine: IAudioEngine;
  32196. /**
  32197. * Default AudioEngine factory responsible of creating the Audio Engine.
  32198. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32199. */
  32200. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32201. /**
  32202. * Default offline support factory responsible of creating a tool used to store data locally.
  32203. * By default, this will create a Database object if the workload has been embedded.
  32204. */
  32205. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32206. private _loadingScreen;
  32207. private _pointerLockRequested;
  32208. private _dummyFramebuffer;
  32209. private _rescalePostProcess;
  32210. /** @hidden */
  32211. protected _alphaMode: number;
  32212. /** @hidden */
  32213. protected _alphaEquation: number;
  32214. private _deterministicLockstep;
  32215. private _lockstepMaxSteps;
  32216. protected readonly _supportsHardwareTextureRescaling: boolean;
  32217. private _fps;
  32218. private _deltaTime;
  32219. /**
  32220. * Turn this value on if you want to pause FPS computation when in background
  32221. */
  32222. disablePerformanceMonitorInBackground: boolean;
  32223. private _performanceMonitor;
  32224. /**
  32225. * Gets the performance monitor attached to this engine
  32226. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32227. */
  32228. readonly performanceMonitor: PerformanceMonitor;
  32229. private _onFocus;
  32230. private _onBlur;
  32231. private _onCanvasPointerOut;
  32232. private _onCanvasBlur;
  32233. private _onCanvasFocus;
  32234. private _onFullscreenChange;
  32235. private _onPointerLockChange;
  32236. /**
  32237. * Creates a new engine
  32238. * @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
  32239. * @param antialias defines enable antialiasing (default: false)
  32240. * @param options defines further options to be sent to the getContext() function
  32241. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32242. */
  32243. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32244. /**
  32245. * Gets current aspect ratio
  32246. * @param viewportOwner defines the camera to use to get the aspect ratio
  32247. * @param useScreen defines if screen size must be used (or the current render target if any)
  32248. * @returns a number defining the aspect ratio
  32249. */
  32250. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32251. /**
  32252. * Gets current screen aspect ratio
  32253. * @returns a number defining the aspect ratio
  32254. */
  32255. getScreenAspectRatio(): number;
  32256. /**
  32257. * Gets host document
  32258. * @returns the host document object
  32259. */
  32260. getHostDocument(): Document;
  32261. /**
  32262. * Gets the client rect of the HTML canvas attached with the current webGL context
  32263. * @returns a client rectanglee
  32264. */
  32265. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32266. /**
  32267. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32268. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32269. * @returns true if engine is in deterministic lock step mode
  32270. */
  32271. isDeterministicLockStep(): boolean;
  32272. /**
  32273. * Gets the max steps when engine is running in deterministic lock step
  32274. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32275. * @returns the max steps
  32276. */
  32277. getLockstepMaxSteps(): number;
  32278. /**
  32279. * Force the mipmap generation for the given render target texture
  32280. * @param texture defines the render target texture to use
  32281. */
  32282. generateMipMapsForCubemap(texture: InternalTexture): void;
  32283. /** States */
  32284. /**
  32285. * Set various states to the webGL context
  32286. * @param culling defines backface culling state
  32287. * @param zOffset defines the value to apply to zOffset (0 by default)
  32288. * @param force defines if states must be applied even if cache is up to date
  32289. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32290. */
  32291. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32292. /**
  32293. * Set the z offset to apply to current rendering
  32294. * @param value defines the offset to apply
  32295. */
  32296. setZOffset(value: number): void;
  32297. /**
  32298. * Gets the current value of the zOffset
  32299. * @returns the current zOffset state
  32300. */
  32301. getZOffset(): number;
  32302. /**
  32303. * Enable or disable depth buffering
  32304. * @param enable defines the state to set
  32305. */
  32306. setDepthBuffer(enable: boolean): void;
  32307. /**
  32308. * Gets a boolean indicating if depth writing is enabled
  32309. * @returns the current depth writing state
  32310. */
  32311. getDepthWrite(): boolean;
  32312. /**
  32313. * Enable or disable depth writing
  32314. * @param enable defines the state to set
  32315. */
  32316. setDepthWrite(enable: boolean): void;
  32317. /**
  32318. * Enable or disable color writing
  32319. * @param enable defines the state to set
  32320. */
  32321. setColorWrite(enable: boolean): void;
  32322. /**
  32323. * Gets a boolean indicating if color writing is enabled
  32324. * @returns the current color writing state
  32325. */
  32326. getColorWrite(): boolean;
  32327. /**
  32328. * Sets alpha constants used by some alpha blending modes
  32329. * @param r defines the red component
  32330. * @param g defines the green component
  32331. * @param b defines the blue component
  32332. * @param a defines the alpha component
  32333. */
  32334. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32335. /**
  32336. * Sets the current alpha mode
  32337. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32338. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32339. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32340. */
  32341. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32342. /**
  32343. * Gets the current alpha mode
  32344. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32345. * @returns the current alpha mode
  32346. */
  32347. getAlphaMode(): number;
  32348. /**
  32349. * Sets the current alpha equation
  32350. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32351. */
  32352. setAlphaEquation(equation: number): void;
  32353. /**
  32354. * Gets the current alpha equation.
  32355. * @returns the current alpha equation
  32356. */
  32357. getAlphaEquation(): number;
  32358. /**
  32359. * Gets a boolean indicating if stencil buffer is enabled
  32360. * @returns the current stencil buffer state
  32361. */
  32362. getStencilBuffer(): boolean;
  32363. /**
  32364. * Enable or disable the stencil buffer
  32365. * @param enable defines if the stencil buffer must be enabled or disabled
  32366. */
  32367. setStencilBuffer(enable: boolean): void;
  32368. /**
  32369. * Gets the current stencil mask
  32370. * @returns a number defining the new stencil mask to use
  32371. */
  32372. getStencilMask(): number;
  32373. /**
  32374. * Sets the current stencil mask
  32375. * @param mask defines the new stencil mask to use
  32376. */
  32377. setStencilMask(mask: number): void;
  32378. /**
  32379. * Gets the current stencil function
  32380. * @returns a number defining the stencil function to use
  32381. */
  32382. getStencilFunction(): number;
  32383. /**
  32384. * Gets the current stencil reference value
  32385. * @returns a number defining the stencil reference value to use
  32386. */
  32387. getStencilFunctionReference(): number;
  32388. /**
  32389. * Gets the current stencil mask
  32390. * @returns a number defining the stencil mask to use
  32391. */
  32392. getStencilFunctionMask(): number;
  32393. /**
  32394. * Sets the current stencil function
  32395. * @param stencilFunc defines the new stencil function to use
  32396. */
  32397. setStencilFunction(stencilFunc: number): void;
  32398. /**
  32399. * Sets the current stencil reference
  32400. * @param reference defines the new stencil reference to use
  32401. */
  32402. setStencilFunctionReference(reference: number): void;
  32403. /**
  32404. * Sets the current stencil mask
  32405. * @param mask defines the new stencil mask to use
  32406. */
  32407. setStencilFunctionMask(mask: number): void;
  32408. /**
  32409. * Gets the current stencil operation when stencil fails
  32410. * @returns a number defining stencil operation to use when stencil fails
  32411. */
  32412. getStencilOperationFail(): number;
  32413. /**
  32414. * Gets the current stencil operation when depth fails
  32415. * @returns a number defining stencil operation to use when depth fails
  32416. */
  32417. getStencilOperationDepthFail(): number;
  32418. /**
  32419. * Gets the current stencil operation when stencil passes
  32420. * @returns a number defining stencil operation to use when stencil passes
  32421. */
  32422. getStencilOperationPass(): number;
  32423. /**
  32424. * Sets the stencil operation to use when stencil fails
  32425. * @param operation defines the stencil operation to use when stencil fails
  32426. */
  32427. setStencilOperationFail(operation: number): void;
  32428. /**
  32429. * Sets the stencil operation to use when depth fails
  32430. * @param operation defines the stencil operation to use when depth fails
  32431. */
  32432. setStencilOperationDepthFail(operation: number): void;
  32433. /**
  32434. * Sets the stencil operation to use when stencil passes
  32435. * @param operation defines the stencil operation to use when stencil passes
  32436. */
  32437. setStencilOperationPass(operation: number): void;
  32438. /**
  32439. * Sets a boolean indicating if the dithering state is enabled or disabled
  32440. * @param value defines the dithering state
  32441. */
  32442. setDitheringState(value: boolean): void;
  32443. /**
  32444. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32445. * @param value defines the rasterizer state
  32446. */
  32447. setRasterizerState(value: boolean): void;
  32448. /**
  32449. * Gets the current depth function
  32450. * @returns a number defining the depth function
  32451. */
  32452. getDepthFunction(): Nullable<number>;
  32453. /**
  32454. * Sets the current depth function
  32455. * @param depthFunc defines the function to use
  32456. */
  32457. setDepthFunction(depthFunc: number): void;
  32458. /**
  32459. * Sets the current depth function to GREATER
  32460. */
  32461. setDepthFunctionToGreater(): void;
  32462. /**
  32463. * Sets the current depth function to GEQUAL
  32464. */
  32465. setDepthFunctionToGreaterOrEqual(): void;
  32466. /**
  32467. * Sets the current depth function to LESS
  32468. */
  32469. setDepthFunctionToLess(): void;
  32470. /**
  32471. * Sets the current depth function to LEQUAL
  32472. */
  32473. setDepthFunctionToLessOrEqual(): void;
  32474. private _cachedStencilBuffer;
  32475. private _cachedStencilFunction;
  32476. private _cachedStencilMask;
  32477. private _cachedStencilOperationPass;
  32478. private _cachedStencilOperationFail;
  32479. private _cachedStencilOperationDepthFail;
  32480. private _cachedStencilReference;
  32481. /**
  32482. * Caches the the state of the stencil buffer
  32483. */
  32484. cacheStencilState(): void;
  32485. /**
  32486. * Restores the state of the stencil buffer
  32487. */
  32488. restoreStencilState(): void;
  32489. /**
  32490. * Directly set the WebGL Viewport
  32491. * @param x defines the x coordinate of the viewport (in screen space)
  32492. * @param y defines the y coordinate of the viewport (in screen space)
  32493. * @param width defines the width of the viewport (in screen space)
  32494. * @param height defines the height of the viewport (in screen space)
  32495. * @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
  32496. */
  32497. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32498. /**
  32499. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32500. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32501. * @param y defines the y-coordinate of the corner of the clear rectangle
  32502. * @param width defines the width of the clear rectangle
  32503. * @param height defines the height of the clear rectangle
  32504. * @param clearColor defines the clear color
  32505. */
  32506. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32507. /**
  32508. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32509. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32510. * @param y defines the y-coordinate of the corner of the clear rectangle
  32511. * @param width defines the width of the clear rectangle
  32512. * @param height defines the height of the clear rectangle
  32513. */
  32514. enableScissor(x: number, y: number, width: number, height: number): void;
  32515. /**
  32516. * Disable previously set scissor test rectangle
  32517. */
  32518. disableScissor(): void;
  32519. /**
  32520. * Initializes a webVR display and starts listening to display change events
  32521. * The onVRDisplayChangedObservable will be notified upon these changes
  32522. * @returns The onVRDisplayChangedObservable
  32523. */
  32524. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32525. /** @hidden */
  32526. _prepareVRComponent(): void;
  32527. /** @hidden */
  32528. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32529. /** @hidden */
  32530. _submitVRFrame(): void;
  32531. /**
  32532. * Call this function to leave webVR mode
  32533. * Will do nothing if webVR is not supported or if there is no webVR device
  32534. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32535. */
  32536. disableVR(): void;
  32537. /**
  32538. * Gets a boolean indicating that the system is in VR mode and is presenting
  32539. * @returns true if VR mode is engaged
  32540. */
  32541. isVRPresenting(): boolean;
  32542. /** @hidden */
  32543. _requestVRFrame(): void;
  32544. /** @hidden */
  32545. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32546. /**
  32547. * Gets the source code of the vertex shader associated with a specific webGL program
  32548. * @param program defines the program to use
  32549. * @returns a string containing the source code of the vertex shader associated with the program
  32550. */
  32551. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32552. /**
  32553. * Gets the source code of the fragment shader associated with a specific webGL program
  32554. * @param program defines the program to use
  32555. * @returns a string containing the source code of the fragment shader associated with the program
  32556. */
  32557. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32558. /**
  32559. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32560. * @param x defines the x coordinate of the rectangle where pixels must be read
  32561. * @param y defines the y coordinate of the rectangle where pixels must be read
  32562. * @param width defines the width of the rectangle where pixels must be read
  32563. * @param height defines the height of the rectangle where pixels must be read
  32564. * @returns a Uint8Array containing RGBA colors
  32565. */
  32566. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32567. /**
  32568. * Sets a depth stencil texture from a render target to the according uniform.
  32569. * @param channel The texture channel
  32570. * @param uniform The uniform to set
  32571. * @param texture The render target texture containing the depth stencil texture to apply
  32572. */
  32573. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32574. /**
  32575. * Sets a texture to the webGL context from a postprocess
  32576. * @param channel defines the channel to use
  32577. * @param postProcess defines the source postprocess
  32578. */
  32579. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32580. /**
  32581. * Binds the output of the passed in post process to the texture channel specified
  32582. * @param channel The channel the texture should be bound to
  32583. * @param postProcess The post process which's output should be bound
  32584. */
  32585. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32586. /** @hidden */
  32587. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32588. protected _rebuildBuffers(): void;
  32589. _renderLoop(): void;
  32590. /**
  32591. * Toggle full screen mode
  32592. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32593. */
  32594. switchFullscreen(requestPointerLock: boolean): void;
  32595. /**
  32596. * Enters full screen mode
  32597. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32598. */
  32599. enterFullscreen(requestPointerLock: boolean): void;
  32600. /**
  32601. * Exits full screen mode
  32602. */
  32603. exitFullscreen(): void;
  32604. /**
  32605. * Enters Pointerlock mode
  32606. */
  32607. enterPointerlock(): void;
  32608. /**
  32609. * Exits Pointerlock mode
  32610. */
  32611. exitPointerlock(): void;
  32612. /**
  32613. * Begin a new frame
  32614. */
  32615. beginFrame(): void;
  32616. /**
  32617. * Enf the current frame
  32618. */
  32619. endFrame(): void;
  32620. resize(): void;
  32621. /**
  32622. * Set the compressed texture format to use, based on the formats you have, and the formats
  32623. * supported by the hardware / browser.
  32624. *
  32625. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32626. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32627. * to API arguments needed to compressed textures. This puts the burden on the container
  32628. * generator to house the arcane code for determining these for current & future formats.
  32629. *
  32630. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32631. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32632. *
  32633. * Note: The result of this call is not taken into account when a texture is base64.
  32634. *
  32635. * @param formatsAvailable defines the list of those format families you have created
  32636. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32637. *
  32638. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32639. * @returns The extension selected.
  32640. */
  32641. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32642. /**
  32643. * Force a specific size of the canvas
  32644. * @param width defines the new canvas' width
  32645. * @param height defines the new canvas' height
  32646. */
  32647. setSize(width: number, height: number): void;
  32648. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32649. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32650. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32651. _releaseTexture(texture: InternalTexture): void;
  32652. /**
  32653. * @hidden
  32654. * Rescales a texture
  32655. * @param source input texutre
  32656. * @param destination destination texture
  32657. * @param scene scene to use to render the resize
  32658. * @param internalFormat format to use when resizing
  32659. * @param onComplete callback to be called when resize has completed
  32660. */
  32661. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32662. /**
  32663. * Gets the current framerate
  32664. * @returns a number representing the framerate
  32665. */
  32666. getFps(): number;
  32667. /**
  32668. * Gets the time spent between current and previous frame
  32669. * @returns a number representing the delta time in ms
  32670. */
  32671. getDeltaTime(): number;
  32672. private _measureFps;
  32673. /**
  32674. * Creates a new render target texture
  32675. * @param size defines the size of the texture
  32676. * @param options defines the options used to create the texture
  32677. * @returns a new render target texture stored in an InternalTexture
  32678. */
  32679. createRenderTargetTexture(size: number | {
  32680. width: number;
  32681. height: number;
  32682. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32683. /**
  32684. * Updates the sample count of a render target texture
  32685. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32686. * @param texture defines the texture to update
  32687. * @param samples defines the sample count to set
  32688. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32689. */
  32690. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32691. /** @hidden */
  32692. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32693. dispose(): void;
  32694. private _disableTouchAction;
  32695. /**
  32696. * Display the loading screen
  32697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32698. */
  32699. displayLoadingUI(): void;
  32700. /**
  32701. * Hide the loading screen
  32702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32703. */
  32704. hideLoadingUI(): void;
  32705. /**
  32706. * Gets the current loading screen object
  32707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32708. */
  32709. /**
  32710. * Sets the current loading screen object
  32711. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32712. */
  32713. loadingScreen: ILoadingScreen;
  32714. /**
  32715. * Sets the current loading screen text
  32716. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32717. */
  32718. loadingUIText: string;
  32719. /**
  32720. * Sets the current loading screen background color
  32721. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32722. */
  32723. loadingUIBackgroundColor: string;
  32724. /** Pointerlock and fullscreen */
  32725. /**
  32726. * Ask the browser to promote the current element to pointerlock mode
  32727. * @param element defines the DOM element to promote
  32728. */
  32729. static _RequestPointerlock(element: HTMLElement): void;
  32730. /**
  32731. * Asks the browser to exit pointerlock mode
  32732. */
  32733. static _ExitPointerlock(): void;
  32734. /**
  32735. * Ask the browser to promote the current element to fullscreen rendering mode
  32736. * @param element defines the DOM element to promote
  32737. */
  32738. static _RequestFullscreen(element: HTMLElement): void;
  32739. /**
  32740. * Asks the browser to exit fullscreen mode
  32741. */
  32742. static _ExitFullscreen(): void;
  32743. }
  32744. }
  32745. declare module "babylonjs/Engines/engineStore" {
  32746. import { Nullable } from "babylonjs/types";
  32747. import { Engine } from "babylonjs/Engines/engine";
  32748. import { Scene } from "babylonjs/scene";
  32749. /**
  32750. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32751. * during the life time of the application.
  32752. */
  32753. export class EngineStore {
  32754. /** Gets the list of created engines */
  32755. static Instances: import("babylonjs/Engines/engine").Engine[];
  32756. /** @hidden */
  32757. static _LastCreatedScene: Nullable<Scene>;
  32758. /**
  32759. * Gets the latest created engine
  32760. */
  32761. static readonly LastCreatedEngine: Nullable<Engine>;
  32762. /**
  32763. * Gets the latest created scene
  32764. */
  32765. static readonly LastCreatedScene: Nullable<Scene>;
  32766. /**
  32767. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32768. * @ignorenaming
  32769. */
  32770. static UseFallbackTexture: boolean;
  32771. /**
  32772. * Texture content used if a texture cannot loaded
  32773. * @ignorenaming
  32774. */
  32775. static FallbackTexture: string;
  32776. }
  32777. }
  32778. declare module "babylonjs/Misc/promise" {
  32779. /**
  32780. * Helper class that provides a small promise polyfill
  32781. */
  32782. export class PromisePolyfill {
  32783. /**
  32784. * Static function used to check if the polyfill is required
  32785. * If this is the case then the function will inject the polyfill to window.Promise
  32786. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32787. */
  32788. static Apply(force?: boolean): void;
  32789. }
  32790. }
  32791. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32792. /**
  32793. * Interface for screenshot methods with describe argument called `size` as object with options
  32794. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32795. */
  32796. export interface IScreenshotSize {
  32797. /**
  32798. * number in pixels for canvas height
  32799. */
  32800. height?: number;
  32801. /**
  32802. * multiplier allowing render at a higher or lower resolution
  32803. * If value is defined then height and width will be ignored and taken from camera
  32804. */
  32805. precision?: number;
  32806. /**
  32807. * number in pixels for canvas width
  32808. */
  32809. width?: number;
  32810. }
  32811. }
  32812. declare module "babylonjs/Misc/tools" {
  32813. import { Nullable, float } from "babylonjs/types";
  32814. import { DomManagement } from "babylonjs/Misc/domManagement";
  32815. import { WebRequest } from "babylonjs/Misc/webRequest";
  32816. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32817. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32818. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32819. import { Camera } from "babylonjs/Cameras/camera";
  32820. import { Engine } from "babylonjs/Engines/engine";
  32821. interface IColor4Like {
  32822. r: float;
  32823. g: float;
  32824. b: float;
  32825. a: float;
  32826. }
  32827. /**
  32828. * Class containing a set of static utilities functions
  32829. */
  32830. export class Tools {
  32831. /**
  32832. * Gets or sets the base URL to use to load assets
  32833. */
  32834. static BaseUrl: string;
  32835. /**
  32836. * Enable/Disable Custom HTTP Request Headers globally.
  32837. * default = false
  32838. * @see CustomRequestHeaders
  32839. */
  32840. static UseCustomRequestHeaders: boolean;
  32841. /**
  32842. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32843. * i.e. when loading files, where the server/service expects an Authorization header
  32844. */
  32845. static CustomRequestHeaders: {
  32846. [key: string]: string;
  32847. };
  32848. /**
  32849. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32850. */
  32851. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32852. /**
  32853. * Default behaviour for cors in the application.
  32854. * It can be a string if the expected behavior is identical in the entire app.
  32855. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32856. */
  32857. static CorsBehavior: string | ((url: string | string[]) => string);
  32858. /**
  32859. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32860. * @ignorenaming
  32861. */
  32862. static UseFallbackTexture: boolean;
  32863. /**
  32864. * Use this object to register external classes like custom textures or material
  32865. * to allow the laoders to instantiate them
  32866. */
  32867. static RegisteredExternalClasses: {
  32868. [key: string]: Object;
  32869. };
  32870. /**
  32871. * Texture content used if a texture cannot loaded
  32872. * @ignorenaming
  32873. */
  32874. static fallbackTexture: string;
  32875. /**
  32876. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32877. * @param u defines the coordinate on X axis
  32878. * @param v defines the coordinate on Y axis
  32879. * @param width defines the width of the source data
  32880. * @param height defines the height of the source data
  32881. * @param pixels defines the source byte array
  32882. * @param color defines the output color
  32883. */
  32884. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32885. /**
  32886. * Interpolates between a and b via alpha
  32887. * @param a The lower value (returned when alpha = 0)
  32888. * @param b The upper value (returned when alpha = 1)
  32889. * @param alpha The interpolation-factor
  32890. * @return The mixed value
  32891. */
  32892. static Mix(a: number, b: number, alpha: number): number;
  32893. /**
  32894. * Tries to instantiate a new object from a given class name
  32895. * @param className defines the class name to instantiate
  32896. * @returns the new object or null if the system was not able to do the instantiation
  32897. */
  32898. static Instantiate(className: string): any;
  32899. /**
  32900. * Provides a slice function that will work even on IE
  32901. * @param data defines the array to slice
  32902. * @param start defines the start of the data (optional)
  32903. * @param end defines the end of the data (optional)
  32904. * @returns the new sliced array
  32905. */
  32906. static Slice<T>(data: T, start?: number, end?: number): T;
  32907. /**
  32908. * Polyfill for setImmediate
  32909. * @param action defines the action to execute after the current execution block
  32910. */
  32911. static SetImmediate(action: () => void): void;
  32912. /**
  32913. * Function indicating if a number is an exponent of 2
  32914. * @param value defines the value to test
  32915. * @returns true if the value is an exponent of 2
  32916. */
  32917. static IsExponentOfTwo(value: number): boolean;
  32918. private static _tmpFloatArray;
  32919. /**
  32920. * Returns the nearest 32-bit single precision float representation of a Number
  32921. * @param value A Number. If the parameter is of a different type, it will get converted
  32922. * to a number or to NaN if it cannot be converted
  32923. * @returns number
  32924. */
  32925. static FloatRound(value: number): number;
  32926. /**
  32927. * Extracts the filename from a path
  32928. * @param path defines the path to use
  32929. * @returns the filename
  32930. */
  32931. static GetFilename(path: string): string;
  32932. /**
  32933. * Extracts the "folder" part of a path (everything before the filename).
  32934. * @param uri The URI to extract the info from
  32935. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32936. * @returns The "folder" part of the path
  32937. */
  32938. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32939. /**
  32940. * Extracts text content from a DOM element hierarchy
  32941. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32942. */
  32943. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32944. /**
  32945. * Convert an angle in radians to degrees
  32946. * @param angle defines the angle to convert
  32947. * @returns the angle in degrees
  32948. */
  32949. static ToDegrees(angle: number): number;
  32950. /**
  32951. * Convert an angle in degrees to radians
  32952. * @param angle defines the angle to convert
  32953. * @returns the angle in radians
  32954. */
  32955. static ToRadians(angle: number): number;
  32956. /**
  32957. * Encode a buffer to a base64 string
  32958. * @param buffer defines the buffer to encode
  32959. * @returns the encoded string
  32960. */
  32961. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32962. /**
  32963. * Returns an array if obj is not an array
  32964. * @param obj defines the object to evaluate as an array
  32965. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32966. * @returns either obj directly if obj is an array or a new array containing obj
  32967. */
  32968. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32969. /**
  32970. * Gets the pointer prefix to use
  32971. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32972. */
  32973. static GetPointerPrefix(): string;
  32974. /**
  32975. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32976. * @param url define the url we are trying
  32977. * @param element define the dom element where to configure the cors policy
  32978. */
  32979. static SetCorsBehavior(url: string | string[], element: {
  32980. crossOrigin: string | null;
  32981. }): void;
  32982. /**
  32983. * Removes unwanted characters from an url
  32984. * @param url defines the url to clean
  32985. * @returns the cleaned url
  32986. */
  32987. static CleanUrl(url: string): string;
  32988. /**
  32989. * Gets or sets a function used to pre-process url before using them to load assets
  32990. */
  32991. static PreprocessUrl: (url: string) => string;
  32992. /**
  32993. * Loads an image as an HTMLImageElement.
  32994. * @param input url string, ArrayBuffer, or Blob to load
  32995. * @param onLoad callback called when the image successfully loads
  32996. * @param onError callback called when the image fails to load
  32997. * @param offlineProvider offline provider for caching
  32998. * @returns the HTMLImageElement of the loaded image
  32999. */
  33000. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  33001. /**
  33002. * Loads a file
  33003. * @param url url string, ArrayBuffer, or Blob to load
  33004. * @param onSuccess callback called when the file successfully loads
  33005. * @param onProgress callback called while file is loading (if the server supports this mode)
  33006. * @param offlineProvider defines the offline provider for caching
  33007. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33008. * @param onError callback called when the file fails to load
  33009. * @returns a file request object
  33010. */
  33011. 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;
  33012. /**
  33013. * Loads a file from a url
  33014. * @param url the file url to load
  33015. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33016. */
  33017. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33018. /**
  33019. * Load a script (identified by an url). When the url returns, the
  33020. * content of this file is added into a new script element, attached to the DOM (body element)
  33021. * @param scriptUrl defines the url of the script to laod
  33022. * @param onSuccess defines the callback called when the script is loaded
  33023. * @param onError defines the callback to call if an error occurs
  33024. * @param scriptId defines the id of the script element
  33025. */
  33026. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33027. /**
  33028. * Load an asynchronous script (identified by an url). When the url returns, the
  33029. * content of this file is added into a new script element, attached to the DOM (body element)
  33030. * @param scriptUrl defines the url of the script to laod
  33031. * @param scriptId defines the id of the script element
  33032. * @returns a promise request object
  33033. */
  33034. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33035. /**
  33036. * Loads a file from a blob
  33037. * @param fileToLoad defines the blob to use
  33038. * @param callback defines the callback to call when data is loaded
  33039. * @param progressCallback defines the callback to call during loading process
  33040. * @returns a file request object
  33041. */
  33042. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33043. /**
  33044. * Loads a file
  33045. * @param fileToLoad defines the file to load
  33046. * @param callback defines the callback to call when data is loaded
  33047. * @param progressCallBack defines the callback to call during loading process
  33048. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33049. * @returns a file request object
  33050. */
  33051. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33052. /**
  33053. * Creates a data url from a given string content
  33054. * @param content defines the content to convert
  33055. * @returns the new data url link
  33056. */
  33057. static FileAsURL(content: string): string;
  33058. /**
  33059. * Format the given number to a specific decimal format
  33060. * @param value defines the number to format
  33061. * @param decimals defines the number of decimals to use
  33062. * @returns the formatted string
  33063. */
  33064. static Format(value: number, decimals?: number): string;
  33065. /**
  33066. * Tries to copy an object by duplicating every property
  33067. * @param source defines the source object
  33068. * @param destination defines the target object
  33069. * @param doNotCopyList defines a list of properties to avoid
  33070. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33071. */
  33072. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33073. /**
  33074. * Gets a boolean indicating if the given object has no own property
  33075. * @param obj defines the object to test
  33076. * @returns true if object has no own property
  33077. */
  33078. static IsEmpty(obj: any): boolean;
  33079. /**
  33080. * Function used to register events at window level
  33081. * @param windowElement defines the Window object to use
  33082. * @param events defines the events to register
  33083. */
  33084. static RegisterTopRootEvents(windowElement: Window, events: {
  33085. name: string;
  33086. handler: Nullable<(e: FocusEvent) => any>;
  33087. }[]): void;
  33088. /**
  33089. * Function used to unregister events from window level
  33090. * @param windowElement defines the Window object to use
  33091. * @param events defines the events to unregister
  33092. */
  33093. static UnregisterTopRootEvents(windowElement: Window, events: {
  33094. name: string;
  33095. handler: Nullable<(e: FocusEvent) => any>;
  33096. }[]): void;
  33097. /**
  33098. * @ignore
  33099. */
  33100. static _ScreenshotCanvas: HTMLCanvasElement;
  33101. /**
  33102. * Dumps the current bound framebuffer
  33103. * @param width defines the rendering width
  33104. * @param height defines the rendering height
  33105. * @param engine defines the hosting engine
  33106. * @param successCallback defines the callback triggered once the data are available
  33107. * @param mimeType defines the mime type of the result
  33108. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33109. */
  33110. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33111. /**
  33112. * Converts the canvas data to blob.
  33113. * This acts as a polyfill for browsers not supporting the to blob function.
  33114. * @param canvas Defines the canvas to extract the data from
  33115. * @param successCallback Defines the callback triggered once the data are available
  33116. * @param mimeType Defines the mime type of the result
  33117. */
  33118. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33119. /**
  33120. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33121. * @param successCallback defines the callback triggered once the data are available
  33122. * @param mimeType defines the mime type of the result
  33123. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33124. */
  33125. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33126. /**
  33127. * Downloads a blob in the browser
  33128. * @param blob defines the blob to download
  33129. * @param fileName defines the name of the downloaded file
  33130. */
  33131. static Download(blob: Blob, fileName: string): void;
  33132. /**
  33133. * Captures a screenshot of the current rendering
  33134. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33135. * @param engine defines the rendering engine
  33136. * @param camera defines the source camera
  33137. * @param size This parameter can be set to a single number or to an object with the
  33138. * following (optional) properties: precision, width, height. If a single number is passed,
  33139. * it will be used for both width and height. If an object is passed, the screenshot size
  33140. * will be derived from the parameters. The precision property is a multiplier allowing
  33141. * rendering at a higher or lower resolution
  33142. * @param successCallback defines the callback receives a single parameter which contains the
  33143. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33144. * src parameter of an <img> to display it
  33145. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33146. * Check your browser for supported MIME types
  33147. */
  33148. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33149. /**
  33150. * Captures a screenshot of the current rendering
  33151. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33152. * @param engine defines the rendering engine
  33153. * @param camera defines the source camera
  33154. * @param size This parameter can be set to a single number or to an object with the
  33155. * following (optional) properties: precision, width, height. If a single number is passed,
  33156. * it will be used for both width and height. If an object is passed, the screenshot size
  33157. * will be derived from the parameters. The precision property is a multiplier allowing
  33158. * rendering at a higher or lower resolution
  33159. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33160. * Check your browser for supported MIME types
  33161. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33162. * to the src parameter of an <img> to display it
  33163. */
  33164. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33165. /**
  33166. * Generates an image screenshot from the specified camera.
  33167. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33168. * @param engine The engine to use for rendering
  33169. * @param camera The camera to use for rendering
  33170. * @param size This parameter can be set to a single number or to an object with the
  33171. * following (optional) properties: precision, width, height. If a single number is passed,
  33172. * it will be used for both width and height. If an object is passed, the screenshot size
  33173. * will be derived from the parameters. The precision property is a multiplier allowing
  33174. * rendering at a higher or lower resolution
  33175. * @param successCallback The callback receives a single parameter which contains the
  33176. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33177. * src parameter of an <img> to display it
  33178. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33179. * Check your browser for supported MIME types
  33180. * @param samples Texture samples (default: 1)
  33181. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33182. * @param fileName A name for for the downloaded file.
  33183. */
  33184. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33185. /**
  33186. * Generates an image screenshot from the specified camera.
  33187. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33188. * @param engine The engine to use for rendering
  33189. * @param camera The camera to use for rendering
  33190. * @param size This parameter can be set to a single number or to an object with the
  33191. * following (optional) properties: precision, width, height. If a single number is passed,
  33192. * it will be used for both width and height. If an object is passed, the screenshot size
  33193. * will be derived from the parameters. The precision property is a multiplier allowing
  33194. * rendering at a higher or lower resolution
  33195. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33196. * Check your browser for supported MIME types
  33197. * @param samples Texture samples (default: 1)
  33198. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33199. * @param fileName A name for for the downloaded file.
  33200. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33201. * to the src parameter of an <img> to display it
  33202. */
  33203. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33204. /**
  33205. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33206. * Be aware Math.random() could cause collisions, but:
  33207. * "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"
  33208. * @returns a pseudo random id
  33209. */
  33210. static RandomId(): string;
  33211. /**
  33212. * Test if the given uri is a base64 string
  33213. * @param uri The uri to test
  33214. * @return True if the uri is a base64 string or false otherwise
  33215. */
  33216. static IsBase64(uri: string): boolean;
  33217. /**
  33218. * Decode the given base64 uri.
  33219. * @param uri The uri to decode
  33220. * @return The decoded base64 data.
  33221. */
  33222. static DecodeBase64(uri: string): ArrayBuffer;
  33223. /**
  33224. * Gets the absolute url.
  33225. * @param url the input url
  33226. * @return the absolute url
  33227. */
  33228. static GetAbsoluteUrl(url: string): string;
  33229. /**
  33230. * No log
  33231. */
  33232. static readonly NoneLogLevel: number;
  33233. /**
  33234. * Only message logs
  33235. */
  33236. static readonly MessageLogLevel: number;
  33237. /**
  33238. * Only warning logs
  33239. */
  33240. static readonly WarningLogLevel: number;
  33241. /**
  33242. * Only error logs
  33243. */
  33244. static readonly ErrorLogLevel: number;
  33245. /**
  33246. * All logs
  33247. */
  33248. static readonly AllLogLevel: number;
  33249. /**
  33250. * Gets a value indicating the number of loading errors
  33251. * @ignorenaming
  33252. */
  33253. static readonly errorsCount: number;
  33254. /**
  33255. * Callback called when a new log is added
  33256. */
  33257. static OnNewCacheEntry: (entry: string) => void;
  33258. /**
  33259. * Log a message to the console
  33260. * @param message defines the message to log
  33261. */
  33262. static Log(message: string): void;
  33263. /**
  33264. * Write a warning message to the console
  33265. * @param message defines the message to log
  33266. */
  33267. static Warn(message: string): void;
  33268. /**
  33269. * Write an error message to the console
  33270. * @param message defines the message to log
  33271. */
  33272. static Error(message: string): void;
  33273. /**
  33274. * Gets current log cache (list of logs)
  33275. */
  33276. static readonly LogCache: string;
  33277. /**
  33278. * Clears the log cache
  33279. */
  33280. static ClearLogCache(): void;
  33281. /**
  33282. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33283. */
  33284. static LogLevels: number;
  33285. /**
  33286. * Checks if the window object exists
  33287. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33288. */
  33289. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33290. /**
  33291. * No performance log
  33292. */
  33293. static readonly PerformanceNoneLogLevel: number;
  33294. /**
  33295. * Use user marks to log performance
  33296. */
  33297. static readonly PerformanceUserMarkLogLevel: number;
  33298. /**
  33299. * Log performance to the console
  33300. */
  33301. static readonly PerformanceConsoleLogLevel: number;
  33302. private static _performance;
  33303. /**
  33304. * Sets the current performance log level
  33305. */
  33306. static PerformanceLogLevel: number;
  33307. private static _StartPerformanceCounterDisabled;
  33308. private static _EndPerformanceCounterDisabled;
  33309. private static _StartUserMark;
  33310. private static _EndUserMark;
  33311. private static _StartPerformanceConsole;
  33312. private static _EndPerformanceConsole;
  33313. /**
  33314. * Starts a performance counter
  33315. */
  33316. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33317. /**
  33318. * Ends a specific performance coutner
  33319. */
  33320. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33321. /**
  33322. * Gets either window.performance.now() if supported or Date.now() else
  33323. */
  33324. static readonly Now: number;
  33325. /**
  33326. * This method will return the name of the class used to create the instance of the given object.
  33327. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33328. * @param object the object to get the class name from
  33329. * @param isType defines if the object is actually a type
  33330. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33331. */
  33332. static GetClassName(object: any, isType?: boolean): string;
  33333. /**
  33334. * Gets the first element of an array satisfying a given predicate
  33335. * @param array defines the array to browse
  33336. * @param predicate defines the predicate to use
  33337. * @returns null if not found or the element
  33338. */
  33339. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33340. /**
  33341. * This method will return the name of the full name of the class, including its owning module (if any).
  33342. * 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).
  33343. * @param object the object to get the class name from
  33344. * @param isType defines if the object is actually a type
  33345. * @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.
  33346. * @ignorenaming
  33347. */
  33348. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33349. /**
  33350. * Returns a promise that resolves after the given amount of time.
  33351. * @param delay Number of milliseconds to delay
  33352. * @returns Promise that resolves after the given amount of time
  33353. */
  33354. static DelayAsync(delay: number): Promise<void>;
  33355. }
  33356. /**
  33357. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33358. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33359. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33360. * @param name The name of the class, case should be preserved
  33361. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33362. */
  33363. export function className(name: string, module?: string): (target: Object) => void;
  33364. /**
  33365. * An implementation of a loop for asynchronous functions.
  33366. */
  33367. export class AsyncLoop {
  33368. /**
  33369. * Defines the number of iterations for the loop
  33370. */
  33371. iterations: number;
  33372. /**
  33373. * Defines the current index of the loop.
  33374. */
  33375. index: number;
  33376. private _done;
  33377. private _fn;
  33378. private _successCallback;
  33379. /**
  33380. * Constructor.
  33381. * @param iterations the number of iterations.
  33382. * @param func the function to run each iteration
  33383. * @param successCallback the callback that will be called upon succesful execution
  33384. * @param offset starting offset.
  33385. */
  33386. constructor(
  33387. /**
  33388. * Defines the number of iterations for the loop
  33389. */
  33390. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33391. /**
  33392. * Execute the next iteration. Must be called after the last iteration was finished.
  33393. */
  33394. executeNext(): void;
  33395. /**
  33396. * Break the loop and run the success callback.
  33397. */
  33398. breakLoop(): void;
  33399. /**
  33400. * Create and run an async loop.
  33401. * @param iterations the number of iterations.
  33402. * @param fn the function to run each iteration
  33403. * @param successCallback the callback that will be called upon succesful execution
  33404. * @param offset starting offset.
  33405. * @returns the created async loop object
  33406. */
  33407. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33408. /**
  33409. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33410. * @param iterations total number of iterations
  33411. * @param syncedIterations number of synchronous iterations in each async iteration.
  33412. * @param fn the function to call each iteration.
  33413. * @param callback a success call back that will be called when iterating stops.
  33414. * @param breakFunction a break condition (optional)
  33415. * @param timeout timeout settings for the setTimeout function. default - 0.
  33416. * @returns the created async loop object
  33417. */
  33418. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33419. }
  33420. }
  33421. declare module "babylonjs/Misc/stringDictionary" {
  33422. import { Nullable } from "babylonjs/types";
  33423. /**
  33424. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33425. * The underlying implementation relies on an associative array to ensure the best performances.
  33426. * The value can be anything including 'null' but except 'undefined'
  33427. */
  33428. export class StringDictionary<T> {
  33429. /**
  33430. * This will clear this dictionary and copy the content from the 'source' one.
  33431. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33432. * @param source the dictionary to take the content from and copy to this dictionary
  33433. */
  33434. copyFrom(source: StringDictionary<T>): void;
  33435. /**
  33436. * Get a value based from its key
  33437. * @param key the given key to get the matching value from
  33438. * @return the value if found, otherwise undefined is returned
  33439. */
  33440. get(key: string): T | undefined;
  33441. /**
  33442. * Get a value from its key or add it if it doesn't exist.
  33443. * This method will ensure you that a given key/data will be present in the dictionary.
  33444. * @param key the given key to get the matching value from
  33445. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33446. * The factory will only be invoked if there's no data for the given key.
  33447. * @return the value corresponding to the key.
  33448. */
  33449. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33450. /**
  33451. * Get a value from its key if present in the dictionary otherwise add it
  33452. * @param key the key to get the value from
  33453. * @param val if there's no such key/value pair in the dictionary add it with this value
  33454. * @return the value corresponding to the key
  33455. */
  33456. getOrAdd(key: string, val: T): T;
  33457. /**
  33458. * Check if there's a given key in the dictionary
  33459. * @param key the key to check for
  33460. * @return true if the key is present, false otherwise
  33461. */
  33462. contains(key: string): boolean;
  33463. /**
  33464. * Add a new key and its corresponding value
  33465. * @param key the key to add
  33466. * @param value the value corresponding to the key
  33467. * @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
  33468. */
  33469. add(key: string, value: T): boolean;
  33470. /**
  33471. * Update a specific value associated to a key
  33472. * @param key defines the key to use
  33473. * @param value defines the value to store
  33474. * @returns true if the value was updated (or false if the key was not found)
  33475. */
  33476. set(key: string, value: T): boolean;
  33477. /**
  33478. * Get the element of the given key and remove it from the dictionary
  33479. * @param key defines the key to search
  33480. * @returns the value associated with the key or null if not found
  33481. */
  33482. getAndRemove(key: string): Nullable<T>;
  33483. /**
  33484. * Remove a key/value from the dictionary.
  33485. * @param key the key to remove
  33486. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33487. */
  33488. remove(key: string): boolean;
  33489. /**
  33490. * Clear the whole content of the dictionary
  33491. */
  33492. clear(): void;
  33493. /**
  33494. * Gets the current count
  33495. */
  33496. readonly count: number;
  33497. /**
  33498. * Execute a callback on each key/val of the dictionary.
  33499. * Note that you can remove any element in this dictionary in the callback implementation
  33500. * @param callback the callback to execute on a given key/value pair
  33501. */
  33502. forEach(callback: (key: string, val: T) => void): void;
  33503. /**
  33504. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33505. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33506. * Note that you can remove any element in this dictionary in the callback implementation
  33507. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33508. * @returns the first item
  33509. */
  33510. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33511. private _count;
  33512. private _data;
  33513. }
  33514. }
  33515. declare module "babylonjs/Collisions/collisionCoordinator" {
  33516. import { Nullable } from "babylonjs/types";
  33517. import { Scene } from "babylonjs/scene";
  33518. import { Vector3 } from "babylonjs/Maths/math.vector";
  33519. import { Collider } from "babylonjs/Collisions/collider";
  33520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33521. /** @hidden */
  33522. export interface ICollisionCoordinator {
  33523. createCollider(): Collider;
  33524. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33525. init(scene: Scene): void;
  33526. }
  33527. /** @hidden */
  33528. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33529. private _scene;
  33530. private _scaledPosition;
  33531. private _scaledVelocity;
  33532. private _finalPosition;
  33533. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33534. createCollider(): Collider;
  33535. init(scene: Scene): void;
  33536. private _collideWithWorld;
  33537. }
  33538. }
  33539. declare module "babylonjs/Inputs/scene.inputManager" {
  33540. import { Nullable } from "babylonjs/types";
  33541. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33542. import { Vector2 } from "babylonjs/Maths/math.vector";
  33543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33544. import { Scene } from "babylonjs/scene";
  33545. /**
  33546. * Class used to manage all inputs for the scene.
  33547. */
  33548. export class InputManager {
  33549. /** The distance in pixel that you have to move to prevent some events */
  33550. static DragMovementThreshold: number;
  33551. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33552. static LongPressDelay: number;
  33553. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33554. static DoubleClickDelay: number;
  33555. /** If you need to check double click without raising a single click at first click, enable this flag */
  33556. static ExclusiveDoubleClickMode: boolean;
  33557. private _wheelEventName;
  33558. private _onPointerMove;
  33559. private _onPointerDown;
  33560. private _onPointerUp;
  33561. private _initClickEvent;
  33562. private _initActionManager;
  33563. private _delayedSimpleClick;
  33564. private _delayedSimpleClickTimeout;
  33565. private _previousDelayedSimpleClickTimeout;
  33566. private _meshPickProceed;
  33567. private _previousButtonPressed;
  33568. private _currentPickResult;
  33569. private _previousPickResult;
  33570. private _totalPointersPressed;
  33571. private _doubleClickOccured;
  33572. private _pointerOverMesh;
  33573. private _pickedDownMesh;
  33574. private _pickedUpMesh;
  33575. private _pointerX;
  33576. private _pointerY;
  33577. private _unTranslatedPointerX;
  33578. private _unTranslatedPointerY;
  33579. private _startingPointerPosition;
  33580. private _previousStartingPointerPosition;
  33581. private _startingPointerTime;
  33582. private _previousStartingPointerTime;
  33583. private _pointerCaptures;
  33584. private _onKeyDown;
  33585. private _onKeyUp;
  33586. private _onCanvasFocusObserver;
  33587. private _onCanvasBlurObserver;
  33588. private _scene;
  33589. /**
  33590. * Creates a new InputManager
  33591. * @param scene defines the hosting scene
  33592. */
  33593. constructor(scene: Scene);
  33594. /**
  33595. * Gets the mesh that is currently under the pointer
  33596. */
  33597. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33598. /**
  33599. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33600. */
  33601. readonly unTranslatedPointer: Vector2;
  33602. /**
  33603. * Gets or sets the current on-screen X position of the pointer
  33604. */
  33605. pointerX: number;
  33606. /**
  33607. * Gets or sets the current on-screen Y position of the pointer
  33608. */
  33609. pointerY: number;
  33610. private _updatePointerPosition;
  33611. private _processPointerMove;
  33612. private _setRayOnPointerInfo;
  33613. private _checkPrePointerObservable;
  33614. /**
  33615. * Use this method to simulate a pointer move on a mesh
  33616. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33617. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33618. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33619. */
  33620. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33621. /**
  33622. * Use this method to simulate a pointer down on a mesh
  33623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33626. */
  33627. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33628. private _processPointerDown;
  33629. /** @hidden */
  33630. _isPointerSwiping(): boolean;
  33631. /**
  33632. * Use this method to simulate a pointer up on a mesh
  33633. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33634. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33635. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33636. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33637. */
  33638. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33639. private _processPointerUp;
  33640. /**
  33641. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33642. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33643. * @returns true if the pointer was captured
  33644. */
  33645. isPointerCaptured(pointerId?: number): boolean;
  33646. /**
  33647. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33648. * @param attachUp defines if you want to attach events to pointerup
  33649. * @param attachDown defines if you want to attach events to pointerdown
  33650. * @param attachMove defines if you want to attach events to pointermove
  33651. */
  33652. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33653. /**
  33654. * Detaches all event handlers
  33655. */
  33656. detachControl(): void;
  33657. /**
  33658. * Force the value of meshUnderPointer
  33659. * @param mesh defines the mesh to use
  33660. */
  33661. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33662. /**
  33663. * Gets the mesh under the pointer
  33664. * @returns a Mesh or null if no mesh is under the pointer
  33665. */
  33666. getPointerOverMesh(): Nullable<AbstractMesh>;
  33667. }
  33668. }
  33669. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33670. /**
  33671. * Helper class used to generate session unique ID
  33672. */
  33673. export class UniqueIdGenerator {
  33674. private static _UniqueIdCounter;
  33675. /**
  33676. * Gets an unique (relatively to the current scene) Id
  33677. */
  33678. static readonly UniqueId: number;
  33679. }
  33680. }
  33681. declare module "babylonjs/Animations/animationGroup" {
  33682. import { Animatable } from "babylonjs/Animations/animatable";
  33683. import { Animation } from "babylonjs/Animations/animation";
  33684. import { Scene, IDisposable } from "babylonjs/scene";
  33685. import { Observable } from "babylonjs/Misc/observable";
  33686. import { Nullable } from "babylonjs/types";
  33687. import "babylonjs/Animations/animatable";
  33688. /**
  33689. * This class defines the direct association between an animation and a target
  33690. */
  33691. export class TargetedAnimation {
  33692. /**
  33693. * Animation to perform
  33694. */
  33695. animation: Animation;
  33696. /**
  33697. * Target to animate
  33698. */
  33699. target: any;
  33700. /**
  33701. * Serialize the object
  33702. * @returns the JSON object representing the current entity
  33703. */
  33704. serialize(): any;
  33705. }
  33706. /**
  33707. * Use this class to create coordinated animations on multiple targets
  33708. */
  33709. export class AnimationGroup implements IDisposable {
  33710. /** The name of the animation group */
  33711. name: string;
  33712. private _scene;
  33713. private _targetedAnimations;
  33714. private _animatables;
  33715. private _from;
  33716. private _to;
  33717. private _isStarted;
  33718. private _isPaused;
  33719. private _speedRatio;
  33720. private _loopAnimation;
  33721. /**
  33722. * Gets or sets the unique id of the node
  33723. */
  33724. uniqueId: number;
  33725. /**
  33726. * This observable will notify when one animation have ended
  33727. */
  33728. onAnimationEndObservable: Observable<TargetedAnimation>;
  33729. /**
  33730. * Observer raised when one animation loops
  33731. */
  33732. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33733. /**
  33734. * This observable will notify when all animations have ended.
  33735. */
  33736. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33737. /**
  33738. * This observable will notify when all animations have paused.
  33739. */
  33740. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33741. /**
  33742. * This observable will notify when all animations are playing.
  33743. */
  33744. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33745. /**
  33746. * Gets the first frame
  33747. */
  33748. readonly from: number;
  33749. /**
  33750. * Gets the last frame
  33751. */
  33752. readonly to: number;
  33753. /**
  33754. * Define if the animations are started
  33755. */
  33756. readonly isStarted: boolean;
  33757. /**
  33758. * Gets a value indicating that the current group is playing
  33759. */
  33760. readonly isPlaying: boolean;
  33761. /**
  33762. * Gets or sets the speed ratio to use for all animations
  33763. */
  33764. /**
  33765. * Gets or sets the speed ratio to use for all animations
  33766. */
  33767. speedRatio: number;
  33768. /**
  33769. * Gets or sets if all animations should loop or not
  33770. */
  33771. loopAnimation: boolean;
  33772. /**
  33773. * Gets the targeted animations for this animation group
  33774. */
  33775. readonly targetedAnimations: Array<TargetedAnimation>;
  33776. /**
  33777. * returning the list of animatables controlled by this animation group.
  33778. */
  33779. readonly animatables: Array<Animatable>;
  33780. /**
  33781. * Instantiates a new Animation Group.
  33782. * This helps managing several animations at once.
  33783. * @see http://doc.babylonjs.com/how_to/group
  33784. * @param name Defines the name of the group
  33785. * @param scene Defines the scene the group belongs to
  33786. */
  33787. constructor(
  33788. /** The name of the animation group */
  33789. name: string, scene?: Nullable<Scene>);
  33790. /**
  33791. * Add an animation (with its target) in the group
  33792. * @param animation defines the animation we want to add
  33793. * @param target defines the target of the animation
  33794. * @returns the TargetedAnimation object
  33795. */
  33796. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33797. /**
  33798. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33799. * It can add constant keys at begin or end
  33800. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33801. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33802. * @returns the animation group
  33803. */
  33804. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33805. /**
  33806. * Start all animations on given targets
  33807. * @param loop defines if animations must loop
  33808. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33809. * @param from defines the from key (optional)
  33810. * @param to defines the to key (optional)
  33811. * @returns the current animation group
  33812. */
  33813. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33814. /**
  33815. * Pause all animations
  33816. * @returns the animation group
  33817. */
  33818. pause(): AnimationGroup;
  33819. /**
  33820. * Play all animations to initial state
  33821. * This function will start() the animations if they were not started or will restart() them if they were paused
  33822. * @param loop defines if animations must loop
  33823. * @returns the animation group
  33824. */
  33825. play(loop?: boolean): AnimationGroup;
  33826. /**
  33827. * Reset all animations to initial state
  33828. * @returns the animation group
  33829. */
  33830. reset(): AnimationGroup;
  33831. /**
  33832. * Restart animations from key 0
  33833. * @returns the animation group
  33834. */
  33835. restart(): AnimationGroup;
  33836. /**
  33837. * Stop all animations
  33838. * @returns the animation group
  33839. */
  33840. stop(): AnimationGroup;
  33841. /**
  33842. * Set animation weight for all animatables
  33843. * @param weight defines the weight to use
  33844. * @return the animationGroup
  33845. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33846. */
  33847. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33848. /**
  33849. * Synchronize and normalize all animatables with a source animatable
  33850. * @param root defines the root animatable to synchronize with
  33851. * @return the animationGroup
  33852. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33853. */
  33854. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33855. /**
  33856. * Goes to a specific frame in this animation group
  33857. * @param frame the frame number to go to
  33858. * @return the animationGroup
  33859. */
  33860. goToFrame(frame: number): AnimationGroup;
  33861. /**
  33862. * Dispose all associated resources
  33863. */
  33864. dispose(): void;
  33865. private _checkAnimationGroupEnded;
  33866. /**
  33867. * Clone the current animation group and returns a copy
  33868. * @param newName defines the name of the new group
  33869. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33870. * @returns the new aniamtion group
  33871. */
  33872. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33873. /**
  33874. * Serializes the animationGroup to an object
  33875. * @returns Serialized object
  33876. */
  33877. serialize(): any;
  33878. /**
  33879. * Returns a new AnimationGroup object parsed from the source provided.
  33880. * @param parsedAnimationGroup defines the source
  33881. * @param scene defines the scene that will receive the animationGroup
  33882. * @returns a new AnimationGroup
  33883. */
  33884. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33885. /**
  33886. * Returns the string "AnimationGroup"
  33887. * @returns "AnimationGroup"
  33888. */
  33889. getClassName(): string;
  33890. /**
  33891. * Creates a detailled string about the object
  33892. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33893. * @returns a string representing the object
  33894. */
  33895. toString(fullDetails?: boolean): string;
  33896. }
  33897. }
  33898. declare module "babylonjs/scene" {
  33899. import { Nullable } from "babylonjs/types";
  33900. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33901. import { Observable } from "babylonjs/Misc/observable";
  33902. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33903. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33904. import { Geometry } from "babylonjs/Meshes/geometry";
  33905. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33906. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33908. import { Mesh } from "babylonjs/Meshes/mesh";
  33909. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33910. import { Bone } from "babylonjs/Bones/bone";
  33911. import { Skeleton } from "babylonjs/Bones/skeleton";
  33912. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33913. import { Camera } from "babylonjs/Cameras/camera";
  33914. import { AbstractScene } from "babylonjs/abstractScene";
  33915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33916. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33917. import { Material } from "babylonjs/Materials/material";
  33918. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33919. import { Effect } from "babylonjs/Materials/effect";
  33920. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33921. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33922. import { Light } from "babylonjs/Lights/light";
  33923. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33924. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33925. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33926. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33927. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33928. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33929. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33930. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33931. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33932. import { Engine } from "babylonjs/Engines/engine";
  33933. import { Node } from "babylonjs/node";
  33934. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33935. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33936. import { WebRequest } from "babylonjs/Misc/webRequest";
  33937. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33938. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33939. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33940. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33941. import { Plane } from "babylonjs/Maths/math.plane";
  33942. import { Ray } from "babylonjs/Culling/ray";
  33943. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33944. import { Animation } from "babylonjs/Animations/animation";
  33945. import { Animatable } from "babylonjs/Animations/animatable";
  33946. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33947. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33948. import { Collider } from "babylonjs/Collisions/collider";
  33949. /**
  33950. * Define an interface for all classes that will hold resources
  33951. */
  33952. export interface IDisposable {
  33953. /**
  33954. * Releases all held resources
  33955. */
  33956. dispose(): void;
  33957. }
  33958. /** Interface defining initialization parameters for Scene class */
  33959. export interface SceneOptions {
  33960. /**
  33961. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33962. * It will improve performance when the number of geometries becomes important.
  33963. */
  33964. useGeometryUniqueIdsMap?: boolean;
  33965. /**
  33966. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33967. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33968. */
  33969. useMaterialMeshMap?: boolean;
  33970. /**
  33971. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33972. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33973. */
  33974. useClonedMeshhMap?: boolean;
  33975. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33976. virtual?: boolean;
  33977. }
  33978. /**
  33979. * Represents a scene to be rendered by the engine.
  33980. * @see http://doc.babylonjs.com/features/scene
  33981. */
  33982. export class Scene extends AbstractScene implements IAnimatable {
  33983. /** The fog is deactivated */
  33984. static readonly FOGMODE_NONE: number;
  33985. /** The fog density is following an exponential function */
  33986. static readonly FOGMODE_EXP: number;
  33987. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33988. static readonly FOGMODE_EXP2: number;
  33989. /** The fog density is following a linear function. */
  33990. static readonly FOGMODE_LINEAR: number;
  33991. /**
  33992. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33993. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33994. */
  33995. static MinDeltaTime: number;
  33996. /**
  33997. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33998. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33999. */
  34000. static MaxDeltaTime: number;
  34001. /**
  34002. * Factory used to create the default material.
  34003. * @param name The name of the material to create
  34004. * @param scene The scene to create the material for
  34005. * @returns The default material
  34006. */
  34007. static DefaultMaterialFactory(scene: Scene): Material;
  34008. /**
  34009. * Factory used to create the a collision coordinator.
  34010. * @returns The collision coordinator
  34011. */
  34012. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34013. /** @hidden */
  34014. _inputManager: InputManager;
  34015. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34016. cameraToUseForPointers: Nullable<Camera>;
  34017. /** @hidden */
  34018. readonly _isScene: boolean;
  34019. /**
  34020. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34021. */
  34022. autoClear: boolean;
  34023. /**
  34024. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34025. */
  34026. autoClearDepthAndStencil: boolean;
  34027. /**
  34028. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34029. */
  34030. clearColor: Color4;
  34031. /**
  34032. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34033. */
  34034. ambientColor: Color3;
  34035. /**
  34036. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34037. * It should only be one of the following (if not the default embedded one):
  34038. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34039. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34040. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34041. * The material properties need to be setup according to the type of texture in use.
  34042. */
  34043. environmentBRDFTexture: BaseTexture;
  34044. /** @hidden */
  34045. protected _environmentTexture: Nullable<BaseTexture>;
  34046. /**
  34047. * Texture used in all pbr material as the reflection texture.
  34048. * As in the majority of the scene they are the same (exception for multi room and so on),
  34049. * this is easier to reference from here than from all the materials.
  34050. */
  34051. /**
  34052. * Texture used in all pbr material as the reflection texture.
  34053. * As in the majority of the scene they are the same (exception for multi room and so on),
  34054. * this is easier to set here than in all the materials.
  34055. */
  34056. environmentTexture: Nullable<BaseTexture>;
  34057. /** @hidden */
  34058. protected _environmentIntensity: number;
  34059. /**
  34060. * Intensity of the environment in all pbr material.
  34061. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34062. * As in the majority of the scene they are the same (exception for multi room and so on),
  34063. * this is easier to reference from here than from all the materials.
  34064. */
  34065. /**
  34066. * Intensity of the environment in all pbr material.
  34067. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34068. * As in the majority of the scene they are the same (exception for multi room and so on),
  34069. * this is easier to set here than in all the materials.
  34070. */
  34071. environmentIntensity: number;
  34072. /** @hidden */
  34073. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34074. /**
  34075. * Default image processing configuration used either in the rendering
  34076. * Forward main pass or through the imageProcessingPostProcess if present.
  34077. * As in the majority of the scene they are the same (exception for multi camera),
  34078. * this is easier to reference from here than from all the materials and post process.
  34079. *
  34080. * No setter as we it is a shared configuration, you can set the values instead.
  34081. */
  34082. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34083. private _forceWireframe;
  34084. /**
  34085. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34086. */
  34087. forceWireframe: boolean;
  34088. private _forcePointsCloud;
  34089. /**
  34090. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34091. */
  34092. forcePointsCloud: boolean;
  34093. /**
  34094. * Gets or sets the active clipplane 1
  34095. */
  34096. clipPlane: Nullable<Plane>;
  34097. /**
  34098. * Gets or sets the active clipplane 2
  34099. */
  34100. clipPlane2: Nullable<Plane>;
  34101. /**
  34102. * Gets or sets the active clipplane 3
  34103. */
  34104. clipPlane3: Nullable<Plane>;
  34105. /**
  34106. * Gets or sets the active clipplane 4
  34107. */
  34108. clipPlane4: Nullable<Plane>;
  34109. /**
  34110. * Gets or sets a boolean indicating if animations are enabled
  34111. */
  34112. animationsEnabled: boolean;
  34113. private _animationPropertiesOverride;
  34114. /**
  34115. * Gets or sets the animation properties override
  34116. */
  34117. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34118. /**
  34119. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34120. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34121. */
  34122. useConstantAnimationDeltaTime: boolean;
  34123. /**
  34124. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34125. * Please note that it requires to run a ray cast through the scene on every frame
  34126. */
  34127. constantlyUpdateMeshUnderPointer: boolean;
  34128. /**
  34129. * Defines the HTML cursor to use when hovering over interactive elements
  34130. */
  34131. hoverCursor: string;
  34132. /**
  34133. * Defines the HTML default cursor to use (empty by default)
  34134. */
  34135. defaultCursor: string;
  34136. /**
  34137. * This is used to call preventDefault() on pointer down
  34138. * in order to block unwanted artifacts like system double clicks
  34139. */
  34140. preventDefaultOnPointerDown: boolean;
  34141. /**
  34142. * This is used to call preventDefault() on pointer up
  34143. * in order to block unwanted artifacts like system double clicks
  34144. */
  34145. preventDefaultOnPointerUp: boolean;
  34146. /**
  34147. * Gets or sets user defined metadata
  34148. */
  34149. metadata: any;
  34150. /**
  34151. * For internal use only. Please do not use.
  34152. */
  34153. reservedDataStore: any;
  34154. /**
  34155. * Gets the name of the plugin used to load this scene (null by default)
  34156. */
  34157. loadingPluginName: string;
  34158. /**
  34159. * Use this array to add regular expressions used to disable offline support for specific urls
  34160. */
  34161. disableOfflineSupportExceptionRules: RegExp[];
  34162. /**
  34163. * An event triggered when the scene is disposed.
  34164. */
  34165. onDisposeObservable: Observable<Scene>;
  34166. private _onDisposeObserver;
  34167. /** Sets a function to be executed when this scene is disposed. */
  34168. onDispose: () => void;
  34169. /**
  34170. * An event triggered before rendering the scene (right after animations and physics)
  34171. */
  34172. onBeforeRenderObservable: Observable<Scene>;
  34173. private _onBeforeRenderObserver;
  34174. /** Sets a function to be executed before rendering this scene */
  34175. beforeRender: Nullable<() => void>;
  34176. /**
  34177. * An event triggered after rendering the scene
  34178. */
  34179. onAfterRenderObservable: Observable<Scene>;
  34180. /**
  34181. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34182. */
  34183. onAfterRenderCameraObservable: Observable<Camera>;
  34184. private _onAfterRenderObserver;
  34185. /** Sets a function to be executed after rendering this scene */
  34186. afterRender: Nullable<() => void>;
  34187. /**
  34188. * An event triggered before animating the scene
  34189. */
  34190. onBeforeAnimationsObservable: Observable<Scene>;
  34191. /**
  34192. * An event triggered after animations processing
  34193. */
  34194. onAfterAnimationsObservable: Observable<Scene>;
  34195. /**
  34196. * An event triggered before draw calls are ready to be sent
  34197. */
  34198. onBeforeDrawPhaseObservable: Observable<Scene>;
  34199. /**
  34200. * An event triggered after draw calls have been sent
  34201. */
  34202. onAfterDrawPhaseObservable: Observable<Scene>;
  34203. /**
  34204. * An event triggered when the scene is ready
  34205. */
  34206. onReadyObservable: Observable<Scene>;
  34207. /**
  34208. * An event triggered before rendering a camera
  34209. */
  34210. onBeforeCameraRenderObservable: Observable<Camera>;
  34211. private _onBeforeCameraRenderObserver;
  34212. /** Sets a function to be executed before rendering a camera*/
  34213. beforeCameraRender: () => void;
  34214. /**
  34215. * An event triggered after rendering a camera
  34216. */
  34217. onAfterCameraRenderObservable: Observable<Camera>;
  34218. private _onAfterCameraRenderObserver;
  34219. /** Sets a function to be executed after rendering a camera*/
  34220. afterCameraRender: () => void;
  34221. /**
  34222. * An event triggered when active meshes evaluation is about to start
  34223. */
  34224. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34225. /**
  34226. * An event triggered when active meshes evaluation is done
  34227. */
  34228. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34229. /**
  34230. * An event triggered when particles rendering is about to start
  34231. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34232. */
  34233. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34234. /**
  34235. * An event triggered when particles rendering is done
  34236. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34237. */
  34238. onAfterParticlesRenderingObservable: Observable<Scene>;
  34239. /**
  34240. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34241. */
  34242. onDataLoadedObservable: Observable<Scene>;
  34243. /**
  34244. * An event triggered when a camera is created
  34245. */
  34246. onNewCameraAddedObservable: Observable<Camera>;
  34247. /**
  34248. * An event triggered when a camera is removed
  34249. */
  34250. onCameraRemovedObservable: Observable<Camera>;
  34251. /**
  34252. * An event triggered when a light is created
  34253. */
  34254. onNewLightAddedObservable: Observable<Light>;
  34255. /**
  34256. * An event triggered when a light is removed
  34257. */
  34258. onLightRemovedObservable: Observable<Light>;
  34259. /**
  34260. * An event triggered when a geometry is created
  34261. */
  34262. onNewGeometryAddedObservable: Observable<Geometry>;
  34263. /**
  34264. * An event triggered when a geometry is removed
  34265. */
  34266. onGeometryRemovedObservable: Observable<Geometry>;
  34267. /**
  34268. * An event triggered when a transform node is created
  34269. */
  34270. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34271. /**
  34272. * An event triggered when a transform node is removed
  34273. */
  34274. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34275. /**
  34276. * An event triggered when a mesh is created
  34277. */
  34278. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34279. /**
  34280. * An event triggered when a mesh is removed
  34281. */
  34282. onMeshRemovedObservable: Observable<AbstractMesh>;
  34283. /**
  34284. * An event triggered when a skeleton is created
  34285. */
  34286. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34287. /**
  34288. * An event triggered when a skeleton is removed
  34289. */
  34290. onSkeletonRemovedObservable: Observable<Skeleton>;
  34291. /**
  34292. * An event triggered when a material is created
  34293. */
  34294. onNewMaterialAddedObservable: Observable<Material>;
  34295. /**
  34296. * An event triggered when a material is removed
  34297. */
  34298. onMaterialRemovedObservable: Observable<Material>;
  34299. /**
  34300. * An event triggered when a texture is created
  34301. */
  34302. onNewTextureAddedObservable: Observable<BaseTexture>;
  34303. /**
  34304. * An event triggered when a texture is removed
  34305. */
  34306. onTextureRemovedObservable: Observable<BaseTexture>;
  34307. /**
  34308. * An event triggered when render targets are about to be rendered
  34309. * Can happen multiple times per frame.
  34310. */
  34311. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34312. /**
  34313. * An event triggered when render targets were rendered.
  34314. * Can happen multiple times per frame.
  34315. */
  34316. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34317. /**
  34318. * An event triggered before calculating deterministic simulation step
  34319. */
  34320. onBeforeStepObservable: Observable<Scene>;
  34321. /**
  34322. * An event triggered after calculating deterministic simulation step
  34323. */
  34324. onAfterStepObservable: Observable<Scene>;
  34325. /**
  34326. * An event triggered when the activeCamera property is updated
  34327. */
  34328. onActiveCameraChanged: Observable<Scene>;
  34329. /**
  34330. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34331. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34332. * 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)
  34333. */
  34334. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34335. /**
  34336. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34337. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34338. * 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)
  34339. */
  34340. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34341. /**
  34342. * This Observable will when a mesh has been imported into the scene.
  34343. */
  34344. onMeshImportedObservable: Observable<AbstractMesh>;
  34345. /**
  34346. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34347. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34348. */
  34349. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34350. /** @hidden */
  34351. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34352. /**
  34353. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34354. */
  34355. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34356. /**
  34357. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34358. */
  34359. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34360. /**
  34361. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34362. */
  34363. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34364. /** Callback called when a pointer move is detected */
  34365. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34366. /** Callback called when a pointer down is detected */
  34367. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34368. /** Callback called when a pointer up is detected */
  34369. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34370. /** Callback called when a pointer pick is detected */
  34371. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34372. /**
  34373. * 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).
  34374. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34375. */
  34376. onPrePointerObservable: Observable<PointerInfoPre>;
  34377. /**
  34378. * Observable event triggered each time an input event is received from the rendering canvas
  34379. */
  34380. onPointerObservable: Observable<PointerInfo>;
  34381. /**
  34382. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34383. */
  34384. readonly unTranslatedPointer: Vector2;
  34385. /**
  34386. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34387. */
  34388. static DragMovementThreshold: number;
  34389. /**
  34390. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34391. */
  34392. static LongPressDelay: number;
  34393. /**
  34394. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34395. */
  34396. static DoubleClickDelay: number;
  34397. /** If you need to check double click without raising a single click at first click, enable this flag */
  34398. static ExclusiveDoubleClickMode: boolean;
  34399. /** @hidden */
  34400. _mirroredCameraPosition: Nullable<Vector3>;
  34401. /**
  34402. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34403. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34404. */
  34405. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34406. /**
  34407. * Observable event triggered each time an keyboard event is received from the hosting window
  34408. */
  34409. onKeyboardObservable: Observable<KeyboardInfo>;
  34410. private _useRightHandedSystem;
  34411. /**
  34412. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34413. */
  34414. useRightHandedSystem: boolean;
  34415. private _timeAccumulator;
  34416. private _currentStepId;
  34417. private _currentInternalStep;
  34418. /**
  34419. * Sets the step Id used by deterministic lock step
  34420. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34421. * @param newStepId defines the step Id
  34422. */
  34423. setStepId(newStepId: number): void;
  34424. /**
  34425. * Gets the step Id used by deterministic lock step
  34426. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34427. * @returns the step Id
  34428. */
  34429. getStepId(): number;
  34430. /**
  34431. * Gets the internal step used by deterministic lock step
  34432. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34433. * @returns the internal step
  34434. */
  34435. getInternalStep(): number;
  34436. private _fogEnabled;
  34437. /**
  34438. * Gets or sets a boolean indicating if fog is enabled on this scene
  34439. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34440. * (Default is true)
  34441. */
  34442. fogEnabled: boolean;
  34443. private _fogMode;
  34444. /**
  34445. * Gets or sets the fog mode to use
  34446. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34447. * | mode | value |
  34448. * | --- | --- |
  34449. * | FOGMODE_NONE | 0 |
  34450. * | FOGMODE_EXP | 1 |
  34451. * | FOGMODE_EXP2 | 2 |
  34452. * | FOGMODE_LINEAR | 3 |
  34453. */
  34454. fogMode: number;
  34455. /**
  34456. * Gets or sets the fog color to use
  34457. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34458. * (Default is Color3(0.2, 0.2, 0.3))
  34459. */
  34460. fogColor: Color3;
  34461. /**
  34462. * Gets or sets the fog density to use
  34463. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34464. * (Default is 0.1)
  34465. */
  34466. fogDensity: number;
  34467. /**
  34468. * Gets or sets the fog start distance to use
  34469. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34470. * (Default is 0)
  34471. */
  34472. fogStart: number;
  34473. /**
  34474. * Gets or sets the fog end distance to use
  34475. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34476. * (Default is 1000)
  34477. */
  34478. fogEnd: number;
  34479. private _shadowsEnabled;
  34480. /**
  34481. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34482. */
  34483. shadowsEnabled: boolean;
  34484. private _lightsEnabled;
  34485. /**
  34486. * Gets or sets a boolean indicating if lights are enabled on this scene
  34487. */
  34488. lightsEnabled: boolean;
  34489. /** All of the active cameras added to this scene. */
  34490. activeCameras: Camera[];
  34491. /** @hidden */
  34492. _activeCamera: Nullable<Camera>;
  34493. /** Gets or sets the current active camera */
  34494. activeCamera: Nullable<Camera>;
  34495. private _defaultMaterial;
  34496. /** The default material used on meshes when no material is affected */
  34497. /** The default material used on meshes when no material is affected */
  34498. defaultMaterial: Material;
  34499. private _texturesEnabled;
  34500. /**
  34501. * Gets or sets a boolean indicating if textures are enabled on this scene
  34502. */
  34503. texturesEnabled: boolean;
  34504. /**
  34505. * Gets or sets a boolean indicating if particles are enabled on this scene
  34506. */
  34507. particlesEnabled: boolean;
  34508. /**
  34509. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34510. */
  34511. spritesEnabled: boolean;
  34512. private _skeletonsEnabled;
  34513. /**
  34514. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34515. */
  34516. skeletonsEnabled: boolean;
  34517. /**
  34518. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34519. */
  34520. lensFlaresEnabled: boolean;
  34521. /**
  34522. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34523. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34524. */
  34525. collisionsEnabled: boolean;
  34526. private _collisionCoordinator;
  34527. /** @hidden */
  34528. readonly collisionCoordinator: ICollisionCoordinator;
  34529. /**
  34530. * Defines the gravity applied to this scene (used only for collisions)
  34531. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34532. */
  34533. gravity: Vector3;
  34534. /**
  34535. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34536. */
  34537. postProcessesEnabled: boolean;
  34538. /**
  34539. * The list of postprocesses added to the scene
  34540. */
  34541. postProcesses: PostProcess[];
  34542. /**
  34543. * Gets the current postprocess manager
  34544. */
  34545. postProcessManager: PostProcessManager;
  34546. /**
  34547. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34548. */
  34549. renderTargetsEnabled: boolean;
  34550. /**
  34551. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34552. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34553. */
  34554. dumpNextRenderTargets: boolean;
  34555. /**
  34556. * The list of user defined render targets added to the scene
  34557. */
  34558. customRenderTargets: RenderTargetTexture[];
  34559. /**
  34560. * Defines if texture loading must be delayed
  34561. * If true, textures will only be loaded when they need to be rendered
  34562. */
  34563. useDelayedTextureLoading: boolean;
  34564. /**
  34565. * Gets the list of meshes imported to the scene through SceneLoader
  34566. */
  34567. importedMeshesFiles: String[];
  34568. /**
  34569. * Gets or sets a boolean indicating if probes are enabled on this scene
  34570. */
  34571. probesEnabled: boolean;
  34572. /**
  34573. * Gets or sets the current offline provider to use to store scene data
  34574. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34575. */
  34576. offlineProvider: IOfflineProvider;
  34577. /**
  34578. * Gets or sets the action manager associated with the scene
  34579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34580. */
  34581. actionManager: AbstractActionManager;
  34582. private _meshesForIntersections;
  34583. /**
  34584. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34585. */
  34586. proceduralTexturesEnabled: boolean;
  34587. private _engine;
  34588. private _totalVertices;
  34589. /** @hidden */
  34590. _activeIndices: PerfCounter;
  34591. /** @hidden */
  34592. _activeParticles: PerfCounter;
  34593. /** @hidden */
  34594. _activeBones: PerfCounter;
  34595. private _animationRatio;
  34596. /** @hidden */
  34597. _animationTimeLast: number;
  34598. /** @hidden */
  34599. _animationTime: number;
  34600. /**
  34601. * Gets or sets a general scale for animation speed
  34602. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34603. */
  34604. animationTimeScale: number;
  34605. /** @hidden */
  34606. _cachedMaterial: Nullable<Material>;
  34607. /** @hidden */
  34608. _cachedEffect: Nullable<Effect>;
  34609. /** @hidden */
  34610. _cachedVisibility: Nullable<number>;
  34611. private _renderId;
  34612. private _frameId;
  34613. private _executeWhenReadyTimeoutId;
  34614. private _intermediateRendering;
  34615. private _viewUpdateFlag;
  34616. private _projectionUpdateFlag;
  34617. /** @hidden */
  34618. _toBeDisposed: Nullable<IDisposable>[];
  34619. private _activeRequests;
  34620. /** @hidden */
  34621. _pendingData: any[];
  34622. private _isDisposed;
  34623. /**
  34624. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34625. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34626. */
  34627. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34628. private _activeMeshes;
  34629. private _processedMaterials;
  34630. private _renderTargets;
  34631. /** @hidden */
  34632. _activeParticleSystems: SmartArray<IParticleSystem>;
  34633. private _activeSkeletons;
  34634. private _softwareSkinnedMeshes;
  34635. private _renderingManager;
  34636. /** @hidden */
  34637. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34638. private _transformMatrix;
  34639. private _sceneUbo;
  34640. /** @hidden */
  34641. _viewMatrix: Matrix;
  34642. private _projectionMatrix;
  34643. /** @hidden */
  34644. _forcedViewPosition: Nullable<Vector3>;
  34645. /** @hidden */
  34646. _frustumPlanes: Plane[];
  34647. /**
  34648. * Gets the list of frustum planes (built from the active camera)
  34649. */
  34650. readonly frustumPlanes: Plane[];
  34651. /**
  34652. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34653. * This is useful if there are more lights that the maximum simulteanous authorized
  34654. */
  34655. requireLightSorting: boolean;
  34656. /** @hidden */
  34657. readonly useMaterialMeshMap: boolean;
  34658. /** @hidden */
  34659. readonly useClonedMeshhMap: boolean;
  34660. private _externalData;
  34661. private _uid;
  34662. /**
  34663. * @hidden
  34664. * Backing store of defined scene components.
  34665. */
  34666. _components: ISceneComponent[];
  34667. /**
  34668. * @hidden
  34669. * Backing store of defined scene components.
  34670. */
  34671. _serializableComponents: ISceneSerializableComponent[];
  34672. /**
  34673. * List of components to register on the next registration step.
  34674. */
  34675. private _transientComponents;
  34676. /**
  34677. * Registers the transient components if needed.
  34678. */
  34679. private _registerTransientComponents;
  34680. /**
  34681. * @hidden
  34682. * Add a component to the scene.
  34683. * Note that the ccomponent could be registered on th next frame if this is called after
  34684. * the register component stage.
  34685. * @param component Defines the component to add to the scene
  34686. */
  34687. _addComponent(component: ISceneComponent): void;
  34688. /**
  34689. * @hidden
  34690. * Gets a component from the scene.
  34691. * @param name defines the name of the component to retrieve
  34692. * @returns the component or null if not present
  34693. */
  34694. _getComponent(name: string): Nullable<ISceneComponent>;
  34695. /**
  34696. * @hidden
  34697. * Defines the actions happening before camera updates.
  34698. */
  34699. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34700. /**
  34701. * @hidden
  34702. * Defines the actions happening before clear the canvas.
  34703. */
  34704. _beforeClearStage: Stage<SimpleStageAction>;
  34705. /**
  34706. * @hidden
  34707. * Defines the actions when collecting render targets for the frame.
  34708. */
  34709. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34710. /**
  34711. * @hidden
  34712. * Defines the actions happening for one camera in the frame.
  34713. */
  34714. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34715. /**
  34716. * @hidden
  34717. * Defines the actions happening during the per mesh ready checks.
  34718. */
  34719. _isReadyForMeshStage: Stage<MeshStageAction>;
  34720. /**
  34721. * @hidden
  34722. * Defines the actions happening before evaluate active mesh checks.
  34723. */
  34724. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34725. /**
  34726. * @hidden
  34727. * Defines the actions happening during the evaluate sub mesh checks.
  34728. */
  34729. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34730. /**
  34731. * @hidden
  34732. * Defines the actions happening during the active mesh stage.
  34733. */
  34734. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34735. /**
  34736. * @hidden
  34737. * Defines the actions happening during the per camera render target step.
  34738. */
  34739. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34740. /**
  34741. * @hidden
  34742. * Defines the actions happening just before the active camera is drawing.
  34743. */
  34744. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34745. /**
  34746. * @hidden
  34747. * Defines the actions happening just before a render target is drawing.
  34748. */
  34749. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34750. /**
  34751. * @hidden
  34752. * Defines the actions happening just before a rendering group is drawing.
  34753. */
  34754. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34755. /**
  34756. * @hidden
  34757. * Defines the actions happening just before a mesh is drawing.
  34758. */
  34759. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34760. /**
  34761. * @hidden
  34762. * Defines the actions happening just after a mesh has been drawn.
  34763. */
  34764. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34765. /**
  34766. * @hidden
  34767. * Defines the actions happening just after a rendering group has been drawn.
  34768. */
  34769. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34770. /**
  34771. * @hidden
  34772. * Defines the actions happening just after the active camera has been drawn.
  34773. */
  34774. _afterCameraDrawStage: Stage<CameraStageAction>;
  34775. /**
  34776. * @hidden
  34777. * Defines the actions happening just after a render target has been drawn.
  34778. */
  34779. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34780. /**
  34781. * @hidden
  34782. * Defines the actions happening just after rendering all cameras and computing intersections.
  34783. */
  34784. _afterRenderStage: Stage<SimpleStageAction>;
  34785. /**
  34786. * @hidden
  34787. * Defines the actions happening when a pointer move event happens.
  34788. */
  34789. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34790. /**
  34791. * @hidden
  34792. * Defines the actions happening when a pointer down event happens.
  34793. */
  34794. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34795. /**
  34796. * @hidden
  34797. * Defines the actions happening when a pointer up event happens.
  34798. */
  34799. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34800. /**
  34801. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34802. */
  34803. private geometriesByUniqueId;
  34804. /**
  34805. * Creates a new Scene
  34806. * @param engine defines the engine to use to render this scene
  34807. * @param options defines the scene options
  34808. */
  34809. constructor(engine: Engine, options?: SceneOptions);
  34810. /**
  34811. * Gets a string idenfifying the name of the class
  34812. * @returns "Scene" string
  34813. */
  34814. getClassName(): string;
  34815. private _defaultMeshCandidates;
  34816. /**
  34817. * @hidden
  34818. */
  34819. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34820. private _defaultSubMeshCandidates;
  34821. /**
  34822. * @hidden
  34823. */
  34824. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34825. /**
  34826. * Sets the default candidate providers for the scene.
  34827. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34828. * and getCollidingSubMeshCandidates to their default function
  34829. */
  34830. setDefaultCandidateProviders(): void;
  34831. /**
  34832. * Gets the mesh that is currently under the pointer
  34833. */
  34834. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34835. /**
  34836. * Gets or sets the current on-screen X position of the pointer
  34837. */
  34838. pointerX: number;
  34839. /**
  34840. * Gets or sets the current on-screen Y position of the pointer
  34841. */
  34842. pointerY: number;
  34843. /**
  34844. * Gets the cached material (ie. the latest rendered one)
  34845. * @returns the cached material
  34846. */
  34847. getCachedMaterial(): Nullable<Material>;
  34848. /**
  34849. * Gets the cached effect (ie. the latest rendered one)
  34850. * @returns the cached effect
  34851. */
  34852. getCachedEffect(): Nullable<Effect>;
  34853. /**
  34854. * Gets the cached visibility state (ie. the latest rendered one)
  34855. * @returns the cached visibility state
  34856. */
  34857. getCachedVisibility(): Nullable<number>;
  34858. /**
  34859. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34860. * @param material defines the current material
  34861. * @param effect defines the current effect
  34862. * @param visibility defines the current visibility state
  34863. * @returns true if one parameter is not cached
  34864. */
  34865. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34866. /**
  34867. * Gets the engine associated with the scene
  34868. * @returns an Engine
  34869. */
  34870. getEngine(): Engine;
  34871. /**
  34872. * Gets the total number of vertices rendered per frame
  34873. * @returns the total number of vertices rendered per frame
  34874. */
  34875. getTotalVertices(): number;
  34876. /**
  34877. * Gets the performance counter for total vertices
  34878. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34879. */
  34880. readonly totalVerticesPerfCounter: PerfCounter;
  34881. /**
  34882. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34883. * @returns the total number of active indices rendered per frame
  34884. */
  34885. getActiveIndices(): number;
  34886. /**
  34887. * Gets the performance counter for active indices
  34888. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34889. */
  34890. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34891. /**
  34892. * Gets the total number of active particles rendered per frame
  34893. * @returns the total number of active particles rendered per frame
  34894. */
  34895. getActiveParticles(): number;
  34896. /**
  34897. * Gets the performance counter for active particles
  34898. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34899. */
  34900. readonly activeParticlesPerfCounter: PerfCounter;
  34901. /**
  34902. * Gets the total number of active bones rendered per frame
  34903. * @returns the total number of active bones rendered per frame
  34904. */
  34905. getActiveBones(): number;
  34906. /**
  34907. * Gets the performance counter for active bones
  34908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34909. */
  34910. readonly activeBonesPerfCounter: PerfCounter;
  34911. /**
  34912. * Gets the array of active meshes
  34913. * @returns an array of AbstractMesh
  34914. */
  34915. getActiveMeshes(): SmartArray<AbstractMesh>;
  34916. /**
  34917. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34918. * @returns a number
  34919. */
  34920. getAnimationRatio(): number;
  34921. /**
  34922. * Gets an unique Id for the current render phase
  34923. * @returns a number
  34924. */
  34925. getRenderId(): number;
  34926. /**
  34927. * Gets an unique Id for the current frame
  34928. * @returns a number
  34929. */
  34930. getFrameId(): number;
  34931. /** Call this function if you want to manually increment the render Id*/
  34932. incrementRenderId(): void;
  34933. private _createUbo;
  34934. /**
  34935. * Use this method to simulate a pointer move on a mesh
  34936. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34937. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34938. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34939. * @returns the current scene
  34940. */
  34941. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34942. /**
  34943. * Use this method to simulate a pointer down on a mesh
  34944. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34945. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34946. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34947. * @returns the current scene
  34948. */
  34949. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34950. /**
  34951. * Use this method to simulate a pointer up on a mesh
  34952. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34953. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34954. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34955. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34956. * @returns the current scene
  34957. */
  34958. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34959. /**
  34960. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34961. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34962. * @returns true if the pointer was captured
  34963. */
  34964. isPointerCaptured(pointerId?: number): boolean;
  34965. /**
  34966. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34967. * @param attachUp defines if you want to attach events to pointerup
  34968. * @param attachDown defines if you want to attach events to pointerdown
  34969. * @param attachMove defines if you want to attach events to pointermove
  34970. */
  34971. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34972. /** Detaches all event handlers*/
  34973. detachControl(): void;
  34974. /**
  34975. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34976. * Delay loaded resources are not taking in account
  34977. * @return true if all required resources are ready
  34978. */
  34979. isReady(): boolean;
  34980. /** Resets all cached information relative to material (including effect and visibility) */
  34981. resetCachedMaterial(): void;
  34982. /**
  34983. * Registers a function to be called before every frame render
  34984. * @param func defines the function to register
  34985. */
  34986. registerBeforeRender(func: () => void): void;
  34987. /**
  34988. * Unregisters a function called before every frame render
  34989. * @param func defines the function to unregister
  34990. */
  34991. unregisterBeforeRender(func: () => void): void;
  34992. /**
  34993. * Registers a function to be called after every frame render
  34994. * @param func defines the function to register
  34995. */
  34996. registerAfterRender(func: () => void): void;
  34997. /**
  34998. * Unregisters a function called after every frame render
  34999. * @param func defines the function to unregister
  35000. */
  35001. unregisterAfterRender(func: () => void): void;
  35002. private _executeOnceBeforeRender;
  35003. /**
  35004. * The provided function will run before render once and will be disposed afterwards.
  35005. * A timeout delay can be provided so that the function will be executed in N ms.
  35006. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35007. * @param func The function to be executed.
  35008. * @param timeout optional delay in ms
  35009. */
  35010. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35011. /** @hidden */
  35012. _addPendingData(data: any): void;
  35013. /** @hidden */
  35014. _removePendingData(data: any): void;
  35015. /**
  35016. * Returns the number of items waiting to be loaded
  35017. * @returns the number of items waiting to be loaded
  35018. */
  35019. getWaitingItemsCount(): number;
  35020. /**
  35021. * Returns a boolean indicating if the scene is still loading data
  35022. */
  35023. readonly isLoading: boolean;
  35024. /**
  35025. * Registers a function to be executed when the scene is ready
  35026. * @param {Function} func - the function to be executed
  35027. */
  35028. executeWhenReady(func: () => void): void;
  35029. /**
  35030. * Returns a promise that resolves when the scene is ready
  35031. * @returns A promise that resolves when the scene is ready
  35032. */
  35033. whenReadyAsync(): Promise<void>;
  35034. /** @hidden */
  35035. _checkIsReady(): void;
  35036. /**
  35037. * Gets all animatable attached to the scene
  35038. */
  35039. readonly animatables: Animatable[];
  35040. /**
  35041. * Resets the last animation time frame.
  35042. * Useful to override when animations start running when loading a scene for the first time.
  35043. */
  35044. resetLastAnimationTimeFrame(): void;
  35045. /**
  35046. * Gets the current view matrix
  35047. * @returns a Matrix
  35048. */
  35049. getViewMatrix(): Matrix;
  35050. /**
  35051. * Gets the current projection matrix
  35052. * @returns a Matrix
  35053. */
  35054. getProjectionMatrix(): Matrix;
  35055. /**
  35056. * Gets the current transform matrix
  35057. * @returns a Matrix made of View * Projection
  35058. */
  35059. getTransformMatrix(): Matrix;
  35060. /**
  35061. * Sets the current transform matrix
  35062. * @param viewL defines the View matrix to use
  35063. * @param projectionL defines the Projection matrix to use
  35064. * @param viewR defines the right View matrix to use (if provided)
  35065. * @param projectionR defines the right Projection matrix to use (if provided)
  35066. */
  35067. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35068. /**
  35069. * Gets the uniform buffer used to store scene data
  35070. * @returns a UniformBuffer
  35071. */
  35072. getSceneUniformBuffer(): UniformBuffer;
  35073. /**
  35074. * Gets an unique (relatively to the current scene) Id
  35075. * @returns an unique number for the scene
  35076. */
  35077. getUniqueId(): number;
  35078. /**
  35079. * Add a mesh to the list of scene's meshes
  35080. * @param newMesh defines the mesh to add
  35081. * @param recursive if all child meshes should also be added to the scene
  35082. */
  35083. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35084. /**
  35085. * Remove a mesh for the list of scene's meshes
  35086. * @param toRemove defines the mesh to remove
  35087. * @param recursive if all child meshes should also be removed from the scene
  35088. * @returns the index where the mesh was in the mesh list
  35089. */
  35090. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35091. /**
  35092. * Add a transform node to the list of scene's transform nodes
  35093. * @param newTransformNode defines the transform node to add
  35094. */
  35095. addTransformNode(newTransformNode: TransformNode): void;
  35096. /**
  35097. * Remove a transform node for the list of scene's transform nodes
  35098. * @param toRemove defines the transform node to remove
  35099. * @returns the index where the transform node was in the transform node list
  35100. */
  35101. removeTransformNode(toRemove: TransformNode): number;
  35102. /**
  35103. * Remove a skeleton for the list of scene's skeletons
  35104. * @param toRemove defines the skeleton to remove
  35105. * @returns the index where the skeleton was in the skeleton list
  35106. */
  35107. removeSkeleton(toRemove: Skeleton): number;
  35108. /**
  35109. * Remove a morph target for the list of scene's morph targets
  35110. * @param toRemove defines the morph target to remove
  35111. * @returns the index where the morph target was in the morph target list
  35112. */
  35113. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35114. /**
  35115. * Remove a light for the list of scene's lights
  35116. * @param toRemove defines the light to remove
  35117. * @returns the index where the light was in the light list
  35118. */
  35119. removeLight(toRemove: Light): number;
  35120. /**
  35121. * Remove a camera for the list of scene's cameras
  35122. * @param toRemove defines the camera to remove
  35123. * @returns the index where the camera was in the camera list
  35124. */
  35125. removeCamera(toRemove: Camera): number;
  35126. /**
  35127. * Remove a particle system for the list of scene's particle systems
  35128. * @param toRemove defines the particle system to remove
  35129. * @returns the index where the particle system was in the particle system list
  35130. */
  35131. removeParticleSystem(toRemove: IParticleSystem): number;
  35132. /**
  35133. * Remove a animation for the list of scene's animations
  35134. * @param toRemove defines the animation to remove
  35135. * @returns the index where the animation was in the animation list
  35136. */
  35137. removeAnimation(toRemove: Animation): number;
  35138. /**
  35139. * Will stop the animation of the given target
  35140. * @param target - the target
  35141. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35142. * @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)
  35143. */
  35144. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35145. /**
  35146. * Removes the given animation group from this scene.
  35147. * @param toRemove The animation group to remove
  35148. * @returns The index of the removed animation group
  35149. */
  35150. removeAnimationGroup(toRemove: AnimationGroup): number;
  35151. /**
  35152. * Removes the given multi-material from this scene.
  35153. * @param toRemove The multi-material to remove
  35154. * @returns The index of the removed multi-material
  35155. */
  35156. removeMultiMaterial(toRemove: MultiMaterial): number;
  35157. /**
  35158. * Removes the given material from this scene.
  35159. * @param toRemove The material to remove
  35160. * @returns The index of the removed material
  35161. */
  35162. removeMaterial(toRemove: Material): number;
  35163. /**
  35164. * Removes the given action manager from this scene.
  35165. * @param toRemove The action manager to remove
  35166. * @returns The index of the removed action manager
  35167. */
  35168. removeActionManager(toRemove: AbstractActionManager): number;
  35169. /**
  35170. * Removes the given texture from this scene.
  35171. * @param toRemove The texture to remove
  35172. * @returns The index of the removed texture
  35173. */
  35174. removeTexture(toRemove: BaseTexture): number;
  35175. /**
  35176. * Adds the given light to this scene
  35177. * @param newLight The light to add
  35178. */
  35179. addLight(newLight: Light): void;
  35180. /**
  35181. * Sorts the list list based on light priorities
  35182. */
  35183. sortLightsByPriority(): void;
  35184. /**
  35185. * Adds the given camera to this scene
  35186. * @param newCamera The camera to add
  35187. */
  35188. addCamera(newCamera: Camera): void;
  35189. /**
  35190. * Adds the given skeleton to this scene
  35191. * @param newSkeleton The skeleton to add
  35192. */
  35193. addSkeleton(newSkeleton: Skeleton): void;
  35194. /**
  35195. * Adds the given particle system to this scene
  35196. * @param newParticleSystem The particle system to add
  35197. */
  35198. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35199. /**
  35200. * Adds the given animation to this scene
  35201. * @param newAnimation The animation to add
  35202. */
  35203. addAnimation(newAnimation: Animation): void;
  35204. /**
  35205. * Adds the given animation group to this scene.
  35206. * @param newAnimationGroup The animation group to add
  35207. */
  35208. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35209. /**
  35210. * Adds the given multi-material to this scene
  35211. * @param newMultiMaterial The multi-material to add
  35212. */
  35213. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35214. /**
  35215. * Adds the given material to this scene
  35216. * @param newMaterial The material to add
  35217. */
  35218. addMaterial(newMaterial: Material): void;
  35219. /**
  35220. * Adds the given morph target to this scene
  35221. * @param newMorphTargetManager The morph target to add
  35222. */
  35223. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35224. /**
  35225. * Adds the given geometry to this scene
  35226. * @param newGeometry The geometry to add
  35227. */
  35228. addGeometry(newGeometry: Geometry): void;
  35229. /**
  35230. * Adds the given action manager to this scene
  35231. * @param newActionManager The action manager to add
  35232. */
  35233. addActionManager(newActionManager: AbstractActionManager): void;
  35234. /**
  35235. * Adds the given texture to this scene.
  35236. * @param newTexture The texture to add
  35237. */
  35238. addTexture(newTexture: BaseTexture): void;
  35239. /**
  35240. * Switch active camera
  35241. * @param newCamera defines the new active camera
  35242. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35243. */
  35244. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35245. /**
  35246. * sets the active camera of the scene using its ID
  35247. * @param id defines the camera's ID
  35248. * @return the new active camera or null if none found.
  35249. */
  35250. setActiveCameraByID(id: string): Nullable<Camera>;
  35251. /**
  35252. * sets the active camera of the scene using its name
  35253. * @param name defines the camera's name
  35254. * @returns the new active camera or null if none found.
  35255. */
  35256. setActiveCameraByName(name: string): Nullable<Camera>;
  35257. /**
  35258. * get an animation group using its name
  35259. * @param name defines the material's name
  35260. * @return the animation group or null if none found.
  35261. */
  35262. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35263. /**
  35264. * Get a material using its unique id
  35265. * @param uniqueId defines the material's unique id
  35266. * @return the material or null if none found.
  35267. */
  35268. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35269. /**
  35270. * get a material using its id
  35271. * @param id defines the material's ID
  35272. * @return the material or null if none found.
  35273. */
  35274. getMaterialByID(id: string): Nullable<Material>;
  35275. /**
  35276. * Gets a the last added material using a given id
  35277. * @param id defines the material's ID
  35278. * @return the last material with the given id or null if none found.
  35279. */
  35280. getLastMaterialByID(id: string): Nullable<Material>;
  35281. /**
  35282. * Gets a material using its name
  35283. * @param name defines the material's name
  35284. * @return the material or null if none found.
  35285. */
  35286. getMaterialByName(name: string): Nullable<Material>;
  35287. /**
  35288. * Get a texture using its unique id
  35289. * @param uniqueId defines the texture's unique id
  35290. * @return the texture or null if none found.
  35291. */
  35292. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35293. /**
  35294. * Gets a camera using its id
  35295. * @param id defines the id to look for
  35296. * @returns the camera or null if not found
  35297. */
  35298. getCameraByID(id: string): Nullable<Camera>;
  35299. /**
  35300. * Gets a camera using its unique id
  35301. * @param uniqueId defines the unique id to look for
  35302. * @returns the camera or null if not found
  35303. */
  35304. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35305. /**
  35306. * Gets a camera using its name
  35307. * @param name defines the camera's name
  35308. * @return the camera or null if none found.
  35309. */
  35310. getCameraByName(name: string): Nullable<Camera>;
  35311. /**
  35312. * Gets a bone using its id
  35313. * @param id defines the bone's id
  35314. * @return the bone or null if not found
  35315. */
  35316. getBoneByID(id: string): Nullable<Bone>;
  35317. /**
  35318. * Gets a bone using its id
  35319. * @param name defines the bone's name
  35320. * @return the bone or null if not found
  35321. */
  35322. getBoneByName(name: string): Nullable<Bone>;
  35323. /**
  35324. * Gets a light node using its name
  35325. * @param name defines the the light's name
  35326. * @return the light or null if none found.
  35327. */
  35328. getLightByName(name: string): Nullable<Light>;
  35329. /**
  35330. * Gets a light node using its id
  35331. * @param id defines the light's id
  35332. * @return the light or null if none found.
  35333. */
  35334. getLightByID(id: string): Nullable<Light>;
  35335. /**
  35336. * Gets a light node using its scene-generated unique ID
  35337. * @param uniqueId defines the light's unique id
  35338. * @return the light or null if none found.
  35339. */
  35340. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35341. /**
  35342. * Gets a particle system by id
  35343. * @param id defines the particle system id
  35344. * @return the corresponding system or null if none found
  35345. */
  35346. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35347. /**
  35348. * Gets a geometry using its ID
  35349. * @param id defines the geometry's id
  35350. * @return the geometry or null if none found.
  35351. */
  35352. getGeometryByID(id: string): Nullable<Geometry>;
  35353. private _getGeometryByUniqueID;
  35354. /**
  35355. * Add a new geometry to this scene
  35356. * @param geometry defines the geometry to be added to the scene.
  35357. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35358. * @return a boolean defining if the geometry was added or not
  35359. */
  35360. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35361. /**
  35362. * Removes an existing geometry
  35363. * @param geometry defines the geometry to be removed from the scene
  35364. * @return a boolean defining if the geometry was removed or not
  35365. */
  35366. removeGeometry(geometry: Geometry): boolean;
  35367. /**
  35368. * Gets the list of geometries attached to the scene
  35369. * @returns an array of Geometry
  35370. */
  35371. getGeometries(): Geometry[];
  35372. /**
  35373. * Gets the first added mesh found of a given ID
  35374. * @param id defines the id to search for
  35375. * @return the mesh found or null if not found at all
  35376. */
  35377. getMeshByID(id: string): Nullable<AbstractMesh>;
  35378. /**
  35379. * Gets a list of meshes using their id
  35380. * @param id defines the id to search for
  35381. * @returns a list of meshes
  35382. */
  35383. getMeshesByID(id: string): Array<AbstractMesh>;
  35384. /**
  35385. * Gets the first added transform node found of a given ID
  35386. * @param id defines the id to search for
  35387. * @return the found transform node or null if not found at all.
  35388. */
  35389. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35390. /**
  35391. * Gets a transform node with its auto-generated unique id
  35392. * @param uniqueId efines the unique id to search for
  35393. * @return the found transform node or null if not found at all.
  35394. */
  35395. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35396. /**
  35397. * Gets a list of transform nodes using their id
  35398. * @param id defines the id to search for
  35399. * @returns a list of transform nodes
  35400. */
  35401. getTransformNodesByID(id: string): Array<TransformNode>;
  35402. /**
  35403. * Gets a mesh with its auto-generated unique id
  35404. * @param uniqueId defines the unique id to search for
  35405. * @return the found mesh or null if not found at all.
  35406. */
  35407. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35408. /**
  35409. * Gets a the last added mesh using a given id
  35410. * @param id defines the id to search for
  35411. * @return the found mesh or null if not found at all.
  35412. */
  35413. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35414. /**
  35415. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35416. * @param id defines the id to search for
  35417. * @return the found node or null if not found at all
  35418. */
  35419. getLastEntryByID(id: string): Nullable<Node>;
  35420. /**
  35421. * Gets a node (Mesh, Camera, Light) using a given id
  35422. * @param id defines the id to search for
  35423. * @return the found node or null if not found at all
  35424. */
  35425. getNodeByID(id: string): Nullable<Node>;
  35426. /**
  35427. * Gets a node (Mesh, Camera, Light) using a given name
  35428. * @param name defines the name to search for
  35429. * @return the found node or null if not found at all.
  35430. */
  35431. getNodeByName(name: string): Nullable<Node>;
  35432. /**
  35433. * Gets a mesh using a given name
  35434. * @param name defines the name to search for
  35435. * @return the found mesh or null if not found at all.
  35436. */
  35437. getMeshByName(name: string): Nullable<AbstractMesh>;
  35438. /**
  35439. * Gets a transform node using a given name
  35440. * @param name defines the name to search for
  35441. * @return the found transform node or null if not found at all.
  35442. */
  35443. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35444. /**
  35445. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35446. * @param id defines the id to search for
  35447. * @return the found skeleton or null if not found at all.
  35448. */
  35449. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35450. /**
  35451. * Gets a skeleton using a given auto generated unique id
  35452. * @param uniqueId defines the unique id to search for
  35453. * @return the found skeleton or null if not found at all.
  35454. */
  35455. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35456. /**
  35457. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35458. * @param id defines the id to search for
  35459. * @return the found skeleton or null if not found at all.
  35460. */
  35461. getSkeletonById(id: string): Nullable<Skeleton>;
  35462. /**
  35463. * Gets a skeleton using a given name
  35464. * @param name defines the name to search for
  35465. * @return the found skeleton or null if not found at all.
  35466. */
  35467. getSkeletonByName(name: string): Nullable<Skeleton>;
  35468. /**
  35469. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35470. * @param id defines the id to search for
  35471. * @return the found morph target manager or null if not found at all.
  35472. */
  35473. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35474. /**
  35475. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35476. * @param id defines the id to search for
  35477. * @return the found morph target or null if not found at all.
  35478. */
  35479. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35480. /**
  35481. * Gets a boolean indicating if the given mesh is active
  35482. * @param mesh defines the mesh to look for
  35483. * @returns true if the mesh is in the active list
  35484. */
  35485. isActiveMesh(mesh: AbstractMesh): boolean;
  35486. /**
  35487. * Return a unique id as a string which can serve as an identifier for the scene
  35488. */
  35489. readonly uid: string;
  35490. /**
  35491. * Add an externaly attached data from its key.
  35492. * This method call will fail and return false, if such key already exists.
  35493. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35494. * @param key the unique key that identifies the data
  35495. * @param data the data object to associate to the key for this Engine instance
  35496. * @return true if no such key were already present and the data was added successfully, false otherwise
  35497. */
  35498. addExternalData<T>(key: string, data: T): boolean;
  35499. /**
  35500. * Get an externaly attached data from its key
  35501. * @param key the unique key that identifies the data
  35502. * @return the associated data, if present (can be null), or undefined if not present
  35503. */
  35504. getExternalData<T>(key: string): Nullable<T>;
  35505. /**
  35506. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35507. * @param key the unique key that identifies the data
  35508. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35509. * @return the associated data, can be null if the factory returned null.
  35510. */
  35511. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35512. /**
  35513. * Remove an externaly attached data from the Engine instance
  35514. * @param key the unique key that identifies the data
  35515. * @return true if the data was successfully removed, false if it doesn't exist
  35516. */
  35517. removeExternalData(key: string): boolean;
  35518. private _evaluateSubMesh;
  35519. /**
  35520. * Clear the processed materials smart array preventing retention point in material dispose.
  35521. */
  35522. freeProcessedMaterials(): void;
  35523. private _preventFreeActiveMeshesAndRenderingGroups;
  35524. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35525. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35526. * when disposing several meshes in a row or a hierarchy of meshes.
  35527. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35528. */
  35529. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35530. /**
  35531. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35532. */
  35533. freeActiveMeshes(): void;
  35534. /**
  35535. * Clear the info related to rendering groups preventing retention points during dispose.
  35536. */
  35537. freeRenderingGroups(): void;
  35538. /** @hidden */
  35539. _isInIntermediateRendering(): boolean;
  35540. /**
  35541. * Lambda returning the list of potentially active meshes.
  35542. */
  35543. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35544. /**
  35545. * Lambda returning the list of potentially active sub meshes.
  35546. */
  35547. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35548. /**
  35549. * Lambda returning the list of potentially intersecting sub meshes.
  35550. */
  35551. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35552. /**
  35553. * Lambda returning the list of potentially colliding sub meshes.
  35554. */
  35555. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35556. private _activeMeshesFrozen;
  35557. /**
  35558. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35559. * @returns the current scene
  35560. */
  35561. freezeActiveMeshes(): Scene;
  35562. /**
  35563. * Use this function to restart evaluating active meshes on every frame
  35564. * @returns the current scene
  35565. */
  35566. unfreezeActiveMeshes(): Scene;
  35567. private _evaluateActiveMeshes;
  35568. private _activeMesh;
  35569. /**
  35570. * Update the transform matrix to update from the current active camera
  35571. * @param force defines a boolean used to force the update even if cache is up to date
  35572. */
  35573. updateTransformMatrix(force?: boolean): void;
  35574. private _bindFrameBuffer;
  35575. /** @hidden */
  35576. _allowPostProcessClearColor: boolean;
  35577. /** @hidden */
  35578. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35579. private _processSubCameras;
  35580. private _checkIntersections;
  35581. /** @hidden */
  35582. _advancePhysicsEngineStep(step: number): void;
  35583. /**
  35584. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35585. */
  35586. getDeterministicFrameTime: () => number;
  35587. /** @hidden */
  35588. _animate(): void;
  35589. /** Execute all animations (for a frame) */
  35590. animate(): void;
  35591. /**
  35592. * Render the scene
  35593. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35594. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35595. */
  35596. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35597. /**
  35598. * Freeze all materials
  35599. * A frozen material will not be updatable but should be faster to render
  35600. */
  35601. freezeMaterials(): void;
  35602. /**
  35603. * Unfreeze all materials
  35604. * A frozen material will not be updatable but should be faster to render
  35605. */
  35606. unfreezeMaterials(): void;
  35607. /**
  35608. * Releases all held ressources
  35609. */
  35610. dispose(): void;
  35611. /**
  35612. * Gets if the scene is already disposed
  35613. */
  35614. readonly isDisposed: boolean;
  35615. /**
  35616. * Call this function to reduce memory footprint of the scene.
  35617. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35618. */
  35619. clearCachedVertexData(): void;
  35620. /**
  35621. * This function will remove the local cached buffer data from texture.
  35622. * It will save memory but will prevent the texture from being rebuilt
  35623. */
  35624. cleanCachedTextureBuffer(): void;
  35625. /**
  35626. * Get the world extend vectors with an optional filter
  35627. *
  35628. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35629. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35630. */
  35631. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35632. min: Vector3;
  35633. max: Vector3;
  35634. };
  35635. /**
  35636. * Creates a ray that can be used to pick in the scene
  35637. * @param x defines the x coordinate of the origin (on-screen)
  35638. * @param y defines the y coordinate of the origin (on-screen)
  35639. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35640. * @param camera defines the camera to use for the picking
  35641. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35642. * @returns a Ray
  35643. */
  35644. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35645. /**
  35646. * Creates a ray that can be used to pick in the scene
  35647. * @param x defines the x coordinate of the origin (on-screen)
  35648. * @param y defines the y coordinate of the origin (on-screen)
  35649. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35650. * @param result defines the ray where to store the picking ray
  35651. * @param camera defines the camera to use for the picking
  35652. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35653. * @returns the current scene
  35654. */
  35655. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35656. /**
  35657. * Creates a ray that can be used to pick in the scene
  35658. * @param x defines the x coordinate of the origin (on-screen)
  35659. * @param y defines the y coordinate of the origin (on-screen)
  35660. * @param camera defines the camera to use for the picking
  35661. * @returns a Ray
  35662. */
  35663. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35664. /**
  35665. * Creates a ray that can be used to pick in the scene
  35666. * @param x defines the x coordinate of the origin (on-screen)
  35667. * @param y defines the y coordinate of the origin (on-screen)
  35668. * @param result defines the ray where to store the picking ray
  35669. * @param camera defines the camera to use for the picking
  35670. * @returns the current scene
  35671. */
  35672. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35673. /** Launch a ray to try to pick a mesh in the scene
  35674. * @param x position on screen
  35675. * @param y position on screen
  35676. * @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
  35677. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35678. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35679. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35680. * @returns a PickingInfo
  35681. */
  35682. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35683. /** Use the given ray to pick a mesh in the scene
  35684. * @param ray The ray to use to pick meshes
  35685. * @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
  35686. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35687. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35688. * @returns a PickingInfo
  35689. */
  35690. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35691. /**
  35692. * Launch a ray to try to pick a mesh in the scene
  35693. * @param x X position on screen
  35694. * @param y Y position on screen
  35695. * @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
  35696. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35697. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35698. * @returns an array of PickingInfo
  35699. */
  35700. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35701. /**
  35702. * Launch a ray to try to pick a mesh in the scene
  35703. * @param ray Ray to use
  35704. * @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
  35705. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35706. * @returns an array of PickingInfo
  35707. */
  35708. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35709. /**
  35710. * Force the value of meshUnderPointer
  35711. * @param mesh defines the mesh to use
  35712. */
  35713. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35714. /**
  35715. * Gets the mesh under the pointer
  35716. * @returns a Mesh or null if no mesh is under the pointer
  35717. */
  35718. getPointerOverMesh(): Nullable<AbstractMesh>;
  35719. /** @hidden */
  35720. _rebuildGeometries(): void;
  35721. /** @hidden */
  35722. _rebuildTextures(): void;
  35723. private _getByTags;
  35724. /**
  35725. * Get a list of meshes by tags
  35726. * @param tagsQuery defines the tags query to use
  35727. * @param forEach defines a predicate used to filter results
  35728. * @returns an array of Mesh
  35729. */
  35730. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35731. /**
  35732. * Get a list of cameras by tags
  35733. * @param tagsQuery defines the tags query to use
  35734. * @param forEach defines a predicate used to filter results
  35735. * @returns an array of Camera
  35736. */
  35737. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35738. /**
  35739. * Get a list of lights by tags
  35740. * @param tagsQuery defines the tags query to use
  35741. * @param forEach defines a predicate used to filter results
  35742. * @returns an array of Light
  35743. */
  35744. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35745. /**
  35746. * Get a list of materials by tags
  35747. * @param tagsQuery defines the tags query to use
  35748. * @param forEach defines a predicate used to filter results
  35749. * @returns an array of Material
  35750. */
  35751. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35752. /**
  35753. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35754. * This allowed control for front to back rendering or reversly depending of the special needs.
  35755. *
  35756. * @param renderingGroupId The rendering group id corresponding to its index
  35757. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35758. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35759. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35760. */
  35761. 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;
  35762. /**
  35763. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35764. *
  35765. * @param renderingGroupId The rendering group id corresponding to its index
  35766. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35767. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35768. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35769. */
  35770. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35771. /**
  35772. * Gets the current auto clear configuration for one rendering group of the rendering
  35773. * manager.
  35774. * @param index the rendering group index to get the information for
  35775. * @returns The auto clear setup for the requested rendering group
  35776. */
  35777. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35778. private _blockMaterialDirtyMechanism;
  35779. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35780. blockMaterialDirtyMechanism: boolean;
  35781. /**
  35782. * Will flag all materials as dirty to trigger new shader compilation
  35783. * @param flag defines the flag used to specify which material part must be marked as dirty
  35784. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35785. */
  35786. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35787. /** @hidden */
  35788. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35789. /** @hidden */
  35790. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35791. }
  35792. }
  35793. declare module "babylonjs/assetContainer" {
  35794. import { AbstractScene } from "babylonjs/abstractScene";
  35795. import { Scene } from "babylonjs/scene";
  35796. import { Mesh } from "babylonjs/Meshes/mesh";
  35797. /**
  35798. * Set of assets to keep when moving a scene into an asset container.
  35799. */
  35800. export class KeepAssets extends AbstractScene {
  35801. }
  35802. /**
  35803. * Container with a set of assets that can be added or removed from a scene.
  35804. */
  35805. export class AssetContainer extends AbstractScene {
  35806. /**
  35807. * The scene the AssetContainer belongs to.
  35808. */
  35809. scene: Scene;
  35810. /**
  35811. * Instantiates an AssetContainer.
  35812. * @param scene The scene the AssetContainer belongs to.
  35813. */
  35814. constructor(scene: Scene);
  35815. /**
  35816. * Adds all the assets from the container to the scene.
  35817. */
  35818. addAllToScene(): void;
  35819. /**
  35820. * Removes all the assets in the container from the scene
  35821. */
  35822. removeAllFromScene(): void;
  35823. /**
  35824. * Disposes all the assets in the container
  35825. */
  35826. dispose(): void;
  35827. private _moveAssets;
  35828. /**
  35829. * Removes all the assets contained in the scene and adds them to the container.
  35830. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35831. */
  35832. moveAllFromScene(keepAssets?: KeepAssets): void;
  35833. /**
  35834. * 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.
  35835. * @returns the root mesh
  35836. */
  35837. createRootMesh(): Mesh;
  35838. }
  35839. }
  35840. declare module "babylonjs/abstractScene" {
  35841. import { Scene } from "babylonjs/scene";
  35842. import { Nullable } from "babylonjs/types";
  35843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35844. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35845. import { Geometry } from "babylonjs/Meshes/geometry";
  35846. import { Skeleton } from "babylonjs/Bones/skeleton";
  35847. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35848. import { AssetContainer } from "babylonjs/assetContainer";
  35849. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35850. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35851. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35852. import { Material } from "babylonjs/Materials/material";
  35853. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35854. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35855. import { Camera } from "babylonjs/Cameras/camera";
  35856. import { Light } from "babylonjs/Lights/light";
  35857. import { Node } from "babylonjs/node";
  35858. import { Animation } from "babylonjs/Animations/animation";
  35859. /**
  35860. * Defines how the parser contract is defined.
  35861. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35862. */
  35863. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35864. /**
  35865. * Defines how the individual parser contract is defined.
  35866. * These parser can parse an individual asset
  35867. */
  35868. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35869. /**
  35870. * Base class of the scene acting as a container for the different elements composing a scene.
  35871. * This class is dynamically extended by the different components of the scene increasing
  35872. * flexibility and reducing coupling
  35873. */
  35874. export abstract class AbstractScene {
  35875. /**
  35876. * Stores the list of available parsers in the application.
  35877. */
  35878. private static _BabylonFileParsers;
  35879. /**
  35880. * Stores the list of available individual parsers in the application.
  35881. */
  35882. private static _IndividualBabylonFileParsers;
  35883. /**
  35884. * Adds a parser in the list of available ones
  35885. * @param name Defines the name of the parser
  35886. * @param parser Defines the parser to add
  35887. */
  35888. static AddParser(name: string, parser: BabylonFileParser): void;
  35889. /**
  35890. * Gets a general parser from the list of avaialble ones
  35891. * @param name Defines the name of the parser
  35892. * @returns the requested parser or null
  35893. */
  35894. static GetParser(name: string): Nullable<BabylonFileParser>;
  35895. /**
  35896. * Adds n individual parser in the list of available ones
  35897. * @param name Defines the name of the parser
  35898. * @param parser Defines the parser to add
  35899. */
  35900. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35901. /**
  35902. * Gets an individual parser from the list of avaialble ones
  35903. * @param name Defines the name of the parser
  35904. * @returns the requested parser or null
  35905. */
  35906. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35907. /**
  35908. * Parser json data and populate both a scene and its associated container object
  35909. * @param jsonData Defines the data to parse
  35910. * @param scene Defines the scene to parse the data for
  35911. * @param container Defines the container attached to the parsing sequence
  35912. * @param rootUrl Defines the root url of the data
  35913. */
  35914. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35915. /**
  35916. * Gets the list of root nodes (ie. nodes with no parent)
  35917. */
  35918. rootNodes: Node[];
  35919. /** All of the cameras added to this scene
  35920. * @see http://doc.babylonjs.com/babylon101/cameras
  35921. */
  35922. cameras: Camera[];
  35923. /**
  35924. * All of the lights added to this scene
  35925. * @see http://doc.babylonjs.com/babylon101/lights
  35926. */
  35927. lights: Light[];
  35928. /**
  35929. * All of the (abstract) meshes added to this scene
  35930. */
  35931. meshes: AbstractMesh[];
  35932. /**
  35933. * The list of skeletons added to the scene
  35934. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35935. */
  35936. skeletons: Skeleton[];
  35937. /**
  35938. * All of the particle systems added to this scene
  35939. * @see http://doc.babylonjs.com/babylon101/particles
  35940. */
  35941. particleSystems: IParticleSystem[];
  35942. /**
  35943. * Gets a list of Animations associated with the scene
  35944. */
  35945. animations: Animation[];
  35946. /**
  35947. * All of the animation groups added to this scene
  35948. * @see http://doc.babylonjs.com/how_to/group
  35949. */
  35950. animationGroups: AnimationGroup[];
  35951. /**
  35952. * All of the multi-materials added to this scene
  35953. * @see http://doc.babylonjs.com/how_to/multi_materials
  35954. */
  35955. multiMaterials: MultiMaterial[];
  35956. /**
  35957. * All of the materials added to this scene
  35958. * In the context of a Scene, it is not supposed to be modified manually.
  35959. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35960. * Note also that the order of the Material wihin the array is not significant and might change.
  35961. * @see http://doc.babylonjs.com/babylon101/materials
  35962. */
  35963. materials: Material[];
  35964. /**
  35965. * The list of morph target managers added to the scene
  35966. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35967. */
  35968. morphTargetManagers: MorphTargetManager[];
  35969. /**
  35970. * The list of geometries used in the scene.
  35971. */
  35972. geometries: Geometry[];
  35973. /**
  35974. * All of the tranform nodes added to this scene
  35975. * In the context of a Scene, it is not supposed to be modified manually.
  35976. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35977. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35978. * @see http://doc.babylonjs.com/how_to/transformnode
  35979. */
  35980. transformNodes: TransformNode[];
  35981. /**
  35982. * ActionManagers available on the scene.
  35983. */
  35984. actionManagers: AbstractActionManager[];
  35985. /**
  35986. * Textures to keep.
  35987. */
  35988. textures: BaseTexture[];
  35989. /**
  35990. * Environment texture for the scene
  35991. */
  35992. environmentTexture: Nullable<BaseTexture>;
  35993. }
  35994. }
  35995. declare module "babylonjs/Audio/sound" {
  35996. import { Observable } from "babylonjs/Misc/observable";
  35997. import { Vector3 } from "babylonjs/Maths/math.vector";
  35998. import { Nullable } from "babylonjs/types";
  35999. import { Scene } from "babylonjs/scene";
  36000. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36001. /**
  36002. * Interface used to define options for Sound class
  36003. */
  36004. export interface ISoundOptions {
  36005. /**
  36006. * Does the sound autoplay once loaded.
  36007. */
  36008. autoplay?: boolean;
  36009. /**
  36010. * Does the sound loop after it finishes playing once.
  36011. */
  36012. loop?: boolean;
  36013. /**
  36014. * Sound's volume
  36015. */
  36016. volume?: number;
  36017. /**
  36018. * Is it a spatial sound?
  36019. */
  36020. spatialSound?: boolean;
  36021. /**
  36022. * Maximum distance to hear that sound
  36023. */
  36024. maxDistance?: number;
  36025. /**
  36026. * Uses user defined attenuation function
  36027. */
  36028. useCustomAttenuation?: boolean;
  36029. /**
  36030. * Define the roll off factor of spatial sounds.
  36031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36032. */
  36033. rolloffFactor?: number;
  36034. /**
  36035. * Define the reference distance the sound should be heard perfectly.
  36036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36037. */
  36038. refDistance?: number;
  36039. /**
  36040. * Define the distance attenuation model the sound will follow.
  36041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36042. */
  36043. distanceModel?: string;
  36044. /**
  36045. * Defines the playback speed (1 by default)
  36046. */
  36047. playbackRate?: number;
  36048. /**
  36049. * Defines if the sound is from a streaming source
  36050. */
  36051. streaming?: boolean;
  36052. /**
  36053. * Defines an optional length (in seconds) inside the sound file
  36054. */
  36055. length?: number;
  36056. /**
  36057. * Defines an optional offset (in seconds) inside the sound file
  36058. */
  36059. offset?: number;
  36060. /**
  36061. * If true, URLs will not be required to state the audio file codec to use.
  36062. */
  36063. skipCodecCheck?: boolean;
  36064. }
  36065. /**
  36066. * Defines a sound that can be played in the application.
  36067. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36069. */
  36070. export class Sound {
  36071. /**
  36072. * The name of the sound in the scene.
  36073. */
  36074. name: string;
  36075. /**
  36076. * Does the sound autoplay once loaded.
  36077. */
  36078. autoplay: boolean;
  36079. /**
  36080. * Does the sound loop after it finishes playing once.
  36081. */
  36082. loop: boolean;
  36083. /**
  36084. * Does the sound use a custom attenuation curve to simulate the falloff
  36085. * happening when the source gets further away from the camera.
  36086. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36087. */
  36088. useCustomAttenuation: boolean;
  36089. /**
  36090. * The sound track id this sound belongs to.
  36091. */
  36092. soundTrackId: number;
  36093. /**
  36094. * Is this sound currently played.
  36095. */
  36096. isPlaying: boolean;
  36097. /**
  36098. * Is this sound currently paused.
  36099. */
  36100. isPaused: boolean;
  36101. /**
  36102. * Does this sound enables spatial sound.
  36103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36104. */
  36105. spatialSound: boolean;
  36106. /**
  36107. * Define the reference distance the sound should be heard perfectly.
  36108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36109. */
  36110. refDistance: number;
  36111. /**
  36112. * Define the roll off factor of spatial sounds.
  36113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36114. */
  36115. rolloffFactor: number;
  36116. /**
  36117. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36119. */
  36120. maxDistance: number;
  36121. /**
  36122. * Define the distance attenuation model the sound will follow.
  36123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36124. */
  36125. distanceModel: string;
  36126. /**
  36127. * @hidden
  36128. * Back Compat
  36129. **/
  36130. onended: () => any;
  36131. /**
  36132. * Observable event when the current playing sound finishes.
  36133. */
  36134. onEndedObservable: Observable<Sound>;
  36135. private _panningModel;
  36136. private _playbackRate;
  36137. private _streaming;
  36138. private _startTime;
  36139. private _startOffset;
  36140. private _position;
  36141. /** @hidden */
  36142. _positionInEmitterSpace: boolean;
  36143. private _localDirection;
  36144. private _volume;
  36145. private _isReadyToPlay;
  36146. private _isDirectional;
  36147. private _readyToPlayCallback;
  36148. private _audioBuffer;
  36149. private _soundSource;
  36150. private _streamingSource;
  36151. private _soundPanner;
  36152. private _soundGain;
  36153. private _inputAudioNode;
  36154. private _outputAudioNode;
  36155. private _coneInnerAngle;
  36156. private _coneOuterAngle;
  36157. private _coneOuterGain;
  36158. private _scene;
  36159. private _connectedTransformNode;
  36160. private _customAttenuationFunction;
  36161. private _registerFunc;
  36162. private _isOutputConnected;
  36163. private _htmlAudioElement;
  36164. private _urlType;
  36165. private _length?;
  36166. private _offset?;
  36167. /** @hidden */
  36168. static _SceneComponentInitialization: (scene: Scene) => void;
  36169. /**
  36170. * Create a sound and attach it to a scene
  36171. * @param name Name of your sound
  36172. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36173. * @param scene defines the scene the sound belongs to
  36174. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36175. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36176. */
  36177. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36178. /**
  36179. * Release the sound and its associated resources
  36180. */
  36181. dispose(): void;
  36182. /**
  36183. * Gets if the sounds is ready to be played or not.
  36184. * @returns true if ready, otherwise false
  36185. */
  36186. isReady(): boolean;
  36187. private _soundLoaded;
  36188. /**
  36189. * Sets the data of the sound from an audiobuffer
  36190. * @param audioBuffer The audioBuffer containing the data
  36191. */
  36192. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36193. /**
  36194. * Updates the current sounds options such as maxdistance, loop...
  36195. * @param options A JSON object containing values named as the object properties
  36196. */
  36197. updateOptions(options: ISoundOptions): void;
  36198. private _createSpatialParameters;
  36199. private _updateSpatialParameters;
  36200. /**
  36201. * Switch the panning model to HRTF:
  36202. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36203. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36204. */
  36205. switchPanningModelToHRTF(): void;
  36206. /**
  36207. * Switch the panning model to Equal Power:
  36208. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36210. */
  36211. switchPanningModelToEqualPower(): void;
  36212. private _switchPanningModel;
  36213. /**
  36214. * Connect this sound to a sound track audio node like gain...
  36215. * @param soundTrackAudioNode the sound track audio node to connect to
  36216. */
  36217. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36218. /**
  36219. * Transform this sound into a directional source
  36220. * @param coneInnerAngle Size of the inner cone in degree
  36221. * @param coneOuterAngle Size of the outer cone in degree
  36222. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36223. */
  36224. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36225. /**
  36226. * Gets or sets the inner angle for the directional cone.
  36227. */
  36228. /**
  36229. * Gets or sets the inner angle for the directional cone.
  36230. */
  36231. directionalConeInnerAngle: number;
  36232. /**
  36233. * Gets or sets the outer angle for the directional cone.
  36234. */
  36235. /**
  36236. * Gets or sets the outer angle for the directional cone.
  36237. */
  36238. directionalConeOuterAngle: number;
  36239. /**
  36240. * Sets the position of the emitter if spatial sound is enabled
  36241. * @param newPosition Defines the new posisiton
  36242. */
  36243. setPosition(newPosition: Vector3): void;
  36244. /**
  36245. * Sets the local direction of the emitter if spatial sound is enabled
  36246. * @param newLocalDirection Defines the new local direction
  36247. */
  36248. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36249. private _updateDirection;
  36250. /** @hidden */
  36251. updateDistanceFromListener(): void;
  36252. /**
  36253. * Sets a new custom attenuation function for the sound.
  36254. * @param callback Defines the function used for the attenuation
  36255. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36256. */
  36257. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36258. /**
  36259. * Play the sound
  36260. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36261. * @param offset (optional) Start the sound at a specific time in seconds
  36262. * @param length (optional) Sound duration (in seconds)
  36263. */
  36264. play(time?: number, offset?: number, length?: number): void;
  36265. private _onended;
  36266. /**
  36267. * Stop the sound
  36268. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36269. */
  36270. stop(time?: number): void;
  36271. /**
  36272. * Put the sound in pause
  36273. */
  36274. pause(): void;
  36275. /**
  36276. * Sets a dedicated volume for this sounds
  36277. * @param newVolume Define the new volume of the sound
  36278. * @param time Define time for gradual change to new volume
  36279. */
  36280. setVolume(newVolume: number, time?: number): void;
  36281. /**
  36282. * Set the sound play back rate
  36283. * @param newPlaybackRate Define the playback rate the sound should be played at
  36284. */
  36285. setPlaybackRate(newPlaybackRate: number): void;
  36286. /**
  36287. * Gets the volume of the sound.
  36288. * @returns the volume of the sound
  36289. */
  36290. getVolume(): number;
  36291. /**
  36292. * Attach the sound to a dedicated mesh
  36293. * @param transformNode The transform node to connect the sound with
  36294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36295. */
  36296. attachToMesh(transformNode: TransformNode): void;
  36297. /**
  36298. * Detach the sound from the previously attached mesh
  36299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36300. */
  36301. detachFromMesh(): void;
  36302. private _onRegisterAfterWorldMatrixUpdate;
  36303. /**
  36304. * Clone the current sound in the scene.
  36305. * @returns the new sound clone
  36306. */
  36307. clone(): Nullable<Sound>;
  36308. /**
  36309. * Gets the current underlying audio buffer containing the data
  36310. * @returns the audio buffer
  36311. */
  36312. getAudioBuffer(): Nullable<AudioBuffer>;
  36313. /**
  36314. * Serializes the Sound in a JSON representation
  36315. * @returns the JSON representation of the sound
  36316. */
  36317. serialize(): any;
  36318. /**
  36319. * Parse a JSON representation of a sound to innstantiate in a given scene
  36320. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36321. * @param scene Define the scene the new parsed sound should be created in
  36322. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36323. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36324. * @returns the newly parsed sound
  36325. */
  36326. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36327. }
  36328. }
  36329. declare module "babylonjs/Actions/directAudioActions" {
  36330. import { Action } from "babylonjs/Actions/action";
  36331. import { Condition } from "babylonjs/Actions/condition";
  36332. import { Sound } from "babylonjs/Audio/sound";
  36333. /**
  36334. * This defines an action helpful to play a defined sound on a triggered action.
  36335. */
  36336. export class PlaySoundAction extends Action {
  36337. private _sound;
  36338. /**
  36339. * Instantiate the action
  36340. * @param triggerOptions defines the trigger options
  36341. * @param sound defines the sound to play
  36342. * @param condition defines the trigger related conditions
  36343. */
  36344. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36345. /** @hidden */
  36346. _prepare(): void;
  36347. /**
  36348. * Execute the action and play the sound.
  36349. */
  36350. execute(): void;
  36351. /**
  36352. * Serializes the actions and its related information.
  36353. * @param parent defines the object to serialize in
  36354. * @returns the serialized object
  36355. */
  36356. serialize(parent: any): any;
  36357. }
  36358. /**
  36359. * This defines an action helpful to stop a defined sound on a triggered action.
  36360. */
  36361. export class StopSoundAction extends Action {
  36362. private _sound;
  36363. /**
  36364. * Instantiate the action
  36365. * @param triggerOptions defines the trigger options
  36366. * @param sound defines the sound to stop
  36367. * @param condition defines the trigger related conditions
  36368. */
  36369. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36370. /** @hidden */
  36371. _prepare(): void;
  36372. /**
  36373. * Execute the action and stop the sound.
  36374. */
  36375. execute(): void;
  36376. /**
  36377. * Serializes the actions and its related information.
  36378. * @param parent defines the object to serialize in
  36379. * @returns the serialized object
  36380. */
  36381. serialize(parent: any): any;
  36382. }
  36383. }
  36384. declare module "babylonjs/Actions/interpolateValueAction" {
  36385. import { Action } from "babylonjs/Actions/action";
  36386. import { Condition } from "babylonjs/Actions/condition";
  36387. import { Observable } from "babylonjs/Misc/observable";
  36388. /**
  36389. * This defines an action responsible to change the value of a property
  36390. * by interpolating between its current value and the newly set one once triggered.
  36391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36392. */
  36393. export class InterpolateValueAction extends Action {
  36394. /**
  36395. * Defines the path of the property where the value should be interpolated
  36396. */
  36397. propertyPath: string;
  36398. /**
  36399. * Defines the target value at the end of the interpolation.
  36400. */
  36401. value: any;
  36402. /**
  36403. * Defines the time it will take for the property to interpolate to the value.
  36404. */
  36405. duration: number;
  36406. /**
  36407. * Defines if the other scene animations should be stopped when the action has been triggered
  36408. */
  36409. stopOtherAnimations?: boolean;
  36410. /**
  36411. * Defines a callback raised once the interpolation animation has been done.
  36412. */
  36413. onInterpolationDone?: () => void;
  36414. /**
  36415. * Observable triggered once the interpolation animation has been done.
  36416. */
  36417. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36418. private _target;
  36419. private _effectiveTarget;
  36420. private _property;
  36421. /**
  36422. * Instantiate the action
  36423. * @param triggerOptions defines the trigger options
  36424. * @param target defines the object containing the value to interpolate
  36425. * @param propertyPath defines the path to the property in the target object
  36426. * @param value defines the target value at the end of the interpolation
  36427. * @param duration deines the time it will take for the property to interpolate to the value.
  36428. * @param condition defines the trigger related conditions
  36429. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36430. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36431. */
  36432. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36433. /** @hidden */
  36434. _prepare(): void;
  36435. /**
  36436. * Execute the action starts the value interpolation.
  36437. */
  36438. execute(): void;
  36439. /**
  36440. * Serializes the actions and its related information.
  36441. * @param parent defines the object to serialize in
  36442. * @returns the serialized object
  36443. */
  36444. serialize(parent: any): any;
  36445. }
  36446. }
  36447. declare module "babylonjs/Actions/index" {
  36448. export * from "babylonjs/Actions/abstractActionManager";
  36449. export * from "babylonjs/Actions/action";
  36450. export * from "babylonjs/Actions/actionEvent";
  36451. export * from "babylonjs/Actions/actionManager";
  36452. export * from "babylonjs/Actions/condition";
  36453. export * from "babylonjs/Actions/directActions";
  36454. export * from "babylonjs/Actions/directAudioActions";
  36455. export * from "babylonjs/Actions/interpolateValueAction";
  36456. }
  36457. declare module "babylonjs/Animations/index" {
  36458. export * from "babylonjs/Animations/animatable";
  36459. export * from "babylonjs/Animations/animation";
  36460. export * from "babylonjs/Animations/animationGroup";
  36461. export * from "babylonjs/Animations/animationPropertiesOverride";
  36462. export * from "babylonjs/Animations/easing";
  36463. export * from "babylonjs/Animations/runtimeAnimation";
  36464. export * from "babylonjs/Animations/animationEvent";
  36465. export * from "babylonjs/Animations/animationGroup";
  36466. export * from "babylonjs/Animations/animationKey";
  36467. export * from "babylonjs/Animations/animationRange";
  36468. export * from "babylonjs/Animations/animatable.interface";
  36469. }
  36470. declare module "babylonjs/Audio/soundTrack" {
  36471. import { Sound } from "babylonjs/Audio/sound";
  36472. import { Analyser } from "babylonjs/Audio/analyser";
  36473. import { Scene } from "babylonjs/scene";
  36474. /**
  36475. * Options allowed during the creation of a sound track.
  36476. */
  36477. export interface ISoundTrackOptions {
  36478. /**
  36479. * The volume the sound track should take during creation
  36480. */
  36481. volume?: number;
  36482. /**
  36483. * Define if the sound track is the main sound track of the scene
  36484. */
  36485. mainTrack?: boolean;
  36486. }
  36487. /**
  36488. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36489. * It will be also used in a future release to apply effects on a specific track.
  36490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36491. */
  36492. export class SoundTrack {
  36493. /**
  36494. * The unique identifier of the sound track in the scene.
  36495. */
  36496. id: number;
  36497. /**
  36498. * The list of sounds included in the sound track.
  36499. */
  36500. soundCollection: Array<Sound>;
  36501. private _outputAudioNode;
  36502. private _scene;
  36503. private _isMainTrack;
  36504. private _connectedAnalyser;
  36505. private _options;
  36506. private _isInitialized;
  36507. /**
  36508. * Creates a new sound track.
  36509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36510. * @param scene Define the scene the sound track belongs to
  36511. * @param options
  36512. */
  36513. constructor(scene: Scene, options?: ISoundTrackOptions);
  36514. private _initializeSoundTrackAudioGraph;
  36515. /**
  36516. * Release the sound track and its associated resources
  36517. */
  36518. dispose(): void;
  36519. /**
  36520. * Adds a sound to this sound track
  36521. * @param sound define the cound to add
  36522. * @ignoreNaming
  36523. */
  36524. AddSound(sound: Sound): void;
  36525. /**
  36526. * Removes a sound to this sound track
  36527. * @param sound define the cound to remove
  36528. * @ignoreNaming
  36529. */
  36530. RemoveSound(sound: Sound): void;
  36531. /**
  36532. * Set a global volume for the full sound track.
  36533. * @param newVolume Define the new volume of the sound track
  36534. */
  36535. setVolume(newVolume: number): void;
  36536. /**
  36537. * Switch the panning model to HRTF:
  36538. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36540. */
  36541. switchPanningModelToHRTF(): void;
  36542. /**
  36543. * Switch the panning model to Equal Power:
  36544. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36545. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36546. */
  36547. switchPanningModelToEqualPower(): void;
  36548. /**
  36549. * Connect the sound track to an audio analyser allowing some amazing
  36550. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36551. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36552. * @param analyser The analyser to connect to the engine
  36553. */
  36554. connectToAnalyser(analyser: Analyser): void;
  36555. }
  36556. }
  36557. declare module "babylonjs/Audio/audioSceneComponent" {
  36558. import { Sound } from "babylonjs/Audio/sound";
  36559. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36560. import { Nullable } from "babylonjs/types";
  36561. import { Vector3 } from "babylonjs/Maths/math.vector";
  36562. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36563. import { Scene } from "babylonjs/scene";
  36564. import { AbstractScene } from "babylonjs/abstractScene";
  36565. import "babylonjs/Audio/audioEngine";
  36566. module "babylonjs/abstractScene" {
  36567. interface AbstractScene {
  36568. /**
  36569. * The list of sounds used in the scene.
  36570. */
  36571. sounds: Nullable<Array<Sound>>;
  36572. }
  36573. }
  36574. module "babylonjs/scene" {
  36575. interface Scene {
  36576. /**
  36577. * @hidden
  36578. * Backing field
  36579. */
  36580. _mainSoundTrack: SoundTrack;
  36581. /**
  36582. * The main sound track played by the scene.
  36583. * It cotains your primary collection of sounds.
  36584. */
  36585. mainSoundTrack: SoundTrack;
  36586. /**
  36587. * The list of sound tracks added to the scene
  36588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36589. */
  36590. soundTracks: Nullable<Array<SoundTrack>>;
  36591. /**
  36592. * Gets a sound using a given name
  36593. * @param name defines the name to search for
  36594. * @return the found sound or null if not found at all.
  36595. */
  36596. getSoundByName(name: string): Nullable<Sound>;
  36597. /**
  36598. * Gets or sets if audio support is enabled
  36599. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36600. */
  36601. audioEnabled: boolean;
  36602. /**
  36603. * Gets or sets if audio will be output to headphones
  36604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36605. */
  36606. headphone: boolean;
  36607. /**
  36608. * Gets or sets custom audio listener position provider
  36609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36610. */
  36611. audioListenerPositionProvider: Nullable<() => Vector3>;
  36612. }
  36613. }
  36614. /**
  36615. * Defines the sound scene component responsible to manage any sounds
  36616. * in a given scene.
  36617. */
  36618. export class AudioSceneComponent implements ISceneSerializableComponent {
  36619. /**
  36620. * The component name helpfull to identify the component in the list of scene components.
  36621. */
  36622. readonly name: string;
  36623. /**
  36624. * The scene the component belongs to.
  36625. */
  36626. scene: Scene;
  36627. private _audioEnabled;
  36628. /**
  36629. * Gets whether audio is enabled or not.
  36630. * Please use related enable/disable method to switch state.
  36631. */
  36632. readonly audioEnabled: boolean;
  36633. private _headphone;
  36634. /**
  36635. * Gets whether audio is outputing to headphone or not.
  36636. * Please use the according Switch methods to change output.
  36637. */
  36638. readonly headphone: boolean;
  36639. private _audioListenerPositionProvider;
  36640. /**
  36641. * Gets the current audio listener position provider
  36642. */
  36643. /**
  36644. * Sets a custom listener position for all sounds in the scene
  36645. * By default, this is the position of the first active camera
  36646. */
  36647. audioListenerPositionProvider: Nullable<() => Vector3>;
  36648. /**
  36649. * Creates a new instance of the component for the given scene
  36650. * @param scene Defines the scene to register the component in
  36651. */
  36652. constructor(scene: Scene);
  36653. /**
  36654. * Registers the component in a given scene
  36655. */
  36656. register(): void;
  36657. /**
  36658. * Rebuilds the elements related to this component in case of
  36659. * context lost for instance.
  36660. */
  36661. rebuild(): void;
  36662. /**
  36663. * Serializes the component data to the specified json object
  36664. * @param serializationObject The object to serialize to
  36665. */
  36666. serialize(serializationObject: any): void;
  36667. /**
  36668. * Adds all the elements from the container to the scene
  36669. * @param container the container holding the elements
  36670. */
  36671. addFromContainer(container: AbstractScene): void;
  36672. /**
  36673. * Removes all the elements in the container from the scene
  36674. * @param container contains the elements to remove
  36675. * @param dispose if the removed element should be disposed (default: false)
  36676. */
  36677. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36678. /**
  36679. * Disposes the component and the associated ressources.
  36680. */
  36681. dispose(): void;
  36682. /**
  36683. * Disables audio in the associated scene.
  36684. */
  36685. disableAudio(): void;
  36686. /**
  36687. * Enables audio in the associated scene.
  36688. */
  36689. enableAudio(): void;
  36690. /**
  36691. * Switch audio to headphone output.
  36692. */
  36693. switchAudioModeForHeadphones(): void;
  36694. /**
  36695. * Switch audio to normal speakers.
  36696. */
  36697. switchAudioModeForNormalSpeakers(): void;
  36698. private _afterRender;
  36699. }
  36700. }
  36701. declare module "babylonjs/Audio/weightedsound" {
  36702. import { Sound } from "babylonjs/Audio/sound";
  36703. /**
  36704. * Wraps one or more Sound objects and selects one with random weight for playback.
  36705. */
  36706. export class WeightedSound {
  36707. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36708. loop: boolean;
  36709. private _coneInnerAngle;
  36710. private _coneOuterAngle;
  36711. private _volume;
  36712. /** A Sound is currently playing. */
  36713. isPlaying: boolean;
  36714. /** A Sound is currently paused. */
  36715. isPaused: boolean;
  36716. private _sounds;
  36717. private _weights;
  36718. private _currentIndex?;
  36719. /**
  36720. * Creates a new WeightedSound from the list of sounds given.
  36721. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36722. * @param sounds Array of Sounds that will be selected from.
  36723. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36724. */
  36725. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36726. /**
  36727. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36728. */
  36729. /**
  36730. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36731. */
  36732. directionalConeInnerAngle: number;
  36733. /**
  36734. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36735. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36736. */
  36737. /**
  36738. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36739. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36740. */
  36741. directionalConeOuterAngle: number;
  36742. /**
  36743. * Playback volume.
  36744. */
  36745. /**
  36746. * Playback volume.
  36747. */
  36748. volume: number;
  36749. private _onended;
  36750. /**
  36751. * Suspend playback
  36752. */
  36753. pause(): void;
  36754. /**
  36755. * Stop playback
  36756. */
  36757. stop(): void;
  36758. /**
  36759. * Start playback.
  36760. * @param startOffset Position the clip head at a specific time in seconds.
  36761. */
  36762. play(startOffset?: number): void;
  36763. }
  36764. }
  36765. declare module "babylonjs/Audio/index" {
  36766. export * from "babylonjs/Audio/analyser";
  36767. export * from "babylonjs/Audio/audioEngine";
  36768. export * from "babylonjs/Audio/audioSceneComponent";
  36769. export * from "babylonjs/Audio/sound";
  36770. export * from "babylonjs/Audio/soundTrack";
  36771. export * from "babylonjs/Audio/weightedsound";
  36772. }
  36773. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36774. import { Behavior } from "babylonjs/Behaviors/behavior";
  36775. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36776. import { BackEase } from "babylonjs/Animations/easing";
  36777. /**
  36778. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36779. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36780. */
  36781. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36782. /**
  36783. * Gets the name of the behavior.
  36784. */
  36785. readonly name: string;
  36786. /**
  36787. * The easing function used by animations
  36788. */
  36789. static EasingFunction: BackEase;
  36790. /**
  36791. * The easing mode used by animations
  36792. */
  36793. static EasingMode: number;
  36794. /**
  36795. * The duration of the animation, in milliseconds
  36796. */
  36797. transitionDuration: number;
  36798. /**
  36799. * Length of the distance animated by the transition when lower radius is reached
  36800. */
  36801. lowerRadiusTransitionRange: number;
  36802. /**
  36803. * Length of the distance animated by the transition when upper radius is reached
  36804. */
  36805. upperRadiusTransitionRange: number;
  36806. private _autoTransitionRange;
  36807. /**
  36808. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36809. */
  36810. /**
  36811. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36812. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36813. */
  36814. autoTransitionRange: boolean;
  36815. private _attachedCamera;
  36816. private _onAfterCheckInputsObserver;
  36817. private _onMeshTargetChangedObserver;
  36818. /**
  36819. * Initializes the behavior.
  36820. */
  36821. init(): void;
  36822. /**
  36823. * Attaches the behavior to its arc rotate camera.
  36824. * @param camera Defines the camera to attach the behavior to
  36825. */
  36826. attach(camera: ArcRotateCamera): void;
  36827. /**
  36828. * Detaches the behavior from its current arc rotate camera.
  36829. */
  36830. detach(): void;
  36831. private _radiusIsAnimating;
  36832. private _radiusBounceTransition;
  36833. private _animatables;
  36834. private _cachedWheelPrecision;
  36835. /**
  36836. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36837. * @param radiusLimit The limit to check against.
  36838. * @return Bool to indicate if at limit.
  36839. */
  36840. private _isRadiusAtLimit;
  36841. /**
  36842. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36843. * @param radiusDelta The delta by which to animate to. Can be negative.
  36844. */
  36845. private _applyBoundRadiusAnimation;
  36846. /**
  36847. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36848. */
  36849. protected _clearAnimationLocks(): void;
  36850. /**
  36851. * Stops and removes all animations that have been applied to the camera
  36852. */
  36853. stopAllAnimations(): void;
  36854. }
  36855. }
  36856. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36857. import { Behavior } from "babylonjs/Behaviors/behavior";
  36858. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36859. import { ExponentialEase } from "babylonjs/Animations/easing";
  36860. import { Nullable } from "babylonjs/types";
  36861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36862. import { Vector3 } from "babylonjs/Maths/math.vector";
  36863. /**
  36864. * 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.
  36865. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36866. */
  36867. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36868. /**
  36869. * Gets the name of the behavior.
  36870. */
  36871. readonly name: string;
  36872. private _mode;
  36873. private _radiusScale;
  36874. private _positionScale;
  36875. private _defaultElevation;
  36876. private _elevationReturnTime;
  36877. private _elevationReturnWaitTime;
  36878. private _zoomStopsAnimation;
  36879. private _framingTime;
  36880. /**
  36881. * The easing function used by animations
  36882. */
  36883. static EasingFunction: ExponentialEase;
  36884. /**
  36885. * The easing mode used by animations
  36886. */
  36887. static EasingMode: number;
  36888. /**
  36889. * Sets the current mode used by the behavior
  36890. */
  36891. /**
  36892. * Gets current mode used by the behavior.
  36893. */
  36894. mode: number;
  36895. /**
  36896. * Sets the scale applied to the radius (1 by default)
  36897. */
  36898. /**
  36899. * Gets the scale applied to the radius
  36900. */
  36901. radiusScale: number;
  36902. /**
  36903. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36904. */
  36905. /**
  36906. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36907. */
  36908. positionScale: number;
  36909. /**
  36910. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36911. * behaviour is triggered, in radians.
  36912. */
  36913. /**
  36914. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36915. * behaviour is triggered, in radians.
  36916. */
  36917. defaultElevation: number;
  36918. /**
  36919. * Sets the time (in milliseconds) taken to return to the default beta position.
  36920. * Negative value indicates camera should not return to default.
  36921. */
  36922. /**
  36923. * Gets the time (in milliseconds) taken to return to the default beta position.
  36924. * Negative value indicates camera should not return to default.
  36925. */
  36926. elevationReturnTime: number;
  36927. /**
  36928. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36929. */
  36930. /**
  36931. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36932. */
  36933. elevationReturnWaitTime: number;
  36934. /**
  36935. * Sets the flag that indicates if user zooming should stop animation.
  36936. */
  36937. /**
  36938. * Gets the flag that indicates if user zooming should stop animation.
  36939. */
  36940. zoomStopsAnimation: boolean;
  36941. /**
  36942. * Sets the transition time when framing the mesh, in milliseconds
  36943. */
  36944. /**
  36945. * Gets the transition time when framing the mesh, in milliseconds
  36946. */
  36947. framingTime: number;
  36948. /**
  36949. * Define if the behavior should automatically change the configured
  36950. * camera limits and sensibilities.
  36951. */
  36952. autoCorrectCameraLimitsAndSensibility: boolean;
  36953. private _onPrePointerObservableObserver;
  36954. private _onAfterCheckInputsObserver;
  36955. private _onMeshTargetChangedObserver;
  36956. private _attachedCamera;
  36957. private _isPointerDown;
  36958. private _lastInteractionTime;
  36959. /**
  36960. * Initializes the behavior.
  36961. */
  36962. init(): void;
  36963. /**
  36964. * Attaches the behavior to its arc rotate camera.
  36965. * @param camera Defines the camera to attach the behavior to
  36966. */
  36967. attach(camera: ArcRotateCamera): void;
  36968. /**
  36969. * Detaches the behavior from its current arc rotate camera.
  36970. */
  36971. detach(): void;
  36972. private _animatables;
  36973. private _betaIsAnimating;
  36974. private _betaTransition;
  36975. private _radiusTransition;
  36976. private _vectorTransition;
  36977. /**
  36978. * Targets the given mesh and updates zoom level accordingly.
  36979. * @param mesh The mesh to target.
  36980. * @param radius Optional. If a cached radius position already exists, overrides default.
  36981. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36982. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36983. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36984. */
  36985. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36986. /**
  36987. * Targets the given mesh with its children and updates zoom level accordingly.
  36988. * @param mesh The mesh to target.
  36989. * @param radius Optional. If a cached radius position already exists, overrides default.
  36990. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36991. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36992. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36993. */
  36994. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36995. /**
  36996. * Targets the given meshes with their children and updates zoom level accordingly.
  36997. * @param meshes The mesh to target.
  36998. * @param radius Optional. If a cached radius position already exists, overrides default.
  36999. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37000. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37001. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37002. */
  37003. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37004. /**
  37005. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37006. * @param minimumWorld Determines the smaller position of the bounding box extend
  37007. * @param maximumWorld Determines the bigger position of the bounding box extend
  37008. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37009. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37010. */
  37011. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37012. /**
  37013. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37014. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37015. * frustum width.
  37016. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37017. * to fully enclose the mesh in the viewing frustum.
  37018. */
  37019. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37020. /**
  37021. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37022. * is automatically returned to its default position (expected to be above ground plane).
  37023. */
  37024. private _maintainCameraAboveGround;
  37025. /**
  37026. * Returns the frustum slope based on the canvas ratio and camera FOV
  37027. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37028. */
  37029. private _getFrustumSlope;
  37030. /**
  37031. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37032. */
  37033. private _clearAnimationLocks;
  37034. /**
  37035. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37036. */
  37037. private _applyUserInteraction;
  37038. /**
  37039. * Stops and removes all animations that have been applied to the camera
  37040. */
  37041. stopAllAnimations(): void;
  37042. /**
  37043. * Gets a value indicating if the user is moving the camera
  37044. */
  37045. readonly isUserIsMoving: boolean;
  37046. /**
  37047. * The camera can move all the way towards the mesh.
  37048. */
  37049. static IgnoreBoundsSizeMode: number;
  37050. /**
  37051. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37052. */
  37053. static FitFrustumSidesMode: number;
  37054. }
  37055. }
  37056. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37057. import { Nullable } from "babylonjs/types";
  37058. import { Camera } from "babylonjs/Cameras/camera";
  37059. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37060. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37061. /**
  37062. * Base class for Camera Pointer Inputs.
  37063. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37064. * for example usage.
  37065. */
  37066. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37067. /**
  37068. * Defines the camera the input is attached to.
  37069. */
  37070. abstract camera: Camera;
  37071. /**
  37072. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37073. */
  37074. protected _altKey: boolean;
  37075. protected _ctrlKey: boolean;
  37076. protected _metaKey: boolean;
  37077. protected _shiftKey: boolean;
  37078. /**
  37079. * Which mouse buttons were pressed at time of last mouse event.
  37080. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37081. */
  37082. protected _buttonsPressed: number;
  37083. /**
  37084. * Defines the buttons associated with the input to handle camera move.
  37085. */
  37086. buttons: number[];
  37087. /**
  37088. * Attach the input controls to a specific dom element to get the input from.
  37089. * @param element Defines the element the controls should be listened from
  37090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37091. */
  37092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37093. /**
  37094. * Detach the current controls from the specified dom element.
  37095. * @param element Defines the element to stop listening the inputs from
  37096. */
  37097. detachControl(element: Nullable<HTMLElement>): void;
  37098. /**
  37099. * Gets the class name of the current input.
  37100. * @returns the class name
  37101. */
  37102. getClassName(): string;
  37103. /**
  37104. * Get the friendly name associated with the input class.
  37105. * @returns the input friendly name
  37106. */
  37107. getSimpleName(): string;
  37108. /**
  37109. * Called on pointer POINTERDOUBLETAP event.
  37110. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37111. */
  37112. protected onDoubleTap(type: string): void;
  37113. /**
  37114. * Called on pointer POINTERMOVE event if only a single touch is active.
  37115. * Override this method to provide functionality.
  37116. */
  37117. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37118. /**
  37119. * Called on pointer POINTERMOVE event if multiple touches are active.
  37120. * Override this method to provide functionality.
  37121. */
  37122. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37123. /**
  37124. * Called on JS contextmenu event.
  37125. * Override this method to provide functionality.
  37126. */
  37127. protected onContextMenu(evt: PointerEvent): void;
  37128. /**
  37129. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37130. * press.
  37131. * Override this method to provide functionality.
  37132. */
  37133. protected onButtonDown(evt: PointerEvent): void;
  37134. /**
  37135. * Called each time a new POINTERUP event occurs. Ie, for each button
  37136. * release.
  37137. * Override this method to provide functionality.
  37138. */
  37139. protected onButtonUp(evt: PointerEvent): void;
  37140. /**
  37141. * Called when window becomes inactive.
  37142. * Override this method to provide functionality.
  37143. */
  37144. protected onLostFocus(): void;
  37145. private _pointerInput;
  37146. private _observer;
  37147. private _onLostFocus;
  37148. private pointA;
  37149. private pointB;
  37150. }
  37151. }
  37152. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37153. import { Nullable } from "babylonjs/types";
  37154. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37155. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37156. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37157. /**
  37158. * Manage the pointers inputs to control an arc rotate camera.
  37159. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37160. */
  37161. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37162. /**
  37163. * Defines the camera the input is attached to.
  37164. */
  37165. camera: ArcRotateCamera;
  37166. /**
  37167. * Gets the class name of the current input.
  37168. * @returns the class name
  37169. */
  37170. getClassName(): string;
  37171. /**
  37172. * Defines the buttons associated with the input to handle camera move.
  37173. */
  37174. buttons: number[];
  37175. /**
  37176. * Defines the pointer angular sensibility along the X axis or how fast is
  37177. * the camera rotating.
  37178. */
  37179. angularSensibilityX: number;
  37180. /**
  37181. * Defines the pointer angular sensibility along the Y axis or how fast is
  37182. * the camera rotating.
  37183. */
  37184. angularSensibilityY: number;
  37185. /**
  37186. * Defines the pointer pinch precision or how fast is the camera zooming.
  37187. */
  37188. pinchPrecision: number;
  37189. /**
  37190. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37191. * from 0.
  37192. * It defines the percentage of current camera.radius to use as delta when
  37193. * pinch zoom is used.
  37194. */
  37195. pinchDeltaPercentage: number;
  37196. /**
  37197. * Defines the pointer panning sensibility or how fast is the camera moving.
  37198. */
  37199. panningSensibility: number;
  37200. /**
  37201. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37202. */
  37203. multiTouchPanning: boolean;
  37204. /**
  37205. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37206. * zoom (pinch) through multitouch.
  37207. */
  37208. multiTouchPanAndZoom: boolean;
  37209. /**
  37210. * Revers pinch action direction.
  37211. */
  37212. pinchInwards: boolean;
  37213. private _isPanClick;
  37214. private _twoFingerActivityCount;
  37215. private _isPinching;
  37216. /**
  37217. * Called on pointer POINTERMOVE event if only a single touch is active.
  37218. */
  37219. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37220. /**
  37221. * Called on pointer POINTERDOUBLETAP event.
  37222. */
  37223. protected onDoubleTap(type: string): void;
  37224. /**
  37225. * Called on pointer POINTERMOVE event if multiple touches are active.
  37226. */
  37227. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37228. /**
  37229. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37230. * press.
  37231. */
  37232. protected onButtonDown(evt: PointerEvent): void;
  37233. /**
  37234. * Called each time a new POINTERUP event occurs. Ie, for each button
  37235. * release.
  37236. */
  37237. protected onButtonUp(evt: PointerEvent): void;
  37238. /**
  37239. * Called when window becomes inactive.
  37240. */
  37241. protected onLostFocus(): void;
  37242. }
  37243. }
  37244. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37245. import { Nullable } from "babylonjs/types";
  37246. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37247. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37248. /**
  37249. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37251. */
  37252. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37253. /**
  37254. * Defines the camera the input is attached to.
  37255. */
  37256. camera: ArcRotateCamera;
  37257. /**
  37258. * Defines the list of key codes associated with the up action (increase alpha)
  37259. */
  37260. keysUp: number[];
  37261. /**
  37262. * Defines the list of key codes associated with the down action (decrease alpha)
  37263. */
  37264. keysDown: number[];
  37265. /**
  37266. * Defines the list of key codes associated with the left action (increase beta)
  37267. */
  37268. keysLeft: number[];
  37269. /**
  37270. * Defines the list of key codes associated with the right action (decrease beta)
  37271. */
  37272. keysRight: number[];
  37273. /**
  37274. * Defines the list of key codes associated with the reset action.
  37275. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37276. */
  37277. keysReset: number[];
  37278. /**
  37279. * Defines the panning sensibility of the inputs.
  37280. * (How fast is the camera paning)
  37281. */
  37282. panningSensibility: number;
  37283. /**
  37284. * Defines the zooming sensibility of the inputs.
  37285. * (How fast is the camera zooming)
  37286. */
  37287. zoomingSensibility: number;
  37288. /**
  37289. * Defines wether maintaining the alt key down switch the movement mode from
  37290. * orientation to zoom.
  37291. */
  37292. useAltToZoom: boolean;
  37293. /**
  37294. * Rotation speed of the camera
  37295. */
  37296. angularSpeed: number;
  37297. private _keys;
  37298. private _ctrlPressed;
  37299. private _altPressed;
  37300. private _onCanvasBlurObserver;
  37301. private _onKeyboardObserver;
  37302. private _engine;
  37303. private _scene;
  37304. /**
  37305. * Attach the input controls to a specific dom element to get the input from.
  37306. * @param element Defines the element the controls should be listened from
  37307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37308. */
  37309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37310. /**
  37311. * Detach the current controls from the specified dom element.
  37312. * @param element Defines the element to stop listening the inputs from
  37313. */
  37314. detachControl(element: Nullable<HTMLElement>): void;
  37315. /**
  37316. * Update the current camera state depending on the inputs that have been used this frame.
  37317. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37318. */
  37319. checkInputs(): void;
  37320. /**
  37321. * Gets the class name of the current intput.
  37322. * @returns the class name
  37323. */
  37324. getClassName(): string;
  37325. /**
  37326. * Get the friendly name associated with the input class.
  37327. * @returns the input friendly name
  37328. */
  37329. getSimpleName(): string;
  37330. }
  37331. }
  37332. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37333. import { Nullable } from "babylonjs/types";
  37334. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37335. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37336. /**
  37337. * Manage the mouse wheel inputs to control an arc rotate camera.
  37338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37339. */
  37340. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37341. /**
  37342. * Defines the camera the input is attached to.
  37343. */
  37344. camera: ArcRotateCamera;
  37345. /**
  37346. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37347. */
  37348. wheelPrecision: number;
  37349. /**
  37350. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37351. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37352. */
  37353. wheelDeltaPercentage: number;
  37354. private _wheel;
  37355. private _observer;
  37356. private computeDeltaFromMouseWheelLegacyEvent;
  37357. /**
  37358. * Attach the input controls to a specific dom element to get the input from.
  37359. * @param element Defines the element the controls should be listened from
  37360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37361. */
  37362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37363. /**
  37364. * Detach the current controls from the specified dom element.
  37365. * @param element Defines the element to stop listening the inputs from
  37366. */
  37367. detachControl(element: Nullable<HTMLElement>): void;
  37368. /**
  37369. * Gets the class name of the current intput.
  37370. * @returns the class name
  37371. */
  37372. getClassName(): string;
  37373. /**
  37374. * Get the friendly name associated with the input class.
  37375. * @returns the input friendly name
  37376. */
  37377. getSimpleName(): string;
  37378. }
  37379. }
  37380. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37381. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37382. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37383. /**
  37384. * Default Inputs manager for the ArcRotateCamera.
  37385. * It groups all the default supported inputs for ease of use.
  37386. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37387. */
  37388. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37389. /**
  37390. * Instantiates a new ArcRotateCameraInputsManager.
  37391. * @param camera Defines the camera the inputs belong to
  37392. */
  37393. constructor(camera: ArcRotateCamera);
  37394. /**
  37395. * Add mouse wheel input support to the input manager.
  37396. * @returns the current input manager
  37397. */
  37398. addMouseWheel(): ArcRotateCameraInputsManager;
  37399. /**
  37400. * Add pointers input support to the input manager.
  37401. * @returns the current input manager
  37402. */
  37403. addPointers(): ArcRotateCameraInputsManager;
  37404. /**
  37405. * Add keyboard input support to the input manager.
  37406. * @returns the current input manager
  37407. */
  37408. addKeyboard(): ArcRotateCameraInputsManager;
  37409. }
  37410. }
  37411. declare module "babylonjs/Cameras/arcRotateCamera" {
  37412. import { Observable } from "babylonjs/Misc/observable";
  37413. import { Nullable } from "babylonjs/types";
  37414. import { Scene } from "babylonjs/scene";
  37415. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37417. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37418. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37419. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37420. import { Camera } from "babylonjs/Cameras/camera";
  37421. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37422. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37423. import { Collider } from "babylonjs/Collisions/collider";
  37424. /**
  37425. * This represents an orbital type of camera.
  37426. *
  37427. * 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.
  37428. * 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.
  37429. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37430. */
  37431. export class ArcRotateCamera extends TargetCamera {
  37432. /**
  37433. * Defines the rotation angle of the camera along the longitudinal axis.
  37434. */
  37435. alpha: number;
  37436. /**
  37437. * Defines the rotation angle of the camera along the latitudinal axis.
  37438. */
  37439. beta: number;
  37440. /**
  37441. * Defines the radius of the camera from it s target point.
  37442. */
  37443. radius: number;
  37444. protected _target: Vector3;
  37445. protected _targetHost: Nullable<AbstractMesh>;
  37446. /**
  37447. * Defines the target point of the camera.
  37448. * The camera looks towards it form the radius distance.
  37449. */
  37450. target: Vector3;
  37451. /**
  37452. * Define the current local position of the camera in the scene
  37453. */
  37454. position: Vector3;
  37455. protected _upVector: Vector3;
  37456. protected _upToYMatrix: Matrix;
  37457. protected _YToUpMatrix: Matrix;
  37458. /**
  37459. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37460. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37461. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37462. */
  37463. upVector: Vector3;
  37464. /**
  37465. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37466. */
  37467. setMatUp(): void;
  37468. /**
  37469. * Current inertia value on the longitudinal axis.
  37470. * The bigger this number the longer it will take for the camera to stop.
  37471. */
  37472. inertialAlphaOffset: number;
  37473. /**
  37474. * Current inertia value on the latitudinal axis.
  37475. * The bigger this number the longer it will take for the camera to stop.
  37476. */
  37477. inertialBetaOffset: number;
  37478. /**
  37479. * Current inertia value on the radius axis.
  37480. * The bigger this number the longer it will take for the camera to stop.
  37481. */
  37482. inertialRadiusOffset: number;
  37483. /**
  37484. * Minimum allowed angle on the longitudinal axis.
  37485. * This can help limiting how the Camera is able to move in the scene.
  37486. */
  37487. lowerAlphaLimit: Nullable<number>;
  37488. /**
  37489. * Maximum allowed angle on the longitudinal axis.
  37490. * This can help limiting how the Camera is able to move in the scene.
  37491. */
  37492. upperAlphaLimit: Nullable<number>;
  37493. /**
  37494. * Minimum allowed angle on the latitudinal axis.
  37495. * This can help limiting how the Camera is able to move in the scene.
  37496. */
  37497. lowerBetaLimit: number;
  37498. /**
  37499. * Maximum allowed angle on the latitudinal axis.
  37500. * This can help limiting how the Camera is able to move in the scene.
  37501. */
  37502. upperBetaLimit: number;
  37503. /**
  37504. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37505. * This can help limiting how the Camera is able to move in the scene.
  37506. */
  37507. lowerRadiusLimit: Nullable<number>;
  37508. /**
  37509. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37510. * This can help limiting how the Camera is able to move in the scene.
  37511. */
  37512. upperRadiusLimit: Nullable<number>;
  37513. /**
  37514. * Defines the current inertia value used during panning of the camera along the X axis.
  37515. */
  37516. inertialPanningX: number;
  37517. /**
  37518. * Defines the current inertia value used during panning of the camera along the Y axis.
  37519. */
  37520. inertialPanningY: number;
  37521. /**
  37522. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37523. * Basically if your fingers moves away from more than this distance you will be considered
  37524. * in pinch mode.
  37525. */
  37526. pinchToPanMaxDistance: number;
  37527. /**
  37528. * Defines the maximum distance the camera can pan.
  37529. * This could help keeping the cammera always in your scene.
  37530. */
  37531. panningDistanceLimit: Nullable<number>;
  37532. /**
  37533. * Defines the target of the camera before paning.
  37534. */
  37535. panningOriginTarget: Vector3;
  37536. /**
  37537. * Defines the value of the inertia used during panning.
  37538. * 0 would mean stop inertia and one would mean no decelleration at all.
  37539. */
  37540. panningInertia: number;
  37541. /**
  37542. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37543. */
  37544. angularSensibilityX: number;
  37545. /**
  37546. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37547. */
  37548. angularSensibilityY: number;
  37549. /**
  37550. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37551. */
  37552. pinchPrecision: number;
  37553. /**
  37554. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37555. * It will be used instead of pinchDeltaPrecision if different from 0.
  37556. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37557. */
  37558. pinchDeltaPercentage: number;
  37559. /**
  37560. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37561. */
  37562. panningSensibility: number;
  37563. /**
  37564. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37565. */
  37566. keysUp: number[];
  37567. /**
  37568. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37569. */
  37570. keysDown: number[];
  37571. /**
  37572. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37573. */
  37574. keysLeft: number[];
  37575. /**
  37576. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37577. */
  37578. keysRight: number[];
  37579. /**
  37580. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37581. */
  37582. wheelPrecision: number;
  37583. /**
  37584. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37585. * It will be used instead of pinchDeltaPrecision if different from 0.
  37586. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37587. */
  37588. wheelDeltaPercentage: number;
  37589. /**
  37590. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37591. */
  37592. zoomOnFactor: number;
  37593. /**
  37594. * Defines a screen offset for the camera position.
  37595. */
  37596. targetScreenOffset: Vector2;
  37597. /**
  37598. * Allows the camera to be completely reversed.
  37599. * If false the camera can not arrive upside down.
  37600. */
  37601. allowUpsideDown: boolean;
  37602. /**
  37603. * Define if double tap/click is used to restore the previously saved state of the camera.
  37604. */
  37605. useInputToRestoreState: boolean;
  37606. /** @hidden */
  37607. _viewMatrix: Matrix;
  37608. /** @hidden */
  37609. _useCtrlForPanning: boolean;
  37610. /** @hidden */
  37611. _panningMouseButton: number;
  37612. /**
  37613. * Defines the input associated to the camera.
  37614. */
  37615. inputs: ArcRotateCameraInputsManager;
  37616. /** @hidden */
  37617. _reset: () => void;
  37618. /**
  37619. * Defines the allowed panning axis.
  37620. */
  37621. panningAxis: Vector3;
  37622. protected _localDirection: Vector3;
  37623. protected _transformedDirection: Vector3;
  37624. private _bouncingBehavior;
  37625. /**
  37626. * Gets the bouncing behavior of the camera if it has been enabled.
  37627. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37628. */
  37629. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37630. /**
  37631. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37632. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37633. */
  37634. useBouncingBehavior: boolean;
  37635. private _framingBehavior;
  37636. /**
  37637. * Gets the framing behavior of the camera if it has been enabled.
  37638. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37639. */
  37640. readonly framingBehavior: Nullable<FramingBehavior>;
  37641. /**
  37642. * Defines if the framing behavior of the camera is enabled on the camera.
  37643. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37644. */
  37645. useFramingBehavior: boolean;
  37646. private _autoRotationBehavior;
  37647. /**
  37648. * Gets the auto rotation behavior of the camera if it has been enabled.
  37649. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37650. */
  37651. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37652. /**
  37653. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37654. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37655. */
  37656. useAutoRotationBehavior: boolean;
  37657. /**
  37658. * Observable triggered when the mesh target has been changed on the camera.
  37659. */
  37660. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37661. /**
  37662. * Event raised when the camera is colliding with a mesh.
  37663. */
  37664. onCollide: (collidedMesh: AbstractMesh) => void;
  37665. /**
  37666. * Defines whether the camera should check collision with the objects oh the scene.
  37667. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37668. */
  37669. checkCollisions: boolean;
  37670. /**
  37671. * Defines the collision radius of the camera.
  37672. * This simulates a sphere around the camera.
  37673. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37674. */
  37675. collisionRadius: Vector3;
  37676. protected _collider: Collider;
  37677. protected _previousPosition: Vector3;
  37678. protected _collisionVelocity: Vector3;
  37679. protected _newPosition: Vector3;
  37680. protected _previousAlpha: number;
  37681. protected _previousBeta: number;
  37682. protected _previousRadius: number;
  37683. protected _collisionTriggered: boolean;
  37684. protected _targetBoundingCenter: Nullable<Vector3>;
  37685. private _computationVector;
  37686. /**
  37687. * Instantiates a new ArcRotateCamera in a given scene
  37688. * @param name Defines the name of the camera
  37689. * @param alpha Defines the camera rotation along the logitudinal axis
  37690. * @param beta Defines the camera rotation along the latitudinal axis
  37691. * @param radius Defines the camera distance from its target
  37692. * @param target Defines the camera target
  37693. * @param scene Defines the scene the camera belongs to
  37694. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37695. */
  37696. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37697. /** @hidden */
  37698. _initCache(): void;
  37699. /** @hidden */
  37700. _updateCache(ignoreParentClass?: boolean): void;
  37701. protected _getTargetPosition(): Vector3;
  37702. private _storedAlpha;
  37703. private _storedBeta;
  37704. private _storedRadius;
  37705. private _storedTarget;
  37706. private _storedTargetScreenOffset;
  37707. /**
  37708. * Stores the current state of the camera (alpha, beta, radius and target)
  37709. * @returns the camera itself
  37710. */
  37711. storeState(): Camera;
  37712. /**
  37713. * @hidden
  37714. * Restored camera state. You must call storeState() first
  37715. */
  37716. _restoreStateValues(): boolean;
  37717. /** @hidden */
  37718. _isSynchronizedViewMatrix(): boolean;
  37719. /**
  37720. * Attached controls to the current camera.
  37721. * @param element Defines the element the controls should be listened from
  37722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37723. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37724. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37725. */
  37726. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37727. /**
  37728. * Detach the current controls from the camera.
  37729. * The camera will stop reacting to inputs.
  37730. * @param element Defines the element to stop listening the inputs from
  37731. */
  37732. detachControl(element: HTMLElement): void;
  37733. /** @hidden */
  37734. _checkInputs(): void;
  37735. protected _checkLimits(): void;
  37736. /**
  37737. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37738. */
  37739. rebuildAnglesAndRadius(): void;
  37740. /**
  37741. * Use a position to define the current camera related information like aplha, beta and radius
  37742. * @param position Defines the position to set the camera at
  37743. */
  37744. setPosition(position: Vector3): void;
  37745. /**
  37746. * Defines the target the camera should look at.
  37747. * This will automatically adapt alpha beta and radius to fit within the new target.
  37748. * @param target Defines the new target as a Vector or a mesh
  37749. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37750. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37751. */
  37752. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37753. /** @hidden */
  37754. _getViewMatrix(): Matrix;
  37755. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37756. /**
  37757. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37758. * @param meshes Defines the mesh to zoom on
  37759. * @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)
  37760. */
  37761. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37762. /**
  37763. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37764. * The target will be changed but the radius
  37765. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37766. * @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)
  37767. */
  37768. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37769. min: Vector3;
  37770. max: Vector3;
  37771. distance: number;
  37772. }, doNotUpdateMaxZ?: boolean): void;
  37773. /**
  37774. * @override
  37775. * Override Camera.createRigCamera
  37776. */
  37777. createRigCamera(name: string, cameraIndex: number): Camera;
  37778. /**
  37779. * @hidden
  37780. * @override
  37781. * Override Camera._updateRigCameras
  37782. */
  37783. _updateRigCameras(): void;
  37784. /**
  37785. * Destroy the camera and release the current resources hold by it.
  37786. */
  37787. dispose(): void;
  37788. /**
  37789. * Gets the current object class name.
  37790. * @return the class name
  37791. */
  37792. getClassName(): string;
  37793. }
  37794. }
  37795. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37796. import { Behavior } from "babylonjs/Behaviors/behavior";
  37797. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37798. /**
  37799. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37800. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37801. */
  37802. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37803. /**
  37804. * Gets the name of the behavior.
  37805. */
  37806. readonly name: string;
  37807. private _zoomStopsAnimation;
  37808. private _idleRotationSpeed;
  37809. private _idleRotationWaitTime;
  37810. private _idleRotationSpinupTime;
  37811. /**
  37812. * Sets the flag that indicates if user zooming should stop animation.
  37813. */
  37814. /**
  37815. * Gets the flag that indicates if user zooming should stop animation.
  37816. */
  37817. zoomStopsAnimation: boolean;
  37818. /**
  37819. * Sets the default speed at which the camera rotates around the model.
  37820. */
  37821. /**
  37822. * Gets the default speed at which the camera rotates around the model.
  37823. */
  37824. idleRotationSpeed: number;
  37825. /**
  37826. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37827. */
  37828. /**
  37829. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37830. */
  37831. idleRotationWaitTime: number;
  37832. /**
  37833. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37834. */
  37835. /**
  37836. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37837. */
  37838. idleRotationSpinupTime: number;
  37839. /**
  37840. * Gets a value indicating if the camera is currently rotating because of this behavior
  37841. */
  37842. readonly rotationInProgress: boolean;
  37843. private _onPrePointerObservableObserver;
  37844. private _onAfterCheckInputsObserver;
  37845. private _attachedCamera;
  37846. private _isPointerDown;
  37847. private _lastFrameTime;
  37848. private _lastInteractionTime;
  37849. private _cameraRotationSpeed;
  37850. /**
  37851. * Initializes the behavior.
  37852. */
  37853. init(): void;
  37854. /**
  37855. * Attaches the behavior to its arc rotate camera.
  37856. * @param camera Defines the camera to attach the behavior to
  37857. */
  37858. attach(camera: ArcRotateCamera): void;
  37859. /**
  37860. * Detaches the behavior from its current arc rotate camera.
  37861. */
  37862. detach(): void;
  37863. /**
  37864. * Returns true if user is scrolling.
  37865. * @return true if user is scrolling.
  37866. */
  37867. private _userIsZooming;
  37868. private _lastFrameRadius;
  37869. private _shouldAnimationStopForInteraction;
  37870. /**
  37871. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37872. */
  37873. private _applyUserInteraction;
  37874. private _userIsMoving;
  37875. }
  37876. }
  37877. declare module "babylonjs/Behaviors/Cameras/index" {
  37878. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37879. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37880. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37881. }
  37882. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37883. import { Mesh } from "babylonjs/Meshes/mesh";
  37884. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37885. import { Behavior } from "babylonjs/Behaviors/behavior";
  37886. /**
  37887. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37888. */
  37889. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37890. private ui;
  37891. /**
  37892. * The name of the behavior
  37893. */
  37894. name: string;
  37895. /**
  37896. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37897. */
  37898. distanceAwayFromFace: number;
  37899. /**
  37900. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37901. */
  37902. distanceAwayFromBottomOfFace: number;
  37903. private _faceVectors;
  37904. private _target;
  37905. private _scene;
  37906. private _onRenderObserver;
  37907. private _tmpMatrix;
  37908. private _tmpVector;
  37909. /**
  37910. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37911. * @param ui The transform node that should be attched to the mesh
  37912. */
  37913. constructor(ui: TransformNode);
  37914. /**
  37915. * Initializes the behavior
  37916. */
  37917. init(): void;
  37918. private _closestFace;
  37919. private _zeroVector;
  37920. private _lookAtTmpMatrix;
  37921. private _lookAtToRef;
  37922. /**
  37923. * Attaches the AttachToBoxBehavior to the passed in mesh
  37924. * @param target The mesh that the specified node will be attached to
  37925. */
  37926. attach(target: Mesh): void;
  37927. /**
  37928. * Detaches the behavior from the mesh
  37929. */
  37930. detach(): void;
  37931. }
  37932. }
  37933. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37934. import { Behavior } from "babylonjs/Behaviors/behavior";
  37935. import { Mesh } from "babylonjs/Meshes/mesh";
  37936. /**
  37937. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37938. */
  37939. export class FadeInOutBehavior implements Behavior<Mesh> {
  37940. /**
  37941. * Time in milliseconds to delay before fading in (Default: 0)
  37942. */
  37943. delay: number;
  37944. /**
  37945. * Time in milliseconds for the mesh to fade in (Default: 300)
  37946. */
  37947. fadeInTime: number;
  37948. private _millisecondsPerFrame;
  37949. private _hovered;
  37950. private _hoverValue;
  37951. private _ownerNode;
  37952. /**
  37953. * Instatiates the FadeInOutBehavior
  37954. */
  37955. constructor();
  37956. /**
  37957. * The name of the behavior
  37958. */
  37959. readonly name: string;
  37960. /**
  37961. * Initializes the behavior
  37962. */
  37963. init(): void;
  37964. /**
  37965. * Attaches the fade behavior on the passed in mesh
  37966. * @param ownerNode The mesh that will be faded in/out once attached
  37967. */
  37968. attach(ownerNode: Mesh): void;
  37969. /**
  37970. * Detaches the behavior from the mesh
  37971. */
  37972. detach(): void;
  37973. /**
  37974. * Triggers the mesh to begin fading in or out
  37975. * @param value if the object should fade in or out (true to fade in)
  37976. */
  37977. fadeIn(value: boolean): void;
  37978. private _update;
  37979. private _setAllVisibility;
  37980. }
  37981. }
  37982. declare module "babylonjs/Misc/pivotTools" {
  37983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37984. /**
  37985. * Class containing a set of static utilities functions for managing Pivots
  37986. * @hidden
  37987. */
  37988. export class PivotTools {
  37989. private static _PivotCached;
  37990. private static _OldPivotPoint;
  37991. private static _PivotTranslation;
  37992. private static _PivotTmpVector;
  37993. /** @hidden */
  37994. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37995. /** @hidden */
  37996. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37997. }
  37998. }
  37999. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38000. import { Scene } from "babylonjs/scene";
  38001. import { Vector4 } from "babylonjs/Maths/math.vector";
  38002. import { Mesh } from "babylonjs/Meshes/mesh";
  38003. import { Nullable } from "babylonjs/types";
  38004. import { Plane } from "babylonjs/Maths/math.plane";
  38005. /**
  38006. * Class containing static functions to help procedurally build meshes
  38007. */
  38008. export class PlaneBuilder {
  38009. /**
  38010. * Creates a plane mesh
  38011. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38012. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38013. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38017. * @param name defines the name of the mesh
  38018. * @param options defines the options used to create the mesh
  38019. * @param scene defines the hosting scene
  38020. * @returns the plane mesh
  38021. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38022. */
  38023. static CreatePlane(name: string, options: {
  38024. size?: number;
  38025. width?: number;
  38026. height?: number;
  38027. sideOrientation?: number;
  38028. frontUVs?: Vector4;
  38029. backUVs?: Vector4;
  38030. updatable?: boolean;
  38031. sourcePlane?: Plane;
  38032. }, scene?: Nullable<Scene>): Mesh;
  38033. }
  38034. }
  38035. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38036. import { Behavior } from "babylonjs/Behaviors/behavior";
  38037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38038. import { Observable } from "babylonjs/Misc/observable";
  38039. import { Vector3 } from "babylonjs/Maths/math.vector";
  38040. import { Ray } from "babylonjs/Culling/ray";
  38041. import "babylonjs/Meshes/Builders/planeBuilder";
  38042. /**
  38043. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38044. */
  38045. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38046. private static _AnyMouseID;
  38047. /**
  38048. * Abstract mesh the behavior is set on
  38049. */
  38050. attachedNode: AbstractMesh;
  38051. private _dragPlane;
  38052. private _scene;
  38053. private _pointerObserver;
  38054. private _beforeRenderObserver;
  38055. private static _planeScene;
  38056. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38057. /**
  38058. * 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)
  38059. */
  38060. maxDragAngle: number;
  38061. /**
  38062. * @hidden
  38063. */
  38064. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38065. /**
  38066. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38067. */
  38068. currentDraggingPointerID: number;
  38069. /**
  38070. * The last position where the pointer hit the drag plane in world space
  38071. */
  38072. lastDragPosition: Vector3;
  38073. /**
  38074. * If the behavior is currently in a dragging state
  38075. */
  38076. dragging: boolean;
  38077. /**
  38078. * 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)
  38079. */
  38080. dragDeltaRatio: number;
  38081. /**
  38082. * If the drag plane orientation should be updated during the dragging (Default: true)
  38083. */
  38084. updateDragPlane: boolean;
  38085. private _debugMode;
  38086. private _moving;
  38087. /**
  38088. * Fires each time the attached mesh is dragged with the pointer
  38089. * * delta between last drag position and current drag position in world space
  38090. * * dragDistance along the drag axis
  38091. * * dragPlaneNormal normal of the current drag plane used during the drag
  38092. * * dragPlanePoint in world space where the drag intersects the drag plane
  38093. */
  38094. onDragObservable: Observable<{
  38095. delta: Vector3;
  38096. dragPlanePoint: Vector3;
  38097. dragPlaneNormal: Vector3;
  38098. dragDistance: number;
  38099. pointerId: number;
  38100. }>;
  38101. /**
  38102. * Fires each time a drag begins (eg. mouse down on mesh)
  38103. */
  38104. onDragStartObservable: Observable<{
  38105. dragPlanePoint: Vector3;
  38106. pointerId: number;
  38107. }>;
  38108. /**
  38109. * Fires each time a drag ends (eg. mouse release after drag)
  38110. */
  38111. onDragEndObservable: Observable<{
  38112. dragPlanePoint: Vector3;
  38113. pointerId: number;
  38114. }>;
  38115. /**
  38116. * If the attached mesh should be moved when dragged
  38117. */
  38118. moveAttached: boolean;
  38119. /**
  38120. * If the drag behavior will react to drag events (Default: true)
  38121. */
  38122. enabled: boolean;
  38123. /**
  38124. * If pointer events should start and release the drag (Default: true)
  38125. */
  38126. startAndReleaseDragOnPointerEvents: boolean;
  38127. /**
  38128. * If camera controls should be detached during the drag
  38129. */
  38130. detachCameraControls: boolean;
  38131. /**
  38132. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38133. */
  38134. useObjectOrienationForDragging: boolean;
  38135. private _options;
  38136. /**
  38137. * Creates a pointer drag behavior that can be attached to a mesh
  38138. * @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)
  38139. */
  38140. constructor(options?: {
  38141. dragAxis?: Vector3;
  38142. dragPlaneNormal?: Vector3;
  38143. });
  38144. /**
  38145. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38146. */
  38147. validateDrag: (targetPosition: Vector3) => boolean;
  38148. /**
  38149. * The name of the behavior
  38150. */
  38151. readonly name: string;
  38152. /**
  38153. * Initializes the behavior
  38154. */
  38155. init(): void;
  38156. private _tmpVector;
  38157. private _alternatePickedPoint;
  38158. private _worldDragAxis;
  38159. private _targetPosition;
  38160. private _attachedElement;
  38161. /**
  38162. * Attaches the drag behavior the passed in mesh
  38163. * @param ownerNode The mesh that will be dragged around once attached
  38164. * @param predicate Predicate to use for pick filtering
  38165. */
  38166. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38167. /**
  38168. * Force relase the drag action by code.
  38169. */
  38170. releaseDrag(): void;
  38171. private _startDragRay;
  38172. private _lastPointerRay;
  38173. /**
  38174. * Simulates the start of a pointer drag event on the behavior
  38175. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38176. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38177. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38178. */
  38179. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38180. private _startDrag;
  38181. private _dragDelta;
  38182. private _moveDrag;
  38183. private _pickWithRayOnDragPlane;
  38184. private _pointA;
  38185. private _pointB;
  38186. private _pointC;
  38187. private _lineA;
  38188. private _lineB;
  38189. private _localAxis;
  38190. private _lookAt;
  38191. private _updateDragPlanePosition;
  38192. /**
  38193. * Detaches the behavior from the mesh
  38194. */
  38195. detach(): void;
  38196. }
  38197. }
  38198. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38199. import { Mesh } from "babylonjs/Meshes/mesh";
  38200. import { Behavior } from "babylonjs/Behaviors/behavior";
  38201. /**
  38202. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38203. */
  38204. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38205. private _dragBehaviorA;
  38206. private _dragBehaviorB;
  38207. private _startDistance;
  38208. private _initialScale;
  38209. private _targetScale;
  38210. private _ownerNode;
  38211. private _sceneRenderObserver;
  38212. /**
  38213. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38214. */
  38215. constructor();
  38216. /**
  38217. * The name of the behavior
  38218. */
  38219. readonly name: string;
  38220. /**
  38221. * Initializes the behavior
  38222. */
  38223. init(): void;
  38224. private _getCurrentDistance;
  38225. /**
  38226. * Attaches the scale behavior the passed in mesh
  38227. * @param ownerNode The mesh that will be scaled around once attached
  38228. */
  38229. attach(ownerNode: Mesh): void;
  38230. /**
  38231. * Detaches the behavior from the mesh
  38232. */
  38233. detach(): void;
  38234. }
  38235. }
  38236. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38237. import { Behavior } from "babylonjs/Behaviors/behavior";
  38238. import { Mesh } from "babylonjs/Meshes/mesh";
  38239. import { Observable } from "babylonjs/Misc/observable";
  38240. /**
  38241. * 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
  38242. */
  38243. export class SixDofDragBehavior implements Behavior<Mesh> {
  38244. private static _virtualScene;
  38245. private _ownerNode;
  38246. private _sceneRenderObserver;
  38247. private _scene;
  38248. private _targetPosition;
  38249. private _virtualOriginMesh;
  38250. private _virtualDragMesh;
  38251. private _pointerObserver;
  38252. private _moving;
  38253. private _startingOrientation;
  38254. /**
  38255. * 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)
  38256. */
  38257. private zDragFactor;
  38258. /**
  38259. * If the object should rotate to face the drag origin
  38260. */
  38261. rotateDraggedObject: boolean;
  38262. /**
  38263. * If the behavior is currently in a dragging state
  38264. */
  38265. dragging: boolean;
  38266. /**
  38267. * 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)
  38268. */
  38269. dragDeltaRatio: number;
  38270. /**
  38271. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38272. */
  38273. currentDraggingPointerID: number;
  38274. /**
  38275. * If camera controls should be detached during the drag
  38276. */
  38277. detachCameraControls: boolean;
  38278. /**
  38279. * Fires each time a drag starts
  38280. */
  38281. onDragStartObservable: Observable<{}>;
  38282. /**
  38283. * Fires each time a drag ends (eg. mouse release after drag)
  38284. */
  38285. onDragEndObservable: Observable<{}>;
  38286. /**
  38287. * 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
  38288. */
  38289. constructor();
  38290. /**
  38291. * The name of the behavior
  38292. */
  38293. readonly name: string;
  38294. /**
  38295. * Initializes the behavior
  38296. */
  38297. init(): void;
  38298. /**
  38299. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38300. */
  38301. private readonly _pointerCamera;
  38302. /**
  38303. * Attaches the scale behavior the passed in mesh
  38304. * @param ownerNode The mesh that will be scaled around once attached
  38305. */
  38306. attach(ownerNode: Mesh): void;
  38307. /**
  38308. * Detaches the behavior from the mesh
  38309. */
  38310. detach(): void;
  38311. }
  38312. }
  38313. declare module "babylonjs/Behaviors/Meshes/index" {
  38314. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38315. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38316. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38317. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38318. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38319. }
  38320. declare module "babylonjs/Behaviors/index" {
  38321. export * from "babylonjs/Behaviors/behavior";
  38322. export * from "babylonjs/Behaviors/Cameras/index";
  38323. export * from "babylonjs/Behaviors/Meshes/index";
  38324. }
  38325. declare module "babylonjs/Bones/boneIKController" {
  38326. import { Bone } from "babylonjs/Bones/bone";
  38327. import { Vector3 } from "babylonjs/Maths/math.vector";
  38328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38329. import { Nullable } from "babylonjs/types";
  38330. /**
  38331. * Class used to apply inverse kinematics to bones
  38332. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38333. */
  38334. export class BoneIKController {
  38335. private static _tmpVecs;
  38336. private static _tmpQuat;
  38337. private static _tmpMats;
  38338. /**
  38339. * Gets or sets the target mesh
  38340. */
  38341. targetMesh: AbstractMesh;
  38342. /** Gets or sets the mesh used as pole */
  38343. poleTargetMesh: AbstractMesh;
  38344. /**
  38345. * Gets or sets the bone used as pole
  38346. */
  38347. poleTargetBone: Nullable<Bone>;
  38348. /**
  38349. * Gets or sets the target position
  38350. */
  38351. targetPosition: Vector3;
  38352. /**
  38353. * Gets or sets the pole target position
  38354. */
  38355. poleTargetPosition: Vector3;
  38356. /**
  38357. * Gets or sets the pole target local offset
  38358. */
  38359. poleTargetLocalOffset: Vector3;
  38360. /**
  38361. * Gets or sets the pole angle
  38362. */
  38363. poleAngle: number;
  38364. /**
  38365. * Gets or sets the mesh associated with the controller
  38366. */
  38367. mesh: AbstractMesh;
  38368. /**
  38369. * 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)
  38370. */
  38371. slerpAmount: number;
  38372. private _bone1Quat;
  38373. private _bone1Mat;
  38374. private _bone2Ang;
  38375. private _bone1;
  38376. private _bone2;
  38377. private _bone1Length;
  38378. private _bone2Length;
  38379. private _maxAngle;
  38380. private _maxReach;
  38381. private _rightHandedSystem;
  38382. private _bendAxis;
  38383. private _slerping;
  38384. private _adjustRoll;
  38385. /**
  38386. * Gets or sets maximum allowed angle
  38387. */
  38388. maxAngle: number;
  38389. /**
  38390. * Creates a new BoneIKController
  38391. * @param mesh defines the mesh to control
  38392. * @param bone defines the bone to control
  38393. * @param options defines options to set up the controller
  38394. */
  38395. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38396. targetMesh?: AbstractMesh;
  38397. poleTargetMesh?: AbstractMesh;
  38398. poleTargetBone?: Bone;
  38399. poleTargetLocalOffset?: Vector3;
  38400. poleAngle?: number;
  38401. bendAxis?: Vector3;
  38402. maxAngle?: number;
  38403. slerpAmount?: number;
  38404. });
  38405. private _setMaxAngle;
  38406. /**
  38407. * Force the controller to update the bones
  38408. */
  38409. update(): void;
  38410. }
  38411. }
  38412. declare module "babylonjs/Bones/boneLookController" {
  38413. import { Vector3 } from "babylonjs/Maths/math.vector";
  38414. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38415. import { Bone } from "babylonjs/Bones/bone";
  38416. import { Space } from "babylonjs/Maths/math.axis";
  38417. /**
  38418. * Class used to make a bone look toward a point in space
  38419. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38420. */
  38421. export class BoneLookController {
  38422. private static _tmpVecs;
  38423. private static _tmpQuat;
  38424. private static _tmpMats;
  38425. /**
  38426. * The target Vector3 that the bone will look at
  38427. */
  38428. target: Vector3;
  38429. /**
  38430. * The mesh that the bone is attached to
  38431. */
  38432. mesh: AbstractMesh;
  38433. /**
  38434. * The bone that will be looking to the target
  38435. */
  38436. bone: Bone;
  38437. /**
  38438. * The up axis of the coordinate system that is used when the bone is rotated
  38439. */
  38440. upAxis: Vector3;
  38441. /**
  38442. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38443. */
  38444. upAxisSpace: Space;
  38445. /**
  38446. * Used to make an adjustment to the yaw of the bone
  38447. */
  38448. adjustYaw: number;
  38449. /**
  38450. * Used to make an adjustment to the pitch of the bone
  38451. */
  38452. adjustPitch: number;
  38453. /**
  38454. * Used to make an adjustment to the roll of the bone
  38455. */
  38456. adjustRoll: number;
  38457. /**
  38458. * 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)
  38459. */
  38460. slerpAmount: number;
  38461. private _minYaw;
  38462. private _maxYaw;
  38463. private _minPitch;
  38464. private _maxPitch;
  38465. private _minYawSin;
  38466. private _minYawCos;
  38467. private _maxYawSin;
  38468. private _maxYawCos;
  38469. private _midYawConstraint;
  38470. private _minPitchTan;
  38471. private _maxPitchTan;
  38472. private _boneQuat;
  38473. private _slerping;
  38474. private _transformYawPitch;
  38475. private _transformYawPitchInv;
  38476. private _firstFrameSkipped;
  38477. private _yawRange;
  38478. private _fowardAxis;
  38479. /**
  38480. * Gets or sets the minimum yaw angle that the bone can look to
  38481. */
  38482. minYaw: number;
  38483. /**
  38484. * Gets or sets the maximum yaw angle that the bone can look to
  38485. */
  38486. maxYaw: number;
  38487. /**
  38488. * Gets or sets the minimum pitch angle that the bone can look to
  38489. */
  38490. minPitch: number;
  38491. /**
  38492. * Gets or sets the maximum pitch angle that the bone can look to
  38493. */
  38494. maxPitch: number;
  38495. /**
  38496. * Create a BoneLookController
  38497. * @param mesh the mesh that the bone belongs to
  38498. * @param bone the bone that will be looking to the target
  38499. * @param target the target Vector3 to look at
  38500. * @param options optional settings:
  38501. * * maxYaw: the maximum angle the bone will yaw to
  38502. * * minYaw: the minimum angle the bone will yaw to
  38503. * * maxPitch: the maximum angle the bone will pitch to
  38504. * * minPitch: the minimum angle the bone will yaw to
  38505. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38506. * * upAxis: the up axis of the coordinate system
  38507. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38508. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38509. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38510. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38511. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38512. * * adjustRoll: used to make an adjustment to the roll of the bone
  38513. **/
  38514. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38515. maxYaw?: number;
  38516. minYaw?: number;
  38517. maxPitch?: number;
  38518. minPitch?: number;
  38519. slerpAmount?: number;
  38520. upAxis?: Vector3;
  38521. upAxisSpace?: Space;
  38522. yawAxis?: Vector3;
  38523. pitchAxis?: Vector3;
  38524. adjustYaw?: number;
  38525. adjustPitch?: number;
  38526. adjustRoll?: number;
  38527. });
  38528. /**
  38529. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38530. */
  38531. update(): void;
  38532. private _getAngleDiff;
  38533. private _getAngleBetween;
  38534. private _isAngleBetween;
  38535. }
  38536. }
  38537. declare module "babylonjs/Bones/index" {
  38538. export * from "babylonjs/Bones/bone";
  38539. export * from "babylonjs/Bones/boneIKController";
  38540. export * from "babylonjs/Bones/boneLookController";
  38541. export * from "babylonjs/Bones/skeleton";
  38542. }
  38543. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38544. import { Nullable } from "babylonjs/types";
  38545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38546. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38547. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38548. /**
  38549. * Manage the gamepad inputs to control an arc rotate camera.
  38550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38551. */
  38552. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38553. /**
  38554. * Defines the camera the input is attached to.
  38555. */
  38556. camera: ArcRotateCamera;
  38557. /**
  38558. * Defines the gamepad the input is gathering event from.
  38559. */
  38560. gamepad: Nullable<Gamepad>;
  38561. /**
  38562. * Defines the gamepad rotation sensiblity.
  38563. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38564. */
  38565. gamepadRotationSensibility: number;
  38566. /**
  38567. * Defines the gamepad move sensiblity.
  38568. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38569. */
  38570. gamepadMoveSensibility: number;
  38571. private _onGamepadConnectedObserver;
  38572. private _onGamepadDisconnectedObserver;
  38573. /**
  38574. * Attach the input controls to a specific dom element to get the input from.
  38575. * @param element Defines the element the controls should be listened from
  38576. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38577. */
  38578. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38579. /**
  38580. * Detach the current controls from the specified dom element.
  38581. * @param element Defines the element to stop listening the inputs from
  38582. */
  38583. detachControl(element: Nullable<HTMLElement>): void;
  38584. /**
  38585. * Update the current camera state depending on the inputs that have been used this frame.
  38586. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38587. */
  38588. checkInputs(): void;
  38589. /**
  38590. * Gets the class name of the current intput.
  38591. * @returns the class name
  38592. */
  38593. getClassName(): string;
  38594. /**
  38595. * Get the friendly name associated with the input class.
  38596. * @returns the input friendly name
  38597. */
  38598. getSimpleName(): string;
  38599. }
  38600. }
  38601. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38602. import { Nullable } from "babylonjs/types";
  38603. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38604. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38605. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38606. interface ArcRotateCameraInputsManager {
  38607. /**
  38608. * Add orientation input support to the input manager.
  38609. * @returns the current input manager
  38610. */
  38611. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38612. }
  38613. }
  38614. /**
  38615. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38616. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38617. */
  38618. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38619. /**
  38620. * Defines the camera the input is attached to.
  38621. */
  38622. camera: ArcRotateCamera;
  38623. /**
  38624. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38625. */
  38626. alphaCorrection: number;
  38627. /**
  38628. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38629. */
  38630. gammaCorrection: number;
  38631. private _alpha;
  38632. private _gamma;
  38633. private _dirty;
  38634. private _deviceOrientationHandler;
  38635. /**
  38636. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38637. */
  38638. constructor();
  38639. /**
  38640. * Attach the input controls to a specific dom element to get the input from.
  38641. * @param element Defines the element the controls should be listened from
  38642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38643. */
  38644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38645. /** @hidden */
  38646. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38647. /**
  38648. * Update the current camera state depending on the inputs that have been used this frame.
  38649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38650. */
  38651. checkInputs(): void;
  38652. /**
  38653. * Detach the current controls from the specified dom element.
  38654. * @param element Defines the element to stop listening the inputs from
  38655. */
  38656. detachControl(element: Nullable<HTMLElement>): void;
  38657. /**
  38658. * Gets the class name of the current intput.
  38659. * @returns the class name
  38660. */
  38661. getClassName(): string;
  38662. /**
  38663. * Get the friendly name associated with the input class.
  38664. * @returns the input friendly name
  38665. */
  38666. getSimpleName(): string;
  38667. }
  38668. }
  38669. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38670. import { Nullable } from "babylonjs/types";
  38671. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38672. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38673. /**
  38674. * Listen to mouse events to control the camera.
  38675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38676. */
  38677. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38678. /**
  38679. * Defines the camera the input is attached to.
  38680. */
  38681. camera: FlyCamera;
  38682. /**
  38683. * Defines if touch is enabled. (Default is true.)
  38684. */
  38685. touchEnabled: boolean;
  38686. /**
  38687. * Defines the buttons associated with the input to handle camera rotation.
  38688. */
  38689. buttons: number[];
  38690. /**
  38691. * Assign buttons for Yaw control.
  38692. */
  38693. buttonsYaw: number[];
  38694. /**
  38695. * Assign buttons for Pitch control.
  38696. */
  38697. buttonsPitch: number[];
  38698. /**
  38699. * Assign buttons for Roll control.
  38700. */
  38701. buttonsRoll: number[];
  38702. /**
  38703. * Detect if any button is being pressed while mouse is moved.
  38704. * -1 = Mouse locked.
  38705. * 0 = Left button.
  38706. * 1 = Middle Button.
  38707. * 2 = Right Button.
  38708. */
  38709. activeButton: number;
  38710. /**
  38711. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38712. * Higher values reduce its sensitivity.
  38713. */
  38714. angularSensibility: number;
  38715. private _mousemoveCallback;
  38716. private _observer;
  38717. private _rollObserver;
  38718. private previousPosition;
  38719. private noPreventDefault;
  38720. private element;
  38721. /**
  38722. * Listen to mouse events to control the camera.
  38723. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38725. */
  38726. constructor(touchEnabled?: boolean);
  38727. /**
  38728. * Attach the mouse control to the HTML DOM element.
  38729. * @param element Defines the element that listens to the input events.
  38730. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38731. */
  38732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38733. /**
  38734. * Detach the current controls from the specified dom element.
  38735. * @param element Defines the element to stop listening the inputs from
  38736. */
  38737. detachControl(element: Nullable<HTMLElement>): void;
  38738. /**
  38739. * Gets the class name of the current input.
  38740. * @returns the class name.
  38741. */
  38742. getClassName(): string;
  38743. /**
  38744. * Get the friendly name associated with the input class.
  38745. * @returns the input's friendly name.
  38746. */
  38747. getSimpleName(): string;
  38748. private _pointerInput;
  38749. private _onMouseMove;
  38750. /**
  38751. * Rotate camera by mouse offset.
  38752. */
  38753. private rotateCamera;
  38754. }
  38755. }
  38756. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38757. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38758. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38759. /**
  38760. * Default Inputs manager for the FlyCamera.
  38761. * It groups all the default supported inputs for ease of use.
  38762. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38763. */
  38764. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38765. /**
  38766. * Instantiates a new FlyCameraInputsManager.
  38767. * @param camera Defines the camera the inputs belong to.
  38768. */
  38769. constructor(camera: FlyCamera);
  38770. /**
  38771. * Add keyboard input support to the input manager.
  38772. * @returns the new FlyCameraKeyboardMoveInput().
  38773. */
  38774. addKeyboard(): FlyCameraInputsManager;
  38775. /**
  38776. * Add mouse input support to the input manager.
  38777. * @param touchEnabled Enable touch screen support.
  38778. * @returns the new FlyCameraMouseInput().
  38779. */
  38780. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38781. }
  38782. }
  38783. declare module "babylonjs/Cameras/flyCamera" {
  38784. import { Scene } from "babylonjs/scene";
  38785. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38787. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38788. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38789. /**
  38790. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38791. * such as in a 3D Space Shooter or a Flight Simulator.
  38792. */
  38793. export class FlyCamera extends TargetCamera {
  38794. /**
  38795. * Define the collision ellipsoid of the camera.
  38796. * This is helpful for simulating a camera body, like a player's body.
  38797. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38798. */
  38799. ellipsoid: Vector3;
  38800. /**
  38801. * Define an offset for the position of the ellipsoid around the camera.
  38802. * This can be helpful if the camera is attached away from the player's body center,
  38803. * such as at its head.
  38804. */
  38805. ellipsoidOffset: Vector3;
  38806. /**
  38807. * Enable or disable collisions of the camera with the rest of the scene objects.
  38808. */
  38809. checkCollisions: boolean;
  38810. /**
  38811. * Enable or disable gravity on the camera.
  38812. */
  38813. applyGravity: boolean;
  38814. /**
  38815. * Define the current direction the camera is moving to.
  38816. */
  38817. cameraDirection: Vector3;
  38818. /**
  38819. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38820. * This overrides and empties cameraRotation.
  38821. */
  38822. rotationQuaternion: Quaternion;
  38823. /**
  38824. * Track Roll to maintain the wanted Rolling when looking around.
  38825. */
  38826. _trackRoll: number;
  38827. /**
  38828. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38829. */
  38830. rollCorrect: number;
  38831. /**
  38832. * Mimic a banked turn, Rolling the camera when Yawing.
  38833. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38834. */
  38835. bankedTurn: boolean;
  38836. /**
  38837. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38838. */
  38839. bankedTurnLimit: number;
  38840. /**
  38841. * Value of 0 disables the banked Roll.
  38842. * Value of 1 is equal to the Yaw angle in radians.
  38843. */
  38844. bankedTurnMultiplier: number;
  38845. /**
  38846. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38847. */
  38848. inputs: FlyCameraInputsManager;
  38849. /**
  38850. * Gets the input sensibility for mouse input.
  38851. * Higher values reduce sensitivity.
  38852. */
  38853. /**
  38854. * Sets the input sensibility for a mouse input.
  38855. * Higher values reduce sensitivity.
  38856. */
  38857. angularSensibility: number;
  38858. /**
  38859. * Get the keys for camera movement forward.
  38860. */
  38861. /**
  38862. * Set the keys for camera movement forward.
  38863. */
  38864. keysForward: number[];
  38865. /**
  38866. * Get the keys for camera movement backward.
  38867. */
  38868. keysBackward: number[];
  38869. /**
  38870. * Get the keys for camera movement up.
  38871. */
  38872. /**
  38873. * Set the keys for camera movement up.
  38874. */
  38875. keysUp: number[];
  38876. /**
  38877. * Get the keys for camera movement down.
  38878. */
  38879. /**
  38880. * Set the keys for camera movement down.
  38881. */
  38882. keysDown: number[];
  38883. /**
  38884. * Get the keys for camera movement left.
  38885. */
  38886. /**
  38887. * Set the keys for camera movement left.
  38888. */
  38889. keysLeft: number[];
  38890. /**
  38891. * Set the keys for camera movement right.
  38892. */
  38893. /**
  38894. * Set the keys for camera movement right.
  38895. */
  38896. keysRight: number[];
  38897. /**
  38898. * Event raised when the camera collides with a mesh in the scene.
  38899. */
  38900. onCollide: (collidedMesh: AbstractMesh) => void;
  38901. private _collider;
  38902. private _needMoveForGravity;
  38903. private _oldPosition;
  38904. private _diffPosition;
  38905. private _newPosition;
  38906. /** @hidden */
  38907. _localDirection: Vector3;
  38908. /** @hidden */
  38909. _transformedDirection: Vector3;
  38910. /**
  38911. * Instantiates a FlyCamera.
  38912. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38913. * such as in a 3D Space Shooter or a Flight Simulator.
  38914. * @param name Define the name of the camera in the scene.
  38915. * @param position Define the starting position of the camera in the scene.
  38916. * @param scene Define the scene the camera belongs to.
  38917. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38918. */
  38919. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38920. /**
  38921. * Attach a control to the HTML DOM element.
  38922. * @param element Defines the element that listens to the input events.
  38923. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38924. */
  38925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38926. /**
  38927. * Detach a control from the HTML DOM element.
  38928. * The camera will stop reacting to that input.
  38929. * @param element Defines the element that listens to the input events.
  38930. */
  38931. detachControl(element: HTMLElement): void;
  38932. private _collisionMask;
  38933. /**
  38934. * Get the mask that the camera ignores in collision events.
  38935. */
  38936. /**
  38937. * Set the mask that the camera ignores in collision events.
  38938. */
  38939. collisionMask: number;
  38940. /** @hidden */
  38941. _collideWithWorld(displacement: Vector3): void;
  38942. /** @hidden */
  38943. private _onCollisionPositionChange;
  38944. /** @hidden */
  38945. _checkInputs(): void;
  38946. /** @hidden */
  38947. _decideIfNeedsToMove(): boolean;
  38948. /** @hidden */
  38949. _updatePosition(): void;
  38950. /**
  38951. * Restore the Roll to its target value at the rate specified.
  38952. * @param rate - Higher means slower restoring.
  38953. * @hidden
  38954. */
  38955. restoreRoll(rate: number): void;
  38956. /**
  38957. * Destroy the camera and release the current resources held by it.
  38958. */
  38959. dispose(): void;
  38960. /**
  38961. * Get the current object class name.
  38962. * @returns the class name.
  38963. */
  38964. getClassName(): string;
  38965. }
  38966. }
  38967. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38968. import { Nullable } from "babylonjs/types";
  38969. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38970. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38971. /**
  38972. * Listen to keyboard events to control the camera.
  38973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38974. */
  38975. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38976. /**
  38977. * Defines the camera the input is attached to.
  38978. */
  38979. camera: FlyCamera;
  38980. /**
  38981. * The list of keyboard keys used to control the forward move of the camera.
  38982. */
  38983. keysForward: number[];
  38984. /**
  38985. * The list of keyboard keys used to control the backward move of the camera.
  38986. */
  38987. keysBackward: number[];
  38988. /**
  38989. * The list of keyboard keys used to control the forward move of the camera.
  38990. */
  38991. keysUp: number[];
  38992. /**
  38993. * The list of keyboard keys used to control the backward move of the camera.
  38994. */
  38995. keysDown: number[];
  38996. /**
  38997. * The list of keyboard keys used to control the right strafe move of the camera.
  38998. */
  38999. keysRight: number[];
  39000. /**
  39001. * The list of keyboard keys used to control the left strafe move of the camera.
  39002. */
  39003. keysLeft: number[];
  39004. private _keys;
  39005. private _onCanvasBlurObserver;
  39006. private _onKeyboardObserver;
  39007. private _engine;
  39008. private _scene;
  39009. /**
  39010. * Attach the input controls to a specific dom element to get the input from.
  39011. * @param element Defines the element the controls should be listened from
  39012. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39013. */
  39014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39015. /**
  39016. * Detach the current controls from the specified dom element.
  39017. * @param element Defines the element to stop listening the inputs from
  39018. */
  39019. detachControl(element: Nullable<HTMLElement>): void;
  39020. /**
  39021. * Gets the class name of the current intput.
  39022. * @returns the class name
  39023. */
  39024. getClassName(): string;
  39025. /** @hidden */
  39026. _onLostFocus(e: FocusEvent): void;
  39027. /**
  39028. * Get the friendly name associated with the input class.
  39029. * @returns the input friendly name
  39030. */
  39031. getSimpleName(): string;
  39032. /**
  39033. * Update the current camera state depending on the inputs that have been used this frame.
  39034. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39035. */
  39036. checkInputs(): void;
  39037. }
  39038. }
  39039. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39040. import { Nullable } from "babylonjs/types";
  39041. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39042. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39043. /**
  39044. * Manage the mouse wheel inputs to control a follow camera.
  39045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39046. */
  39047. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39048. /**
  39049. * Defines the camera the input is attached to.
  39050. */
  39051. camera: FollowCamera;
  39052. /**
  39053. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39054. */
  39055. axisControlRadius: boolean;
  39056. /**
  39057. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39058. */
  39059. axisControlHeight: boolean;
  39060. /**
  39061. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39062. */
  39063. axisControlRotation: boolean;
  39064. /**
  39065. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39066. * relation to mouseWheel events.
  39067. */
  39068. wheelPrecision: number;
  39069. /**
  39070. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39071. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39072. */
  39073. wheelDeltaPercentage: number;
  39074. private _wheel;
  39075. private _observer;
  39076. /**
  39077. * Attach the input controls to a specific dom element to get the input from.
  39078. * @param element Defines the element the controls should be listened from
  39079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39080. */
  39081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39082. /**
  39083. * Detach the current controls from the specified dom element.
  39084. * @param element Defines the element to stop listening the inputs from
  39085. */
  39086. detachControl(element: Nullable<HTMLElement>): void;
  39087. /**
  39088. * Gets the class name of the current intput.
  39089. * @returns the class name
  39090. */
  39091. getClassName(): string;
  39092. /**
  39093. * Get the friendly name associated with the input class.
  39094. * @returns the input friendly name
  39095. */
  39096. getSimpleName(): string;
  39097. }
  39098. }
  39099. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39100. import { Nullable } from "babylonjs/types";
  39101. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39102. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39103. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39104. /**
  39105. * Manage the pointers inputs to control an follow camera.
  39106. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39107. */
  39108. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39109. /**
  39110. * Defines the camera the input is attached to.
  39111. */
  39112. camera: FollowCamera;
  39113. /**
  39114. * Gets the class name of the current input.
  39115. * @returns the class name
  39116. */
  39117. getClassName(): string;
  39118. /**
  39119. * Defines the pointer angular sensibility along the X axis or how fast is
  39120. * the camera rotating.
  39121. * A negative number will reverse the axis direction.
  39122. */
  39123. angularSensibilityX: number;
  39124. /**
  39125. * Defines the pointer angular sensibility along the Y axis or how fast is
  39126. * the camera rotating.
  39127. * A negative number will reverse the axis direction.
  39128. */
  39129. angularSensibilityY: number;
  39130. /**
  39131. * Defines the pointer pinch precision or how fast is the camera zooming.
  39132. * A negative number will reverse the axis direction.
  39133. */
  39134. pinchPrecision: number;
  39135. /**
  39136. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39137. * from 0.
  39138. * It defines the percentage of current camera.radius to use as delta when
  39139. * pinch zoom is used.
  39140. */
  39141. pinchDeltaPercentage: number;
  39142. /**
  39143. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39144. */
  39145. axisXControlRadius: boolean;
  39146. /**
  39147. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39148. */
  39149. axisXControlHeight: boolean;
  39150. /**
  39151. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39152. */
  39153. axisXControlRotation: boolean;
  39154. /**
  39155. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39156. */
  39157. axisYControlRadius: boolean;
  39158. /**
  39159. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39160. */
  39161. axisYControlHeight: boolean;
  39162. /**
  39163. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39164. */
  39165. axisYControlRotation: boolean;
  39166. /**
  39167. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39168. */
  39169. axisPinchControlRadius: boolean;
  39170. /**
  39171. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39172. */
  39173. axisPinchControlHeight: boolean;
  39174. /**
  39175. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39176. */
  39177. axisPinchControlRotation: boolean;
  39178. /**
  39179. * Log error messages if basic misconfiguration has occurred.
  39180. */
  39181. warningEnable: boolean;
  39182. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39183. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39184. private _warningCounter;
  39185. private _warning;
  39186. }
  39187. }
  39188. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39189. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39190. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39191. /**
  39192. * Default Inputs manager for the FollowCamera.
  39193. * It groups all the default supported inputs for ease of use.
  39194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39195. */
  39196. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39197. /**
  39198. * Instantiates a new FollowCameraInputsManager.
  39199. * @param camera Defines the camera the inputs belong to
  39200. */
  39201. constructor(camera: FollowCamera);
  39202. /**
  39203. * Add keyboard input support to the input manager.
  39204. * @returns the current input manager
  39205. */
  39206. addKeyboard(): FollowCameraInputsManager;
  39207. /**
  39208. * Add mouse wheel input support to the input manager.
  39209. * @returns the current input manager
  39210. */
  39211. addMouseWheel(): FollowCameraInputsManager;
  39212. /**
  39213. * Add pointers input support to the input manager.
  39214. * @returns the current input manager
  39215. */
  39216. addPointers(): FollowCameraInputsManager;
  39217. /**
  39218. * Add orientation input support to the input manager.
  39219. * @returns the current input manager
  39220. */
  39221. addVRDeviceOrientation(): FollowCameraInputsManager;
  39222. }
  39223. }
  39224. declare module "babylonjs/Cameras/followCamera" {
  39225. import { Nullable } from "babylonjs/types";
  39226. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39227. import { Scene } from "babylonjs/scene";
  39228. import { Vector3 } from "babylonjs/Maths/math.vector";
  39229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39230. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39231. /**
  39232. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39233. * an arc rotate version arcFollowCamera are available.
  39234. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39235. */
  39236. export class FollowCamera extends TargetCamera {
  39237. /**
  39238. * Distance the follow camera should follow an object at
  39239. */
  39240. radius: number;
  39241. /**
  39242. * Minimum allowed distance of the camera to the axis of rotation
  39243. * (The camera can not get closer).
  39244. * This can help limiting how the Camera is able to move in the scene.
  39245. */
  39246. lowerRadiusLimit: Nullable<number>;
  39247. /**
  39248. * Maximum allowed distance of the camera to the axis of rotation
  39249. * (The camera can not get further).
  39250. * This can help limiting how the Camera is able to move in the scene.
  39251. */
  39252. upperRadiusLimit: Nullable<number>;
  39253. /**
  39254. * Define a rotation offset between the camera and the object it follows
  39255. */
  39256. rotationOffset: number;
  39257. /**
  39258. * Minimum allowed angle to camera position relative to target object.
  39259. * This can help limiting how the Camera is able to move in the scene.
  39260. */
  39261. lowerRotationOffsetLimit: Nullable<number>;
  39262. /**
  39263. * Maximum allowed angle to camera position relative to target object.
  39264. * This can help limiting how the Camera is able to move in the scene.
  39265. */
  39266. upperRotationOffsetLimit: Nullable<number>;
  39267. /**
  39268. * Define a height offset between the camera and the object it follows.
  39269. * It can help following an object from the top (like a car chaing a plane)
  39270. */
  39271. heightOffset: number;
  39272. /**
  39273. * Minimum allowed height of camera position relative to target object.
  39274. * This can help limiting how the Camera is able to move in the scene.
  39275. */
  39276. lowerHeightOffsetLimit: Nullable<number>;
  39277. /**
  39278. * Maximum allowed height of camera position relative to target object.
  39279. * This can help limiting how the Camera is able to move in the scene.
  39280. */
  39281. upperHeightOffsetLimit: Nullable<number>;
  39282. /**
  39283. * Define how fast the camera can accelerate to follow it s target.
  39284. */
  39285. cameraAcceleration: number;
  39286. /**
  39287. * Define the speed limit of the camera following an object.
  39288. */
  39289. maxCameraSpeed: number;
  39290. /**
  39291. * Define the target of the camera.
  39292. */
  39293. lockedTarget: Nullable<AbstractMesh>;
  39294. /**
  39295. * Defines the input associated with the camera.
  39296. */
  39297. inputs: FollowCameraInputsManager;
  39298. /**
  39299. * Instantiates the follow camera.
  39300. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39301. * @param name Define the name of the camera in the scene
  39302. * @param position Define the position of the camera
  39303. * @param scene Define the scene the camera belong to
  39304. * @param lockedTarget Define the target of the camera
  39305. */
  39306. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39307. private _follow;
  39308. /**
  39309. * Attached controls to the current camera.
  39310. * @param element Defines the element the controls should be listened from
  39311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39312. */
  39313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39314. /**
  39315. * Detach the current controls from the camera.
  39316. * The camera will stop reacting to inputs.
  39317. * @param element Defines the element to stop listening the inputs from
  39318. */
  39319. detachControl(element: HTMLElement): void;
  39320. /** @hidden */
  39321. _checkInputs(): void;
  39322. private _checkLimits;
  39323. /**
  39324. * Gets the camera class name.
  39325. * @returns the class name
  39326. */
  39327. getClassName(): string;
  39328. }
  39329. /**
  39330. * Arc Rotate version of the follow camera.
  39331. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39332. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39333. */
  39334. export class ArcFollowCamera extends TargetCamera {
  39335. /** The longitudinal angle of the camera */
  39336. alpha: number;
  39337. /** The latitudinal angle of the camera */
  39338. beta: number;
  39339. /** The radius of the camera from its target */
  39340. radius: number;
  39341. /** Define the camera target (the messh it should follow) */
  39342. target: Nullable<AbstractMesh>;
  39343. private _cartesianCoordinates;
  39344. /**
  39345. * Instantiates a new ArcFollowCamera
  39346. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39347. * @param name Define the name of the camera
  39348. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39349. * @param beta Define the rotation angle of the camera around the elevation axis
  39350. * @param radius Define the radius of the camera from its target point
  39351. * @param target Define the target of the camera
  39352. * @param scene Define the scene the camera belongs to
  39353. */
  39354. constructor(name: string,
  39355. /** The longitudinal angle of the camera */
  39356. alpha: number,
  39357. /** The latitudinal angle of the camera */
  39358. beta: number,
  39359. /** The radius of the camera from its target */
  39360. radius: number,
  39361. /** Define the camera target (the messh it should follow) */
  39362. target: Nullable<AbstractMesh>, scene: Scene);
  39363. private _follow;
  39364. /** @hidden */
  39365. _checkInputs(): void;
  39366. /**
  39367. * Returns the class name of the object.
  39368. * It is mostly used internally for serialization purposes.
  39369. */
  39370. getClassName(): string;
  39371. }
  39372. }
  39373. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39374. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39375. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39376. import { Nullable } from "babylonjs/types";
  39377. /**
  39378. * Manage the keyboard inputs to control the movement of a follow camera.
  39379. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39380. */
  39381. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39382. /**
  39383. * Defines the camera the input is attached to.
  39384. */
  39385. camera: FollowCamera;
  39386. /**
  39387. * Defines the list of key codes associated with the up action (increase heightOffset)
  39388. */
  39389. keysHeightOffsetIncr: number[];
  39390. /**
  39391. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39392. */
  39393. keysHeightOffsetDecr: number[];
  39394. /**
  39395. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39396. */
  39397. keysHeightOffsetModifierAlt: boolean;
  39398. /**
  39399. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39400. */
  39401. keysHeightOffsetModifierCtrl: boolean;
  39402. /**
  39403. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39404. */
  39405. keysHeightOffsetModifierShift: boolean;
  39406. /**
  39407. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39408. */
  39409. keysRotationOffsetIncr: number[];
  39410. /**
  39411. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39412. */
  39413. keysRotationOffsetDecr: number[];
  39414. /**
  39415. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39416. */
  39417. keysRotationOffsetModifierAlt: boolean;
  39418. /**
  39419. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39420. */
  39421. keysRotationOffsetModifierCtrl: boolean;
  39422. /**
  39423. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39424. */
  39425. keysRotationOffsetModifierShift: boolean;
  39426. /**
  39427. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39428. */
  39429. keysRadiusIncr: number[];
  39430. /**
  39431. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39432. */
  39433. keysRadiusDecr: number[];
  39434. /**
  39435. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39436. */
  39437. keysRadiusModifierAlt: boolean;
  39438. /**
  39439. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39440. */
  39441. keysRadiusModifierCtrl: boolean;
  39442. /**
  39443. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39444. */
  39445. keysRadiusModifierShift: boolean;
  39446. /**
  39447. * Defines the rate of change of heightOffset.
  39448. */
  39449. heightSensibility: number;
  39450. /**
  39451. * Defines the rate of change of rotationOffset.
  39452. */
  39453. rotationSensibility: number;
  39454. /**
  39455. * Defines the rate of change of radius.
  39456. */
  39457. radiusSensibility: number;
  39458. private _keys;
  39459. private _ctrlPressed;
  39460. private _altPressed;
  39461. private _shiftPressed;
  39462. private _onCanvasBlurObserver;
  39463. private _onKeyboardObserver;
  39464. private _engine;
  39465. private _scene;
  39466. /**
  39467. * Attach the input controls to a specific dom element to get the input from.
  39468. * @param element Defines the element the controls should be listened from
  39469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39470. */
  39471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39472. /**
  39473. * Detach the current controls from the specified dom element.
  39474. * @param element Defines the element to stop listening the inputs from
  39475. */
  39476. detachControl(element: Nullable<HTMLElement>): void;
  39477. /**
  39478. * Update the current camera state depending on the inputs that have been used this frame.
  39479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39480. */
  39481. checkInputs(): void;
  39482. /**
  39483. * Gets the class name of the current input.
  39484. * @returns the class name
  39485. */
  39486. getClassName(): string;
  39487. /**
  39488. * Get the friendly name associated with the input class.
  39489. * @returns the input friendly name
  39490. */
  39491. getSimpleName(): string;
  39492. /**
  39493. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39494. * allow modification of the heightOffset value.
  39495. */
  39496. private _modifierHeightOffset;
  39497. /**
  39498. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39499. * allow modification of the rotationOffset value.
  39500. */
  39501. private _modifierRotationOffset;
  39502. /**
  39503. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39504. * allow modification of the radius value.
  39505. */
  39506. private _modifierRadius;
  39507. }
  39508. }
  39509. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39510. import { Nullable } from "babylonjs/types";
  39511. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39512. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39513. import { Observable } from "babylonjs/Misc/observable";
  39514. module "babylonjs/Cameras/freeCameraInputsManager" {
  39515. interface FreeCameraInputsManager {
  39516. /**
  39517. * @hidden
  39518. */
  39519. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39520. /**
  39521. * Add orientation input support to the input manager.
  39522. * @returns the current input manager
  39523. */
  39524. addDeviceOrientation(): FreeCameraInputsManager;
  39525. }
  39526. }
  39527. /**
  39528. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39529. * Screen rotation is taken into account.
  39530. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39531. */
  39532. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39533. private _camera;
  39534. private _screenOrientationAngle;
  39535. private _constantTranform;
  39536. private _screenQuaternion;
  39537. private _alpha;
  39538. private _beta;
  39539. private _gamma;
  39540. /**
  39541. * Can be used to detect if a device orientation sensor is availible on a device
  39542. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39543. * @returns a promise that will resolve on orientation change
  39544. */
  39545. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39546. /**
  39547. * @hidden
  39548. */
  39549. _onDeviceOrientationChangedObservable: Observable<void>;
  39550. /**
  39551. * Instantiates a new input
  39552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39553. */
  39554. constructor();
  39555. /**
  39556. * Define the camera controlled by the input.
  39557. */
  39558. camera: FreeCamera;
  39559. /**
  39560. * Attach the input controls to a specific dom element to get the input from.
  39561. * @param element Defines the element the controls should be listened from
  39562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39563. */
  39564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39565. private _orientationChanged;
  39566. private _deviceOrientation;
  39567. /**
  39568. * Detach the current controls from the specified dom element.
  39569. * @param element Defines the element to stop listening the inputs from
  39570. */
  39571. detachControl(element: Nullable<HTMLElement>): void;
  39572. /**
  39573. * Update the current camera state depending on the inputs that have been used this frame.
  39574. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39575. */
  39576. checkInputs(): void;
  39577. /**
  39578. * Gets the class name of the current intput.
  39579. * @returns the class name
  39580. */
  39581. getClassName(): string;
  39582. /**
  39583. * Get the friendly name associated with the input class.
  39584. * @returns the input friendly name
  39585. */
  39586. getSimpleName(): string;
  39587. }
  39588. }
  39589. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39590. import { Nullable } from "babylonjs/types";
  39591. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39592. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39593. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39594. /**
  39595. * Manage the gamepad inputs to control a free camera.
  39596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39597. */
  39598. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39599. /**
  39600. * Define the camera the input is attached to.
  39601. */
  39602. camera: FreeCamera;
  39603. /**
  39604. * Define the Gamepad controlling the input
  39605. */
  39606. gamepad: Nullable<Gamepad>;
  39607. /**
  39608. * Defines the gamepad rotation sensiblity.
  39609. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39610. */
  39611. gamepadAngularSensibility: number;
  39612. /**
  39613. * Defines the gamepad move sensiblity.
  39614. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39615. */
  39616. gamepadMoveSensibility: number;
  39617. private _onGamepadConnectedObserver;
  39618. private _onGamepadDisconnectedObserver;
  39619. private _cameraTransform;
  39620. private _deltaTransform;
  39621. private _vector3;
  39622. private _vector2;
  39623. /**
  39624. * Attach the input controls to a specific dom element to get the input from.
  39625. * @param element Defines the element the controls should be listened from
  39626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39627. */
  39628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39629. /**
  39630. * Detach the current controls from the specified dom element.
  39631. * @param element Defines the element to stop listening the inputs from
  39632. */
  39633. detachControl(element: Nullable<HTMLElement>): void;
  39634. /**
  39635. * Update the current camera state depending on the inputs that have been used this frame.
  39636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39637. */
  39638. checkInputs(): void;
  39639. /**
  39640. * Gets the class name of the current intput.
  39641. * @returns the class name
  39642. */
  39643. getClassName(): string;
  39644. /**
  39645. * Get the friendly name associated with the input class.
  39646. * @returns the input friendly name
  39647. */
  39648. getSimpleName(): string;
  39649. }
  39650. }
  39651. declare module "babylonjs/Misc/virtualJoystick" {
  39652. import { Nullable } from "babylonjs/types";
  39653. import { Vector3 } from "babylonjs/Maths/math.vector";
  39654. /**
  39655. * Defines the potential axis of a Joystick
  39656. */
  39657. export enum JoystickAxis {
  39658. /** X axis */
  39659. X = 0,
  39660. /** Y axis */
  39661. Y = 1,
  39662. /** Z axis */
  39663. Z = 2
  39664. }
  39665. /**
  39666. * Class used to define virtual joystick (used in touch mode)
  39667. */
  39668. export class VirtualJoystick {
  39669. /**
  39670. * Gets or sets a boolean indicating that left and right values must be inverted
  39671. */
  39672. reverseLeftRight: boolean;
  39673. /**
  39674. * Gets or sets a boolean indicating that up and down values must be inverted
  39675. */
  39676. reverseUpDown: boolean;
  39677. /**
  39678. * Gets the offset value for the position (ie. the change of the position value)
  39679. */
  39680. deltaPosition: Vector3;
  39681. /**
  39682. * Gets a boolean indicating if the virtual joystick was pressed
  39683. */
  39684. pressed: boolean;
  39685. /**
  39686. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39687. */
  39688. static Canvas: Nullable<HTMLCanvasElement>;
  39689. private static _globalJoystickIndex;
  39690. private static vjCanvasContext;
  39691. private static vjCanvasWidth;
  39692. private static vjCanvasHeight;
  39693. private static halfWidth;
  39694. private _action;
  39695. private _axisTargetedByLeftAndRight;
  39696. private _axisTargetedByUpAndDown;
  39697. private _joystickSensibility;
  39698. private _inversedSensibility;
  39699. private _joystickPointerID;
  39700. private _joystickColor;
  39701. private _joystickPointerPos;
  39702. private _joystickPreviousPointerPos;
  39703. private _joystickPointerStartPos;
  39704. private _deltaJoystickVector;
  39705. private _leftJoystick;
  39706. private _touches;
  39707. private _onPointerDownHandlerRef;
  39708. private _onPointerMoveHandlerRef;
  39709. private _onPointerUpHandlerRef;
  39710. private _onResize;
  39711. /**
  39712. * Creates a new virtual joystick
  39713. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39714. */
  39715. constructor(leftJoystick?: boolean);
  39716. /**
  39717. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39718. * @param newJoystickSensibility defines the new sensibility
  39719. */
  39720. setJoystickSensibility(newJoystickSensibility: number): void;
  39721. private _onPointerDown;
  39722. private _onPointerMove;
  39723. private _onPointerUp;
  39724. /**
  39725. * Change the color of the virtual joystick
  39726. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39727. */
  39728. setJoystickColor(newColor: string): void;
  39729. /**
  39730. * Defines a callback to call when the joystick is touched
  39731. * @param action defines the callback
  39732. */
  39733. setActionOnTouch(action: () => any): void;
  39734. /**
  39735. * Defines which axis you'd like to control for left & right
  39736. * @param axis defines the axis to use
  39737. */
  39738. setAxisForLeftRight(axis: JoystickAxis): void;
  39739. /**
  39740. * Defines which axis you'd like to control for up & down
  39741. * @param axis defines the axis to use
  39742. */
  39743. setAxisForUpDown(axis: JoystickAxis): void;
  39744. private _drawVirtualJoystick;
  39745. /**
  39746. * Release internal HTML canvas
  39747. */
  39748. releaseCanvas(): void;
  39749. }
  39750. }
  39751. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39752. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39753. import { Nullable } from "babylonjs/types";
  39754. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39755. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39756. module "babylonjs/Cameras/freeCameraInputsManager" {
  39757. interface FreeCameraInputsManager {
  39758. /**
  39759. * Add virtual joystick input support to the input manager.
  39760. * @returns the current input manager
  39761. */
  39762. addVirtualJoystick(): FreeCameraInputsManager;
  39763. }
  39764. }
  39765. /**
  39766. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39768. */
  39769. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39770. /**
  39771. * Defines the camera the input is attached to.
  39772. */
  39773. camera: FreeCamera;
  39774. private _leftjoystick;
  39775. private _rightjoystick;
  39776. /**
  39777. * Gets the left stick of the virtual joystick.
  39778. * @returns The virtual Joystick
  39779. */
  39780. getLeftJoystick(): VirtualJoystick;
  39781. /**
  39782. * Gets the right stick of the virtual joystick.
  39783. * @returns The virtual Joystick
  39784. */
  39785. getRightJoystick(): VirtualJoystick;
  39786. /**
  39787. * Update the current camera state depending on the inputs that have been used this frame.
  39788. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39789. */
  39790. checkInputs(): void;
  39791. /**
  39792. * Attach the input controls to a specific dom element to get the input from.
  39793. * @param element Defines the element the controls should be listened from
  39794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39795. */
  39796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39797. /**
  39798. * Detach the current controls from the specified dom element.
  39799. * @param element Defines the element to stop listening the inputs from
  39800. */
  39801. detachControl(element: Nullable<HTMLElement>): void;
  39802. /**
  39803. * Gets the class name of the current intput.
  39804. * @returns the class name
  39805. */
  39806. getClassName(): string;
  39807. /**
  39808. * Get the friendly name associated with the input class.
  39809. * @returns the input friendly name
  39810. */
  39811. getSimpleName(): string;
  39812. }
  39813. }
  39814. declare module "babylonjs/Cameras/Inputs/index" {
  39815. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39816. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39817. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39818. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39819. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39820. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39821. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39822. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39823. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39824. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39825. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39826. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39827. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39828. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39829. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39830. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39831. }
  39832. declare module "babylonjs/Cameras/touchCamera" {
  39833. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39834. import { Scene } from "babylonjs/scene";
  39835. import { Vector3 } from "babylonjs/Maths/math.vector";
  39836. /**
  39837. * This represents a FPS type of camera controlled by touch.
  39838. * This is like a universal camera minus the Gamepad controls.
  39839. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39840. */
  39841. export class TouchCamera extends FreeCamera {
  39842. /**
  39843. * Defines the touch sensibility for rotation.
  39844. * The higher the faster.
  39845. */
  39846. touchAngularSensibility: number;
  39847. /**
  39848. * Defines the touch sensibility for move.
  39849. * The higher the faster.
  39850. */
  39851. touchMoveSensibility: number;
  39852. /**
  39853. * Instantiates a new touch camera.
  39854. * This represents a FPS type of camera controlled by touch.
  39855. * This is like a universal camera minus the Gamepad controls.
  39856. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39857. * @param name Define the name of the camera in the scene
  39858. * @param position Define the start position of the camera in the scene
  39859. * @param scene Define the scene the camera belongs to
  39860. */
  39861. constructor(name: string, position: Vector3, scene: Scene);
  39862. /**
  39863. * Gets the current object class name.
  39864. * @return the class name
  39865. */
  39866. getClassName(): string;
  39867. /** @hidden */
  39868. _setupInputs(): void;
  39869. }
  39870. }
  39871. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39872. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39873. import { Scene } from "babylonjs/scene";
  39874. import { Vector3 } from "babylonjs/Maths/math.vector";
  39875. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39876. import { Axis } from "babylonjs/Maths/math.axis";
  39877. /**
  39878. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39879. * being tilted forward or back and left or right.
  39880. */
  39881. export class DeviceOrientationCamera extends FreeCamera {
  39882. private _initialQuaternion;
  39883. private _quaternionCache;
  39884. private _tmpDragQuaternion;
  39885. private _disablePointerInputWhenUsingDeviceOrientation;
  39886. /**
  39887. * Creates a new device orientation camera
  39888. * @param name The name of the camera
  39889. * @param position The start position camera
  39890. * @param scene The scene the camera belongs to
  39891. */
  39892. constructor(name: string, position: Vector3, scene: Scene);
  39893. /**
  39894. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39895. */
  39896. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39897. private _dragFactor;
  39898. /**
  39899. * Enabled turning on the y axis when the orientation sensor is active
  39900. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39901. */
  39902. enableHorizontalDragging(dragFactor?: number): void;
  39903. /**
  39904. * Gets the current instance class name ("DeviceOrientationCamera").
  39905. * This helps avoiding instanceof at run time.
  39906. * @returns the class name
  39907. */
  39908. getClassName(): string;
  39909. /**
  39910. * @hidden
  39911. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39912. */
  39913. _checkInputs(): void;
  39914. /**
  39915. * Reset the camera to its default orientation on the specified axis only.
  39916. * @param axis The axis to reset
  39917. */
  39918. resetToCurrentRotation(axis?: Axis): void;
  39919. }
  39920. }
  39921. declare module "babylonjs/Gamepads/xboxGamepad" {
  39922. import { Observable } from "babylonjs/Misc/observable";
  39923. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39924. /**
  39925. * Defines supported buttons for XBox360 compatible gamepads
  39926. */
  39927. export enum Xbox360Button {
  39928. /** A */
  39929. A = 0,
  39930. /** B */
  39931. B = 1,
  39932. /** X */
  39933. X = 2,
  39934. /** Y */
  39935. Y = 3,
  39936. /** Start */
  39937. Start = 4,
  39938. /** Back */
  39939. Back = 5,
  39940. /** Left button */
  39941. LB = 6,
  39942. /** Right button */
  39943. RB = 7,
  39944. /** Left stick */
  39945. LeftStick = 8,
  39946. /** Right stick */
  39947. RightStick = 9
  39948. }
  39949. /** Defines values for XBox360 DPad */
  39950. export enum Xbox360Dpad {
  39951. /** Up */
  39952. Up = 0,
  39953. /** Down */
  39954. Down = 1,
  39955. /** Left */
  39956. Left = 2,
  39957. /** Right */
  39958. Right = 3
  39959. }
  39960. /**
  39961. * Defines a XBox360 gamepad
  39962. */
  39963. export class Xbox360Pad extends Gamepad {
  39964. private _leftTrigger;
  39965. private _rightTrigger;
  39966. private _onlefttriggerchanged;
  39967. private _onrighttriggerchanged;
  39968. private _onbuttondown;
  39969. private _onbuttonup;
  39970. private _ondpaddown;
  39971. private _ondpadup;
  39972. /** Observable raised when a button is pressed */
  39973. onButtonDownObservable: Observable<Xbox360Button>;
  39974. /** Observable raised when a button is released */
  39975. onButtonUpObservable: Observable<Xbox360Button>;
  39976. /** Observable raised when a pad is pressed */
  39977. onPadDownObservable: Observable<Xbox360Dpad>;
  39978. /** Observable raised when a pad is released */
  39979. onPadUpObservable: Observable<Xbox360Dpad>;
  39980. private _buttonA;
  39981. private _buttonB;
  39982. private _buttonX;
  39983. private _buttonY;
  39984. private _buttonBack;
  39985. private _buttonStart;
  39986. private _buttonLB;
  39987. private _buttonRB;
  39988. private _buttonLeftStick;
  39989. private _buttonRightStick;
  39990. private _dPadUp;
  39991. private _dPadDown;
  39992. private _dPadLeft;
  39993. private _dPadRight;
  39994. private _isXboxOnePad;
  39995. /**
  39996. * Creates a new XBox360 gamepad object
  39997. * @param id defines the id of this gamepad
  39998. * @param index defines its index
  39999. * @param gamepad defines the internal HTML gamepad object
  40000. * @param xboxOne defines if it is a XBox One gamepad
  40001. */
  40002. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40003. /**
  40004. * Defines the callback to call when left trigger is pressed
  40005. * @param callback defines the callback to use
  40006. */
  40007. onlefttriggerchanged(callback: (value: number) => void): void;
  40008. /**
  40009. * Defines the callback to call when right trigger is pressed
  40010. * @param callback defines the callback to use
  40011. */
  40012. onrighttriggerchanged(callback: (value: number) => void): void;
  40013. /**
  40014. * Gets the left trigger value
  40015. */
  40016. /**
  40017. * Sets the left trigger value
  40018. */
  40019. leftTrigger: number;
  40020. /**
  40021. * Gets the right trigger value
  40022. */
  40023. /**
  40024. * Sets the right trigger value
  40025. */
  40026. rightTrigger: number;
  40027. /**
  40028. * Defines the callback to call when a button is pressed
  40029. * @param callback defines the callback to use
  40030. */
  40031. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40032. /**
  40033. * Defines the callback to call when a button is released
  40034. * @param callback defines the callback to use
  40035. */
  40036. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40037. /**
  40038. * Defines the callback to call when a pad is pressed
  40039. * @param callback defines the callback to use
  40040. */
  40041. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40042. /**
  40043. * Defines the callback to call when a pad is released
  40044. * @param callback defines the callback to use
  40045. */
  40046. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40047. private _setButtonValue;
  40048. private _setDPadValue;
  40049. /**
  40050. * Gets the value of the `A` button
  40051. */
  40052. /**
  40053. * Sets the value of the `A` button
  40054. */
  40055. buttonA: number;
  40056. /**
  40057. * Gets the value of the `B` button
  40058. */
  40059. /**
  40060. * Sets the value of the `B` button
  40061. */
  40062. buttonB: number;
  40063. /**
  40064. * Gets the value of the `X` button
  40065. */
  40066. /**
  40067. * Sets the value of the `X` button
  40068. */
  40069. buttonX: number;
  40070. /**
  40071. * Gets the value of the `Y` button
  40072. */
  40073. /**
  40074. * Sets the value of the `Y` button
  40075. */
  40076. buttonY: number;
  40077. /**
  40078. * Gets the value of the `Start` button
  40079. */
  40080. /**
  40081. * Sets the value of the `Start` button
  40082. */
  40083. buttonStart: number;
  40084. /**
  40085. * Gets the value of the `Back` button
  40086. */
  40087. /**
  40088. * Sets the value of the `Back` button
  40089. */
  40090. buttonBack: number;
  40091. /**
  40092. * Gets the value of the `Left` button
  40093. */
  40094. /**
  40095. * Sets the value of the `Left` button
  40096. */
  40097. buttonLB: number;
  40098. /**
  40099. * Gets the value of the `Right` button
  40100. */
  40101. /**
  40102. * Sets the value of the `Right` button
  40103. */
  40104. buttonRB: number;
  40105. /**
  40106. * Gets the value of the Left joystick
  40107. */
  40108. /**
  40109. * Sets the value of the Left joystick
  40110. */
  40111. buttonLeftStick: number;
  40112. /**
  40113. * Gets the value of the Right joystick
  40114. */
  40115. /**
  40116. * Sets the value of the Right joystick
  40117. */
  40118. buttonRightStick: number;
  40119. /**
  40120. * Gets the value of D-pad up
  40121. */
  40122. /**
  40123. * Sets the value of D-pad up
  40124. */
  40125. dPadUp: number;
  40126. /**
  40127. * Gets the value of D-pad down
  40128. */
  40129. /**
  40130. * Sets the value of D-pad down
  40131. */
  40132. dPadDown: number;
  40133. /**
  40134. * Gets the value of D-pad left
  40135. */
  40136. /**
  40137. * Sets the value of D-pad left
  40138. */
  40139. dPadLeft: number;
  40140. /**
  40141. * Gets the value of D-pad right
  40142. */
  40143. /**
  40144. * Sets the value of D-pad right
  40145. */
  40146. dPadRight: number;
  40147. /**
  40148. * Force the gamepad to synchronize with device values
  40149. */
  40150. update(): void;
  40151. /**
  40152. * Disposes the gamepad
  40153. */
  40154. dispose(): void;
  40155. }
  40156. }
  40157. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40158. import { Observable } from "babylonjs/Misc/observable";
  40159. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40160. /**
  40161. * Defines supported buttons for DualShock compatible gamepads
  40162. */
  40163. export enum DualShockButton {
  40164. /** Cross */
  40165. Cross = 0,
  40166. /** Circle */
  40167. Circle = 1,
  40168. /** Square */
  40169. Square = 2,
  40170. /** Triangle */
  40171. Triangle = 3,
  40172. /** Options */
  40173. Options = 4,
  40174. /** Share */
  40175. Share = 5,
  40176. /** L1 */
  40177. L1 = 6,
  40178. /** R1 */
  40179. R1 = 7,
  40180. /** Left stick */
  40181. LeftStick = 8,
  40182. /** Right stick */
  40183. RightStick = 9
  40184. }
  40185. /** Defines values for DualShock DPad */
  40186. export enum DualShockDpad {
  40187. /** Up */
  40188. Up = 0,
  40189. /** Down */
  40190. Down = 1,
  40191. /** Left */
  40192. Left = 2,
  40193. /** Right */
  40194. Right = 3
  40195. }
  40196. /**
  40197. * Defines a DualShock gamepad
  40198. */
  40199. export class DualShockPad extends Gamepad {
  40200. private _leftTrigger;
  40201. private _rightTrigger;
  40202. private _onlefttriggerchanged;
  40203. private _onrighttriggerchanged;
  40204. private _onbuttondown;
  40205. private _onbuttonup;
  40206. private _ondpaddown;
  40207. private _ondpadup;
  40208. /** Observable raised when a button is pressed */
  40209. onButtonDownObservable: Observable<DualShockButton>;
  40210. /** Observable raised when a button is released */
  40211. onButtonUpObservable: Observable<DualShockButton>;
  40212. /** Observable raised when a pad is pressed */
  40213. onPadDownObservable: Observable<DualShockDpad>;
  40214. /** Observable raised when a pad is released */
  40215. onPadUpObservable: Observable<DualShockDpad>;
  40216. private _buttonCross;
  40217. private _buttonCircle;
  40218. private _buttonSquare;
  40219. private _buttonTriangle;
  40220. private _buttonShare;
  40221. private _buttonOptions;
  40222. private _buttonL1;
  40223. private _buttonR1;
  40224. private _buttonLeftStick;
  40225. private _buttonRightStick;
  40226. private _dPadUp;
  40227. private _dPadDown;
  40228. private _dPadLeft;
  40229. private _dPadRight;
  40230. /**
  40231. * Creates a new DualShock gamepad object
  40232. * @param id defines the id of this gamepad
  40233. * @param index defines its index
  40234. * @param gamepad defines the internal HTML gamepad object
  40235. */
  40236. constructor(id: string, index: number, gamepad: any);
  40237. /**
  40238. * Defines the callback to call when left trigger is pressed
  40239. * @param callback defines the callback to use
  40240. */
  40241. onlefttriggerchanged(callback: (value: number) => void): void;
  40242. /**
  40243. * Defines the callback to call when right trigger is pressed
  40244. * @param callback defines the callback to use
  40245. */
  40246. onrighttriggerchanged(callback: (value: number) => void): void;
  40247. /**
  40248. * Gets the left trigger value
  40249. */
  40250. /**
  40251. * Sets the left trigger value
  40252. */
  40253. leftTrigger: number;
  40254. /**
  40255. * Gets the right trigger value
  40256. */
  40257. /**
  40258. * Sets the right trigger value
  40259. */
  40260. rightTrigger: number;
  40261. /**
  40262. * Defines the callback to call when a button is pressed
  40263. * @param callback defines the callback to use
  40264. */
  40265. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40266. /**
  40267. * Defines the callback to call when a button is released
  40268. * @param callback defines the callback to use
  40269. */
  40270. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40271. /**
  40272. * Defines the callback to call when a pad is pressed
  40273. * @param callback defines the callback to use
  40274. */
  40275. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40276. /**
  40277. * Defines the callback to call when a pad is released
  40278. * @param callback defines the callback to use
  40279. */
  40280. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40281. private _setButtonValue;
  40282. private _setDPadValue;
  40283. /**
  40284. * Gets the value of the `Cross` button
  40285. */
  40286. /**
  40287. * Sets the value of the `Cross` button
  40288. */
  40289. buttonCross: number;
  40290. /**
  40291. * Gets the value of the `Circle` button
  40292. */
  40293. /**
  40294. * Sets the value of the `Circle` button
  40295. */
  40296. buttonCircle: number;
  40297. /**
  40298. * Gets the value of the `Square` button
  40299. */
  40300. /**
  40301. * Sets the value of the `Square` button
  40302. */
  40303. buttonSquare: number;
  40304. /**
  40305. * Gets the value of the `Triangle` button
  40306. */
  40307. /**
  40308. * Sets the value of the `Triangle` button
  40309. */
  40310. buttonTriangle: number;
  40311. /**
  40312. * Gets the value of the `Options` button
  40313. */
  40314. /**
  40315. * Sets the value of the `Options` button
  40316. */
  40317. buttonOptions: number;
  40318. /**
  40319. * Gets the value of the `Share` button
  40320. */
  40321. /**
  40322. * Sets the value of the `Share` button
  40323. */
  40324. buttonShare: number;
  40325. /**
  40326. * Gets the value of the `L1` button
  40327. */
  40328. /**
  40329. * Sets the value of the `L1` button
  40330. */
  40331. buttonL1: number;
  40332. /**
  40333. * Gets the value of the `R1` button
  40334. */
  40335. /**
  40336. * Sets the value of the `R1` button
  40337. */
  40338. buttonR1: number;
  40339. /**
  40340. * Gets the value of the Left joystick
  40341. */
  40342. /**
  40343. * Sets the value of the Left joystick
  40344. */
  40345. buttonLeftStick: number;
  40346. /**
  40347. * Gets the value of the Right joystick
  40348. */
  40349. /**
  40350. * Sets the value of the Right joystick
  40351. */
  40352. buttonRightStick: number;
  40353. /**
  40354. * Gets the value of D-pad up
  40355. */
  40356. /**
  40357. * Sets the value of D-pad up
  40358. */
  40359. dPadUp: number;
  40360. /**
  40361. * Gets the value of D-pad down
  40362. */
  40363. /**
  40364. * Sets the value of D-pad down
  40365. */
  40366. dPadDown: number;
  40367. /**
  40368. * Gets the value of D-pad left
  40369. */
  40370. /**
  40371. * Sets the value of D-pad left
  40372. */
  40373. dPadLeft: number;
  40374. /**
  40375. * Gets the value of D-pad right
  40376. */
  40377. /**
  40378. * Sets the value of D-pad right
  40379. */
  40380. dPadRight: number;
  40381. /**
  40382. * Force the gamepad to synchronize with device values
  40383. */
  40384. update(): void;
  40385. /**
  40386. * Disposes the gamepad
  40387. */
  40388. dispose(): void;
  40389. }
  40390. }
  40391. declare module "babylonjs/Gamepads/gamepadManager" {
  40392. import { Observable } from "babylonjs/Misc/observable";
  40393. import { Nullable } from "babylonjs/types";
  40394. import { Scene } from "babylonjs/scene";
  40395. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40396. /**
  40397. * Manager for handling gamepads
  40398. */
  40399. export class GamepadManager {
  40400. private _scene?;
  40401. private _babylonGamepads;
  40402. private _oneGamepadConnected;
  40403. /** @hidden */
  40404. _isMonitoring: boolean;
  40405. private _gamepadEventSupported;
  40406. private _gamepadSupport;
  40407. /**
  40408. * observable to be triggered when the gamepad controller has been connected
  40409. */
  40410. onGamepadConnectedObservable: Observable<Gamepad>;
  40411. /**
  40412. * observable to be triggered when the gamepad controller has been disconnected
  40413. */
  40414. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40415. private _onGamepadConnectedEvent;
  40416. private _onGamepadDisconnectedEvent;
  40417. /**
  40418. * Initializes the gamepad manager
  40419. * @param _scene BabylonJS scene
  40420. */
  40421. constructor(_scene?: Scene | undefined);
  40422. /**
  40423. * The gamepads in the game pad manager
  40424. */
  40425. readonly gamepads: Gamepad[];
  40426. /**
  40427. * Get the gamepad controllers based on type
  40428. * @param type The type of gamepad controller
  40429. * @returns Nullable gamepad
  40430. */
  40431. getGamepadByType(type?: number): Nullable<Gamepad>;
  40432. /**
  40433. * Disposes the gamepad manager
  40434. */
  40435. dispose(): void;
  40436. private _addNewGamepad;
  40437. private _startMonitoringGamepads;
  40438. private _stopMonitoringGamepads;
  40439. /** @hidden */
  40440. _checkGamepadsStatus(): void;
  40441. private _updateGamepadObjects;
  40442. }
  40443. }
  40444. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40445. import { Nullable } from "babylonjs/types";
  40446. import { Scene } from "babylonjs/scene";
  40447. import { ISceneComponent } from "babylonjs/sceneComponent";
  40448. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40449. module "babylonjs/scene" {
  40450. interface Scene {
  40451. /** @hidden */
  40452. _gamepadManager: Nullable<GamepadManager>;
  40453. /**
  40454. * Gets the gamepad manager associated with the scene
  40455. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40456. */
  40457. gamepadManager: GamepadManager;
  40458. }
  40459. }
  40460. module "babylonjs/Cameras/freeCameraInputsManager" {
  40461. /**
  40462. * Interface representing a free camera inputs manager
  40463. */
  40464. interface FreeCameraInputsManager {
  40465. /**
  40466. * Adds gamepad input support to the FreeCameraInputsManager.
  40467. * @returns the FreeCameraInputsManager
  40468. */
  40469. addGamepad(): FreeCameraInputsManager;
  40470. }
  40471. }
  40472. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40473. /**
  40474. * Interface representing an arc rotate camera inputs manager
  40475. */
  40476. interface ArcRotateCameraInputsManager {
  40477. /**
  40478. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40479. * @returns the camera inputs manager
  40480. */
  40481. addGamepad(): ArcRotateCameraInputsManager;
  40482. }
  40483. }
  40484. /**
  40485. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40486. */
  40487. export class GamepadSystemSceneComponent implements ISceneComponent {
  40488. /**
  40489. * The component name helpfull to identify the component in the list of scene components.
  40490. */
  40491. readonly name: string;
  40492. /**
  40493. * The scene the component belongs to.
  40494. */
  40495. scene: Scene;
  40496. /**
  40497. * Creates a new instance of the component for the given scene
  40498. * @param scene Defines the scene to register the component in
  40499. */
  40500. constructor(scene: Scene);
  40501. /**
  40502. * Registers the component in a given scene
  40503. */
  40504. register(): void;
  40505. /**
  40506. * Rebuilds the elements related to this component in case of
  40507. * context lost for instance.
  40508. */
  40509. rebuild(): void;
  40510. /**
  40511. * Disposes the component and the associated ressources
  40512. */
  40513. dispose(): void;
  40514. private _beforeCameraUpdate;
  40515. }
  40516. }
  40517. declare module "babylonjs/Cameras/universalCamera" {
  40518. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40519. import { Scene } from "babylonjs/scene";
  40520. import { Vector3 } from "babylonjs/Maths/math.vector";
  40521. import "babylonjs/Gamepads/gamepadSceneComponent";
  40522. /**
  40523. * 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,
  40524. * which still works and will still be found in many Playgrounds.
  40525. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40526. */
  40527. export class UniversalCamera extends TouchCamera {
  40528. /**
  40529. * Defines the gamepad rotation sensiblity.
  40530. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40531. */
  40532. gamepadAngularSensibility: number;
  40533. /**
  40534. * Defines the gamepad move sensiblity.
  40535. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40536. */
  40537. gamepadMoveSensibility: number;
  40538. /**
  40539. * 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,
  40540. * which still works and will still be found in many Playgrounds.
  40541. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40542. * @param name Define the name of the camera in the scene
  40543. * @param position Define the start position of the camera in the scene
  40544. * @param scene Define the scene the camera belongs to
  40545. */
  40546. constructor(name: string, position: Vector3, scene: Scene);
  40547. /**
  40548. * Gets the current object class name.
  40549. * @return the class name
  40550. */
  40551. getClassName(): string;
  40552. }
  40553. }
  40554. declare module "babylonjs/Cameras/gamepadCamera" {
  40555. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40556. import { Scene } from "babylonjs/scene";
  40557. import { Vector3 } from "babylonjs/Maths/math.vector";
  40558. /**
  40559. * This represents a FPS type of camera. This is only here for back compat purpose.
  40560. * Please use the UniversalCamera instead as both are identical.
  40561. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40562. */
  40563. export class GamepadCamera extends UniversalCamera {
  40564. /**
  40565. * Instantiates a new Gamepad Camera
  40566. * This represents a FPS type of camera. This is only here for back compat purpose.
  40567. * Please use the UniversalCamera instead as both are identical.
  40568. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40569. * @param name Define the name of the camera in the scene
  40570. * @param position Define the start position of the camera in the scene
  40571. * @param scene Define the scene the camera belongs to
  40572. */
  40573. constructor(name: string, position: Vector3, scene: Scene);
  40574. /**
  40575. * Gets the current object class name.
  40576. * @return the class name
  40577. */
  40578. getClassName(): string;
  40579. }
  40580. }
  40581. declare module "babylonjs/Shaders/pass.fragment" {
  40582. /** @hidden */
  40583. export var passPixelShader: {
  40584. name: string;
  40585. shader: string;
  40586. };
  40587. }
  40588. declare module "babylonjs/Shaders/passCube.fragment" {
  40589. /** @hidden */
  40590. export var passCubePixelShader: {
  40591. name: string;
  40592. shader: string;
  40593. };
  40594. }
  40595. declare module "babylonjs/PostProcesses/passPostProcess" {
  40596. import { Nullable } from "babylonjs/types";
  40597. import { Camera } from "babylonjs/Cameras/camera";
  40598. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40599. import { Engine } from "babylonjs/Engines/engine";
  40600. import "babylonjs/Shaders/pass.fragment";
  40601. import "babylonjs/Shaders/passCube.fragment";
  40602. /**
  40603. * PassPostProcess which produces an output the same as it's input
  40604. */
  40605. export class PassPostProcess extends PostProcess {
  40606. /**
  40607. * Creates the PassPostProcess
  40608. * @param name The name of the effect.
  40609. * @param options The required width/height ratio to downsize to before computing the render pass.
  40610. * @param camera The camera to apply the render pass to.
  40611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40612. * @param engine The engine which the post process will be applied. (default: current engine)
  40613. * @param reusable If the post process can be reused on the same frame. (default: false)
  40614. * @param textureType The type of texture to be used when performing the post processing.
  40615. * @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)
  40616. */
  40617. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40618. }
  40619. /**
  40620. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40621. */
  40622. export class PassCubePostProcess extends PostProcess {
  40623. private _face;
  40624. /**
  40625. * Gets or sets the cube face to display.
  40626. * * 0 is +X
  40627. * * 1 is -X
  40628. * * 2 is +Y
  40629. * * 3 is -Y
  40630. * * 4 is +Z
  40631. * * 5 is -Z
  40632. */
  40633. face: number;
  40634. /**
  40635. * Creates the PassCubePostProcess
  40636. * @param name The name of the effect.
  40637. * @param options The required width/height ratio to downsize to before computing the render pass.
  40638. * @param camera The camera to apply the render pass to.
  40639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40640. * @param engine The engine which the post process will be applied. (default: current engine)
  40641. * @param reusable If the post process can be reused on the same frame. (default: false)
  40642. * @param textureType The type of texture to be used when performing the post processing.
  40643. * @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)
  40644. */
  40645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40646. }
  40647. }
  40648. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40649. /** @hidden */
  40650. export var anaglyphPixelShader: {
  40651. name: string;
  40652. shader: string;
  40653. };
  40654. }
  40655. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40656. import { Engine } from "babylonjs/Engines/engine";
  40657. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40658. import { Camera } from "babylonjs/Cameras/camera";
  40659. import "babylonjs/Shaders/anaglyph.fragment";
  40660. /**
  40661. * Postprocess used to generate anaglyphic rendering
  40662. */
  40663. export class AnaglyphPostProcess extends PostProcess {
  40664. private _passedProcess;
  40665. /**
  40666. * Creates a new AnaglyphPostProcess
  40667. * @param name defines postprocess name
  40668. * @param options defines creation options or target ratio scale
  40669. * @param rigCameras defines cameras using this postprocess
  40670. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40671. * @param engine defines hosting engine
  40672. * @param reusable defines if the postprocess will be reused multiple times per frame
  40673. */
  40674. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40675. }
  40676. }
  40677. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40678. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40679. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40680. import { Scene } from "babylonjs/scene";
  40681. import { Vector3 } from "babylonjs/Maths/math.vector";
  40682. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40683. /**
  40684. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40685. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40686. */
  40687. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40688. /**
  40689. * Creates a new AnaglyphArcRotateCamera
  40690. * @param name defines camera name
  40691. * @param alpha defines alpha angle (in radians)
  40692. * @param beta defines beta angle (in radians)
  40693. * @param radius defines radius
  40694. * @param target defines camera target
  40695. * @param interaxialDistance defines distance between each color axis
  40696. * @param scene defines the hosting scene
  40697. */
  40698. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40699. /**
  40700. * Gets camera class name
  40701. * @returns AnaglyphArcRotateCamera
  40702. */
  40703. getClassName(): string;
  40704. }
  40705. }
  40706. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40707. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40708. import { Scene } from "babylonjs/scene";
  40709. import { Vector3 } from "babylonjs/Maths/math.vector";
  40710. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40711. /**
  40712. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40713. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40714. */
  40715. export class AnaglyphFreeCamera extends FreeCamera {
  40716. /**
  40717. * Creates a new AnaglyphFreeCamera
  40718. * @param name defines camera name
  40719. * @param position defines initial position
  40720. * @param interaxialDistance defines distance between each color axis
  40721. * @param scene defines the hosting scene
  40722. */
  40723. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40724. /**
  40725. * Gets camera class name
  40726. * @returns AnaglyphFreeCamera
  40727. */
  40728. getClassName(): string;
  40729. }
  40730. }
  40731. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40732. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40733. import { Scene } from "babylonjs/scene";
  40734. import { Vector3 } from "babylonjs/Maths/math.vector";
  40735. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40736. /**
  40737. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40738. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40739. */
  40740. export class AnaglyphGamepadCamera extends GamepadCamera {
  40741. /**
  40742. * Creates a new AnaglyphGamepadCamera
  40743. * @param name defines camera name
  40744. * @param position defines initial position
  40745. * @param interaxialDistance defines distance between each color axis
  40746. * @param scene defines the hosting scene
  40747. */
  40748. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40749. /**
  40750. * Gets camera class name
  40751. * @returns AnaglyphGamepadCamera
  40752. */
  40753. getClassName(): string;
  40754. }
  40755. }
  40756. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40757. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40758. import { Scene } from "babylonjs/scene";
  40759. import { Vector3 } from "babylonjs/Maths/math.vector";
  40760. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40761. /**
  40762. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40763. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40764. */
  40765. export class AnaglyphUniversalCamera extends UniversalCamera {
  40766. /**
  40767. * Creates a new AnaglyphUniversalCamera
  40768. * @param name defines camera name
  40769. * @param position defines initial position
  40770. * @param interaxialDistance defines distance between each color axis
  40771. * @param scene defines the hosting scene
  40772. */
  40773. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40774. /**
  40775. * Gets camera class name
  40776. * @returns AnaglyphUniversalCamera
  40777. */
  40778. getClassName(): string;
  40779. }
  40780. }
  40781. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40782. /** @hidden */
  40783. export var stereoscopicInterlacePixelShader: {
  40784. name: string;
  40785. shader: string;
  40786. };
  40787. }
  40788. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40789. import { Camera } from "babylonjs/Cameras/camera";
  40790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40791. import { Engine } from "babylonjs/Engines/engine";
  40792. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40793. /**
  40794. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40795. */
  40796. export class StereoscopicInterlacePostProcess extends PostProcess {
  40797. private _stepSize;
  40798. private _passedProcess;
  40799. /**
  40800. * Initializes a StereoscopicInterlacePostProcess
  40801. * @param name The name of the effect.
  40802. * @param rigCameras The rig cameras to be appled to the post process
  40803. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40805. * @param engine The engine which the post process will be applied. (default: current engine)
  40806. * @param reusable If the post process can be reused on the same frame. (default: false)
  40807. */
  40808. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40809. }
  40810. }
  40811. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40812. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40813. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40814. import { Scene } from "babylonjs/scene";
  40815. import { Vector3 } from "babylonjs/Maths/math.vector";
  40816. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40817. /**
  40818. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40819. * @see http://doc.babylonjs.com/features/cameras
  40820. */
  40821. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40822. /**
  40823. * Creates a new StereoscopicArcRotateCamera
  40824. * @param name defines camera name
  40825. * @param alpha defines alpha angle (in radians)
  40826. * @param beta defines beta angle (in radians)
  40827. * @param radius defines radius
  40828. * @param target defines camera target
  40829. * @param interaxialDistance defines distance between each color axis
  40830. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40831. * @param scene defines the hosting scene
  40832. */
  40833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40834. /**
  40835. * Gets camera class name
  40836. * @returns StereoscopicArcRotateCamera
  40837. */
  40838. getClassName(): string;
  40839. }
  40840. }
  40841. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40842. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40843. import { Scene } from "babylonjs/scene";
  40844. import { Vector3 } from "babylonjs/Maths/math.vector";
  40845. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40846. /**
  40847. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40848. * @see http://doc.babylonjs.com/features/cameras
  40849. */
  40850. export class StereoscopicFreeCamera extends FreeCamera {
  40851. /**
  40852. * Creates a new StereoscopicFreeCamera
  40853. * @param name defines camera name
  40854. * @param position defines initial position
  40855. * @param interaxialDistance defines distance between each color axis
  40856. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40857. * @param scene defines the hosting scene
  40858. */
  40859. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40860. /**
  40861. * Gets camera class name
  40862. * @returns StereoscopicFreeCamera
  40863. */
  40864. getClassName(): string;
  40865. }
  40866. }
  40867. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40868. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40869. import { Scene } from "babylonjs/scene";
  40870. import { Vector3 } from "babylonjs/Maths/math.vector";
  40871. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40872. /**
  40873. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40874. * @see http://doc.babylonjs.com/features/cameras
  40875. */
  40876. export class StereoscopicGamepadCamera extends GamepadCamera {
  40877. /**
  40878. * Creates a new StereoscopicGamepadCamera
  40879. * @param name defines camera name
  40880. * @param position defines initial position
  40881. * @param interaxialDistance defines distance between each color axis
  40882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40883. * @param scene defines the hosting scene
  40884. */
  40885. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40886. /**
  40887. * Gets camera class name
  40888. * @returns StereoscopicGamepadCamera
  40889. */
  40890. getClassName(): string;
  40891. }
  40892. }
  40893. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40894. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40895. import { Scene } from "babylonjs/scene";
  40896. import { Vector3 } from "babylonjs/Maths/math.vector";
  40897. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40898. /**
  40899. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40900. * @see http://doc.babylonjs.com/features/cameras
  40901. */
  40902. export class StereoscopicUniversalCamera extends UniversalCamera {
  40903. /**
  40904. * Creates a new StereoscopicUniversalCamera
  40905. * @param name defines camera name
  40906. * @param position defines initial position
  40907. * @param interaxialDistance defines distance between each color axis
  40908. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40909. * @param scene defines the hosting scene
  40910. */
  40911. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40912. /**
  40913. * Gets camera class name
  40914. * @returns StereoscopicUniversalCamera
  40915. */
  40916. getClassName(): string;
  40917. }
  40918. }
  40919. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40920. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40921. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40922. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40923. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40924. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40925. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40926. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40927. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40928. }
  40929. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40930. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40931. import { Scene } from "babylonjs/scene";
  40932. import { Vector3 } from "babylonjs/Maths/math.vector";
  40933. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40934. /**
  40935. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40936. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40937. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40938. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40939. */
  40940. export class VirtualJoysticksCamera extends FreeCamera {
  40941. /**
  40942. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40943. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40944. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40945. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40946. * @param name Define the name of the camera in the scene
  40947. * @param position Define the start position of the camera in the scene
  40948. * @param scene Define the scene the camera belongs to
  40949. */
  40950. constructor(name: string, position: Vector3, scene: Scene);
  40951. /**
  40952. * Gets the current object class name.
  40953. * @return the class name
  40954. */
  40955. getClassName(): string;
  40956. }
  40957. }
  40958. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40959. import { Matrix } from "babylonjs/Maths/math.vector";
  40960. /**
  40961. * This represents all the required metrics to create a VR camera.
  40962. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40963. */
  40964. export class VRCameraMetrics {
  40965. /**
  40966. * Define the horizontal resolution off the screen.
  40967. */
  40968. hResolution: number;
  40969. /**
  40970. * Define the vertical resolution off the screen.
  40971. */
  40972. vResolution: number;
  40973. /**
  40974. * Define the horizontal screen size.
  40975. */
  40976. hScreenSize: number;
  40977. /**
  40978. * Define the vertical screen size.
  40979. */
  40980. vScreenSize: number;
  40981. /**
  40982. * Define the vertical screen center position.
  40983. */
  40984. vScreenCenter: number;
  40985. /**
  40986. * Define the distance of the eyes to the screen.
  40987. */
  40988. eyeToScreenDistance: number;
  40989. /**
  40990. * Define the distance between both lenses
  40991. */
  40992. lensSeparationDistance: number;
  40993. /**
  40994. * Define the distance between both viewer's eyes.
  40995. */
  40996. interpupillaryDistance: number;
  40997. /**
  40998. * Define the distortion factor of the VR postprocess.
  40999. * Please, touch with care.
  41000. */
  41001. distortionK: number[];
  41002. /**
  41003. * Define the chromatic aberration correction factors for the VR post process.
  41004. */
  41005. chromaAbCorrection: number[];
  41006. /**
  41007. * Define the scale factor of the post process.
  41008. * The smaller the better but the slower.
  41009. */
  41010. postProcessScaleFactor: number;
  41011. /**
  41012. * Define an offset for the lens center.
  41013. */
  41014. lensCenterOffset: number;
  41015. /**
  41016. * Define if the current vr camera should compensate the distortion of the lense or not.
  41017. */
  41018. compensateDistortion: boolean;
  41019. /**
  41020. * Defines if multiview should be enabled when rendering (Default: false)
  41021. */
  41022. multiviewEnabled: boolean;
  41023. /**
  41024. * Gets the rendering aspect ratio based on the provided resolutions.
  41025. */
  41026. readonly aspectRatio: number;
  41027. /**
  41028. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41029. */
  41030. readonly aspectRatioFov: number;
  41031. /**
  41032. * @hidden
  41033. */
  41034. readonly leftHMatrix: Matrix;
  41035. /**
  41036. * @hidden
  41037. */
  41038. readonly rightHMatrix: Matrix;
  41039. /**
  41040. * @hidden
  41041. */
  41042. readonly leftPreViewMatrix: Matrix;
  41043. /**
  41044. * @hidden
  41045. */
  41046. readonly rightPreViewMatrix: Matrix;
  41047. /**
  41048. * Get the default VRMetrics based on the most generic setup.
  41049. * @returns the default vr metrics
  41050. */
  41051. static GetDefault(): VRCameraMetrics;
  41052. }
  41053. }
  41054. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41055. /** @hidden */
  41056. export var vrDistortionCorrectionPixelShader: {
  41057. name: string;
  41058. shader: string;
  41059. };
  41060. }
  41061. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41062. import { Camera } from "babylonjs/Cameras/camera";
  41063. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41064. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41065. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41066. /**
  41067. * VRDistortionCorrectionPostProcess used for mobile VR
  41068. */
  41069. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41070. private _isRightEye;
  41071. private _distortionFactors;
  41072. private _postProcessScaleFactor;
  41073. private _lensCenterOffset;
  41074. private _scaleIn;
  41075. private _scaleFactor;
  41076. private _lensCenter;
  41077. /**
  41078. * Initializes the VRDistortionCorrectionPostProcess
  41079. * @param name The name of the effect.
  41080. * @param camera The camera to apply the render pass to.
  41081. * @param isRightEye If this is for the right eye distortion
  41082. * @param vrMetrics All the required metrics for the VR camera
  41083. */
  41084. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41085. }
  41086. }
  41087. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41088. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41089. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41090. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41091. import { Scene } from "babylonjs/scene";
  41092. import { Vector3 } from "babylonjs/Maths/math.vector";
  41093. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41094. import "babylonjs/Cameras/RigModes/vrRigMode";
  41095. /**
  41096. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41097. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41098. */
  41099. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41100. /**
  41101. * Creates a new VRDeviceOrientationArcRotateCamera
  41102. * @param name defines camera name
  41103. * @param alpha defines the camera rotation along the logitudinal axis
  41104. * @param beta defines the camera rotation along the latitudinal axis
  41105. * @param radius defines the camera distance from its target
  41106. * @param target defines the camera target
  41107. * @param scene defines the scene the camera belongs to
  41108. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41109. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41110. */
  41111. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41112. /**
  41113. * Gets camera class name
  41114. * @returns VRDeviceOrientationArcRotateCamera
  41115. */
  41116. getClassName(): string;
  41117. }
  41118. }
  41119. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41120. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41121. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41122. import { Scene } from "babylonjs/scene";
  41123. import { Vector3 } from "babylonjs/Maths/math.vector";
  41124. import "babylonjs/Cameras/RigModes/vrRigMode";
  41125. /**
  41126. * Camera used to simulate VR rendering (based on FreeCamera)
  41127. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41128. */
  41129. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41130. /**
  41131. * Creates a new VRDeviceOrientationFreeCamera
  41132. * @param name defines camera name
  41133. * @param position defines the start position of the camera
  41134. * @param scene defines the scene the camera belongs to
  41135. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41136. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41137. */
  41138. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41139. /**
  41140. * Gets camera class name
  41141. * @returns VRDeviceOrientationFreeCamera
  41142. */
  41143. getClassName(): string;
  41144. }
  41145. }
  41146. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41147. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41148. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41149. import { Scene } from "babylonjs/scene";
  41150. import { Vector3 } from "babylonjs/Maths/math.vector";
  41151. import "babylonjs/Gamepads/gamepadSceneComponent";
  41152. /**
  41153. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41154. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41155. */
  41156. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41157. /**
  41158. * Creates a new VRDeviceOrientationGamepadCamera
  41159. * @param name defines camera name
  41160. * @param position defines the start position of the camera
  41161. * @param scene defines the scene the camera belongs to
  41162. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41163. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41164. */
  41165. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41166. /**
  41167. * Gets camera class name
  41168. * @returns VRDeviceOrientationGamepadCamera
  41169. */
  41170. getClassName(): string;
  41171. }
  41172. }
  41173. declare module "babylonjs/Materials/pushMaterial" {
  41174. import { Nullable } from "babylonjs/types";
  41175. import { Scene } from "babylonjs/scene";
  41176. import { Matrix } from "babylonjs/Maths/math.vector";
  41177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41178. import { Mesh } from "babylonjs/Meshes/mesh";
  41179. import { Material } from "babylonjs/Materials/material";
  41180. import { Effect } from "babylonjs/Materials/effect";
  41181. /**
  41182. * Base class of materials working in push mode in babylon JS
  41183. * @hidden
  41184. */
  41185. export class PushMaterial extends Material {
  41186. protected _activeEffect: Effect;
  41187. protected _normalMatrix: Matrix;
  41188. /**
  41189. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41190. * This means that the material can keep using a previous shader while a new one is being compiled.
  41191. * This is mostly used when shader parallel compilation is supported (true by default)
  41192. */
  41193. allowShaderHotSwapping: boolean;
  41194. constructor(name: string, scene: Scene);
  41195. getEffect(): Effect;
  41196. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41197. /**
  41198. * Binds the given world matrix to the active effect
  41199. *
  41200. * @param world the matrix to bind
  41201. */
  41202. bindOnlyWorldMatrix(world: Matrix): void;
  41203. /**
  41204. * Binds the given normal matrix to the active effect
  41205. *
  41206. * @param normalMatrix the matrix to bind
  41207. */
  41208. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41209. bind(world: Matrix, mesh?: Mesh): void;
  41210. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41211. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41212. }
  41213. }
  41214. declare module "babylonjs/Materials/materialFlags" {
  41215. /**
  41216. * This groups all the flags used to control the materials channel.
  41217. */
  41218. export class MaterialFlags {
  41219. private static _DiffuseTextureEnabled;
  41220. /**
  41221. * Are diffuse textures enabled in the application.
  41222. */
  41223. static DiffuseTextureEnabled: boolean;
  41224. private static _AmbientTextureEnabled;
  41225. /**
  41226. * Are ambient textures enabled in the application.
  41227. */
  41228. static AmbientTextureEnabled: boolean;
  41229. private static _OpacityTextureEnabled;
  41230. /**
  41231. * Are opacity textures enabled in the application.
  41232. */
  41233. static OpacityTextureEnabled: boolean;
  41234. private static _ReflectionTextureEnabled;
  41235. /**
  41236. * Are reflection textures enabled in the application.
  41237. */
  41238. static ReflectionTextureEnabled: boolean;
  41239. private static _EmissiveTextureEnabled;
  41240. /**
  41241. * Are emissive textures enabled in the application.
  41242. */
  41243. static EmissiveTextureEnabled: boolean;
  41244. private static _SpecularTextureEnabled;
  41245. /**
  41246. * Are specular textures enabled in the application.
  41247. */
  41248. static SpecularTextureEnabled: boolean;
  41249. private static _BumpTextureEnabled;
  41250. /**
  41251. * Are bump textures enabled in the application.
  41252. */
  41253. static BumpTextureEnabled: boolean;
  41254. private static _LightmapTextureEnabled;
  41255. /**
  41256. * Are lightmap textures enabled in the application.
  41257. */
  41258. static LightmapTextureEnabled: boolean;
  41259. private static _RefractionTextureEnabled;
  41260. /**
  41261. * Are refraction textures enabled in the application.
  41262. */
  41263. static RefractionTextureEnabled: boolean;
  41264. private static _ColorGradingTextureEnabled;
  41265. /**
  41266. * Are color grading textures enabled in the application.
  41267. */
  41268. static ColorGradingTextureEnabled: boolean;
  41269. private static _FresnelEnabled;
  41270. /**
  41271. * Are fresnels enabled in the application.
  41272. */
  41273. static FresnelEnabled: boolean;
  41274. private static _ClearCoatTextureEnabled;
  41275. /**
  41276. * Are clear coat textures enabled in the application.
  41277. */
  41278. static ClearCoatTextureEnabled: boolean;
  41279. private static _ClearCoatBumpTextureEnabled;
  41280. /**
  41281. * Are clear coat bump textures enabled in the application.
  41282. */
  41283. static ClearCoatBumpTextureEnabled: boolean;
  41284. private static _ClearCoatTintTextureEnabled;
  41285. /**
  41286. * Are clear coat tint textures enabled in the application.
  41287. */
  41288. static ClearCoatTintTextureEnabled: boolean;
  41289. private static _SheenTextureEnabled;
  41290. /**
  41291. * Are sheen textures enabled in the application.
  41292. */
  41293. static SheenTextureEnabled: boolean;
  41294. private static _AnisotropicTextureEnabled;
  41295. /**
  41296. * Are anisotropic textures enabled in the application.
  41297. */
  41298. static AnisotropicTextureEnabled: boolean;
  41299. private static _ThicknessTextureEnabled;
  41300. /**
  41301. * Are thickness textures enabled in the application.
  41302. */
  41303. static ThicknessTextureEnabled: boolean;
  41304. }
  41305. }
  41306. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41307. /** @hidden */
  41308. export var defaultFragmentDeclaration: {
  41309. name: string;
  41310. shader: string;
  41311. };
  41312. }
  41313. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41314. /** @hidden */
  41315. export var defaultUboDeclaration: {
  41316. name: string;
  41317. shader: string;
  41318. };
  41319. }
  41320. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41321. /** @hidden */
  41322. export var lightFragmentDeclaration: {
  41323. name: string;
  41324. shader: string;
  41325. };
  41326. }
  41327. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41328. /** @hidden */
  41329. export var lightUboDeclaration: {
  41330. name: string;
  41331. shader: string;
  41332. };
  41333. }
  41334. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41335. /** @hidden */
  41336. export var lightsFragmentFunctions: {
  41337. name: string;
  41338. shader: string;
  41339. };
  41340. }
  41341. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41342. /** @hidden */
  41343. export var shadowsFragmentFunctions: {
  41344. name: string;
  41345. shader: string;
  41346. };
  41347. }
  41348. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41349. /** @hidden */
  41350. export var fresnelFunction: {
  41351. name: string;
  41352. shader: string;
  41353. };
  41354. }
  41355. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41356. /** @hidden */
  41357. export var reflectionFunction: {
  41358. name: string;
  41359. shader: string;
  41360. };
  41361. }
  41362. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41363. /** @hidden */
  41364. export var bumpFragmentFunctions: {
  41365. name: string;
  41366. shader: string;
  41367. };
  41368. }
  41369. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41370. /** @hidden */
  41371. export var logDepthDeclaration: {
  41372. name: string;
  41373. shader: string;
  41374. };
  41375. }
  41376. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41377. /** @hidden */
  41378. export var bumpFragment: {
  41379. name: string;
  41380. shader: string;
  41381. };
  41382. }
  41383. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41384. /** @hidden */
  41385. export var depthPrePass: {
  41386. name: string;
  41387. shader: string;
  41388. };
  41389. }
  41390. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41391. /** @hidden */
  41392. export var lightFragment: {
  41393. name: string;
  41394. shader: string;
  41395. };
  41396. }
  41397. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41398. /** @hidden */
  41399. export var logDepthFragment: {
  41400. name: string;
  41401. shader: string;
  41402. };
  41403. }
  41404. declare module "babylonjs/Shaders/default.fragment" {
  41405. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41406. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41407. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41408. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41409. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41410. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41411. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41412. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41413. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41414. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41415. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41416. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41417. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41418. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41419. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41420. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41421. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41422. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41423. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41424. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41425. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41426. /** @hidden */
  41427. export var defaultPixelShader: {
  41428. name: string;
  41429. shader: string;
  41430. };
  41431. }
  41432. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41433. /** @hidden */
  41434. export var defaultVertexDeclaration: {
  41435. name: string;
  41436. shader: string;
  41437. };
  41438. }
  41439. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41440. /** @hidden */
  41441. export var bumpVertexDeclaration: {
  41442. name: string;
  41443. shader: string;
  41444. };
  41445. }
  41446. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41447. /** @hidden */
  41448. export var bumpVertex: {
  41449. name: string;
  41450. shader: string;
  41451. };
  41452. }
  41453. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41454. /** @hidden */
  41455. export var fogVertex: {
  41456. name: string;
  41457. shader: string;
  41458. };
  41459. }
  41460. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41461. /** @hidden */
  41462. export var shadowsVertex: {
  41463. name: string;
  41464. shader: string;
  41465. };
  41466. }
  41467. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41468. /** @hidden */
  41469. export var pointCloudVertex: {
  41470. name: string;
  41471. shader: string;
  41472. };
  41473. }
  41474. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41475. /** @hidden */
  41476. export var logDepthVertex: {
  41477. name: string;
  41478. shader: string;
  41479. };
  41480. }
  41481. declare module "babylonjs/Shaders/default.vertex" {
  41482. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41483. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41484. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41485. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41486. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41487. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41488. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41489. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41490. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41491. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41493. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41494. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41495. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41496. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41497. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41498. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41499. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41500. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41501. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41502. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41503. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41504. /** @hidden */
  41505. export var defaultVertexShader: {
  41506. name: string;
  41507. shader: string;
  41508. };
  41509. }
  41510. declare module "babylonjs/Materials/standardMaterial" {
  41511. import { SmartArray } from "babylonjs/Misc/smartArray";
  41512. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41513. import { Nullable } from "babylonjs/types";
  41514. import { Scene } from "babylonjs/scene";
  41515. import { Matrix } from "babylonjs/Maths/math.vector";
  41516. import { Color3 } from "babylonjs/Maths/math.color";
  41517. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41518. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41519. import { Mesh } from "babylonjs/Meshes/mesh";
  41520. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41521. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41522. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41523. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41524. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41526. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41527. import "babylonjs/Shaders/default.fragment";
  41528. import "babylonjs/Shaders/default.vertex";
  41529. /** @hidden */
  41530. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41531. MAINUV1: boolean;
  41532. MAINUV2: boolean;
  41533. DIFFUSE: boolean;
  41534. DIFFUSEDIRECTUV: number;
  41535. AMBIENT: boolean;
  41536. AMBIENTDIRECTUV: number;
  41537. OPACITY: boolean;
  41538. OPACITYDIRECTUV: number;
  41539. OPACITYRGB: boolean;
  41540. REFLECTION: boolean;
  41541. EMISSIVE: boolean;
  41542. EMISSIVEDIRECTUV: number;
  41543. SPECULAR: boolean;
  41544. SPECULARDIRECTUV: number;
  41545. BUMP: boolean;
  41546. BUMPDIRECTUV: number;
  41547. PARALLAX: boolean;
  41548. PARALLAXOCCLUSION: boolean;
  41549. SPECULAROVERALPHA: boolean;
  41550. CLIPPLANE: boolean;
  41551. CLIPPLANE2: boolean;
  41552. CLIPPLANE3: boolean;
  41553. CLIPPLANE4: boolean;
  41554. ALPHATEST: boolean;
  41555. DEPTHPREPASS: boolean;
  41556. ALPHAFROMDIFFUSE: boolean;
  41557. POINTSIZE: boolean;
  41558. FOG: boolean;
  41559. SPECULARTERM: boolean;
  41560. DIFFUSEFRESNEL: boolean;
  41561. OPACITYFRESNEL: boolean;
  41562. REFLECTIONFRESNEL: boolean;
  41563. REFRACTIONFRESNEL: boolean;
  41564. EMISSIVEFRESNEL: boolean;
  41565. FRESNEL: boolean;
  41566. NORMAL: boolean;
  41567. UV1: boolean;
  41568. UV2: boolean;
  41569. VERTEXCOLOR: boolean;
  41570. VERTEXALPHA: boolean;
  41571. NUM_BONE_INFLUENCERS: number;
  41572. BonesPerMesh: number;
  41573. BONETEXTURE: boolean;
  41574. INSTANCES: boolean;
  41575. GLOSSINESS: boolean;
  41576. ROUGHNESS: boolean;
  41577. EMISSIVEASILLUMINATION: boolean;
  41578. LINKEMISSIVEWITHDIFFUSE: boolean;
  41579. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41580. LIGHTMAP: boolean;
  41581. LIGHTMAPDIRECTUV: number;
  41582. OBJECTSPACE_NORMALMAP: boolean;
  41583. USELIGHTMAPASSHADOWMAP: boolean;
  41584. REFLECTIONMAP_3D: boolean;
  41585. REFLECTIONMAP_SPHERICAL: boolean;
  41586. REFLECTIONMAP_PLANAR: boolean;
  41587. REFLECTIONMAP_CUBIC: boolean;
  41588. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41589. REFLECTIONMAP_PROJECTION: boolean;
  41590. REFLECTIONMAP_SKYBOX: boolean;
  41591. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41592. REFLECTIONMAP_EXPLICIT: boolean;
  41593. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41594. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41595. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41596. INVERTCUBICMAP: boolean;
  41597. LOGARITHMICDEPTH: boolean;
  41598. REFRACTION: boolean;
  41599. REFRACTIONMAP_3D: boolean;
  41600. REFLECTIONOVERALPHA: boolean;
  41601. TWOSIDEDLIGHTING: boolean;
  41602. SHADOWFLOAT: boolean;
  41603. MORPHTARGETS: boolean;
  41604. MORPHTARGETS_NORMAL: boolean;
  41605. MORPHTARGETS_TANGENT: boolean;
  41606. MORPHTARGETS_UV: boolean;
  41607. NUM_MORPH_INFLUENCERS: number;
  41608. NONUNIFORMSCALING: boolean;
  41609. PREMULTIPLYALPHA: boolean;
  41610. IMAGEPROCESSING: boolean;
  41611. VIGNETTE: boolean;
  41612. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41613. VIGNETTEBLENDMODEOPAQUE: boolean;
  41614. TONEMAPPING: boolean;
  41615. TONEMAPPING_ACES: boolean;
  41616. CONTRAST: boolean;
  41617. COLORCURVES: boolean;
  41618. COLORGRADING: boolean;
  41619. COLORGRADING3D: boolean;
  41620. SAMPLER3DGREENDEPTH: boolean;
  41621. SAMPLER3DBGRMAP: boolean;
  41622. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41623. MULTIVIEW: boolean;
  41624. /**
  41625. * If the reflection texture on this material is in linear color space
  41626. * @hidden
  41627. */
  41628. IS_REFLECTION_LINEAR: boolean;
  41629. /**
  41630. * If the refraction texture on this material is in linear color space
  41631. * @hidden
  41632. */
  41633. IS_REFRACTION_LINEAR: boolean;
  41634. EXPOSURE: boolean;
  41635. constructor();
  41636. setReflectionMode(modeToEnable: string): void;
  41637. }
  41638. /**
  41639. * This is the default material used in Babylon. It is the best trade off between quality
  41640. * and performances.
  41641. * @see http://doc.babylonjs.com/babylon101/materials
  41642. */
  41643. export class StandardMaterial extends PushMaterial {
  41644. private _diffuseTexture;
  41645. /**
  41646. * The basic texture of the material as viewed under a light.
  41647. */
  41648. diffuseTexture: Nullable<BaseTexture>;
  41649. private _ambientTexture;
  41650. /**
  41651. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41652. */
  41653. ambientTexture: Nullable<BaseTexture>;
  41654. private _opacityTexture;
  41655. /**
  41656. * Define the transparency of the material from a texture.
  41657. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41658. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41659. */
  41660. opacityTexture: Nullable<BaseTexture>;
  41661. private _reflectionTexture;
  41662. /**
  41663. * Define the texture used to display the reflection.
  41664. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41665. */
  41666. reflectionTexture: Nullable<BaseTexture>;
  41667. private _emissiveTexture;
  41668. /**
  41669. * Define texture of the material as if self lit.
  41670. * This will be mixed in the final result even in the absence of light.
  41671. */
  41672. emissiveTexture: Nullable<BaseTexture>;
  41673. private _specularTexture;
  41674. /**
  41675. * Define how the color and intensity of the highlight given by the light in the material.
  41676. */
  41677. specularTexture: Nullable<BaseTexture>;
  41678. private _bumpTexture;
  41679. /**
  41680. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41681. * 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.
  41682. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41683. */
  41684. bumpTexture: Nullable<BaseTexture>;
  41685. private _lightmapTexture;
  41686. /**
  41687. * Complex lighting can be computationally expensive to compute at runtime.
  41688. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41689. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41690. */
  41691. lightmapTexture: Nullable<BaseTexture>;
  41692. private _refractionTexture;
  41693. /**
  41694. * Define the texture used to display the refraction.
  41695. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41696. */
  41697. refractionTexture: Nullable<BaseTexture>;
  41698. /**
  41699. * The color of the material lit by the environmental background lighting.
  41700. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41701. */
  41702. ambientColor: Color3;
  41703. /**
  41704. * The basic color of the material as viewed under a light.
  41705. */
  41706. diffuseColor: Color3;
  41707. /**
  41708. * Define how the color and intensity of the highlight given by the light in the material.
  41709. */
  41710. specularColor: Color3;
  41711. /**
  41712. * Define the color of the material as if self lit.
  41713. * This will be mixed in the final result even in the absence of light.
  41714. */
  41715. emissiveColor: Color3;
  41716. /**
  41717. * Defines how sharp are the highlights in the material.
  41718. * The bigger the value the sharper giving a more glossy feeling to the result.
  41719. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41720. */
  41721. specularPower: number;
  41722. private _useAlphaFromDiffuseTexture;
  41723. /**
  41724. * Does the transparency come from the diffuse texture alpha channel.
  41725. */
  41726. useAlphaFromDiffuseTexture: boolean;
  41727. private _useEmissiveAsIllumination;
  41728. /**
  41729. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41730. */
  41731. useEmissiveAsIllumination: boolean;
  41732. private _linkEmissiveWithDiffuse;
  41733. /**
  41734. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41735. * the emissive level when the final color is close to one.
  41736. */
  41737. linkEmissiveWithDiffuse: boolean;
  41738. private _useSpecularOverAlpha;
  41739. /**
  41740. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41741. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41742. */
  41743. useSpecularOverAlpha: boolean;
  41744. private _useReflectionOverAlpha;
  41745. /**
  41746. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41747. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41748. */
  41749. useReflectionOverAlpha: boolean;
  41750. private _disableLighting;
  41751. /**
  41752. * Does lights from the scene impacts this material.
  41753. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41754. */
  41755. disableLighting: boolean;
  41756. private _useObjectSpaceNormalMap;
  41757. /**
  41758. * Allows using an object space normal map (instead of tangent space).
  41759. */
  41760. useObjectSpaceNormalMap: boolean;
  41761. private _useParallax;
  41762. /**
  41763. * Is parallax enabled or not.
  41764. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41765. */
  41766. useParallax: boolean;
  41767. private _useParallaxOcclusion;
  41768. /**
  41769. * Is parallax occlusion enabled or not.
  41770. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41771. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41772. */
  41773. useParallaxOcclusion: boolean;
  41774. /**
  41775. * 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.
  41776. */
  41777. parallaxScaleBias: number;
  41778. private _roughness;
  41779. /**
  41780. * Helps to define how blurry the reflections should appears in the material.
  41781. */
  41782. roughness: number;
  41783. /**
  41784. * In case of refraction, define the value of the index of refraction.
  41785. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41786. */
  41787. indexOfRefraction: number;
  41788. /**
  41789. * Invert the refraction texture alongside the y axis.
  41790. * It can be useful with procedural textures or probe for instance.
  41791. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41792. */
  41793. invertRefractionY: boolean;
  41794. /**
  41795. * Defines the alpha limits in alpha test mode.
  41796. */
  41797. alphaCutOff: number;
  41798. private _useLightmapAsShadowmap;
  41799. /**
  41800. * In case of light mapping, define whether the map contains light or shadow informations.
  41801. */
  41802. useLightmapAsShadowmap: boolean;
  41803. private _diffuseFresnelParameters;
  41804. /**
  41805. * Define the diffuse fresnel parameters of the material.
  41806. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41807. */
  41808. diffuseFresnelParameters: FresnelParameters;
  41809. private _opacityFresnelParameters;
  41810. /**
  41811. * Define the opacity fresnel parameters of the material.
  41812. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41813. */
  41814. opacityFresnelParameters: FresnelParameters;
  41815. private _reflectionFresnelParameters;
  41816. /**
  41817. * Define the reflection fresnel parameters of the material.
  41818. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41819. */
  41820. reflectionFresnelParameters: FresnelParameters;
  41821. private _refractionFresnelParameters;
  41822. /**
  41823. * Define the refraction fresnel parameters of the material.
  41824. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41825. */
  41826. refractionFresnelParameters: FresnelParameters;
  41827. private _emissiveFresnelParameters;
  41828. /**
  41829. * Define the emissive fresnel parameters of the material.
  41830. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41831. */
  41832. emissiveFresnelParameters: FresnelParameters;
  41833. private _useReflectionFresnelFromSpecular;
  41834. /**
  41835. * If true automatically deducts the fresnels values from the material specularity.
  41836. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41837. */
  41838. useReflectionFresnelFromSpecular: boolean;
  41839. private _useGlossinessFromSpecularMapAlpha;
  41840. /**
  41841. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41842. */
  41843. useGlossinessFromSpecularMapAlpha: boolean;
  41844. private _maxSimultaneousLights;
  41845. /**
  41846. * Defines the maximum number of lights that can be used in the material
  41847. */
  41848. maxSimultaneousLights: number;
  41849. private _invertNormalMapX;
  41850. /**
  41851. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41852. */
  41853. invertNormalMapX: boolean;
  41854. private _invertNormalMapY;
  41855. /**
  41856. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41857. */
  41858. invertNormalMapY: boolean;
  41859. private _twoSidedLighting;
  41860. /**
  41861. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41862. */
  41863. twoSidedLighting: boolean;
  41864. /**
  41865. * Default configuration related to image processing available in the standard Material.
  41866. */
  41867. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41868. /**
  41869. * Gets the image processing configuration used either in this material.
  41870. */
  41871. /**
  41872. * Sets the Default image processing configuration used either in the this material.
  41873. *
  41874. * If sets to null, the scene one is in use.
  41875. */
  41876. imageProcessingConfiguration: ImageProcessingConfiguration;
  41877. /**
  41878. * Keep track of the image processing observer to allow dispose and replace.
  41879. */
  41880. private _imageProcessingObserver;
  41881. /**
  41882. * Attaches a new image processing configuration to the Standard Material.
  41883. * @param configuration
  41884. */
  41885. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41886. /**
  41887. * Gets wether the color curves effect is enabled.
  41888. */
  41889. /**
  41890. * Sets wether the color curves effect is enabled.
  41891. */
  41892. cameraColorCurvesEnabled: boolean;
  41893. /**
  41894. * Gets wether the color grading effect is enabled.
  41895. */
  41896. /**
  41897. * Gets wether the color grading effect is enabled.
  41898. */
  41899. cameraColorGradingEnabled: boolean;
  41900. /**
  41901. * Gets wether tonemapping is enabled or not.
  41902. */
  41903. /**
  41904. * Sets wether tonemapping is enabled or not
  41905. */
  41906. cameraToneMappingEnabled: boolean;
  41907. /**
  41908. * The camera exposure used on this material.
  41909. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41910. * This corresponds to a photographic exposure.
  41911. */
  41912. /**
  41913. * The camera exposure used on this material.
  41914. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41915. * This corresponds to a photographic exposure.
  41916. */
  41917. cameraExposure: number;
  41918. /**
  41919. * Gets The camera contrast used on this material.
  41920. */
  41921. /**
  41922. * Sets The camera contrast used on this material.
  41923. */
  41924. cameraContrast: number;
  41925. /**
  41926. * Gets the Color Grading 2D Lookup Texture.
  41927. */
  41928. /**
  41929. * Sets the Color Grading 2D Lookup Texture.
  41930. */
  41931. cameraColorGradingTexture: Nullable<BaseTexture>;
  41932. /**
  41933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41935. * 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;
  41936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41937. */
  41938. /**
  41939. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41940. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41941. * 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;
  41942. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41943. */
  41944. cameraColorCurves: Nullable<ColorCurves>;
  41945. /**
  41946. * Custom callback helping to override the default shader used in the material.
  41947. */
  41948. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41949. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41950. protected _worldViewProjectionMatrix: Matrix;
  41951. protected _globalAmbientColor: Color3;
  41952. protected _useLogarithmicDepth: boolean;
  41953. protected _rebuildInParallel: boolean;
  41954. /**
  41955. * Instantiates a new standard material.
  41956. * This is the default material used in Babylon. It is the best trade off between quality
  41957. * and performances.
  41958. * @see http://doc.babylonjs.com/babylon101/materials
  41959. * @param name Define the name of the material in the scene
  41960. * @param scene Define the scene the material belong to
  41961. */
  41962. constructor(name: string, scene: Scene);
  41963. /**
  41964. * Gets a boolean indicating that current material needs to register RTT
  41965. */
  41966. readonly hasRenderTargetTextures: boolean;
  41967. /**
  41968. * Gets the current class name of the material e.g. "StandardMaterial"
  41969. * Mainly use in serialization.
  41970. * @returns the class name
  41971. */
  41972. getClassName(): string;
  41973. /**
  41974. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41975. * You can try switching to logarithmic depth.
  41976. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41977. */
  41978. useLogarithmicDepth: boolean;
  41979. /**
  41980. * Specifies if the material will require alpha blending
  41981. * @returns a boolean specifying if alpha blending is needed
  41982. */
  41983. needAlphaBlending(): boolean;
  41984. /**
  41985. * Specifies if this material should be rendered in alpha test mode
  41986. * @returns a boolean specifying if an alpha test is needed.
  41987. */
  41988. needAlphaTesting(): boolean;
  41989. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41990. /**
  41991. * Get the texture used for alpha test purpose.
  41992. * @returns the diffuse texture in case of the standard material.
  41993. */
  41994. getAlphaTestTexture(): Nullable<BaseTexture>;
  41995. /**
  41996. * Get if the submesh is ready to be used and all its information available.
  41997. * Child classes can use it to update shaders
  41998. * @param mesh defines the mesh to check
  41999. * @param subMesh defines which submesh to check
  42000. * @param useInstances specifies that instances should be used
  42001. * @returns a boolean indicating that the submesh is ready or not
  42002. */
  42003. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42004. /**
  42005. * Builds the material UBO layouts.
  42006. * Used internally during the effect preparation.
  42007. */
  42008. buildUniformLayout(): void;
  42009. /**
  42010. * Unbinds the material from the mesh
  42011. */
  42012. unbind(): void;
  42013. /**
  42014. * Binds the submesh to this material by preparing the effect and shader to draw
  42015. * @param world defines the world transformation matrix
  42016. * @param mesh defines the mesh containing the submesh
  42017. * @param subMesh defines the submesh to bind the material to
  42018. */
  42019. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42020. /**
  42021. * Get the list of animatables in the material.
  42022. * @returns the list of animatables object used in the material
  42023. */
  42024. getAnimatables(): IAnimatable[];
  42025. /**
  42026. * Gets the active textures from the material
  42027. * @returns an array of textures
  42028. */
  42029. getActiveTextures(): BaseTexture[];
  42030. /**
  42031. * Specifies if the material uses a texture
  42032. * @param texture defines the texture to check against the material
  42033. * @returns a boolean specifying if the material uses the texture
  42034. */
  42035. hasTexture(texture: BaseTexture): boolean;
  42036. /**
  42037. * Disposes the material
  42038. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42039. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42040. */
  42041. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42042. /**
  42043. * Makes a duplicate of the material, and gives it a new name
  42044. * @param name defines the new name for the duplicated material
  42045. * @returns the cloned material
  42046. */
  42047. clone(name: string): StandardMaterial;
  42048. /**
  42049. * Serializes this material in a JSON representation
  42050. * @returns the serialized material object
  42051. */
  42052. serialize(): any;
  42053. /**
  42054. * Creates a standard material from parsed material data
  42055. * @param source defines the JSON representation of the material
  42056. * @param scene defines the hosting scene
  42057. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42058. * @returns a new standard material
  42059. */
  42060. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42061. /**
  42062. * Are diffuse textures enabled in the application.
  42063. */
  42064. static DiffuseTextureEnabled: boolean;
  42065. /**
  42066. * Are ambient textures enabled in the application.
  42067. */
  42068. static AmbientTextureEnabled: boolean;
  42069. /**
  42070. * Are opacity textures enabled in the application.
  42071. */
  42072. static OpacityTextureEnabled: boolean;
  42073. /**
  42074. * Are reflection textures enabled in the application.
  42075. */
  42076. static ReflectionTextureEnabled: boolean;
  42077. /**
  42078. * Are emissive textures enabled in the application.
  42079. */
  42080. static EmissiveTextureEnabled: boolean;
  42081. /**
  42082. * Are specular textures enabled in the application.
  42083. */
  42084. static SpecularTextureEnabled: boolean;
  42085. /**
  42086. * Are bump textures enabled in the application.
  42087. */
  42088. static BumpTextureEnabled: boolean;
  42089. /**
  42090. * Are lightmap textures enabled in the application.
  42091. */
  42092. static LightmapTextureEnabled: boolean;
  42093. /**
  42094. * Are refraction textures enabled in the application.
  42095. */
  42096. static RefractionTextureEnabled: boolean;
  42097. /**
  42098. * Are color grading textures enabled in the application.
  42099. */
  42100. static ColorGradingTextureEnabled: boolean;
  42101. /**
  42102. * Are fresnels enabled in the application.
  42103. */
  42104. static FresnelEnabled: boolean;
  42105. }
  42106. }
  42107. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42108. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42109. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42110. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42111. /** @hidden */
  42112. export var imageProcessingPixelShader: {
  42113. name: string;
  42114. shader: string;
  42115. };
  42116. }
  42117. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42118. import { Nullable } from "babylonjs/types";
  42119. import { Color4 } from "babylonjs/Maths/math.color";
  42120. import { Camera } from "babylonjs/Cameras/camera";
  42121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42122. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42123. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42124. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42125. import { Engine } from "babylonjs/Engines/engine";
  42126. import "babylonjs/Shaders/imageProcessing.fragment";
  42127. import "babylonjs/Shaders/postprocess.vertex";
  42128. /**
  42129. * ImageProcessingPostProcess
  42130. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42131. */
  42132. export class ImageProcessingPostProcess extends PostProcess {
  42133. /**
  42134. * Default configuration related to image processing available in the PBR Material.
  42135. */
  42136. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42137. /**
  42138. * Gets the image processing configuration used either in this material.
  42139. */
  42140. /**
  42141. * Sets the Default image processing configuration used either in the this material.
  42142. *
  42143. * If sets to null, the scene one is in use.
  42144. */
  42145. imageProcessingConfiguration: ImageProcessingConfiguration;
  42146. /**
  42147. * Keep track of the image processing observer to allow dispose and replace.
  42148. */
  42149. private _imageProcessingObserver;
  42150. /**
  42151. * Attaches a new image processing configuration to the PBR Material.
  42152. * @param configuration
  42153. */
  42154. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42155. /**
  42156. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42157. */
  42158. /**
  42159. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42160. */
  42161. colorCurves: Nullable<ColorCurves>;
  42162. /**
  42163. * Gets wether the color curves effect is enabled.
  42164. */
  42165. /**
  42166. * Sets wether the color curves effect is enabled.
  42167. */
  42168. colorCurvesEnabled: boolean;
  42169. /**
  42170. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42171. */
  42172. /**
  42173. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42174. */
  42175. colorGradingTexture: Nullable<BaseTexture>;
  42176. /**
  42177. * Gets wether the color grading effect is enabled.
  42178. */
  42179. /**
  42180. * Gets wether the color grading effect is enabled.
  42181. */
  42182. colorGradingEnabled: boolean;
  42183. /**
  42184. * Gets exposure used in the effect.
  42185. */
  42186. /**
  42187. * Sets exposure used in the effect.
  42188. */
  42189. exposure: number;
  42190. /**
  42191. * Gets wether tonemapping is enabled or not.
  42192. */
  42193. /**
  42194. * Sets wether tonemapping is enabled or not
  42195. */
  42196. toneMappingEnabled: boolean;
  42197. /**
  42198. * Gets the type of tone mapping effect.
  42199. */
  42200. /**
  42201. * Sets the type of tone mapping effect.
  42202. */
  42203. toneMappingType: number;
  42204. /**
  42205. * Gets contrast used in the effect.
  42206. */
  42207. /**
  42208. * Sets contrast used in the effect.
  42209. */
  42210. contrast: number;
  42211. /**
  42212. * Gets Vignette stretch size.
  42213. */
  42214. /**
  42215. * Sets Vignette stretch size.
  42216. */
  42217. vignetteStretch: number;
  42218. /**
  42219. * Gets Vignette centre X Offset.
  42220. */
  42221. /**
  42222. * Sets Vignette centre X Offset.
  42223. */
  42224. vignetteCentreX: number;
  42225. /**
  42226. * Gets Vignette centre Y Offset.
  42227. */
  42228. /**
  42229. * Sets Vignette centre Y Offset.
  42230. */
  42231. vignetteCentreY: number;
  42232. /**
  42233. * Gets Vignette weight or intensity of the vignette effect.
  42234. */
  42235. /**
  42236. * Sets Vignette weight or intensity of the vignette effect.
  42237. */
  42238. vignetteWeight: number;
  42239. /**
  42240. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42241. * if vignetteEnabled is set to true.
  42242. */
  42243. /**
  42244. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42245. * if vignetteEnabled is set to true.
  42246. */
  42247. vignetteColor: Color4;
  42248. /**
  42249. * Gets Camera field of view used by the Vignette effect.
  42250. */
  42251. /**
  42252. * Sets Camera field of view used by the Vignette effect.
  42253. */
  42254. vignetteCameraFov: number;
  42255. /**
  42256. * Gets the vignette blend mode allowing different kind of effect.
  42257. */
  42258. /**
  42259. * Sets the vignette blend mode allowing different kind of effect.
  42260. */
  42261. vignetteBlendMode: number;
  42262. /**
  42263. * Gets wether the vignette effect is enabled.
  42264. */
  42265. /**
  42266. * Sets wether the vignette effect is enabled.
  42267. */
  42268. vignetteEnabled: boolean;
  42269. private _fromLinearSpace;
  42270. /**
  42271. * Gets wether the input of the processing is in Gamma or Linear Space.
  42272. */
  42273. /**
  42274. * Sets wether the input of the processing is in Gamma or Linear Space.
  42275. */
  42276. fromLinearSpace: boolean;
  42277. /**
  42278. * Defines cache preventing GC.
  42279. */
  42280. private _defines;
  42281. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42282. /**
  42283. * "ImageProcessingPostProcess"
  42284. * @returns "ImageProcessingPostProcess"
  42285. */
  42286. getClassName(): string;
  42287. protected _updateParameters(): void;
  42288. dispose(camera?: Camera): void;
  42289. }
  42290. }
  42291. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42292. import { Scene } from "babylonjs/scene";
  42293. import { Color3 } from "babylonjs/Maths/math.color";
  42294. import { Mesh } from "babylonjs/Meshes/mesh";
  42295. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42296. import { Nullable } from "babylonjs/types";
  42297. /**
  42298. * Class containing static functions to help procedurally build meshes
  42299. */
  42300. export class GroundBuilder {
  42301. /**
  42302. * Creates a ground mesh
  42303. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42304. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42306. * @param name defines the name of the mesh
  42307. * @param options defines the options used to create the mesh
  42308. * @param scene defines the hosting scene
  42309. * @returns the ground mesh
  42310. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42311. */
  42312. static CreateGround(name: string, options: {
  42313. width?: number;
  42314. height?: number;
  42315. subdivisions?: number;
  42316. subdivisionsX?: number;
  42317. subdivisionsY?: number;
  42318. updatable?: boolean;
  42319. }, scene: any): Mesh;
  42320. /**
  42321. * Creates a tiled ground mesh
  42322. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42323. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42324. * * 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
  42325. * * 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
  42326. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42327. * @param name defines the name of the mesh
  42328. * @param options defines the options used to create the mesh
  42329. * @param scene defines the hosting scene
  42330. * @returns the tiled ground mesh
  42331. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42332. */
  42333. static CreateTiledGround(name: string, options: {
  42334. xmin: number;
  42335. zmin: number;
  42336. xmax: number;
  42337. zmax: number;
  42338. subdivisions?: {
  42339. w: number;
  42340. h: number;
  42341. };
  42342. precision?: {
  42343. w: number;
  42344. h: number;
  42345. };
  42346. updatable?: boolean;
  42347. }, scene?: Nullable<Scene>): Mesh;
  42348. /**
  42349. * Creates a ground mesh from a height map
  42350. * * The parameter `url` sets the URL of the height map image resource.
  42351. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42352. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42353. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42354. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42355. * * 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.
  42356. * * 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).
  42357. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42359. * @param name defines the name of the mesh
  42360. * @param url defines the url to the height map
  42361. * @param options defines the options used to create the mesh
  42362. * @param scene defines the hosting scene
  42363. * @returns the ground mesh
  42364. * @see https://doc.babylonjs.com/babylon101/height_map
  42365. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42366. */
  42367. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42368. width?: number;
  42369. height?: number;
  42370. subdivisions?: number;
  42371. minHeight?: number;
  42372. maxHeight?: number;
  42373. colorFilter?: Color3;
  42374. alphaFilter?: number;
  42375. updatable?: boolean;
  42376. onReady?: (mesh: GroundMesh) => void;
  42377. }, scene?: Nullable<Scene>): GroundMesh;
  42378. }
  42379. }
  42380. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42381. import { Vector4 } from "babylonjs/Maths/math.vector";
  42382. import { Mesh } from "babylonjs/Meshes/mesh";
  42383. /**
  42384. * Class containing static functions to help procedurally build meshes
  42385. */
  42386. export class TorusBuilder {
  42387. /**
  42388. * Creates a torus mesh
  42389. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42390. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42391. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42395. * @param name defines the name of the mesh
  42396. * @param options defines the options used to create the mesh
  42397. * @param scene defines the hosting scene
  42398. * @returns the torus mesh
  42399. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42400. */
  42401. static CreateTorus(name: string, options: {
  42402. diameter?: number;
  42403. thickness?: number;
  42404. tessellation?: number;
  42405. updatable?: boolean;
  42406. sideOrientation?: number;
  42407. frontUVs?: Vector4;
  42408. backUVs?: Vector4;
  42409. }, scene: any): Mesh;
  42410. }
  42411. }
  42412. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42413. import { Vector4 } from "babylonjs/Maths/math.vector";
  42414. import { Color4 } from "babylonjs/Maths/math.color";
  42415. import { Mesh } from "babylonjs/Meshes/mesh";
  42416. /**
  42417. * Class containing static functions to help procedurally build meshes
  42418. */
  42419. export class CylinderBuilder {
  42420. /**
  42421. * Creates a cylinder or a cone mesh
  42422. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42423. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42424. * * 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.
  42425. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42426. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42427. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42428. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42429. * * 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).
  42430. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42431. * * 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).
  42432. * * 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
  42433. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42434. * * 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
  42435. * * 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.
  42436. * * If `enclose` is false, a ring surface is one element.
  42437. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42438. * * 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
  42439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42442. * @param name defines the name of the mesh
  42443. * @param options defines the options used to create the mesh
  42444. * @param scene defines the hosting scene
  42445. * @returns the cylinder mesh
  42446. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42447. */
  42448. static CreateCylinder(name: string, options: {
  42449. height?: number;
  42450. diameterTop?: number;
  42451. diameterBottom?: number;
  42452. diameter?: number;
  42453. tessellation?: number;
  42454. subdivisions?: number;
  42455. arc?: number;
  42456. faceColors?: Color4[];
  42457. faceUV?: Vector4[];
  42458. updatable?: boolean;
  42459. hasRings?: boolean;
  42460. enclose?: boolean;
  42461. cap?: number;
  42462. sideOrientation?: number;
  42463. frontUVs?: Vector4;
  42464. backUVs?: Vector4;
  42465. }, scene: any): Mesh;
  42466. }
  42467. }
  42468. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42469. import { Observable } from "babylonjs/Misc/observable";
  42470. import { Nullable } from "babylonjs/types";
  42471. import { Camera } from "babylonjs/Cameras/camera";
  42472. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42473. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42474. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42475. import { Scene } from "babylonjs/scene";
  42476. import { Vector3 } from "babylonjs/Maths/math.vector";
  42477. import { Color3 } from "babylonjs/Maths/math.color";
  42478. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42479. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42480. import { Mesh } from "babylonjs/Meshes/mesh";
  42481. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42482. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42483. import "babylonjs/Meshes/Builders/groundBuilder";
  42484. import "babylonjs/Meshes/Builders/torusBuilder";
  42485. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42486. import "babylonjs/Gamepads/gamepadSceneComponent";
  42487. import "babylonjs/Animations/animatable";
  42488. /**
  42489. * Options to modify the vr teleportation behavior.
  42490. */
  42491. export interface VRTeleportationOptions {
  42492. /**
  42493. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42494. */
  42495. floorMeshName?: string;
  42496. /**
  42497. * A list of meshes to be used as the teleportation floor. (default: empty)
  42498. */
  42499. floorMeshes?: Mesh[];
  42500. }
  42501. /**
  42502. * Options to modify the vr experience helper's behavior.
  42503. */
  42504. export interface VRExperienceHelperOptions extends WebVROptions {
  42505. /**
  42506. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42507. */
  42508. createDeviceOrientationCamera?: boolean;
  42509. /**
  42510. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42511. */
  42512. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42513. /**
  42514. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42515. */
  42516. laserToggle?: boolean;
  42517. /**
  42518. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42519. */
  42520. floorMeshes?: Mesh[];
  42521. /**
  42522. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42523. */
  42524. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42525. }
  42526. /**
  42527. * Event containing information after VR has been entered
  42528. */
  42529. export class OnAfterEnteringVRObservableEvent {
  42530. /**
  42531. * If entering vr was successful
  42532. */
  42533. success: boolean;
  42534. }
  42535. /**
  42536. * Helps to quickly add VR support to an existing scene.
  42537. * See http://doc.babylonjs.com/how_to/webvr_helper
  42538. */
  42539. export class VRExperienceHelper {
  42540. /** Options to modify the vr experience helper's behavior. */
  42541. webVROptions: VRExperienceHelperOptions;
  42542. private _scene;
  42543. private _position;
  42544. private _btnVR;
  42545. private _btnVRDisplayed;
  42546. private _webVRsupported;
  42547. private _webVRready;
  42548. private _webVRrequesting;
  42549. private _webVRpresenting;
  42550. private _hasEnteredVR;
  42551. private _fullscreenVRpresenting;
  42552. private _canvas;
  42553. private _webVRCamera;
  42554. private _vrDeviceOrientationCamera;
  42555. private _deviceOrientationCamera;
  42556. private _existingCamera;
  42557. private _onKeyDown;
  42558. private _onVrDisplayPresentChange;
  42559. private _onVRDisplayChanged;
  42560. private _onVRRequestPresentStart;
  42561. private _onVRRequestPresentComplete;
  42562. /**
  42563. * 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)
  42564. */
  42565. enableGazeEvenWhenNoPointerLock: boolean;
  42566. /**
  42567. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42568. */
  42569. exitVROnDoubleTap: boolean;
  42570. /**
  42571. * Observable raised right before entering VR.
  42572. */
  42573. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42574. /**
  42575. * Observable raised when entering VR has completed.
  42576. */
  42577. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42578. /**
  42579. * Observable raised when exiting VR.
  42580. */
  42581. onExitingVRObservable: Observable<VRExperienceHelper>;
  42582. /**
  42583. * Observable raised when controller mesh is loaded.
  42584. */
  42585. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42586. /** Return this.onEnteringVRObservable
  42587. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42588. */
  42589. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42590. /** Return this.onExitingVRObservable
  42591. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42592. */
  42593. readonly onExitingVR: Observable<VRExperienceHelper>;
  42594. /** Return this.onControllerMeshLoadedObservable
  42595. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42596. */
  42597. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42598. private _rayLength;
  42599. private _useCustomVRButton;
  42600. private _teleportationRequested;
  42601. private _teleportActive;
  42602. private _floorMeshName;
  42603. private _floorMeshesCollection;
  42604. private _rotationAllowed;
  42605. private _teleportBackwardsVector;
  42606. private _teleportationTarget;
  42607. private _isDefaultTeleportationTarget;
  42608. private _postProcessMove;
  42609. private _teleportationFillColor;
  42610. private _teleportationBorderColor;
  42611. private _rotationAngle;
  42612. private _haloCenter;
  42613. private _cameraGazer;
  42614. private _padSensibilityUp;
  42615. private _padSensibilityDown;
  42616. private _leftController;
  42617. private _rightController;
  42618. /**
  42619. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42620. */
  42621. onNewMeshSelected: Observable<AbstractMesh>;
  42622. /**
  42623. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42624. * This observable will provide the mesh and the controller used to select the mesh
  42625. */
  42626. onMeshSelectedWithController: Observable<{
  42627. mesh: AbstractMesh;
  42628. controller: WebVRController;
  42629. }>;
  42630. /**
  42631. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42632. */
  42633. onNewMeshPicked: Observable<PickingInfo>;
  42634. private _circleEase;
  42635. /**
  42636. * Observable raised before camera teleportation
  42637. */
  42638. onBeforeCameraTeleport: Observable<Vector3>;
  42639. /**
  42640. * Observable raised after camera teleportation
  42641. */
  42642. onAfterCameraTeleport: Observable<Vector3>;
  42643. /**
  42644. * Observable raised when current selected mesh gets unselected
  42645. */
  42646. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42647. private _raySelectionPredicate;
  42648. /**
  42649. * To be optionaly changed by user to define custom ray selection
  42650. */
  42651. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42652. /**
  42653. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42654. */
  42655. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42656. /**
  42657. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42658. */
  42659. teleportationEnabled: boolean;
  42660. private _defaultHeight;
  42661. private _teleportationInitialized;
  42662. private _interactionsEnabled;
  42663. private _interactionsRequested;
  42664. private _displayGaze;
  42665. private _displayLaserPointer;
  42666. /**
  42667. * The mesh used to display where the user is going to teleport.
  42668. */
  42669. /**
  42670. * Sets the mesh to be used to display where the user is going to teleport.
  42671. */
  42672. teleportationTarget: Mesh;
  42673. /**
  42674. * 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
  42675. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42676. * See http://doc.babylonjs.com/resources/baking_transformations
  42677. */
  42678. gazeTrackerMesh: Mesh;
  42679. /**
  42680. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42681. */
  42682. updateGazeTrackerScale: boolean;
  42683. /**
  42684. * If the gaze trackers color should be updated when selecting meshes
  42685. */
  42686. updateGazeTrackerColor: boolean;
  42687. /**
  42688. * If the controller laser color should be updated when selecting meshes
  42689. */
  42690. updateControllerLaserColor: boolean;
  42691. /**
  42692. * The gaze tracking mesh corresponding to the left controller
  42693. */
  42694. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42695. /**
  42696. * The gaze tracking mesh corresponding to the right controller
  42697. */
  42698. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42699. /**
  42700. * If the ray of the gaze should be displayed.
  42701. */
  42702. /**
  42703. * Sets if the ray of the gaze should be displayed.
  42704. */
  42705. displayGaze: boolean;
  42706. /**
  42707. * If the ray of the LaserPointer should be displayed.
  42708. */
  42709. /**
  42710. * Sets if the ray of the LaserPointer should be displayed.
  42711. */
  42712. displayLaserPointer: boolean;
  42713. /**
  42714. * The deviceOrientationCamera used as the camera when not in VR.
  42715. */
  42716. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42717. /**
  42718. * Based on the current WebVR support, returns the current VR camera used.
  42719. */
  42720. readonly currentVRCamera: Nullable<Camera>;
  42721. /**
  42722. * The webVRCamera which is used when in VR.
  42723. */
  42724. readonly webVRCamera: WebVRFreeCamera;
  42725. /**
  42726. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42727. */
  42728. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42729. /**
  42730. * The html button that is used to trigger entering into VR.
  42731. */
  42732. readonly vrButton: Nullable<HTMLButtonElement>;
  42733. private readonly _teleportationRequestInitiated;
  42734. /**
  42735. * Defines wether or not Pointer lock should be requested when switching to
  42736. * full screen.
  42737. */
  42738. requestPointerLockOnFullScreen: boolean;
  42739. /**
  42740. * Instantiates a VRExperienceHelper.
  42741. * Helps to quickly add VR support to an existing scene.
  42742. * @param scene The scene the VRExperienceHelper belongs to.
  42743. * @param webVROptions Options to modify the vr experience helper's behavior.
  42744. */
  42745. constructor(scene: Scene,
  42746. /** Options to modify the vr experience helper's behavior. */
  42747. webVROptions?: VRExperienceHelperOptions);
  42748. private _onDefaultMeshLoaded;
  42749. private _onResize;
  42750. private _onFullscreenChange;
  42751. /**
  42752. * Gets a value indicating if we are currently in VR mode.
  42753. */
  42754. readonly isInVRMode: boolean;
  42755. private onVrDisplayPresentChange;
  42756. private onVRDisplayChanged;
  42757. private moveButtonToBottomRight;
  42758. private displayVRButton;
  42759. private updateButtonVisibility;
  42760. private _cachedAngularSensibility;
  42761. /**
  42762. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42763. * Otherwise, will use the fullscreen API.
  42764. */
  42765. enterVR(): void;
  42766. /**
  42767. * Attempt to exit VR, or fullscreen.
  42768. */
  42769. exitVR(): void;
  42770. /**
  42771. * The position of the vr experience helper.
  42772. */
  42773. /**
  42774. * Sets the position of the vr experience helper.
  42775. */
  42776. position: Vector3;
  42777. /**
  42778. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42779. */
  42780. enableInteractions(): void;
  42781. private readonly _noControllerIsActive;
  42782. private beforeRender;
  42783. private _isTeleportationFloor;
  42784. /**
  42785. * Adds a floor mesh to be used for teleportation.
  42786. * @param floorMesh the mesh to be used for teleportation.
  42787. */
  42788. addFloorMesh(floorMesh: Mesh): void;
  42789. /**
  42790. * Removes a floor mesh from being used for teleportation.
  42791. * @param floorMesh the mesh to be removed.
  42792. */
  42793. removeFloorMesh(floorMesh: Mesh): void;
  42794. /**
  42795. * Enables interactions and teleportation using the VR controllers and gaze.
  42796. * @param vrTeleportationOptions options to modify teleportation behavior.
  42797. */
  42798. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42799. private _onNewGamepadConnected;
  42800. private _tryEnableInteractionOnController;
  42801. private _onNewGamepadDisconnected;
  42802. private _enableInteractionOnController;
  42803. private _checkTeleportWithRay;
  42804. private _checkRotate;
  42805. private _checkTeleportBackwards;
  42806. private _enableTeleportationOnController;
  42807. private _createTeleportationCircles;
  42808. private _displayTeleportationTarget;
  42809. private _hideTeleportationTarget;
  42810. private _rotateCamera;
  42811. private _moveTeleportationSelectorTo;
  42812. private _workingVector;
  42813. private _workingQuaternion;
  42814. private _workingMatrix;
  42815. /**
  42816. * Teleports the users feet to the desired location
  42817. * @param location The location where the user's feet should be placed
  42818. */
  42819. teleportCamera(location: Vector3): void;
  42820. private _convertNormalToDirectionOfRay;
  42821. private _castRayAndSelectObject;
  42822. private _notifySelectedMeshUnselected;
  42823. /**
  42824. * Sets the color of the laser ray from the vr controllers.
  42825. * @param color new color for the ray.
  42826. */
  42827. changeLaserColor(color: Color3): void;
  42828. /**
  42829. * Sets the color of the ray from the vr headsets gaze.
  42830. * @param color new color for the ray.
  42831. */
  42832. changeGazeColor(color: Color3): void;
  42833. /**
  42834. * Exits VR and disposes of the vr experience helper
  42835. */
  42836. dispose(): void;
  42837. /**
  42838. * Gets the name of the VRExperienceHelper class
  42839. * @returns "VRExperienceHelper"
  42840. */
  42841. getClassName(): string;
  42842. }
  42843. }
  42844. declare module "babylonjs/Cameras/VR/index" {
  42845. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42846. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42847. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42848. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42849. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42850. export * from "babylonjs/Cameras/VR/webVRCamera";
  42851. }
  42852. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42853. import { Observable } from "babylonjs/Misc/observable";
  42854. import { Nullable } from "babylonjs/types";
  42855. import { IDisposable, Scene } from "babylonjs/scene";
  42856. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42857. /**
  42858. * Manages an XRSession to work with Babylon's engine
  42859. * @see https://doc.babylonjs.com/how_to/webxr
  42860. */
  42861. export class WebXRSessionManager implements IDisposable {
  42862. private scene;
  42863. /**
  42864. * Fires every time a new xrFrame arrives which can be used to update the camera
  42865. */
  42866. onXRFrameObservable: Observable<any>;
  42867. /**
  42868. * Fires when the xr session is ended either by the device or manually done
  42869. */
  42870. onXRSessionEnded: Observable<any>;
  42871. /**
  42872. * Underlying xr session
  42873. */
  42874. session: XRSession;
  42875. /**
  42876. * Type of reference space used when creating the session
  42877. */
  42878. referenceSpace: XRReferenceSpace;
  42879. /** @hidden */
  42880. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42881. /**
  42882. * Current XR frame
  42883. */
  42884. currentFrame: Nullable<XRFrame>;
  42885. private _xrNavigator;
  42886. private baseLayer;
  42887. /**
  42888. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42889. * @param scene The scene which the session should be created for
  42890. */
  42891. constructor(scene: Scene);
  42892. /**
  42893. * Initializes the manager
  42894. * After initialization enterXR can be called to start an XR session
  42895. * @returns Promise which resolves after it is initialized
  42896. */
  42897. initializeAsync(): Promise<void>;
  42898. /**
  42899. * Initializes an xr session
  42900. * @param xrSessionMode mode to initialize
  42901. * @returns a promise which will resolve once the session has been initialized
  42902. */
  42903. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42904. /**
  42905. * Sets the reference space on the xr session
  42906. * @param referenceSpace space to set
  42907. * @returns a promise that will resolve once the reference space has been set
  42908. */
  42909. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42910. /**
  42911. * Updates the render state of the session
  42912. * @param state state to set
  42913. * @returns a promise that resolves once the render state has been updated
  42914. */
  42915. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42916. /**
  42917. * Starts rendering to the xr layer
  42918. * @returns a promise that will resolve once rendering has started
  42919. */
  42920. startRenderingToXRAsync(): Promise<void>;
  42921. /**
  42922. * Stops the xrSession and restores the renderloop
  42923. * @returns Promise which resolves after it exits XR
  42924. */
  42925. exitXRAsync(): Promise<unknown>;
  42926. /**
  42927. * Checks if a session would be supported for the creation options specified
  42928. * @param sessionMode session mode to check if supported eg. immersive-vr
  42929. * @returns true if supported
  42930. */
  42931. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42932. /**
  42933. * @hidden
  42934. * Converts the render layer of xrSession to a render target
  42935. * @param session session to create render target for
  42936. * @param scene scene the new render target should be created for
  42937. */
  42938. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42939. /**
  42940. * Disposes of the session manager
  42941. */
  42942. dispose(): void;
  42943. }
  42944. }
  42945. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42946. import { Scene } from "babylonjs/scene";
  42947. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42948. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42949. /**
  42950. * WebXR Camera which holds the views for the xrSession
  42951. * @see https://doc.babylonjs.com/how_to/webxr
  42952. */
  42953. export class WebXRCamera extends FreeCamera {
  42954. private static _TmpMatrix;
  42955. /**
  42956. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42957. * @param name the name of the camera
  42958. * @param scene the scene to add the camera to
  42959. */
  42960. constructor(name: string, scene: Scene);
  42961. private _updateNumberOfRigCameras;
  42962. /** @hidden */
  42963. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42964. /**
  42965. * Updates the cameras position from the current pose information of the XR session
  42966. * @param xrSessionManager the session containing pose information
  42967. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42968. */
  42969. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42970. }
  42971. }
  42972. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42973. import { Nullable } from "babylonjs/types";
  42974. import { IDisposable } from "babylonjs/scene";
  42975. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42976. /**
  42977. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42978. */
  42979. export class WebXRManagedOutputCanvas implements IDisposable {
  42980. private helper;
  42981. private _canvas;
  42982. /**
  42983. * xrpresent context of the canvas which can be used to display/mirror xr content
  42984. */
  42985. canvasContext: WebGLRenderingContext;
  42986. /**
  42987. * xr layer for the canvas
  42988. */
  42989. xrLayer: Nullable<XRWebGLLayer>;
  42990. /**
  42991. * Initializes the xr layer for the session
  42992. * @param xrSession xr session
  42993. * @returns a promise that will resolve once the XR Layer has been created
  42994. */
  42995. initializeXRLayerAsync(xrSession: any): any;
  42996. /**
  42997. * Initializes the canvas to be added/removed upon entering/exiting xr
  42998. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42999. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43000. */
  43001. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43002. /**
  43003. * Disposes of the object
  43004. */
  43005. dispose(): void;
  43006. private _setManagedOutputCanvas;
  43007. private _addCanvas;
  43008. private _removeCanvas;
  43009. }
  43010. }
  43011. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43012. import { Observable } from "babylonjs/Misc/observable";
  43013. import { IDisposable, Scene } from "babylonjs/scene";
  43014. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43016. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43017. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43018. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43019. /**
  43020. * States of the webXR experience
  43021. */
  43022. export enum WebXRState {
  43023. /**
  43024. * Transitioning to being in XR mode
  43025. */
  43026. ENTERING_XR = 0,
  43027. /**
  43028. * Transitioning to non XR mode
  43029. */
  43030. EXITING_XR = 1,
  43031. /**
  43032. * In XR mode and presenting
  43033. */
  43034. IN_XR = 2,
  43035. /**
  43036. * Not entered XR mode
  43037. */
  43038. NOT_IN_XR = 3
  43039. }
  43040. /**
  43041. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43042. * @see https://doc.babylonjs.com/how_to/webxr
  43043. */
  43044. export class WebXRExperienceHelper implements IDisposable {
  43045. private scene;
  43046. /**
  43047. * 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
  43048. */
  43049. container: AbstractMesh;
  43050. /**
  43051. * Camera used to render xr content
  43052. */
  43053. camera: WebXRCamera;
  43054. /**
  43055. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43056. */
  43057. state: WebXRState;
  43058. private _setState;
  43059. private static _TmpVector;
  43060. /**
  43061. * Fires when the state of the experience helper has changed
  43062. */
  43063. onStateChangedObservable: Observable<WebXRState>;
  43064. /** Session manager used to keep track of xr session */
  43065. sessionManager: WebXRSessionManager;
  43066. private _nonVRCamera;
  43067. private _originalSceneAutoClear;
  43068. private _supported;
  43069. /**
  43070. * Creates the experience helper
  43071. * @param scene the scene to attach the experience helper to
  43072. * @returns a promise for the experience helper
  43073. */
  43074. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43075. /**
  43076. * Creates a WebXRExperienceHelper
  43077. * @param scene The scene the helper should be created in
  43078. */
  43079. private constructor();
  43080. /**
  43081. * Exits XR mode and returns the scene to its original state
  43082. * @returns promise that resolves after xr mode has exited
  43083. */
  43084. exitXRAsync(): Promise<unknown>;
  43085. /**
  43086. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43087. * @param sessionCreationOptions options for the XR session
  43088. * @param referenceSpaceType frame of reference of the XR session
  43089. * @param outputCanvas the output canvas that will be used to enter XR mode
  43090. * @returns promise that resolves after xr mode has entered
  43091. */
  43092. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43093. /**
  43094. * Updates the global position of the camera by moving the camera's container
  43095. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43096. * @param position The desired global position of the camera
  43097. */
  43098. setPositionOfCameraUsingContainer(position: Vector3): void;
  43099. /**
  43100. * Rotates the xr camera by rotating the camera's container around the camera's position
  43101. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43102. * @param rotation the desired quaternion rotation to apply to the camera
  43103. */
  43104. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43105. /**
  43106. * Disposes of the experience helper
  43107. */
  43108. dispose(): void;
  43109. }
  43110. }
  43111. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43112. import { Nullable } from "babylonjs/types";
  43113. import { Observable } from "babylonjs/Misc/observable";
  43114. import { IDisposable, Scene } from "babylonjs/scene";
  43115. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43116. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43117. /**
  43118. * Button which can be used to enter a different mode of XR
  43119. */
  43120. export class WebXREnterExitUIButton {
  43121. /** button element */
  43122. element: HTMLElement;
  43123. /** XR initialization options for the button */
  43124. sessionMode: XRSessionMode;
  43125. /** Reference space type */
  43126. referenceSpaceType: XRReferenceSpaceType;
  43127. /**
  43128. * Creates a WebXREnterExitUIButton
  43129. * @param element button element
  43130. * @param sessionMode XR initialization session mode
  43131. * @param referenceSpaceType the type of reference space to be used
  43132. */
  43133. constructor(
  43134. /** button element */
  43135. element: HTMLElement,
  43136. /** XR initialization options for the button */
  43137. sessionMode: XRSessionMode,
  43138. /** Reference space type */
  43139. referenceSpaceType: XRReferenceSpaceType);
  43140. /**
  43141. * Overwritable function which can be used to update the button's visuals when the state changes
  43142. * @param activeButton the current active button in the UI
  43143. */
  43144. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43145. }
  43146. /**
  43147. * Options to create the webXR UI
  43148. */
  43149. export class WebXREnterExitUIOptions {
  43150. /**
  43151. * Context to enter xr with
  43152. */
  43153. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43154. /**
  43155. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43156. */
  43157. customButtons?: Array<WebXREnterExitUIButton>;
  43158. }
  43159. /**
  43160. * UI to allow the user to enter/exit XR mode
  43161. */
  43162. export class WebXREnterExitUI implements IDisposable {
  43163. private scene;
  43164. private _overlay;
  43165. private _buttons;
  43166. private _activeButton;
  43167. /**
  43168. * Fired every time the active button is changed.
  43169. *
  43170. * When xr is entered via a button that launches xr that button will be the callback parameter
  43171. *
  43172. * When exiting xr the callback parameter will be null)
  43173. */
  43174. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43175. /**
  43176. * Creates UI to allow the user to enter/exit XR mode
  43177. * @param scene the scene to add the ui to
  43178. * @param helper the xr experience helper to enter/exit xr with
  43179. * @param options options to configure the UI
  43180. * @returns the created ui
  43181. */
  43182. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43183. private constructor();
  43184. private _updateButtons;
  43185. /**
  43186. * Disposes of the object
  43187. */
  43188. dispose(): void;
  43189. }
  43190. }
  43191. declare module "babylonjs/Cameras/XR/webXRController" {
  43192. import { Nullable } from "babylonjs/types";
  43193. import { Observable } from "babylonjs/Misc/observable";
  43194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43195. import { Ray } from "babylonjs/Culling/ray";
  43196. import { Scene } from "babylonjs/scene";
  43197. /**
  43198. * Represents an XR input
  43199. */
  43200. export class WebXRController {
  43201. private scene;
  43202. /** The underlying input source for the controller */
  43203. inputSource: XRInputSource;
  43204. private parentContainer;
  43205. /**
  43206. * 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
  43207. */
  43208. grip?: AbstractMesh;
  43209. /**
  43210. * Pointer which can be used to select objects or attach a visible laser to
  43211. */
  43212. pointer: AbstractMesh;
  43213. /**
  43214. * Event that fires when the controller is removed/disposed
  43215. */
  43216. onDisposeObservable: Observable<{}>;
  43217. private _tmpMatrix;
  43218. private _tmpQuaternion;
  43219. private _tmpVector;
  43220. /**
  43221. * Creates the controller
  43222. * @see https://doc.babylonjs.com/how_to/webxr
  43223. * @param scene the scene which the controller should be associated to
  43224. * @param inputSource the underlying input source for the controller
  43225. * @param parentContainer parent that the controller meshes should be children of
  43226. */
  43227. constructor(scene: Scene,
  43228. /** The underlying input source for the controller */
  43229. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43230. /**
  43231. * Updates the controller pose based on the given XRFrame
  43232. * @param xrFrame xr frame to update the pose with
  43233. * @param referenceSpace reference space to use
  43234. */
  43235. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43236. /**
  43237. * Gets a world space ray coming from the controller
  43238. * @param result the resulting ray
  43239. */
  43240. getWorldPointerRayToRef(result: Ray): void;
  43241. /**
  43242. * Disposes of the object
  43243. */
  43244. dispose(): void;
  43245. }
  43246. }
  43247. declare module "babylonjs/Cameras/XR/webXRInput" {
  43248. import { Observable } from "babylonjs/Misc/observable";
  43249. import { IDisposable } from "babylonjs/scene";
  43250. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43251. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43252. /**
  43253. * XR input used to track XR inputs such as controllers/rays
  43254. */
  43255. export class WebXRInput implements IDisposable {
  43256. /**
  43257. * Base experience the input listens to
  43258. */
  43259. baseExperience: WebXRExperienceHelper;
  43260. /**
  43261. * XR controllers being tracked
  43262. */
  43263. controllers: Array<WebXRController>;
  43264. private _frameObserver;
  43265. private _stateObserver;
  43266. /**
  43267. * Event when a controller has been connected/added
  43268. */
  43269. onControllerAddedObservable: Observable<WebXRController>;
  43270. /**
  43271. * Event when a controller has been removed/disconnected
  43272. */
  43273. onControllerRemovedObservable: Observable<WebXRController>;
  43274. /**
  43275. * Initializes the WebXRInput
  43276. * @param baseExperience experience helper which the input should be created for
  43277. */
  43278. constructor(
  43279. /**
  43280. * Base experience the input listens to
  43281. */
  43282. baseExperience: WebXRExperienceHelper);
  43283. private _onInputSourcesChange;
  43284. private _addAndRemoveControllers;
  43285. /**
  43286. * Disposes of the object
  43287. */
  43288. dispose(): void;
  43289. }
  43290. }
  43291. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43293. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43294. /**
  43295. * Enables teleportation
  43296. */
  43297. export class WebXRControllerTeleportation {
  43298. private _teleportationFillColor;
  43299. private _teleportationBorderColor;
  43300. private _tmpRay;
  43301. private _tmpVector;
  43302. /**
  43303. * Creates a WebXRControllerTeleportation
  43304. * @param input input manager to add teleportation to
  43305. * @param floorMeshes floormeshes which can be teleported to
  43306. */
  43307. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43308. }
  43309. }
  43310. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43311. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43312. /**
  43313. * Handles pointer input automatically for the pointer of XR controllers
  43314. */
  43315. export class WebXRControllerPointerSelection {
  43316. private static _idCounter;
  43317. private _tmpRay;
  43318. /**
  43319. * Creates a WebXRControllerPointerSelection
  43320. * @param input input manager to setup pointer selection
  43321. */
  43322. constructor(input: WebXRInput);
  43323. private _convertNormalToDirectionOfRay;
  43324. private _updatePointerDistance;
  43325. }
  43326. }
  43327. declare module "babylonjs/Loading/sceneLoader" {
  43328. import { Observable } from "babylonjs/Misc/observable";
  43329. import { Nullable } from "babylonjs/types";
  43330. import { Scene } from "babylonjs/scene";
  43331. import { Engine } from "babylonjs/Engines/engine";
  43332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43333. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43334. import { AssetContainer } from "babylonjs/assetContainer";
  43335. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43336. import { Skeleton } from "babylonjs/Bones/skeleton";
  43337. /**
  43338. * Class used to represent data loading progression
  43339. */
  43340. export class SceneLoaderProgressEvent {
  43341. /** defines if data length to load can be evaluated */
  43342. readonly lengthComputable: boolean;
  43343. /** defines the loaded data length */
  43344. readonly loaded: number;
  43345. /** defines the data length to load */
  43346. readonly total: number;
  43347. /**
  43348. * Create a new progress event
  43349. * @param lengthComputable defines if data length to load can be evaluated
  43350. * @param loaded defines the loaded data length
  43351. * @param total defines the data length to load
  43352. */
  43353. constructor(
  43354. /** defines if data length to load can be evaluated */
  43355. lengthComputable: boolean,
  43356. /** defines the loaded data length */
  43357. loaded: number,
  43358. /** defines the data length to load */
  43359. total: number);
  43360. /**
  43361. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43362. * @param event defines the source event
  43363. * @returns a new SceneLoaderProgressEvent
  43364. */
  43365. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43366. }
  43367. /**
  43368. * Interface used by SceneLoader plugins to define supported file extensions
  43369. */
  43370. export interface ISceneLoaderPluginExtensions {
  43371. /**
  43372. * Defines the list of supported extensions
  43373. */
  43374. [extension: string]: {
  43375. isBinary: boolean;
  43376. };
  43377. }
  43378. /**
  43379. * Interface used by SceneLoader plugin factory
  43380. */
  43381. export interface ISceneLoaderPluginFactory {
  43382. /**
  43383. * Defines the name of the factory
  43384. */
  43385. name: string;
  43386. /**
  43387. * Function called to create a new plugin
  43388. * @return the new plugin
  43389. */
  43390. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43391. /**
  43392. * Boolean indicating if the plugin can direct load specific data
  43393. */
  43394. canDirectLoad?: (data: string) => boolean;
  43395. }
  43396. /**
  43397. * Interface used to define a SceneLoader plugin
  43398. */
  43399. export interface ISceneLoaderPlugin {
  43400. /**
  43401. * The friendly name of this plugin.
  43402. */
  43403. name: string;
  43404. /**
  43405. * The file extensions supported by this plugin.
  43406. */
  43407. extensions: string | ISceneLoaderPluginExtensions;
  43408. /**
  43409. * Import meshes into a scene.
  43410. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43411. * @param scene The scene to import into
  43412. * @param data The data to import
  43413. * @param rootUrl The root url for scene and resources
  43414. * @param meshes The meshes array to import into
  43415. * @param particleSystems The particle systems array to import into
  43416. * @param skeletons The skeletons array to import into
  43417. * @param onError The callback when import fails
  43418. * @returns True if successful or false otherwise
  43419. */
  43420. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43421. /**
  43422. * Load into a scene.
  43423. * @param scene The scene to load into
  43424. * @param data The data to import
  43425. * @param rootUrl The root url for scene and resources
  43426. * @param onError The callback when import fails
  43427. * @returns true if successful or false otherwise
  43428. */
  43429. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43430. /**
  43431. * The callback that returns true if the data can be directly loaded.
  43432. */
  43433. canDirectLoad?: (data: string) => boolean;
  43434. /**
  43435. * The callback that allows custom handling of the root url based on the response url.
  43436. */
  43437. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43438. /**
  43439. * Load into an asset container.
  43440. * @param scene The scene to load into
  43441. * @param data The data to import
  43442. * @param rootUrl The root url for scene and resources
  43443. * @param onError The callback when import fails
  43444. * @returns The loaded asset container
  43445. */
  43446. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43447. }
  43448. /**
  43449. * Interface used to define an async SceneLoader plugin
  43450. */
  43451. export interface ISceneLoaderPluginAsync {
  43452. /**
  43453. * The friendly name of this plugin.
  43454. */
  43455. name: string;
  43456. /**
  43457. * The file extensions supported by this plugin.
  43458. */
  43459. extensions: string | ISceneLoaderPluginExtensions;
  43460. /**
  43461. * Import meshes into a scene.
  43462. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43463. * @param scene The scene to import into
  43464. * @param data The data to import
  43465. * @param rootUrl The root url for scene and resources
  43466. * @param onProgress The callback when the load progresses
  43467. * @param fileName Defines the name of the file to load
  43468. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43469. */
  43470. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43471. meshes: AbstractMesh[];
  43472. particleSystems: IParticleSystem[];
  43473. skeletons: Skeleton[];
  43474. animationGroups: AnimationGroup[];
  43475. }>;
  43476. /**
  43477. * Load into a scene.
  43478. * @param scene The scene to load into
  43479. * @param data The data to import
  43480. * @param rootUrl The root url for scene and resources
  43481. * @param onProgress The callback when the load progresses
  43482. * @param fileName Defines the name of the file to load
  43483. * @returns Nothing
  43484. */
  43485. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43486. /**
  43487. * The callback that returns true if the data can be directly loaded.
  43488. */
  43489. canDirectLoad?: (data: string) => boolean;
  43490. /**
  43491. * The callback that allows custom handling of the root url based on the response url.
  43492. */
  43493. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43494. /**
  43495. * Load into an asset container.
  43496. * @param scene The scene to load into
  43497. * @param data The data to import
  43498. * @param rootUrl The root url for scene and resources
  43499. * @param onProgress The callback when the load progresses
  43500. * @param fileName Defines the name of the file to load
  43501. * @returns The loaded asset container
  43502. */
  43503. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43504. }
  43505. /**
  43506. * Class used to load scene from various file formats using registered plugins
  43507. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43508. */
  43509. export class SceneLoader {
  43510. /**
  43511. * No logging while loading
  43512. */
  43513. static readonly NO_LOGGING: number;
  43514. /**
  43515. * Minimal logging while loading
  43516. */
  43517. static readonly MINIMAL_LOGGING: number;
  43518. /**
  43519. * Summary logging while loading
  43520. */
  43521. static readonly SUMMARY_LOGGING: number;
  43522. /**
  43523. * Detailled logging while loading
  43524. */
  43525. static readonly DETAILED_LOGGING: number;
  43526. /**
  43527. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43528. */
  43529. static ForceFullSceneLoadingForIncremental: boolean;
  43530. /**
  43531. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43532. */
  43533. static ShowLoadingScreen: boolean;
  43534. /**
  43535. * Defines the current logging level (while loading the scene)
  43536. * @ignorenaming
  43537. */
  43538. static loggingLevel: number;
  43539. /**
  43540. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43541. */
  43542. static CleanBoneMatrixWeights: boolean;
  43543. /**
  43544. * Event raised when a plugin is used to load a scene
  43545. */
  43546. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43547. private static _registeredPlugins;
  43548. private static _getDefaultPlugin;
  43549. private static _getPluginForExtension;
  43550. private static _getPluginForDirectLoad;
  43551. private static _getPluginForFilename;
  43552. private static _getDirectLoad;
  43553. private static _loadData;
  43554. private static _getFileInfo;
  43555. /**
  43556. * Gets a plugin that can load the given extension
  43557. * @param extension defines the extension to load
  43558. * @returns a plugin or null if none works
  43559. */
  43560. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43561. /**
  43562. * Gets a boolean indicating that the given extension can be loaded
  43563. * @param extension defines the extension to load
  43564. * @returns true if the extension is supported
  43565. */
  43566. static IsPluginForExtensionAvailable(extension: string): boolean;
  43567. /**
  43568. * Adds a new plugin to the list of registered plugins
  43569. * @param plugin defines the plugin to add
  43570. */
  43571. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43572. /**
  43573. * Import meshes into a scene
  43574. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43575. * @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)
  43576. * @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)
  43577. * @param scene the instance of BABYLON.Scene to append to
  43578. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43579. * @param onProgress a callback with a progress event for each file being loaded
  43580. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43581. * @param pluginExtension the extension used to determine the plugin
  43582. * @returns The loaded plugin
  43583. */
  43584. 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>;
  43585. /**
  43586. * Import meshes into a scene
  43587. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43588. * @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)
  43589. * @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)
  43590. * @param scene the instance of BABYLON.Scene to append to
  43591. * @param onProgress a callback with a progress event for each file being loaded
  43592. * @param pluginExtension the extension used to determine the plugin
  43593. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43594. */
  43595. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43596. meshes: AbstractMesh[];
  43597. particleSystems: IParticleSystem[];
  43598. skeletons: Skeleton[];
  43599. animationGroups: AnimationGroup[];
  43600. }>;
  43601. /**
  43602. * Load a scene
  43603. * @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)
  43604. * @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)
  43605. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43606. * @param onSuccess a callback with the scene when import succeeds
  43607. * @param onProgress a callback with a progress event for each file being loaded
  43608. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43609. * @param pluginExtension the extension used to determine the plugin
  43610. * @returns The loaded plugin
  43611. */
  43612. 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>;
  43613. /**
  43614. * Load a scene
  43615. * @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)
  43616. * @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)
  43617. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43618. * @param onProgress a callback with a progress event for each file being loaded
  43619. * @param pluginExtension the extension used to determine the plugin
  43620. * @returns The loaded scene
  43621. */
  43622. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43623. /**
  43624. * Append a scene
  43625. * @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)
  43626. * @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)
  43627. * @param scene is the instance of BABYLON.Scene to append to
  43628. * @param onSuccess a callback with the scene when import succeeds
  43629. * @param onProgress a callback with a progress event for each file being loaded
  43630. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43631. * @param pluginExtension the extension used to determine the plugin
  43632. * @returns The loaded plugin
  43633. */
  43634. 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>;
  43635. /**
  43636. * Append a scene
  43637. * @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)
  43638. * @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)
  43639. * @param scene is the instance of BABYLON.Scene to append to
  43640. * @param onProgress a callback with a progress event for each file being loaded
  43641. * @param pluginExtension the extension used to determine the plugin
  43642. * @returns The given scene
  43643. */
  43644. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43645. /**
  43646. * Load a scene into an asset container
  43647. * @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)
  43648. * @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)
  43649. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43650. * @param onSuccess a callback with the scene when import succeeds
  43651. * @param onProgress a callback with a progress event for each file being loaded
  43652. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43653. * @param pluginExtension the extension used to determine the plugin
  43654. * @returns The loaded plugin
  43655. */
  43656. 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>;
  43657. /**
  43658. * Load a scene into an asset container
  43659. * @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)
  43660. * @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)
  43661. * @param scene is the instance of Scene to append to
  43662. * @param onProgress a callback with a progress event for each file being loaded
  43663. * @param pluginExtension the extension used to determine the plugin
  43664. * @returns The loaded asset container
  43665. */
  43666. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43667. }
  43668. }
  43669. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43670. import { Scene } from "babylonjs/scene";
  43671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43672. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43673. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43674. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43675. /**
  43676. * Generic Controller
  43677. */
  43678. export class GenericController extends WebVRController {
  43679. /**
  43680. * Base Url for the controller model.
  43681. */
  43682. static readonly MODEL_BASE_URL: string;
  43683. /**
  43684. * File name for the controller model.
  43685. */
  43686. static readonly MODEL_FILENAME: string;
  43687. /**
  43688. * Creates a new GenericController from a gamepad
  43689. * @param vrGamepad the gamepad that the controller should be created from
  43690. */
  43691. constructor(vrGamepad: any);
  43692. /**
  43693. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43694. * @param scene scene in which to add meshes
  43695. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43696. */
  43697. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43698. /**
  43699. * Called once for each button that changed state since the last frame
  43700. * @param buttonIdx Which button index changed
  43701. * @param state New state of the button
  43702. * @param changes Which properties on the state changed since last frame
  43703. */
  43704. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43705. }
  43706. }
  43707. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43708. import { Observable } from "babylonjs/Misc/observable";
  43709. import { Scene } from "babylonjs/scene";
  43710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43711. import { Ray } from "babylonjs/Culling/ray";
  43712. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43713. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43714. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43715. /**
  43716. * Defines the WindowsMotionController object that the state of the windows motion controller
  43717. */
  43718. export class WindowsMotionController extends WebVRController {
  43719. /**
  43720. * The base url used to load the left and right controller models
  43721. */
  43722. static MODEL_BASE_URL: string;
  43723. /**
  43724. * The name of the left controller model file
  43725. */
  43726. static MODEL_LEFT_FILENAME: string;
  43727. /**
  43728. * The name of the right controller model file
  43729. */
  43730. static MODEL_RIGHT_FILENAME: string;
  43731. /**
  43732. * The controller name prefix for this controller type
  43733. */
  43734. static readonly GAMEPAD_ID_PREFIX: string;
  43735. /**
  43736. * The controller id pattern for this controller type
  43737. */
  43738. private static readonly GAMEPAD_ID_PATTERN;
  43739. private _loadedMeshInfo;
  43740. private readonly _mapping;
  43741. /**
  43742. * Fired when the trackpad on this controller is clicked
  43743. */
  43744. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43745. /**
  43746. * Fired when the trackpad on this controller is modified
  43747. */
  43748. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43749. /**
  43750. * The current x and y values of this controller's trackpad
  43751. */
  43752. trackpad: StickValues;
  43753. /**
  43754. * Creates a new WindowsMotionController from a gamepad
  43755. * @param vrGamepad the gamepad that the controller should be created from
  43756. */
  43757. constructor(vrGamepad: any);
  43758. /**
  43759. * Fired when the trigger on this controller is modified
  43760. */
  43761. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43762. /**
  43763. * Fired when the menu button on this controller is modified
  43764. */
  43765. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43766. /**
  43767. * Fired when the grip button on this controller is modified
  43768. */
  43769. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43770. /**
  43771. * Fired when the thumbstick button on this controller is modified
  43772. */
  43773. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43774. /**
  43775. * Fired when the touchpad button on this controller is modified
  43776. */
  43777. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43778. /**
  43779. * Fired when the touchpad values on this controller are modified
  43780. */
  43781. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43782. private _updateTrackpad;
  43783. /**
  43784. * Called once per frame by the engine.
  43785. */
  43786. update(): void;
  43787. /**
  43788. * Called once for each button that changed state since the last frame
  43789. * @param buttonIdx Which button index changed
  43790. * @param state New state of the button
  43791. * @param changes Which properties on the state changed since last frame
  43792. */
  43793. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43794. /**
  43795. * Moves the buttons on the controller mesh based on their current state
  43796. * @param buttonName the name of the button to move
  43797. * @param buttonValue the value of the button which determines the buttons new position
  43798. */
  43799. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43800. /**
  43801. * Moves the axis on the controller mesh based on its current state
  43802. * @param axis the index of the axis
  43803. * @param axisValue the value of the axis which determines the meshes new position
  43804. * @hidden
  43805. */
  43806. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43807. /**
  43808. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43809. * @param scene scene in which to add meshes
  43810. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43811. */
  43812. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43813. /**
  43814. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43815. * can be transformed by button presses and axes values, based on this._mapping.
  43816. *
  43817. * @param scene scene in which the meshes exist
  43818. * @param meshes list of meshes that make up the controller model to process
  43819. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43820. */
  43821. private processModel;
  43822. private createMeshInfo;
  43823. /**
  43824. * Gets the ray of the controller in the direction the controller is pointing
  43825. * @param length the length the resulting ray should be
  43826. * @returns a ray in the direction the controller is pointing
  43827. */
  43828. getForwardRay(length?: number): Ray;
  43829. /**
  43830. * Disposes of the controller
  43831. */
  43832. dispose(): void;
  43833. }
  43834. }
  43835. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43836. import { Observable } from "babylonjs/Misc/observable";
  43837. import { Scene } from "babylonjs/scene";
  43838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43839. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43840. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43841. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43842. /**
  43843. * Oculus Touch Controller
  43844. */
  43845. export class OculusTouchController extends WebVRController {
  43846. /**
  43847. * Base Url for the controller model.
  43848. */
  43849. static MODEL_BASE_URL: string;
  43850. /**
  43851. * File name for the left controller model.
  43852. */
  43853. static MODEL_LEFT_FILENAME: string;
  43854. /**
  43855. * File name for the right controller model.
  43856. */
  43857. static MODEL_RIGHT_FILENAME: string;
  43858. /**
  43859. * Base Url for the Quest controller model.
  43860. */
  43861. static QUEST_MODEL_BASE_URL: string;
  43862. /**
  43863. * @hidden
  43864. * If the controllers are running on a device that needs the updated Quest controller models
  43865. */
  43866. static _IsQuest: boolean;
  43867. /**
  43868. * Fired when the secondary trigger on this controller is modified
  43869. */
  43870. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43871. /**
  43872. * Fired when the thumb rest on this controller is modified
  43873. */
  43874. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43875. /**
  43876. * Creates a new OculusTouchController from a gamepad
  43877. * @param vrGamepad the gamepad that the controller should be created from
  43878. */
  43879. constructor(vrGamepad: any);
  43880. /**
  43881. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43882. * @param scene scene in which to add meshes
  43883. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43884. */
  43885. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43886. /**
  43887. * Fired when the A button on this controller is modified
  43888. */
  43889. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43890. /**
  43891. * Fired when the B button on this controller is modified
  43892. */
  43893. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43894. /**
  43895. * Fired when the X button on this controller is modified
  43896. */
  43897. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43898. /**
  43899. * Fired when the Y button on this controller is modified
  43900. */
  43901. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43902. /**
  43903. * Called once for each button that changed state since the last frame
  43904. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43905. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43906. * 2) secondary trigger (same)
  43907. * 3) A (right) X (left), touch, pressed = value
  43908. * 4) B / Y
  43909. * 5) thumb rest
  43910. * @param buttonIdx Which button index changed
  43911. * @param state New state of the button
  43912. * @param changes Which properties on the state changed since last frame
  43913. */
  43914. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43915. }
  43916. }
  43917. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43918. import { Scene } from "babylonjs/scene";
  43919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43920. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43921. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43922. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43923. import { Observable } from "babylonjs/Misc/observable";
  43924. /**
  43925. * Vive Controller
  43926. */
  43927. export class ViveController extends WebVRController {
  43928. /**
  43929. * Base Url for the controller model.
  43930. */
  43931. static MODEL_BASE_URL: string;
  43932. /**
  43933. * File name for the controller model.
  43934. */
  43935. static MODEL_FILENAME: string;
  43936. /**
  43937. * Creates a new ViveController from a gamepad
  43938. * @param vrGamepad the gamepad that the controller should be created from
  43939. */
  43940. constructor(vrGamepad: any);
  43941. /**
  43942. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43943. * @param scene scene in which to add meshes
  43944. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43945. */
  43946. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43947. /**
  43948. * Fired when the left button on this controller is modified
  43949. */
  43950. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43951. /**
  43952. * Fired when the right button on this controller is modified
  43953. */
  43954. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43955. /**
  43956. * Fired when the menu button on this controller is modified
  43957. */
  43958. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43959. /**
  43960. * Called once for each button that changed state since the last frame
  43961. * Vive mapping:
  43962. * 0: touchpad
  43963. * 1: trigger
  43964. * 2: left AND right buttons
  43965. * 3: menu button
  43966. * @param buttonIdx Which button index changed
  43967. * @param state New state of the button
  43968. * @param changes Which properties on the state changed since last frame
  43969. */
  43970. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43971. }
  43972. }
  43973. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43974. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43975. /**
  43976. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43977. */
  43978. export class WebXRControllerModelLoader {
  43979. /**
  43980. * Creates the WebXRControllerModelLoader
  43981. * @param input xr input that creates the controllers
  43982. */
  43983. constructor(input: WebXRInput);
  43984. }
  43985. }
  43986. declare module "babylonjs/Cameras/XR/index" {
  43987. export * from "babylonjs/Cameras/XR/webXRCamera";
  43988. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43989. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43990. export * from "babylonjs/Cameras/XR/webXRInput";
  43991. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43992. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43993. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43994. export * from "babylonjs/Cameras/XR/webXRController";
  43995. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43996. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43997. }
  43998. declare module "babylonjs/Cameras/RigModes/index" {
  43999. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44000. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44001. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44002. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44003. }
  44004. declare module "babylonjs/Cameras/index" {
  44005. export * from "babylonjs/Cameras/Inputs/index";
  44006. export * from "babylonjs/Cameras/cameraInputsManager";
  44007. export * from "babylonjs/Cameras/camera";
  44008. export * from "babylonjs/Cameras/targetCamera";
  44009. export * from "babylonjs/Cameras/freeCamera";
  44010. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44011. export * from "babylonjs/Cameras/touchCamera";
  44012. export * from "babylonjs/Cameras/arcRotateCamera";
  44013. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44014. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44015. export * from "babylonjs/Cameras/flyCamera";
  44016. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44017. export * from "babylonjs/Cameras/followCamera";
  44018. export * from "babylonjs/Cameras/followCameraInputsManager";
  44019. export * from "babylonjs/Cameras/gamepadCamera";
  44020. export * from "babylonjs/Cameras/Stereoscopic/index";
  44021. export * from "babylonjs/Cameras/universalCamera";
  44022. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44023. export * from "babylonjs/Cameras/VR/index";
  44024. export * from "babylonjs/Cameras/XR/index";
  44025. export * from "babylonjs/Cameras/RigModes/index";
  44026. }
  44027. declare module "babylonjs/Collisions/index" {
  44028. export * from "babylonjs/Collisions/collider";
  44029. export * from "babylonjs/Collisions/collisionCoordinator";
  44030. export * from "babylonjs/Collisions/pickingInfo";
  44031. export * from "babylonjs/Collisions/intersectionInfo";
  44032. export * from "babylonjs/Collisions/meshCollisionData";
  44033. }
  44034. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44035. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44036. import { Vector3 } from "babylonjs/Maths/math.vector";
  44037. import { Ray } from "babylonjs/Culling/ray";
  44038. import { Plane } from "babylonjs/Maths/math.plane";
  44039. /**
  44040. * Contains an array of blocks representing the octree
  44041. */
  44042. export interface IOctreeContainer<T> {
  44043. /**
  44044. * Blocks within the octree
  44045. */
  44046. blocks: Array<OctreeBlock<T>>;
  44047. }
  44048. /**
  44049. * Class used to store a cell in an octree
  44050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44051. */
  44052. export class OctreeBlock<T> {
  44053. /**
  44054. * Gets the content of the current block
  44055. */
  44056. entries: T[];
  44057. /**
  44058. * Gets the list of block children
  44059. */
  44060. blocks: Array<OctreeBlock<T>>;
  44061. private _depth;
  44062. private _maxDepth;
  44063. private _capacity;
  44064. private _minPoint;
  44065. private _maxPoint;
  44066. private _boundingVectors;
  44067. private _creationFunc;
  44068. /**
  44069. * Creates a new block
  44070. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44071. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44072. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44073. * @param depth defines the current depth of this block in the octree
  44074. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44075. * @param creationFunc defines a callback to call when an element is added to the block
  44076. */
  44077. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44078. /**
  44079. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44080. */
  44081. readonly capacity: number;
  44082. /**
  44083. * Gets the minimum vector (in world space) of the block's bounding box
  44084. */
  44085. readonly minPoint: Vector3;
  44086. /**
  44087. * Gets the maximum vector (in world space) of the block's bounding box
  44088. */
  44089. readonly maxPoint: Vector3;
  44090. /**
  44091. * Add a new element to this block
  44092. * @param entry defines the element to add
  44093. */
  44094. addEntry(entry: T): void;
  44095. /**
  44096. * Remove an element from this block
  44097. * @param entry defines the element to remove
  44098. */
  44099. removeEntry(entry: T): void;
  44100. /**
  44101. * Add an array of elements to this block
  44102. * @param entries defines the array of elements to add
  44103. */
  44104. addEntries(entries: T[]): void;
  44105. /**
  44106. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44107. * @param frustumPlanes defines the frustum planes to test
  44108. * @param selection defines the array to store current content if selection is positive
  44109. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44110. */
  44111. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44112. /**
  44113. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44114. * @param sphereCenter defines the bounding sphere center
  44115. * @param sphereRadius defines the bounding sphere radius
  44116. * @param selection defines the array to store current content if selection is positive
  44117. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44118. */
  44119. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44120. /**
  44121. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44122. * @param ray defines the ray to test with
  44123. * @param selection defines the array to store current content if selection is positive
  44124. */
  44125. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44126. /**
  44127. * Subdivide the content into child blocks (this block will then be empty)
  44128. */
  44129. createInnerBlocks(): void;
  44130. /**
  44131. * @hidden
  44132. */
  44133. 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;
  44134. }
  44135. }
  44136. declare module "babylonjs/Culling/Octrees/octree" {
  44137. import { SmartArray } from "babylonjs/Misc/smartArray";
  44138. import { Vector3 } from "babylonjs/Maths/math.vector";
  44139. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44141. import { Ray } from "babylonjs/Culling/ray";
  44142. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44143. import { Plane } from "babylonjs/Maths/math.plane";
  44144. /**
  44145. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44146. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44147. */
  44148. export class Octree<T> {
  44149. /** 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.) */
  44150. maxDepth: number;
  44151. /**
  44152. * Blocks within the octree containing objects
  44153. */
  44154. blocks: Array<OctreeBlock<T>>;
  44155. /**
  44156. * Content stored in the octree
  44157. */
  44158. dynamicContent: T[];
  44159. private _maxBlockCapacity;
  44160. private _selectionContent;
  44161. private _creationFunc;
  44162. /**
  44163. * Creates a octree
  44164. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44165. * @param creationFunc function to be used to instatiate the octree
  44166. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44167. * @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.)
  44168. */
  44169. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44170. /** 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.) */
  44171. maxDepth?: number);
  44172. /**
  44173. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44174. * @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);
  44175. * @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);
  44176. * @param entries meshes to be added to the octree blocks
  44177. */
  44178. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44179. /**
  44180. * Adds a mesh to the octree
  44181. * @param entry Mesh to add to the octree
  44182. */
  44183. addMesh(entry: T): void;
  44184. /**
  44185. * Remove an element from the octree
  44186. * @param entry defines the element to remove
  44187. */
  44188. removeMesh(entry: T): void;
  44189. /**
  44190. * Selects an array of meshes within the frustum
  44191. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44192. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44193. * @returns array of meshes within the frustum
  44194. */
  44195. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44196. /**
  44197. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44198. * @param sphereCenter defines the bounding sphere center
  44199. * @param sphereRadius defines the bounding sphere radius
  44200. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44201. * @returns an array of objects that intersect the sphere
  44202. */
  44203. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44204. /**
  44205. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44206. * @param ray defines the ray to test with
  44207. * @returns array of intersected objects
  44208. */
  44209. intersectsRay(ray: Ray): SmartArray<T>;
  44210. /**
  44211. * Adds a mesh into the octree block if it intersects the block
  44212. */
  44213. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44214. /**
  44215. * Adds a submesh into the octree block if it intersects the block
  44216. */
  44217. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44218. }
  44219. }
  44220. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44221. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44222. import { Scene } from "babylonjs/scene";
  44223. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44225. import { Ray } from "babylonjs/Culling/ray";
  44226. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44227. import { Collider } from "babylonjs/Collisions/collider";
  44228. module "babylonjs/scene" {
  44229. interface Scene {
  44230. /**
  44231. * @hidden
  44232. * Backing Filed
  44233. */
  44234. _selectionOctree: Octree<AbstractMesh>;
  44235. /**
  44236. * Gets the octree used to boost mesh selection (picking)
  44237. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44238. */
  44239. selectionOctree: Octree<AbstractMesh>;
  44240. /**
  44241. * Creates or updates the octree used to boost selection (picking)
  44242. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44243. * @param maxCapacity defines the maximum capacity per leaf
  44244. * @param maxDepth defines the maximum depth of the octree
  44245. * @returns an octree of AbstractMesh
  44246. */
  44247. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44248. }
  44249. }
  44250. module "babylonjs/Meshes/abstractMesh" {
  44251. interface AbstractMesh {
  44252. /**
  44253. * @hidden
  44254. * Backing Field
  44255. */
  44256. _submeshesOctree: Octree<SubMesh>;
  44257. /**
  44258. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44259. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44260. * @param maxCapacity defines the maximum size of each block (64 by default)
  44261. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44262. * @returns the new octree
  44263. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44264. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44265. */
  44266. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44267. }
  44268. }
  44269. /**
  44270. * Defines the octree scene component responsible to manage any octrees
  44271. * in a given scene.
  44272. */
  44273. export class OctreeSceneComponent {
  44274. /**
  44275. * The component name help to identify the component in the list of scene components.
  44276. */
  44277. readonly name: string;
  44278. /**
  44279. * The scene the component belongs to.
  44280. */
  44281. scene: Scene;
  44282. /**
  44283. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44284. */
  44285. readonly checksIsEnabled: boolean;
  44286. /**
  44287. * Creates a new instance of the component for the given scene
  44288. * @param scene Defines the scene to register the component in
  44289. */
  44290. constructor(scene: Scene);
  44291. /**
  44292. * Registers the component in a given scene
  44293. */
  44294. register(): void;
  44295. /**
  44296. * Return the list of active meshes
  44297. * @returns the list of active meshes
  44298. */
  44299. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44300. /**
  44301. * Return the list of active sub meshes
  44302. * @param mesh The mesh to get the candidates sub meshes from
  44303. * @returns the list of active sub meshes
  44304. */
  44305. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44306. private _tempRay;
  44307. /**
  44308. * Return the list of sub meshes intersecting with a given local ray
  44309. * @param mesh defines the mesh to find the submesh for
  44310. * @param localRay defines the ray in local space
  44311. * @returns the list of intersecting sub meshes
  44312. */
  44313. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44314. /**
  44315. * Return the list of sub meshes colliding with a collider
  44316. * @param mesh defines the mesh to find the submesh for
  44317. * @param collider defines the collider to evaluate the collision against
  44318. * @returns the list of colliding sub meshes
  44319. */
  44320. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44321. /**
  44322. * Rebuilds the elements related to this component in case of
  44323. * context lost for instance.
  44324. */
  44325. rebuild(): void;
  44326. /**
  44327. * Disposes the component and the associated ressources.
  44328. */
  44329. dispose(): void;
  44330. }
  44331. }
  44332. declare module "babylonjs/Culling/Octrees/index" {
  44333. export * from "babylonjs/Culling/Octrees/octree";
  44334. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44335. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44336. }
  44337. declare module "babylonjs/Culling/index" {
  44338. export * from "babylonjs/Culling/boundingBox";
  44339. export * from "babylonjs/Culling/boundingInfo";
  44340. export * from "babylonjs/Culling/boundingSphere";
  44341. export * from "babylonjs/Culling/Octrees/index";
  44342. export * from "babylonjs/Culling/ray";
  44343. }
  44344. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44345. import { IDisposable, Scene } from "babylonjs/scene";
  44346. import { Nullable } from "babylonjs/types";
  44347. import { Observable } from "babylonjs/Misc/observable";
  44348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44349. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44350. import { Camera } from "babylonjs/Cameras/camera";
  44351. /**
  44352. * Renders a layer on top of an existing scene
  44353. */
  44354. export class UtilityLayerRenderer implements IDisposable {
  44355. /** the original scene that will be rendered on top of */
  44356. originalScene: Scene;
  44357. private _pointerCaptures;
  44358. private _lastPointerEvents;
  44359. private static _DefaultUtilityLayer;
  44360. private static _DefaultKeepDepthUtilityLayer;
  44361. private _sharedGizmoLight;
  44362. private _renderCamera;
  44363. /**
  44364. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44365. * @returns the camera that is used when rendering the utility layer
  44366. */
  44367. getRenderCamera(): Nullable<Camera>;
  44368. /**
  44369. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44370. * @param cam the camera that should be used when rendering the utility layer
  44371. */
  44372. setRenderCamera(cam: Nullable<Camera>): void;
  44373. /**
  44374. * @hidden
  44375. * Light which used by gizmos to get light shading
  44376. */
  44377. _getSharedGizmoLight(): HemisphericLight;
  44378. /**
  44379. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44380. */
  44381. pickUtilitySceneFirst: boolean;
  44382. /**
  44383. * 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)
  44384. */
  44385. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44386. /**
  44387. * 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)
  44388. */
  44389. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44390. /**
  44391. * The scene that is rendered on top of the original scene
  44392. */
  44393. utilityLayerScene: Scene;
  44394. /**
  44395. * If the utility layer should automatically be rendered on top of existing scene
  44396. */
  44397. shouldRender: boolean;
  44398. /**
  44399. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44400. */
  44401. onlyCheckPointerDownEvents: boolean;
  44402. /**
  44403. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44404. */
  44405. processAllEvents: boolean;
  44406. /**
  44407. * Observable raised when the pointer move from the utility layer scene to the main scene
  44408. */
  44409. onPointerOutObservable: Observable<number>;
  44410. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44411. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44412. private _afterRenderObserver;
  44413. private _sceneDisposeObserver;
  44414. private _originalPointerObserver;
  44415. /**
  44416. * Instantiates a UtilityLayerRenderer
  44417. * @param originalScene the original scene that will be rendered on top of
  44418. * @param handleEvents boolean indicating if the utility layer should handle events
  44419. */
  44420. constructor(
  44421. /** the original scene that will be rendered on top of */
  44422. originalScene: Scene, handleEvents?: boolean);
  44423. private _notifyObservers;
  44424. /**
  44425. * Renders the utility layers scene on top of the original scene
  44426. */
  44427. render(): void;
  44428. /**
  44429. * Disposes of the renderer
  44430. */
  44431. dispose(): void;
  44432. private _updateCamera;
  44433. }
  44434. }
  44435. declare module "babylonjs/Gizmos/gizmo" {
  44436. import { Nullable } from "babylonjs/types";
  44437. import { IDisposable } from "babylonjs/scene";
  44438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44439. import { Mesh } from "babylonjs/Meshes/mesh";
  44440. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44441. /**
  44442. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44443. */
  44444. export class Gizmo implements IDisposable {
  44445. /** The utility layer the gizmo will be added to */
  44446. gizmoLayer: UtilityLayerRenderer;
  44447. /**
  44448. * The root mesh of the gizmo
  44449. */
  44450. _rootMesh: Mesh;
  44451. private _attachedMesh;
  44452. /**
  44453. * Ratio for the scale of the gizmo (Default: 1)
  44454. */
  44455. scaleRatio: number;
  44456. /**
  44457. * If a custom mesh has been set (Default: false)
  44458. */
  44459. protected _customMeshSet: boolean;
  44460. /**
  44461. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44462. * * When set, interactions will be enabled
  44463. */
  44464. attachedMesh: Nullable<AbstractMesh>;
  44465. /**
  44466. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44467. * @param mesh The mesh to replace the default mesh of the gizmo
  44468. */
  44469. setCustomMesh(mesh: Mesh): void;
  44470. /**
  44471. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44472. */
  44473. updateGizmoRotationToMatchAttachedMesh: boolean;
  44474. /**
  44475. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44476. */
  44477. updateGizmoPositionToMatchAttachedMesh: boolean;
  44478. /**
  44479. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44480. */
  44481. updateScale: boolean;
  44482. protected _interactionsEnabled: boolean;
  44483. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44484. private _beforeRenderObserver;
  44485. private _tempVector;
  44486. /**
  44487. * Creates a gizmo
  44488. * @param gizmoLayer The utility layer the gizmo will be added to
  44489. */
  44490. constructor(
  44491. /** The utility layer the gizmo will be added to */
  44492. gizmoLayer?: UtilityLayerRenderer);
  44493. /**
  44494. * Updates the gizmo to match the attached mesh's position/rotation
  44495. */
  44496. protected _update(): void;
  44497. /**
  44498. * Disposes of the gizmo
  44499. */
  44500. dispose(): void;
  44501. }
  44502. }
  44503. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44504. import { Observable } from "babylonjs/Misc/observable";
  44505. import { Nullable } from "babylonjs/types";
  44506. import { Vector3 } from "babylonjs/Maths/math.vector";
  44507. import { Color3 } from "babylonjs/Maths/math.color";
  44508. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44510. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44511. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44512. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44513. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44514. import { Scene } from "babylonjs/scene";
  44515. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44516. /**
  44517. * Single plane drag gizmo
  44518. */
  44519. export class PlaneDragGizmo extends Gizmo {
  44520. /**
  44521. * Drag behavior responsible for the gizmos dragging interactions
  44522. */
  44523. dragBehavior: PointerDragBehavior;
  44524. private _pointerObserver;
  44525. /**
  44526. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44527. */
  44528. snapDistance: number;
  44529. /**
  44530. * Event that fires each time the gizmo snaps to a new location.
  44531. * * snapDistance is the the change in distance
  44532. */
  44533. onSnapObservable: Observable<{
  44534. snapDistance: number;
  44535. }>;
  44536. private _plane;
  44537. private _coloredMaterial;
  44538. private _hoverMaterial;
  44539. private _isEnabled;
  44540. private _parent;
  44541. /** @hidden */
  44542. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44543. /** @hidden */
  44544. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44545. /**
  44546. * Creates a PlaneDragGizmo
  44547. * @param gizmoLayer The utility layer the gizmo will be added to
  44548. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44549. * @param color The color of the gizmo
  44550. */
  44551. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44552. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44553. /**
  44554. * If the gizmo is enabled
  44555. */
  44556. isEnabled: boolean;
  44557. /**
  44558. * Disposes of the gizmo
  44559. */
  44560. dispose(): void;
  44561. }
  44562. }
  44563. declare module "babylonjs/Gizmos/positionGizmo" {
  44564. import { Observable } from "babylonjs/Misc/observable";
  44565. import { Nullable } from "babylonjs/types";
  44566. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44567. import { Mesh } from "babylonjs/Meshes/mesh";
  44568. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44569. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44570. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44571. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44572. /**
  44573. * Gizmo that enables dragging a mesh along 3 axis
  44574. */
  44575. export class PositionGizmo extends Gizmo {
  44576. /**
  44577. * Internal gizmo used for interactions on the x axis
  44578. */
  44579. xGizmo: AxisDragGizmo;
  44580. /**
  44581. * Internal gizmo used for interactions on the y axis
  44582. */
  44583. yGizmo: AxisDragGizmo;
  44584. /**
  44585. * Internal gizmo used for interactions on the z axis
  44586. */
  44587. zGizmo: AxisDragGizmo;
  44588. /**
  44589. * Internal gizmo used for interactions on the yz plane
  44590. */
  44591. xPlaneGizmo: PlaneDragGizmo;
  44592. /**
  44593. * Internal gizmo used for interactions on the xz plane
  44594. */
  44595. yPlaneGizmo: PlaneDragGizmo;
  44596. /**
  44597. * Internal gizmo used for interactions on the xy plane
  44598. */
  44599. zPlaneGizmo: PlaneDragGizmo;
  44600. /**
  44601. * private variables
  44602. */
  44603. private _meshAttached;
  44604. private _updateGizmoRotationToMatchAttachedMesh;
  44605. private _snapDistance;
  44606. private _scaleRatio;
  44607. /** Fires an event when any of it's sub gizmos are dragged */
  44608. onDragStartObservable: Observable<unknown>;
  44609. /** Fires an event when any of it's sub gizmos are released from dragging */
  44610. onDragEndObservable: Observable<unknown>;
  44611. /**
  44612. * If set to true, planar drag is enabled
  44613. */
  44614. private _planarGizmoEnabled;
  44615. attachedMesh: Nullable<AbstractMesh>;
  44616. /**
  44617. * Creates a PositionGizmo
  44618. * @param gizmoLayer The utility layer the gizmo will be added to
  44619. */
  44620. constructor(gizmoLayer?: UtilityLayerRenderer);
  44621. /**
  44622. * If the planar drag gizmo is enabled
  44623. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44624. */
  44625. planarGizmoEnabled: boolean;
  44626. updateGizmoRotationToMatchAttachedMesh: boolean;
  44627. /**
  44628. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44629. */
  44630. snapDistance: number;
  44631. /**
  44632. * Ratio for the scale of the gizmo (Default: 1)
  44633. */
  44634. scaleRatio: number;
  44635. /**
  44636. * Disposes of the gizmo
  44637. */
  44638. dispose(): void;
  44639. /**
  44640. * CustomMeshes are not supported by this gizmo
  44641. * @param mesh The mesh to replace the default mesh of the gizmo
  44642. */
  44643. setCustomMesh(mesh: Mesh): void;
  44644. }
  44645. }
  44646. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44647. import { Observable } from "babylonjs/Misc/observable";
  44648. import { Nullable } from "babylonjs/types";
  44649. import { Vector3 } from "babylonjs/Maths/math.vector";
  44650. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44652. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44653. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44654. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44655. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44656. import { Scene } from "babylonjs/scene";
  44657. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44658. import { Color3 } from "babylonjs/Maths/math.color";
  44659. /**
  44660. * Single axis drag gizmo
  44661. */
  44662. export class AxisDragGizmo extends Gizmo {
  44663. /**
  44664. * Drag behavior responsible for the gizmos dragging interactions
  44665. */
  44666. dragBehavior: PointerDragBehavior;
  44667. private _pointerObserver;
  44668. /**
  44669. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44670. */
  44671. snapDistance: number;
  44672. /**
  44673. * Event that fires each time the gizmo snaps to a new location.
  44674. * * snapDistance is the the change in distance
  44675. */
  44676. onSnapObservable: Observable<{
  44677. snapDistance: number;
  44678. }>;
  44679. private _isEnabled;
  44680. private _parent;
  44681. private _arrow;
  44682. private _coloredMaterial;
  44683. private _hoverMaterial;
  44684. /** @hidden */
  44685. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44686. /** @hidden */
  44687. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44688. /**
  44689. * Creates an AxisDragGizmo
  44690. * @param gizmoLayer The utility layer the gizmo will be added to
  44691. * @param dragAxis The axis which the gizmo will be able to drag on
  44692. * @param color The color of the gizmo
  44693. */
  44694. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44695. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44696. /**
  44697. * If the gizmo is enabled
  44698. */
  44699. isEnabled: boolean;
  44700. /**
  44701. * Disposes of the gizmo
  44702. */
  44703. dispose(): void;
  44704. }
  44705. }
  44706. declare module "babylonjs/Debug/axesViewer" {
  44707. import { Vector3 } from "babylonjs/Maths/math.vector";
  44708. import { Nullable } from "babylonjs/types";
  44709. import { Scene } from "babylonjs/scene";
  44710. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44711. /**
  44712. * The Axes viewer will show 3 axes in a specific point in space
  44713. */
  44714. export class AxesViewer {
  44715. private _xAxis;
  44716. private _yAxis;
  44717. private _zAxis;
  44718. private _scaleLinesFactor;
  44719. private _instanced;
  44720. /**
  44721. * Gets the hosting scene
  44722. */
  44723. scene: Scene;
  44724. /**
  44725. * Gets or sets a number used to scale line length
  44726. */
  44727. scaleLines: number;
  44728. /** Gets the node hierarchy used to render x-axis */
  44729. readonly xAxis: TransformNode;
  44730. /** Gets the node hierarchy used to render y-axis */
  44731. readonly yAxis: TransformNode;
  44732. /** Gets the node hierarchy used to render z-axis */
  44733. readonly zAxis: TransformNode;
  44734. /**
  44735. * Creates a new AxesViewer
  44736. * @param scene defines the hosting scene
  44737. * @param scaleLines defines a number used to scale line length (1 by default)
  44738. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44739. * @param xAxis defines the node hierarchy used to render the x-axis
  44740. * @param yAxis defines the node hierarchy used to render the y-axis
  44741. * @param zAxis defines the node hierarchy used to render the z-axis
  44742. */
  44743. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44744. /**
  44745. * Force the viewer to update
  44746. * @param position defines the position of the viewer
  44747. * @param xaxis defines the x axis of the viewer
  44748. * @param yaxis defines the y axis of the viewer
  44749. * @param zaxis defines the z axis of the viewer
  44750. */
  44751. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44752. /**
  44753. * Creates an instance of this axes viewer.
  44754. * @returns a new axes viewer with instanced meshes
  44755. */
  44756. createInstance(): AxesViewer;
  44757. /** Releases resources */
  44758. dispose(): void;
  44759. private static _SetRenderingGroupId;
  44760. }
  44761. }
  44762. declare module "babylonjs/Debug/boneAxesViewer" {
  44763. import { Nullable } from "babylonjs/types";
  44764. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44765. import { Vector3 } from "babylonjs/Maths/math.vector";
  44766. import { Mesh } from "babylonjs/Meshes/mesh";
  44767. import { Bone } from "babylonjs/Bones/bone";
  44768. import { Scene } from "babylonjs/scene";
  44769. /**
  44770. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44771. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44772. */
  44773. export class BoneAxesViewer extends AxesViewer {
  44774. /**
  44775. * Gets or sets the target mesh where to display the axes viewer
  44776. */
  44777. mesh: Nullable<Mesh>;
  44778. /**
  44779. * Gets or sets the target bone where to display the axes viewer
  44780. */
  44781. bone: Nullable<Bone>;
  44782. /** Gets current position */
  44783. pos: Vector3;
  44784. /** Gets direction of X axis */
  44785. xaxis: Vector3;
  44786. /** Gets direction of Y axis */
  44787. yaxis: Vector3;
  44788. /** Gets direction of Z axis */
  44789. zaxis: Vector3;
  44790. /**
  44791. * Creates a new BoneAxesViewer
  44792. * @param scene defines the hosting scene
  44793. * @param bone defines the target bone
  44794. * @param mesh defines the target mesh
  44795. * @param scaleLines defines a scaling factor for line length (1 by default)
  44796. */
  44797. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44798. /**
  44799. * Force the viewer to update
  44800. */
  44801. update(): void;
  44802. /** Releases resources */
  44803. dispose(): void;
  44804. }
  44805. }
  44806. declare module "babylonjs/Debug/debugLayer" {
  44807. import { Scene } from "babylonjs/scene";
  44808. /**
  44809. * Interface used to define scene explorer extensibility option
  44810. */
  44811. export interface IExplorerExtensibilityOption {
  44812. /**
  44813. * Define the option label
  44814. */
  44815. label: string;
  44816. /**
  44817. * Defines the action to execute on click
  44818. */
  44819. action: (entity: any) => void;
  44820. }
  44821. /**
  44822. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44823. */
  44824. export interface IExplorerExtensibilityGroup {
  44825. /**
  44826. * Defines a predicate to test if a given type mut be extended
  44827. */
  44828. predicate: (entity: any) => boolean;
  44829. /**
  44830. * Gets the list of options added to a type
  44831. */
  44832. entries: IExplorerExtensibilityOption[];
  44833. }
  44834. /**
  44835. * Interface used to define the options to use to create the Inspector
  44836. */
  44837. export interface IInspectorOptions {
  44838. /**
  44839. * Display in overlay mode (default: false)
  44840. */
  44841. overlay?: boolean;
  44842. /**
  44843. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44844. */
  44845. globalRoot?: HTMLElement;
  44846. /**
  44847. * Display the Scene explorer
  44848. */
  44849. showExplorer?: boolean;
  44850. /**
  44851. * Display the property inspector
  44852. */
  44853. showInspector?: boolean;
  44854. /**
  44855. * Display in embed mode (both panes on the right)
  44856. */
  44857. embedMode?: boolean;
  44858. /**
  44859. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44860. */
  44861. handleResize?: boolean;
  44862. /**
  44863. * Allow the panes to popup (default: true)
  44864. */
  44865. enablePopup?: boolean;
  44866. /**
  44867. * Allow the panes to be closed by users (default: true)
  44868. */
  44869. enableClose?: boolean;
  44870. /**
  44871. * Optional list of extensibility entries
  44872. */
  44873. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44874. /**
  44875. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44876. */
  44877. inspectorURL?: string;
  44878. }
  44879. module "babylonjs/scene" {
  44880. interface Scene {
  44881. /**
  44882. * @hidden
  44883. * Backing field
  44884. */
  44885. _debugLayer: DebugLayer;
  44886. /**
  44887. * Gets the debug layer (aka Inspector) associated with the scene
  44888. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44889. */
  44890. debugLayer: DebugLayer;
  44891. }
  44892. }
  44893. /**
  44894. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44895. * what is happening in your scene
  44896. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44897. */
  44898. export class DebugLayer {
  44899. /**
  44900. * Define the url to get the inspector script from.
  44901. * By default it uses the babylonjs CDN.
  44902. * @ignoreNaming
  44903. */
  44904. static InspectorURL: string;
  44905. private _scene;
  44906. private BJSINSPECTOR;
  44907. private _onPropertyChangedObservable?;
  44908. /**
  44909. * Observable triggered when a property is changed through the inspector.
  44910. */
  44911. readonly onPropertyChangedObservable: any;
  44912. /**
  44913. * Instantiates a new debug layer.
  44914. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44915. * what is happening in your scene
  44916. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44917. * @param scene Defines the scene to inspect
  44918. */
  44919. constructor(scene: Scene);
  44920. /** Creates the inspector window. */
  44921. private _createInspector;
  44922. /**
  44923. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44924. * @param entity defines the entity to select
  44925. * @param lineContainerTitle defines the specific block to highlight
  44926. */
  44927. select(entity: any, lineContainerTitle?: string): void;
  44928. /** Get the inspector from bundle or global */
  44929. private _getGlobalInspector;
  44930. /**
  44931. * Get if the inspector is visible or not.
  44932. * @returns true if visible otherwise, false
  44933. */
  44934. isVisible(): boolean;
  44935. /**
  44936. * Hide the inspector and close its window.
  44937. */
  44938. hide(): void;
  44939. /**
  44940. * Launch the debugLayer.
  44941. * @param config Define the configuration of the inspector
  44942. * @return a promise fulfilled when the debug layer is visible
  44943. */
  44944. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44945. }
  44946. }
  44947. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44948. import { Nullable } from "babylonjs/types";
  44949. import { Scene } from "babylonjs/scene";
  44950. import { Vector4 } from "babylonjs/Maths/math.vector";
  44951. import { Color4 } from "babylonjs/Maths/math.color";
  44952. import { Mesh } from "babylonjs/Meshes/mesh";
  44953. /**
  44954. * Class containing static functions to help procedurally build meshes
  44955. */
  44956. export class BoxBuilder {
  44957. /**
  44958. * Creates a box mesh
  44959. * * The parameter `size` sets the size (float) of each box side (default 1)
  44960. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44961. * * 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)
  44962. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44966. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44967. * @param name defines the name of the mesh
  44968. * @param options defines the options used to create the mesh
  44969. * @param scene defines the hosting scene
  44970. * @returns the box mesh
  44971. */
  44972. static CreateBox(name: string, options: {
  44973. size?: number;
  44974. width?: number;
  44975. height?: number;
  44976. depth?: number;
  44977. faceUV?: Vector4[];
  44978. faceColors?: Color4[];
  44979. sideOrientation?: number;
  44980. frontUVs?: Vector4;
  44981. backUVs?: Vector4;
  44982. wrap?: boolean;
  44983. topBaseAt?: number;
  44984. bottomBaseAt?: number;
  44985. updatable?: boolean;
  44986. }, scene?: Nullable<Scene>): Mesh;
  44987. }
  44988. }
  44989. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44990. import { Vector4 } from "babylonjs/Maths/math.vector";
  44991. import { Mesh } from "babylonjs/Meshes/mesh";
  44992. import { Scene } from "babylonjs/scene";
  44993. import { Nullable } from "babylonjs/types";
  44994. /**
  44995. * Class containing static functions to help procedurally build meshes
  44996. */
  44997. export class SphereBuilder {
  44998. /**
  44999. * Creates a sphere mesh
  45000. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45001. * * 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`)
  45002. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45003. * * 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
  45004. * * 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)
  45005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45006. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45008. * @param name defines the name of the mesh
  45009. * @param options defines the options used to create the mesh
  45010. * @param scene defines the hosting scene
  45011. * @returns the sphere mesh
  45012. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45013. */
  45014. static CreateSphere(name: string, options: {
  45015. segments?: number;
  45016. diameter?: number;
  45017. diameterX?: number;
  45018. diameterY?: number;
  45019. diameterZ?: number;
  45020. arc?: number;
  45021. slice?: number;
  45022. sideOrientation?: number;
  45023. frontUVs?: Vector4;
  45024. backUVs?: Vector4;
  45025. updatable?: boolean;
  45026. }, scene?: Nullable<Scene>): Mesh;
  45027. }
  45028. }
  45029. declare module "babylonjs/Debug/physicsViewer" {
  45030. import { Nullable } from "babylonjs/types";
  45031. import { Scene } from "babylonjs/scene";
  45032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45033. import { Mesh } from "babylonjs/Meshes/mesh";
  45034. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45035. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45036. /**
  45037. * Used to show the physics impostor around the specific mesh
  45038. */
  45039. export class PhysicsViewer {
  45040. /** @hidden */
  45041. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45042. /** @hidden */
  45043. protected _meshes: Array<Nullable<AbstractMesh>>;
  45044. /** @hidden */
  45045. protected _scene: Nullable<Scene>;
  45046. /** @hidden */
  45047. protected _numMeshes: number;
  45048. /** @hidden */
  45049. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45050. private _renderFunction;
  45051. private _utilityLayer;
  45052. private _debugBoxMesh;
  45053. private _debugSphereMesh;
  45054. private _debugCylinderMesh;
  45055. private _debugMaterial;
  45056. private _debugMeshMeshes;
  45057. /**
  45058. * Creates a new PhysicsViewer
  45059. * @param scene defines the hosting scene
  45060. */
  45061. constructor(scene: Scene);
  45062. /** @hidden */
  45063. protected _updateDebugMeshes(): void;
  45064. /**
  45065. * Renders a specified physic impostor
  45066. * @param impostor defines the impostor to render
  45067. * @param targetMesh defines the mesh represented by the impostor
  45068. * @returns the new debug mesh used to render the impostor
  45069. */
  45070. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45071. /**
  45072. * Hides a specified physic impostor
  45073. * @param impostor defines the impostor to hide
  45074. */
  45075. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45076. private _getDebugMaterial;
  45077. private _getDebugBoxMesh;
  45078. private _getDebugSphereMesh;
  45079. private _getDebugCylinderMesh;
  45080. private _getDebugMeshMesh;
  45081. private _getDebugMesh;
  45082. /** Releases all resources */
  45083. dispose(): void;
  45084. }
  45085. }
  45086. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45087. import { Vector3 } from "babylonjs/Maths/math.vector";
  45088. import { Color4 } from "babylonjs/Maths/math.color";
  45089. import { Nullable } from "babylonjs/types";
  45090. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45091. import { Scene } from "babylonjs/scene";
  45092. /**
  45093. * Class containing static functions to help procedurally build meshes
  45094. */
  45095. export class LinesBuilder {
  45096. /**
  45097. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45098. * * 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
  45099. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45100. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45101. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45102. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45103. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45104. * * 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
  45105. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45108. * @param name defines the name of the new line system
  45109. * @param options defines the options used to create the line system
  45110. * @param scene defines the hosting scene
  45111. * @returns a new line system mesh
  45112. */
  45113. static CreateLineSystem(name: string, options: {
  45114. lines: Vector3[][];
  45115. updatable?: boolean;
  45116. instance?: Nullable<LinesMesh>;
  45117. colors?: Nullable<Color4[][]>;
  45118. useVertexAlpha?: boolean;
  45119. }, scene: Nullable<Scene>): LinesMesh;
  45120. /**
  45121. * Creates a line mesh
  45122. * 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
  45123. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45124. * * The parameter `points` is an array successive Vector3
  45125. * * 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
  45126. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45127. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45128. * * When updating an instance, remember that only point positions can change, not the number of points
  45129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45130. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45131. * @param name defines the name of the new line system
  45132. * @param options defines the options used to create the line system
  45133. * @param scene defines the hosting scene
  45134. * @returns a new line mesh
  45135. */
  45136. static CreateLines(name: string, options: {
  45137. points: Vector3[];
  45138. updatable?: boolean;
  45139. instance?: Nullable<LinesMesh>;
  45140. colors?: Color4[];
  45141. useVertexAlpha?: boolean;
  45142. }, scene?: Nullable<Scene>): LinesMesh;
  45143. /**
  45144. * Creates a dashed line mesh
  45145. * * 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
  45146. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45147. * * The parameter `points` is an array successive Vector3
  45148. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45149. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45150. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45151. * * 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
  45152. * * When updating an instance, remember that only point positions can change, not the number of points
  45153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45154. * @param name defines the name of the mesh
  45155. * @param options defines the options used to create the mesh
  45156. * @param scene defines the hosting scene
  45157. * @returns the dashed line mesh
  45158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45159. */
  45160. static CreateDashedLines(name: string, options: {
  45161. points: Vector3[];
  45162. dashSize?: number;
  45163. gapSize?: number;
  45164. dashNb?: number;
  45165. updatable?: boolean;
  45166. instance?: LinesMesh;
  45167. }, scene?: Nullable<Scene>): LinesMesh;
  45168. }
  45169. }
  45170. declare module "babylonjs/Debug/rayHelper" {
  45171. import { Nullable } from "babylonjs/types";
  45172. import { Ray } from "babylonjs/Culling/ray";
  45173. import { Vector3 } from "babylonjs/Maths/math.vector";
  45174. import { Color3 } from "babylonjs/Maths/math.color";
  45175. import { Scene } from "babylonjs/scene";
  45176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45177. import "babylonjs/Meshes/Builders/linesBuilder";
  45178. /**
  45179. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45180. * in order to better appreciate the issue one might have.
  45181. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45182. */
  45183. export class RayHelper {
  45184. /**
  45185. * Defines the ray we are currently tryin to visualize.
  45186. */
  45187. ray: Nullable<Ray>;
  45188. private _renderPoints;
  45189. private _renderLine;
  45190. private _renderFunction;
  45191. private _scene;
  45192. private _updateToMeshFunction;
  45193. private _attachedToMesh;
  45194. private _meshSpaceDirection;
  45195. private _meshSpaceOrigin;
  45196. /**
  45197. * Helper function to create a colored helper in a scene in one line.
  45198. * @param ray Defines the ray we are currently tryin to visualize
  45199. * @param scene Defines the scene the ray is used in
  45200. * @param color Defines the color we want to see the ray in
  45201. * @returns The newly created ray helper.
  45202. */
  45203. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45204. /**
  45205. * Instantiate a new ray helper.
  45206. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45207. * in order to better appreciate the issue one might have.
  45208. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45209. * @param ray Defines the ray we are currently tryin to visualize
  45210. */
  45211. constructor(ray: Ray);
  45212. /**
  45213. * Shows the ray we are willing to debug.
  45214. * @param scene Defines the scene the ray needs to be rendered in
  45215. * @param color Defines the color the ray needs to be rendered in
  45216. */
  45217. show(scene: Scene, color?: Color3): void;
  45218. /**
  45219. * Hides the ray we are debugging.
  45220. */
  45221. hide(): void;
  45222. private _render;
  45223. /**
  45224. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45225. * @param mesh Defines the mesh we want the helper attached to
  45226. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45227. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45228. * @param length Defines the length of the ray
  45229. */
  45230. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45231. /**
  45232. * Detach the ray helper from the mesh it has previously been attached to.
  45233. */
  45234. detachFromMesh(): void;
  45235. private _updateToMesh;
  45236. /**
  45237. * Dispose the helper and release its associated resources.
  45238. */
  45239. dispose(): void;
  45240. }
  45241. }
  45242. declare module "babylonjs/Debug/skeletonViewer" {
  45243. import { Color3 } from "babylonjs/Maths/math.color";
  45244. import { Scene } from "babylonjs/scene";
  45245. import { Nullable } from "babylonjs/types";
  45246. import { Skeleton } from "babylonjs/Bones/skeleton";
  45247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45248. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45249. /**
  45250. * Class used to render a debug view of a given skeleton
  45251. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45252. */
  45253. export class SkeletonViewer {
  45254. /** defines the skeleton to render */
  45255. skeleton: Skeleton;
  45256. /** defines the mesh attached to the skeleton */
  45257. mesh: AbstractMesh;
  45258. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45259. autoUpdateBonesMatrices: boolean;
  45260. /** defines the rendering group id to use with the viewer */
  45261. renderingGroupId: number;
  45262. /** Gets or sets the color used to render the skeleton */
  45263. color: Color3;
  45264. private _scene;
  45265. private _debugLines;
  45266. private _debugMesh;
  45267. private _isEnabled;
  45268. private _renderFunction;
  45269. private _utilityLayer;
  45270. /**
  45271. * Returns the mesh used to render the bones
  45272. */
  45273. readonly debugMesh: Nullable<LinesMesh>;
  45274. /**
  45275. * Creates a new SkeletonViewer
  45276. * @param skeleton defines the skeleton to render
  45277. * @param mesh defines the mesh attached to the skeleton
  45278. * @param scene defines the hosting scene
  45279. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45280. * @param renderingGroupId defines the rendering group id to use with the viewer
  45281. */
  45282. constructor(
  45283. /** defines the skeleton to render */
  45284. skeleton: Skeleton,
  45285. /** defines the mesh attached to the skeleton */
  45286. mesh: AbstractMesh, scene: Scene,
  45287. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45288. autoUpdateBonesMatrices?: boolean,
  45289. /** defines the rendering group id to use with the viewer */
  45290. renderingGroupId?: number);
  45291. /** Gets or sets a boolean indicating if the viewer is enabled */
  45292. isEnabled: boolean;
  45293. private _getBonePosition;
  45294. private _getLinesForBonesWithLength;
  45295. private _getLinesForBonesNoLength;
  45296. /** Update the viewer to sync with current skeleton state */
  45297. update(): void;
  45298. /** Release associated resources */
  45299. dispose(): void;
  45300. }
  45301. }
  45302. declare module "babylonjs/Debug/index" {
  45303. export * from "babylonjs/Debug/axesViewer";
  45304. export * from "babylonjs/Debug/boneAxesViewer";
  45305. export * from "babylonjs/Debug/debugLayer";
  45306. export * from "babylonjs/Debug/physicsViewer";
  45307. export * from "babylonjs/Debug/rayHelper";
  45308. export * from "babylonjs/Debug/skeletonViewer";
  45309. }
  45310. declare module "babylonjs/Engines/nullEngine" {
  45311. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45312. import { Scene } from "babylonjs/scene";
  45313. import { Engine } from "babylonjs/Engines/engine";
  45314. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45315. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45316. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45317. import { Effect } from "babylonjs/Materials/effect";
  45318. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45319. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45320. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45321. /**
  45322. * Options to create the null engine
  45323. */
  45324. export class NullEngineOptions {
  45325. /**
  45326. * Render width (Default: 512)
  45327. */
  45328. renderWidth: number;
  45329. /**
  45330. * Render height (Default: 256)
  45331. */
  45332. renderHeight: number;
  45333. /**
  45334. * Texture size (Default: 512)
  45335. */
  45336. textureSize: number;
  45337. /**
  45338. * If delta time between frames should be constant
  45339. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45340. */
  45341. deterministicLockstep: boolean;
  45342. /**
  45343. * Maximum about of steps between frames (Default: 4)
  45344. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45345. */
  45346. lockstepMaxSteps: number;
  45347. }
  45348. /**
  45349. * The null engine class provides support for headless version of babylon.js.
  45350. * This can be used in server side scenario or for testing purposes
  45351. */
  45352. export class NullEngine extends Engine {
  45353. private _options;
  45354. /**
  45355. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45356. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45357. * @returns true if engine is in deterministic lock step mode
  45358. */
  45359. isDeterministicLockStep(): boolean;
  45360. /**
  45361. * Gets the max steps when engine is running in deterministic lock step
  45362. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45363. * @returns the max steps
  45364. */
  45365. getLockstepMaxSteps(): number;
  45366. /**
  45367. * Gets the current hardware scaling level.
  45368. * By default the hardware scaling level is computed from the window device ratio.
  45369. * 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.
  45370. * @returns a number indicating the current hardware scaling level
  45371. */
  45372. getHardwareScalingLevel(): number;
  45373. constructor(options?: NullEngineOptions);
  45374. /**
  45375. * Creates a vertex buffer
  45376. * @param vertices the data for the vertex buffer
  45377. * @returns the new WebGL static buffer
  45378. */
  45379. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45380. /**
  45381. * Creates a new index buffer
  45382. * @param indices defines the content of the index buffer
  45383. * @param updatable defines if the index buffer must be updatable
  45384. * @returns a new webGL buffer
  45385. */
  45386. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45387. /**
  45388. * Clear the current render buffer or the current render target (if any is set up)
  45389. * @param color defines the color to use
  45390. * @param backBuffer defines if the back buffer must be cleared
  45391. * @param depth defines if the depth buffer must be cleared
  45392. * @param stencil defines if the stencil buffer must be cleared
  45393. */
  45394. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45395. /**
  45396. * Gets the current render width
  45397. * @param useScreen defines if screen size must be used (or the current render target if any)
  45398. * @returns a number defining the current render width
  45399. */
  45400. getRenderWidth(useScreen?: boolean): number;
  45401. /**
  45402. * Gets the current render height
  45403. * @param useScreen defines if screen size must be used (or the current render target if any)
  45404. * @returns a number defining the current render height
  45405. */
  45406. getRenderHeight(useScreen?: boolean): number;
  45407. /**
  45408. * Set the WebGL's viewport
  45409. * @param viewport defines the viewport element to be used
  45410. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45411. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45412. */
  45413. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45414. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45415. /**
  45416. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45417. * @param pipelineContext defines the pipeline context to use
  45418. * @param uniformsNames defines the list of uniform names
  45419. * @returns an array of webGL uniform locations
  45420. */
  45421. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45422. /**
  45423. * Gets the lsit of active attributes for a given webGL program
  45424. * @param pipelineContext defines the pipeline context to use
  45425. * @param attributesNames defines the list of attribute names to get
  45426. * @returns an array of indices indicating the offset of each attribute
  45427. */
  45428. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45429. /**
  45430. * Binds an effect to the webGL context
  45431. * @param effect defines the effect to bind
  45432. */
  45433. bindSamplers(effect: Effect): void;
  45434. /**
  45435. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45436. * @param effect defines the effect to activate
  45437. */
  45438. enableEffect(effect: Effect): void;
  45439. /**
  45440. * Set various states to the webGL context
  45441. * @param culling defines backface culling state
  45442. * @param zOffset defines the value to apply to zOffset (0 by default)
  45443. * @param force defines if states must be applied even if cache is up to date
  45444. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45445. */
  45446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45447. /**
  45448. * Set the value of an uniform to an array of int32
  45449. * @param uniform defines the webGL uniform location where to store the value
  45450. * @param array defines the array of int32 to store
  45451. */
  45452. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45453. /**
  45454. * Set the value of an uniform to an array of int32 (stored as vec2)
  45455. * @param uniform defines the webGL uniform location where to store the value
  45456. * @param array defines the array of int32 to store
  45457. */
  45458. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45459. /**
  45460. * Set the value of an uniform to an array of int32 (stored as vec3)
  45461. * @param uniform defines the webGL uniform location where to store the value
  45462. * @param array defines the array of int32 to store
  45463. */
  45464. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45465. /**
  45466. * Set the value of an uniform to an array of int32 (stored as vec4)
  45467. * @param uniform defines the webGL uniform location where to store the value
  45468. * @param array defines the array of int32 to store
  45469. */
  45470. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45471. /**
  45472. * Set the value of an uniform to an array of float32
  45473. * @param uniform defines the webGL uniform location where to store the value
  45474. * @param array defines the array of float32 to store
  45475. */
  45476. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45477. /**
  45478. * Set the value of an uniform to an array of float32 (stored as vec2)
  45479. * @param uniform defines the webGL uniform location where to store the value
  45480. * @param array defines the array of float32 to store
  45481. */
  45482. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45483. /**
  45484. * Set the value of an uniform to an array of float32 (stored as vec3)
  45485. * @param uniform defines the webGL uniform location where to store the value
  45486. * @param array defines the array of float32 to store
  45487. */
  45488. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45489. /**
  45490. * Set the value of an uniform to an array of float32 (stored as vec4)
  45491. * @param uniform defines the webGL uniform location where to store the value
  45492. * @param array defines the array of float32 to store
  45493. */
  45494. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45495. /**
  45496. * Set the value of an uniform to an array of number
  45497. * @param uniform defines the webGL uniform location where to store the value
  45498. * @param array defines the array of number to store
  45499. */
  45500. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45501. /**
  45502. * Set the value of an uniform to an array of number (stored as vec2)
  45503. * @param uniform defines the webGL uniform location where to store the value
  45504. * @param array defines the array of number to store
  45505. */
  45506. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45507. /**
  45508. * Set the value of an uniform to an array of number (stored as vec3)
  45509. * @param uniform defines the webGL uniform location where to store the value
  45510. * @param array defines the array of number to store
  45511. */
  45512. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45513. /**
  45514. * Set the value of an uniform to an array of number (stored as vec4)
  45515. * @param uniform defines the webGL uniform location where to store the value
  45516. * @param array defines the array of number to store
  45517. */
  45518. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45519. /**
  45520. * Set the value of an uniform to an array of float32 (stored as matrices)
  45521. * @param uniform defines the webGL uniform location where to store the value
  45522. * @param matrices defines the array of float32 to store
  45523. */
  45524. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45525. /**
  45526. * Set the value of an uniform to a matrix (3x3)
  45527. * @param uniform defines the webGL uniform location where to store the value
  45528. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45529. */
  45530. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45531. /**
  45532. * Set the value of an uniform to a matrix (2x2)
  45533. * @param uniform defines the webGL uniform location where to store the value
  45534. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45535. */
  45536. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45537. /**
  45538. * Set the value of an uniform to a number (float)
  45539. * @param uniform defines the webGL uniform location where to store the value
  45540. * @param value defines the float number to store
  45541. */
  45542. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45543. /**
  45544. * Set the value of an uniform to a vec2
  45545. * @param uniform defines the webGL uniform location where to store the value
  45546. * @param x defines the 1st component of the value
  45547. * @param y defines the 2nd component of the value
  45548. */
  45549. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45550. /**
  45551. * Set the value of an uniform to a vec3
  45552. * @param uniform defines the webGL uniform location where to store the value
  45553. * @param x defines the 1st component of the value
  45554. * @param y defines the 2nd component of the value
  45555. * @param z defines the 3rd component of the value
  45556. */
  45557. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45558. /**
  45559. * Set the value of an uniform to a boolean
  45560. * @param uniform defines the webGL uniform location where to store the value
  45561. * @param bool defines the boolean to store
  45562. */
  45563. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45564. /**
  45565. * Set the value of an uniform to a vec4
  45566. * @param uniform defines the webGL uniform location where to store the value
  45567. * @param x defines the 1st component of the value
  45568. * @param y defines the 2nd component of the value
  45569. * @param z defines the 3rd component of the value
  45570. * @param w defines the 4th component of the value
  45571. */
  45572. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45573. /**
  45574. * Sets the current alpha mode
  45575. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45576. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45577. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45578. */
  45579. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45580. /**
  45581. * Bind webGl buffers directly to the webGL context
  45582. * @param vertexBuffers defines the vertex buffer to bind
  45583. * @param indexBuffer defines the index buffer to bind
  45584. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45585. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45586. * @param effect defines the effect associated with the vertex buffer
  45587. */
  45588. bindBuffers(vertexBuffers: {
  45589. [key: string]: VertexBuffer;
  45590. }, indexBuffer: DataBuffer, effect: Effect): void;
  45591. /**
  45592. * Force the entire cache to be cleared
  45593. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45594. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45595. */
  45596. wipeCaches(bruteForce?: boolean): void;
  45597. /**
  45598. * Send a draw order
  45599. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45600. * @param indexStart defines the starting index
  45601. * @param indexCount defines the number of index to draw
  45602. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45603. */
  45604. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45605. /**
  45606. * Draw a list of indexed primitives
  45607. * @param fillMode defines the primitive to use
  45608. * @param indexStart defines the starting index
  45609. * @param indexCount defines the number of index to draw
  45610. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45611. */
  45612. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45613. /**
  45614. * Draw a list of unindexed primitives
  45615. * @param fillMode defines the primitive to use
  45616. * @param verticesStart defines the index of first vertex to draw
  45617. * @param verticesCount defines the count of vertices to draw
  45618. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45619. */
  45620. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45621. /** @hidden */
  45622. _createTexture(): WebGLTexture;
  45623. /** @hidden */
  45624. _releaseTexture(texture: InternalTexture): void;
  45625. /**
  45626. * Usually called from Texture.ts.
  45627. * Passed information to create a WebGLTexture
  45628. * @param urlArg defines a value which contains one of the following:
  45629. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45630. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45631. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45632. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45633. * @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)
  45634. * @param scene needed for loading to the correct scene
  45635. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45636. * @param onLoad optional callback to be called upon successful completion
  45637. * @param onError optional callback to be called upon failure
  45638. * @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
  45639. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45640. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45641. * @param forcedExtension defines the extension to use to pick the right loader
  45642. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45643. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45644. */
  45645. 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;
  45646. /**
  45647. * Creates a new render target texture
  45648. * @param size defines the size of the texture
  45649. * @param options defines the options used to create the texture
  45650. * @returns a new render target texture stored in an InternalTexture
  45651. */
  45652. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45653. /**
  45654. * Update the sampling mode of a given texture
  45655. * @param samplingMode defines the required sampling mode
  45656. * @param texture defines the texture to update
  45657. */
  45658. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45659. /**
  45660. * Binds the frame buffer to the specified texture.
  45661. * @param texture The texture to render to or null for the default canvas
  45662. * @param faceIndex The face of the texture to render to in case of cube texture
  45663. * @param requiredWidth The width of the target to render to
  45664. * @param requiredHeight The height of the target to render to
  45665. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45666. * @param depthStencilTexture The depth stencil texture to use to render
  45667. * @param lodLevel defines le lod level to bind to the frame buffer
  45668. */
  45669. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45670. /**
  45671. * Unbind the current render target texture from the webGL context
  45672. * @param texture defines the render target texture to unbind
  45673. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45674. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45675. */
  45676. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45677. /**
  45678. * Creates a dynamic vertex buffer
  45679. * @param vertices the data for the dynamic vertex buffer
  45680. * @returns the new WebGL dynamic buffer
  45681. */
  45682. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45683. /**
  45684. * Update the content of a dynamic texture
  45685. * @param texture defines the texture to update
  45686. * @param canvas defines the canvas containing the source
  45687. * @param invertY defines if data must be stored with Y axis inverted
  45688. * @param premulAlpha defines if alpha is stored as premultiplied
  45689. * @param format defines the format of the data
  45690. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45691. */
  45692. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45693. /**
  45694. * Gets a boolean indicating if all created effects are ready
  45695. * @returns true if all effects are ready
  45696. */
  45697. areAllEffectsReady(): boolean;
  45698. /**
  45699. * @hidden
  45700. * Get the current error code of the webGL context
  45701. * @returns the error code
  45702. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45703. */
  45704. getError(): number;
  45705. /** @hidden */
  45706. _getUnpackAlignement(): number;
  45707. /** @hidden */
  45708. _unpackFlipY(value: boolean): void;
  45709. /**
  45710. * Update a dynamic index buffer
  45711. * @param indexBuffer defines the target index buffer
  45712. * @param indices defines the data to update
  45713. * @param offset defines the offset in the target index buffer where update should start
  45714. */
  45715. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45716. /**
  45717. * Updates a dynamic vertex buffer.
  45718. * @param vertexBuffer the vertex buffer to update
  45719. * @param vertices the data used to update the vertex buffer
  45720. * @param byteOffset the byte offset of the data (optional)
  45721. * @param byteLength the byte length of the data (optional)
  45722. */
  45723. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45724. /** @hidden */
  45725. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45726. /** @hidden */
  45727. _bindTexture(channel: number, texture: InternalTexture): void;
  45728. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45729. /**
  45730. * 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
  45731. */
  45732. releaseEffects(): void;
  45733. displayLoadingUI(): void;
  45734. hideLoadingUI(): void;
  45735. /** @hidden */
  45736. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45737. /** @hidden */
  45738. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45739. /** @hidden */
  45740. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45741. /** @hidden */
  45742. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45743. }
  45744. }
  45745. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45746. import { Nullable, int } from "babylonjs/types";
  45747. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45748. /** @hidden */
  45749. export class _OcclusionDataStorage {
  45750. /** @hidden */
  45751. occlusionInternalRetryCounter: number;
  45752. /** @hidden */
  45753. isOcclusionQueryInProgress: boolean;
  45754. /** @hidden */
  45755. isOccluded: boolean;
  45756. /** @hidden */
  45757. occlusionRetryCount: number;
  45758. /** @hidden */
  45759. occlusionType: number;
  45760. /** @hidden */
  45761. occlusionQueryAlgorithmType: number;
  45762. }
  45763. module "babylonjs/Engines/engine" {
  45764. interface Engine {
  45765. /**
  45766. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45767. * @return the new query
  45768. */
  45769. createQuery(): WebGLQuery;
  45770. /**
  45771. * Delete and release a webGL query
  45772. * @param query defines the query to delete
  45773. * @return the current engine
  45774. */
  45775. deleteQuery(query: WebGLQuery): Engine;
  45776. /**
  45777. * Check if a given query has resolved and got its value
  45778. * @param query defines the query to check
  45779. * @returns true if the query got its value
  45780. */
  45781. isQueryResultAvailable(query: WebGLQuery): boolean;
  45782. /**
  45783. * Gets the value of a given query
  45784. * @param query defines the query to check
  45785. * @returns the value of the query
  45786. */
  45787. getQueryResult(query: WebGLQuery): number;
  45788. /**
  45789. * Initiates an occlusion query
  45790. * @param algorithmType defines the algorithm to use
  45791. * @param query defines the query to use
  45792. * @returns the current engine
  45793. * @see http://doc.babylonjs.com/features/occlusionquery
  45794. */
  45795. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45796. /**
  45797. * Ends an occlusion query
  45798. * @see http://doc.babylonjs.com/features/occlusionquery
  45799. * @param algorithmType defines the algorithm to use
  45800. * @returns the current engine
  45801. */
  45802. endOcclusionQuery(algorithmType: number): Engine;
  45803. /**
  45804. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45805. * Please note that only one query can be issued at a time
  45806. * @returns a time token used to track the time span
  45807. */
  45808. startTimeQuery(): Nullable<_TimeToken>;
  45809. /**
  45810. * Ends a time query
  45811. * @param token defines the token used to measure the time span
  45812. * @returns the time spent (in ns)
  45813. */
  45814. endTimeQuery(token: _TimeToken): int;
  45815. /** @hidden */
  45816. _currentNonTimestampToken: Nullable<_TimeToken>;
  45817. /** @hidden */
  45818. _createTimeQuery(): WebGLQuery;
  45819. /** @hidden */
  45820. _deleteTimeQuery(query: WebGLQuery): void;
  45821. /** @hidden */
  45822. _getGlAlgorithmType(algorithmType: number): number;
  45823. /** @hidden */
  45824. _getTimeQueryResult(query: WebGLQuery): any;
  45825. /** @hidden */
  45826. _getTimeQueryAvailability(query: WebGLQuery): any;
  45827. }
  45828. }
  45829. module "babylonjs/Meshes/abstractMesh" {
  45830. interface AbstractMesh {
  45831. /**
  45832. * Backing filed
  45833. * @hidden
  45834. */
  45835. __occlusionDataStorage: _OcclusionDataStorage;
  45836. /**
  45837. * Access property
  45838. * @hidden
  45839. */
  45840. _occlusionDataStorage: _OcclusionDataStorage;
  45841. /**
  45842. * 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.
  45843. * The default value is -1 which means don't break the query and wait till the result
  45844. * @see http://doc.babylonjs.com/features/occlusionquery
  45845. */
  45846. occlusionRetryCount: number;
  45847. /**
  45848. * 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:
  45849. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45850. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45851. * * 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.
  45852. * @see http://doc.babylonjs.com/features/occlusionquery
  45853. */
  45854. occlusionType: number;
  45855. /**
  45856. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45857. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45858. * * 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.
  45859. * @see http://doc.babylonjs.com/features/occlusionquery
  45860. */
  45861. occlusionQueryAlgorithmType: number;
  45862. /**
  45863. * 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
  45864. * @see http://doc.babylonjs.com/features/occlusionquery
  45865. */
  45866. isOccluded: boolean;
  45867. /**
  45868. * Flag to check the progress status of the query
  45869. * @see http://doc.babylonjs.com/features/occlusionquery
  45870. */
  45871. isOcclusionQueryInProgress: boolean;
  45872. }
  45873. }
  45874. }
  45875. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45876. import { Nullable } from "babylonjs/types";
  45877. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45878. /** @hidden */
  45879. export var _forceTransformFeedbackToBundle: boolean;
  45880. module "babylonjs/Engines/engine" {
  45881. interface Engine {
  45882. /**
  45883. * Creates a webGL transform feedback object
  45884. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45885. * @returns the webGL transform feedback object
  45886. */
  45887. createTransformFeedback(): WebGLTransformFeedback;
  45888. /**
  45889. * Delete a webGL transform feedback object
  45890. * @param value defines the webGL transform feedback object to delete
  45891. */
  45892. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45893. /**
  45894. * Bind a webGL transform feedback object to the webgl context
  45895. * @param value defines the webGL transform feedback object to bind
  45896. */
  45897. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45898. /**
  45899. * Begins a transform feedback operation
  45900. * @param usePoints defines if points or triangles must be used
  45901. */
  45902. beginTransformFeedback(usePoints: boolean): void;
  45903. /**
  45904. * Ends a transform feedback operation
  45905. */
  45906. endTransformFeedback(): void;
  45907. /**
  45908. * Specify the varyings to use with transform feedback
  45909. * @param program defines the associated webGL program
  45910. * @param value defines the list of strings representing the varying names
  45911. */
  45912. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45913. /**
  45914. * Bind a webGL buffer for a transform feedback operation
  45915. * @param value defines the webGL buffer to bind
  45916. */
  45917. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45918. }
  45919. }
  45920. }
  45921. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45922. import { Scene } from "babylonjs/scene";
  45923. import { Engine } from "babylonjs/Engines/engine";
  45924. import { Texture } from "babylonjs/Materials/Textures/texture";
  45925. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45926. import "babylonjs/Engines/Extensions/engine.multiRender";
  45927. /**
  45928. * Creation options of the multi render target texture.
  45929. */
  45930. export interface IMultiRenderTargetOptions {
  45931. /**
  45932. * Define if the texture needs to create mip maps after render.
  45933. */
  45934. generateMipMaps?: boolean;
  45935. /**
  45936. * Define the types of all the draw buffers we want to create
  45937. */
  45938. types?: number[];
  45939. /**
  45940. * Define the sampling modes of all the draw buffers we want to create
  45941. */
  45942. samplingModes?: number[];
  45943. /**
  45944. * Define if a depth buffer is required
  45945. */
  45946. generateDepthBuffer?: boolean;
  45947. /**
  45948. * Define if a stencil buffer is required
  45949. */
  45950. generateStencilBuffer?: boolean;
  45951. /**
  45952. * Define if a depth texture is required instead of a depth buffer
  45953. */
  45954. generateDepthTexture?: boolean;
  45955. /**
  45956. * Define the number of desired draw buffers
  45957. */
  45958. textureCount?: number;
  45959. /**
  45960. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45961. */
  45962. doNotChangeAspectRatio?: boolean;
  45963. /**
  45964. * Define the default type of the buffers we are creating
  45965. */
  45966. defaultType?: number;
  45967. }
  45968. /**
  45969. * A multi render target, like a render target provides the ability to render to a texture.
  45970. * Unlike the render target, it can render to several draw buffers in one draw.
  45971. * This is specially interesting in deferred rendering or for any effects requiring more than
  45972. * just one color from a single pass.
  45973. */
  45974. export class MultiRenderTarget extends RenderTargetTexture {
  45975. private _internalTextures;
  45976. private _textures;
  45977. private _multiRenderTargetOptions;
  45978. /**
  45979. * Get if draw buffers are currently supported by the used hardware and browser.
  45980. */
  45981. readonly isSupported: boolean;
  45982. /**
  45983. * Get the list of textures generated by the multi render target.
  45984. */
  45985. readonly textures: Texture[];
  45986. /**
  45987. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45988. */
  45989. readonly depthTexture: Texture;
  45990. /**
  45991. * Set the wrapping mode on U of all the textures we are rendering to.
  45992. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45993. */
  45994. wrapU: number;
  45995. /**
  45996. * Set the wrapping mode on V of all the textures we are rendering to.
  45997. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45998. */
  45999. wrapV: number;
  46000. /**
  46001. * Instantiate a new multi render target texture.
  46002. * A multi render target, like a render target provides the ability to render to a texture.
  46003. * Unlike the render target, it can render to several draw buffers in one draw.
  46004. * This is specially interesting in deferred rendering or for any effects requiring more than
  46005. * just one color from a single pass.
  46006. * @param name Define the name of the texture
  46007. * @param size Define the size of the buffers to render to
  46008. * @param count Define the number of target we are rendering into
  46009. * @param scene Define the scene the texture belongs to
  46010. * @param options Define the options used to create the multi render target
  46011. */
  46012. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46013. /** @hidden */
  46014. _rebuild(): void;
  46015. private _createInternalTextures;
  46016. private _createTextures;
  46017. /**
  46018. * Define the number of samples used if MSAA is enabled.
  46019. */
  46020. samples: number;
  46021. /**
  46022. * Resize all the textures in the multi render target.
  46023. * Be carrefull as it will recreate all the data in the new texture.
  46024. * @param size Define the new size
  46025. */
  46026. resize(size: any): void;
  46027. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46028. /**
  46029. * Dispose the render targets and their associated resources
  46030. */
  46031. dispose(): void;
  46032. /**
  46033. * Release all the underlying texture used as draw buffers.
  46034. */
  46035. releaseInternalTextures(): void;
  46036. }
  46037. }
  46038. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46040. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46041. import { Nullable } from "babylonjs/types";
  46042. module "babylonjs/Engines/thinEngine" {
  46043. interface ThinEngine {
  46044. /**
  46045. * Unbind a list of render target textures from the webGL context
  46046. * This is used only when drawBuffer extension or webGL2 are active
  46047. * @param textures defines the render target textures to unbind
  46048. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46049. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46050. */
  46051. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46052. /**
  46053. * Create a multi render target texture
  46054. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46055. * @param size defines the size of the texture
  46056. * @param options defines the creation options
  46057. * @returns the cube texture as an InternalTexture
  46058. */
  46059. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46060. /**
  46061. * Update the sample count for a given multiple render target texture
  46062. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46063. * @param textures defines the textures to update
  46064. * @param samples defines the sample count to set
  46065. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46066. */
  46067. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46068. }
  46069. }
  46070. }
  46071. declare module "babylonjs/Engines/Extensions/index" {
  46072. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46073. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46074. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46075. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46076. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46077. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46078. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46079. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46080. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46081. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46082. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46083. }
  46084. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46085. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46086. /** @hidden */
  46087. export var rgbdEncodePixelShader: {
  46088. name: string;
  46089. shader: string;
  46090. };
  46091. }
  46092. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46093. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46094. /** @hidden */
  46095. export var rgbdDecodePixelShader: {
  46096. name: string;
  46097. shader: string;
  46098. };
  46099. }
  46100. declare module "babylonjs/Misc/environmentTextureTools" {
  46101. import { Nullable } from "babylonjs/types";
  46102. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46103. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46104. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46105. import "babylonjs/Engines/Extensions/engine.renderTarget";
  46106. import "babylonjs/Shaders/rgbdEncode.fragment";
  46107. import "babylonjs/Shaders/rgbdDecode.fragment";
  46108. /**
  46109. * Raw texture data and descriptor sufficient for WebGL texture upload
  46110. */
  46111. export interface EnvironmentTextureInfo {
  46112. /**
  46113. * Version of the environment map
  46114. */
  46115. version: number;
  46116. /**
  46117. * Width of image
  46118. */
  46119. width: number;
  46120. /**
  46121. * Irradiance information stored in the file.
  46122. */
  46123. irradiance: any;
  46124. /**
  46125. * Specular information stored in the file.
  46126. */
  46127. specular: any;
  46128. }
  46129. /**
  46130. * Defines One Image in the file. It requires only the position in the file
  46131. * as well as the length.
  46132. */
  46133. interface BufferImageData {
  46134. /**
  46135. * Length of the image data.
  46136. */
  46137. length: number;
  46138. /**
  46139. * Position of the data from the null terminator delimiting the end of the JSON.
  46140. */
  46141. position: number;
  46142. }
  46143. /**
  46144. * Defines the specular data enclosed in the file.
  46145. * This corresponds to the version 1 of the data.
  46146. */
  46147. export interface EnvironmentTextureSpecularInfoV1 {
  46148. /**
  46149. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46150. */
  46151. specularDataPosition?: number;
  46152. /**
  46153. * This contains all the images data needed to reconstruct the cubemap.
  46154. */
  46155. mipmaps: Array<BufferImageData>;
  46156. /**
  46157. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46158. */
  46159. lodGenerationScale: number;
  46160. }
  46161. /**
  46162. * Sets of helpers addressing the serialization and deserialization of environment texture
  46163. * stored in a BabylonJS env file.
  46164. * Those files are usually stored as .env files.
  46165. */
  46166. export class EnvironmentTextureTools {
  46167. /**
  46168. * Magic number identifying the env file.
  46169. */
  46170. private static _MagicBytes;
  46171. /**
  46172. * Gets the environment info from an env file.
  46173. * @param data The array buffer containing the .env bytes.
  46174. * @returns the environment file info (the json header) if successfully parsed.
  46175. */
  46176. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46177. /**
  46178. * Creates an environment texture from a loaded cube texture.
  46179. * @param texture defines the cube texture to convert in env file
  46180. * @return a promise containing the environment data if succesfull.
  46181. */
  46182. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46183. /**
  46184. * Creates a JSON representation of the spherical data.
  46185. * @param texture defines the texture containing the polynomials
  46186. * @return the JSON representation of the spherical info
  46187. */
  46188. private static _CreateEnvTextureIrradiance;
  46189. /**
  46190. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46191. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46192. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46193. * @return the views described by info providing access to the underlying buffer
  46194. */
  46195. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46196. /**
  46197. * Uploads the texture info contained in the env file to the GPU.
  46198. * @param texture defines the internal texture to upload to
  46199. * @param arrayBuffer defines the buffer cotaining the data to load
  46200. * @param info defines the texture info retrieved through the GetEnvInfo method
  46201. * @returns a promise
  46202. */
  46203. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46204. /**
  46205. * Uploads the levels of image data to the GPU.
  46206. * @param texture defines the internal texture to upload to
  46207. * @param imageData defines the array buffer views of image data [mipmap][face]
  46208. * @returns a promise
  46209. */
  46210. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46211. /**
  46212. * Uploads spherical polynomials information to the texture.
  46213. * @param texture defines the texture we are trying to upload the information to
  46214. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46215. */
  46216. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46217. /** @hidden */
  46218. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46219. }
  46220. }
  46221. declare module "babylonjs/Maths/math.vertexFormat" {
  46222. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46223. /**
  46224. * Contains position and normal vectors for a vertex
  46225. */
  46226. export class PositionNormalVertex {
  46227. /** the position of the vertex (defaut: 0,0,0) */
  46228. position: Vector3;
  46229. /** the normal of the vertex (defaut: 0,1,0) */
  46230. normal: Vector3;
  46231. /**
  46232. * Creates a PositionNormalVertex
  46233. * @param position the position of the vertex (defaut: 0,0,0)
  46234. * @param normal the normal of the vertex (defaut: 0,1,0)
  46235. */
  46236. constructor(
  46237. /** the position of the vertex (defaut: 0,0,0) */
  46238. position?: Vector3,
  46239. /** the normal of the vertex (defaut: 0,1,0) */
  46240. normal?: Vector3);
  46241. /**
  46242. * Clones the PositionNormalVertex
  46243. * @returns the cloned PositionNormalVertex
  46244. */
  46245. clone(): PositionNormalVertex;
  46246. }
  46247. /**
  46248. * Contains position, normal and uv vectors for a vertex
  46249. */
  46250. export class PositionNormalTextureVertex {
  46251. /** the position of the vertex (defaut: 0,0,0) */
  46252. position: Vector3;
  46253. /** the normal of the vertex (defaut: 0,1,0) */
  46254. normal: Vector3;
  46255. /** the uv of the vertex (default: 0,0) */
  46256. uv: Vector2;
  46257. /**
  46258. * Creates a PositionNormalTextureVertex
  46259. * @param position the position of the vertex (defaut: 0,0,0)
  46260. * @param normal the normal of the vertex (defaut: 0,1,0)
  46261. * @param uv the uv of the vertex (default: 0,0)
  46262. */
  46263. constructor(
  46264. /** the position of the vertex (defaut: 0,0,0) */
  46265. position?: Vector3,
  46266. /** the normal of the vertex (defaut: 0,1,0) */
  46267. normal?: Vector3,
  46268. /** the uv of the vertex (default: 0,0) */
  46269. uv?: Vector2);
  46270. /**
  46271. * Clones the PositionNormalTextureVertex
  46272. * @returns the cloned PositionNormalTextureVertex
  46273. */
  46274. clone(): PositionNormalTextureVertex;
  46275. }
  46276. }
  46277. declare module "babylonjs/Maths/math" {
  46278. export * from "babylonjs/Maths/math.axis";
  46279. export * from "babylonjs/Maths/math.color";
  46280. export * from "babylonjs/Maths/math.constants";
  46281. export * from "babylonjs/Maths/math.frustum";
  46282. export * from "babylonjs/Maths/math.path";
  46283. export * from "babylonjs/Maths/math.plane";
  46284. export * from "babylonjs/Maths/math.size";
  46285. export * from "babylonjs/Maths/math.vector";
  46286. export * from "babylonjs/Maths/math.vertexFormat";
  46287. export * from "babylonjs/Maths/math.viewport";
  46288. }
  46289. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46290. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46291. /** @hidden */
  46292. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46293. private _genericAttributeLocation;
  46294. private _varyingLocationCount;
  46295. private _varyingLocationMap;
  46296. private _replacements;
  46297. private _textureCount;
  46298. private _uniforms;
  46299. lineProcessor(line: string): string;
  46300. attributeProcessor(attribute: string): string;
  46301. varyingProcessor(varying: string, isFragment: boolean): string;
  46302. uniformProcessor(uniform: string): string;
  46303. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46304. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46305. }
  46306. }
  46307. declare module "babylonjs/Engines/nativeEngine" {
  46308. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46309. import { Engine } from "babylonjs/Engines/engine";
  46310. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46311. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46313. import { Effect } from "babylonjs/Materials/effect";
  46314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46315. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46316. import { Scene } from "babylonjs/scene";
  46317. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46318. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46319. /**
  46320. * Container for accessors for natively-stored mesh data buffers.
  46321. */
  46322. class NativeDataBuffer extends DataBuffer {
  46323. /**
  46324. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46325. */
  46326. nativeIndexBuffer?: any;
  46327. /**
  46328. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46329. */
  46330. nativeVertexBuffer?: any;
  46331. }
  46332. /** @hidden */
  46333. export class NativeEngine extends Engine {
  46334. private readonly _native;
  46335. getHardwareScalingLevel(): number;
  46336. constructor();
  46337. /**
  46338. * Can be used to override the current requestAnimationFrame requester.
  46339. * @hidden
  46340. */
  46341. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46342. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46343. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46344. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46345. recordVertexArrayObject(vertexBuffers: {
  46346. [key: string]: VertexBuffer;
  46347. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46348. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46349. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46350. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46351. /**
  46352. * Draw a list of indexed primitives
  46353. * @param fillMode defines the primitive to use
  46354. * @param indexStart defines the starting index
  46355. * @param indexCount defines the number of index to draw
  46356. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46357. */
  46358. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46359. /**
  46360. * Draw a list of unindexed primitives
  46361. * @param fillMode defines the primitive to use
  46362. * @param verticesStart defines the index of first vertex to draw
  46363. * @param verticesCount defines the count of vertices to draw
  46364. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46365. */
  46366. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46367. createPipelineContext(): IPipelineContext;
  46368. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46369. /** @hidden */
  46370. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46371. /** @hidden */
  46372. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46373. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46374. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46375. protected _setProgram(program: WebGLProgram): void;
  46376. _releaseEffect(effect: Effect): void;
  46377. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46378. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46379. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46380. bindSamplers(effect: Effect): void;
  46381. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46382. getRenderWidth(useScreen?: boolean): number;
  46383. getRenderHeight(useScreen?: boolean): number;
  46384. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46385. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46386. /**
  46387. * Set the z offset to apply to current rendering
  46388. * @param value defines the offset to apply
  46389. */
  46390. setZOffset(value: number): void;
  46391. /**
  46392. * Gets the current value of the zOffset
  46393. * @returns the current zOffset state
  46394. */
  46395. getZOffset(): number;
  46396. /**
  46397. * Enable or disable depth buffering
  46398. * @param enable defines the state to set
  46399. */
  46400. setDepthBuffer(enable: boolean): void;
  46401. /**
  46402. * Gets a boolean indicating if depth writing is enabled
  46403. * @returns the current depth writing state
  46404. */
  46405. getDepthWrite(): boolean;
  46406. /**
  46407. * Enable or disable depth writing
  46408. * @param enable defines the state to set
  46409. */
  46410. setDepthWrite(enable: boolean): void;
  46411. /**
  46412. * Enable or disable color writing
  46413. * @param enable defines the state to set
  46414. */
  46415. setColorWrite(enable: boolean): void;
  46416. /**
  46417. * Gets a boolean indicating if color writing is enabled
  46418. * @returns the current color writing state
  46419. */
  46420. getColorWrite(): boolean;
  46421. /**
  46422. * Sets alpha constants used by some alpha blending modes
  46423. * @param r defines the red component
  46424. * @param g defines the green component
  46425. * @param b defines the blue component
  46426. * @param a defines the alpha component
  46427. */
  46428. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46429. /**
  46430. * Sets the current alpha mode
  46431. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46432. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46433. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46434. */
  46435. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46436. /**
  46437. * Gets the current alpha mode
  46438. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46439. * @returns the current alpha mode
  46440. */
  46441. getAlphaMode(): number;
  46442. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46443. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46444. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46445. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46446. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46447. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46448. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46449. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46450. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46451. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46452. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46453. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46454. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46455. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46456. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46457. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46458. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46459. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46460. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46461. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46462. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46463. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46464. wipeCaches(bruteForce?: boolean): void;
  46465. _createTexture(): WebGLTexture;
  46466. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46467. /**
  46468. * Usually called from BABYLON.Texture.ts.
  46469. * Passed information to create a WebGLTexture
  46470. * @param urlArg defines a value which contains one of the following:
  46471. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46472. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46473. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46474. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46475. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46476. * @param scene needed for loading to the correct scene
  46477. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46478. * @param onLoad optional callback to be called upon successful completion
  46479. * @param onError optional callback to be called upon failure
  46480. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46481. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46482. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46483. * @param forcedExtension defines the extension to use to pick the right loader
  46484. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46485. */
  46486. 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;
  46487. /**
  46488. * Creates a cube texture
  46489. * @param rootUrl defines the url where the files to load is located
  46490. * @param scene defines the current scene
  46491. * @param files defines the list of files to load (1 per face)
  46492. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46493. * @param onLoad defines an optional callback raised when the texture is loaded
  46494. * @param onError defines an optional callback raised if there is an issue to load the texture
  46495. * @param format defines the format of the data
  46496. * @param forcedExtension defines the extension to use to pick the right loader
  46497. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46498. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46499. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46500. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46501. * @returns the cube texture as an InternalTexture
  46502. */
  46503. 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;
  46504. private _getSamplingFilter;
  46505. private static _GetNativeTextureFormat;
  46506. createRenderTargetTexture(size: number | {
  46507. width: number;
  46508. height: number;
  46509. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46510. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46511. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46512. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46513. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46514. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46515. /**
  46516. * Updates a dynamic vertex buffer.
  46517. * @param vertexBuffer the vertex buffer to update
  46518. * @param data the data used to update the vertex buffer
  46519. * @param byteOffset the byte offset of the data (optional)
  46520. * @param byteLength the byte length of the data (optional)
  46521. */
  46522. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46523. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46524. private _updateAnisotropicLevel;
  46525. private _getAddressMode;
  46526. /** @hidden */
  46527. _bindTexture(channel: number, texture: InternalTexture): void;
  46528. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46529. releaseEffects(): void;
  46530. /** @hidden */
  46531. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46532. /** @hidden */
  46533. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46534. /** @hidden */
  46535. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46536. /** @hidden */
  46537. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46538. }
  46539. }
  46540. declare module "babylonjs/Engines/index" {
  46541. export * from "babylonjs/Engines/constants";
  46542. export * from "babylonjs/Engines/engineCapabilities";
  46543. export * from "babylonjs/Engines/instancingAttributeInfo";
  46544. export * from "babylonjs/Engines/thinEngine";
  46545. export * from "babylonjs/Engines/engine";
  46546. export * from "babylonjs/Engines/engineStore";
  46547. export * from "babylonjs/Engines/nullEngine";
  46548. export * from "babylonjs/Engines/Extensions/index";
  46549. export * from "babylonjs/Engines/IPipelineContext";
  46550. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46551. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46552. export * from "babylonjs/Engines/nativeEngine";
  46553. }
  46554. declare module "babylonjs/Events/clipboardEvents" {
  46555. /**
  46556. * Gather the list of clipboard event types as constants.
  46557. */
  46558. export class ClipboardEventTypes {
  46559. /**
  46560. * The clipboard event is fired when a copy command is active (pressed).
  46561. */
  46562. static readonly COPY: number;
  46563. /**
  46564. * The clipboard event is fired when a cut command is active (pressed).
  46565. */
  46566. static readonly CUT: number;
  46567. /**
  46568. * The clipboard event is fired when a paste command is active (pressed).
  46569. */
  46570. static readonly PASTE: number;
  46571. }
  46572. /**
  46573. * This class is used to store clipboard related info for the onClipboardObservable event.
  46574. */
  46575. export class ClipboardInfo {
  46576. /**
  46577. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46578. */
  46579. type: number;
  46580. /**
  46581. * Defines the related dom event
  46582. */
  46583. event: ClipboardEvent;
  46584. /**
  46585. *Creates an instance of ClipboardInfo.
  46586. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46587. * @param event Defines the related dom event
  46588. */
  46589. constructor(
  46590. /**
  46591. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46592. */
  46593. type: number,
  46594. /**
  46595. * Defines the related dom event
  46596. */
  46597. event: ClipboardEvent);
  46598. /**
  46599. * Get the clipboard event's type from the keycode.
  46600. * @param keyCode Defines the keyCode for the current keyboard event.
  46601. * @return {number}
  46602. */
  46603. static GetTypeFromCharacter(keyCode: number): number;
  46604. }
  46605. }
  46606. declare module "babylonjs/Events/index" {
  46607. export * from "babylonjs/Events/keyboardEvents";
  46608. export * from "babylonjs/Events/pointerEvents";
  46609. export * from "babylonjs/Events/clipboardEvents";
  46610. }
  46611. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46612. import { Scene } from "babylonjs/scene";
  46613. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46614. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46615. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46616. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46617. /**
  46618. * Google Daydream controller
  46619. */
  46620. export class DaydreamController extends WebVRController {
  46621. /**
  46622. * Base Url for the controller model.
  46623. */
  46624. static MODEL_BASE_URL: string;
  46625. /**
  46626. * File name for the controller model.
  46627. */
  46628. static MODEL_FILENAME: string;
  46629. /**
  46630. * Gamepad Id prefix used to identify Daydream Controller.
  46631. */
  46632. static readonly GAMEPAD_ID_PREFIX: string;
  46633. /**
  46634. * Creates a new DaydreamController from a gamepad
  46635. * @param vrGamepad the gamepad that the controller should be created from
  46636. */
  46637. constructor(vrGamepad: any);
  46638. /**
  46639. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46640. * @param scene scene in which to add meshes
  46641. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46642. */
  46643. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46644. /**
  46645. * Called once for each button that changed state since the last frame
  46646. * @param buttonIdx Which button index changed
  46647. * @param state New state of the button
  46648. * @param changes Which properties on the state changed since last frame
  46649. */
  46650. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46651. }
  46652. }
  46653. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46654. import { Scene } from "babylonjs/scene";
  46655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46656. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46657. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46658. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46659. /**
  46660. * Gear VR Controller
  46661. */
  46662. export class GearVRController extends WebVRController {
  46663. /**
  46664. * Base Url for the controller model.
  46665. */
  46666. static MODEL_BASE_URL: string;
  46667. /**
  46668. * File name for the controller model.
  46669. */
  46670. static MODEL_FILENAME: string;
  46671. /**
  46672. * Gamepad Id prefix used to identify this controller.
  46673. */
  46674. static readonly GAMEPAD_ID_PREFIX: string;
  46675. private readonly _buttonIndexToObservableNameMap;
  46676. /**
  46677. * Creates a new GearVRController from a gamepad
  46678. * @param vrGamepad the gamepad that the controller should be created from
  46679. */
  46680. constructor(vrGamepad: any);
  46681. /**
  46682. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46683. * @param scene scene in which to add meshes
  46684. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46685. */
  46686. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46687. /**
  46688. * Called once for each button that changed state since the last frame
  46689. * @param buttonIdx Which button index changed
  46690. * @param state New state of the button
  46691. * @param changes Which properties on the state changed since last frame
  46692. */
  46693. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46694. }
  46695. }
  46696. declare module "babylonjs/Gamepads/Controllers/index" {
  46697. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46698. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46699. export * from "babylonjs/Gamepads/Controllers/genericController";
  46700. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46701. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46702. export * from "babylonjs/Gamepads/Controllers/viveController";
  46703. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46704. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46705. }
  46706. declare module "babylonjs/Gamepads/index" {
  46707. export * from "babylonjs/Gamepads/Controllers/index";
  46708. export * from "babylonjs/Gamepads/gamepad";
  46709. export * from "babylonjs/Gamepads/gamepadManager";
  46710. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46711. export * from "babylonjs/Gamepads/xboxGamepad";
  46712. export * from "babylonjs/Gamepads/dualShockGamepad";
  46713. }
  46714. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46715. import { Scene } from "babylonjs/scene";
  46716. import { Vector4 } from "babylonjs/Maths/math.vector";
  46717. import { Color4 } from "babylonjs/Maths/math.color";
  46718. import { Mesh } from "babylonjs/Meshes/mesh";
  46719. import { Nullable } from "babylonjs/types";
  46720. /**
  46721. * Class containing static functions to help procedurally build meshes
  46722. */
  46723. export class PolyhedronBuilder {
  46724. /**
  46725. * Creates a polyhedron mesh
  46726. * * 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
  46727. * * The parameter `size` (positive float, default 1) sets the polygon size
  46728. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46729. * * 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`
  46730. * * 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
  46731. * * 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)`)
  46732. * * 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
  46733. * * 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
  46734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46735. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46736. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46737. * @param name defines the name of the mesh
  46738. * @param options defines the options used to create the mesh
  46739. * @param scene defines the hosting scene
  46740. * @returns the polyhedron mesh
  46741. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46742. */
  46743. static CreatePolyhedron(name: string, options: {
  46744. type?: number;
  46745. size?: number;
  46746. sizeX?: number;
  46747. sizeY?: number;
  46748. sizeZ?: number;
  46749. custom?: any;
  46750. faceUV?: Vector4[];
  46751. faceColors?: Color4[];
  46752. flat?: boolean;
  46753. updatable?: boolean;
  46754. sideOrientation?: number;
  46755. frontUVs?: Vector4;
  46756. backUVs?: Vector4;
  46757. }, scene?: Nullable<Scene>): Mesh;
  46758. }
  46759. }
  46760. declare module "babylonjs/Gizmos/scaleGizmo" {
  46761. import { Observable } from "babylonjs/Misc/observable";
  46762. import { Nullable } from "babylonjs/types";
  46763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46764. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46765. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46766. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46767. /**
  46768. * Gizmo that enables scaling a mesh along 3 axis
  46769. */
  46770. export class ScaleGizmo extends Gizmo {
  46771. /**
  46772. * Internal gizmo used for interactions on the x axis
  46773. */
  46774. xGizmo: AxisScaleGizmo;
  46775. /**
  46776. * Internal gizmo used for interactions on the y axis
  46777. */
  46778. yGizmo: AxisScaleGizmo;
  46779. /**
  46780. * Internal gizmo used for interactions on the z axis
  46781. */
  46782. zGizmo: AxisScaleGizmo;
  46783. /**
  46784. * Internal gizmo used to scale all axis equally
  46785. */
  46786. uniformScaleGizmo: AxisScaleGizmo;
  46787. private _meshAttached;
  46788. private _updateGizmoRotationToMatchAttachedMesh;
  46789. private _snapDistance;
  46790. private _scaleRatio;
  46791. private _uniformScalingMesh;
  46792. private _octahedron;
  46793. /** Fires an event when any of it's sub gizmos are dragged */
  46794. onDragStartObservable: Observable<unknown>;
  46795. /** Fires an event when any of it's sub gizmos are released from dragging */
  46796. onDragEndObservable: Observable<unknown>;
  46797. attachedMesh: Nullable<AbstractMesh>;
  46798. /**
  46799. * Creates a ScaleGizmo
  46800. * @param gizmoLayer The utility layer the gizmo will be added to
  46801. */
  46802. constructor(gizmoLayer?: UtilityLayerRenderer);
  46803. updateGizmoRotationToMatchAttachedMesh: boolean;
  46804. /**
  46805. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46806. */
  46807. snapDistance: number;
  46808. /**
  46809. * Ratio for the scale of the gizmo (Default: 1)
  46810. */
  46811. scaleRatio: number;
  46812. /**
  46813. * Disposes of the gizmo
  46814. */
  46815. dispose(): void;
  46816. }
  46817. }
  46818. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46819. import { Observable } from "babylonjs/Misc/observable";
  46820. import { Nullable } from "babylonjs/types";
  46821. import { Vector3 } from "babylonjs/Maths/math.vector";
  46822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46823. import { Mesh } from "babylonjs/Meshes/mesh";
  46824. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46825. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46826. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46827. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46828. import { Color3 } from "babylonjs/Maths/math.color";
  46829. /**
  46830. * Single axis scale gizmo
  46831. */
  46832. export class AxisScaleGizmo extends Gizmo {
  46833. /**
  46834. * Drag behavior responsible for the gizmos dragging interactions
  46835. */
  46836. dragBehavior: PointerDragBehavior;
  46837. private _pointerObserver;
  46838. /**
  46839. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46840. */
  46841. snapDistance: number;
  46842. /**
  46843. * Event that fires each time the gizmo snaps to a new location.
  46844. * * snapDistance is the the change in distance
  46845. */
  46846. onSnapObservable: Observable<{
  46847. snapDistance: number;
  46848. }>;
  46849. /**
  46850. * If the scaling operation should be done on all axis (default: false)
  46851. */
  46852. uniformScaling: boolean;
  46853. private _isEnabled;
  46854. private _parent;
  46855. private _arrow;
  46856. private _coloredMaterial;
  46857. private _hoverMaterial;
  46858. /**
  46859. * Creates an AxisScaleGizmo
  46860. * @param gizmoLayer The utility layer the gizmo will be added to
  46861. * @param dragAxis The axis which the gizmo will be able to scale on
  46862. * @param color The color of the gizmo
  46863. */
  46864. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46865. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46866. /**
  46867. * If the gizmo is enabled
  46868. */
  46869. isEnabled: boolean;
  46870. /**
  46871. * Disposes of the gizmo
  46872. */
  46873. dispose(): void;
  46874. /**
  46875. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46876. * @param mesh The mesh to replace the default mesh of the gizmo
  46877. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46878. */
  46879. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46880. }
  46881. }
  46882. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46883. import { Observable } from "babylonjs/Misc/observable";
  46884. import { Nullable } from "babylonjs/types";
  46885. import { Vector3 } from "babylonjs/Maths/math.vector";
  46886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46887. import { Mesh } from "babylonjs/Meshes/mesh";
  46888. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46889. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46890. import { Color3 } from "babylonjs/Maths/math.color";
  46891. import "babylonjs/Meshes/Builders/boxBuilder";
  46892. /**
  46893. * Bounding box gizmo
  46894. */
  46895. export class BoundingBoxGizmo extends Gizmo {
  46896. private _lineBoundingBox;
  46897. private _rotateSpheresParent;
  46898. private _scaleBoxesParent;
  46899. private _boundingDimensions;
  46900. private _renderObserver;
  46901. private _pointerObserver;
  46902. private _scaleDragSpeed;
  46903. private _tmpQuaternion;
  46904. private _tmpVector;
  46905. private _tmpRotationMatrix;
  46906. /**
  46907. * 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)
  46908. */
  46909. ignoreChildren: boolean;
  46910. /**
  46911. * 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)
  46912. */
  46913. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46914. /**
  46915. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46916. */
  46917. rotationSphereSize: number;
  46918. /**
  46919. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46920. */
  46921. scaleBoxSize: number;
  46922. /**
  46923. * 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)
  46924. */
  46925. fixedDragMeshScreenSize: boolean;
  46926. /**
  46927. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46928. */
  46929. fixedDragMeshScreenSizeDistanceFactor: number;
  46930. /**
  46931. * Fired when a rotation sphere or scale box is dragged
  46932. */
  46933. onDragStartObservable: Observable<{}>;
  46934. /**
  46935. * Fired when a scale box is dragged
  46936. */
  46937. onScaleBoxDragObservable: Observable<{}>;
  46938. /**
  46939. * Fired when a scale box drag is ended
  46940. */
  46941. onScaleBoxDragEndObservable: Observable<{}>;
  46942. /**
  46943. * Fired when a rotation sphere is dragged
  46944. */
  46945. onRotationSphereDragObservable: Observable<{}>;
  46946. /**
  46947. * Fired when a rotation sphere drag is ended
  46948. */
  46949. onRotationSphereDragEndObservable: Observable<{}>;
  46950. /**
  46951. * 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)
  46952. */
  46953. scalePivot: Nullable<Vector3>;
  46954. /**
  46955. * Mesh used as a pivot to rotate the attached mesh
  46956. */
  46957. private _anchorMesh;
  46958. private _existingMeshScale;
  46959. private _dragMesh;
  46960. private pointerDragBehavior;
  46961. private coloredMaterial;
  46962. private hoverColoredMaterial;
  46963. /**
  46964. * Sets the color of the bounding box gizmo
  46965. * @param color the color to set
  46966. */
  46967. setColor(color: Color3): void;
  46968. /**
  46969. * Creates an BoundingBoxGizmo
  46970. * @param gizmoLayer The utility layer the gizmo will be added to
  46971. * @param color The color of the gizmo
  46972. */
  46973. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46974. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46975. private _selectNode;
  46976. /**
  46977. * Updates the bounding box information for the Gizmo
  46978. */
  46979. updateBoundingBox(): void;
  46980. private _updateRotationSpheres;
  46981. private _updateScaleBoxes;
  46982. /**
  46983. * Enables rotation on the specified axis and disables rotation on the others
  46984. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46985. */
  46986. setEnabledRotationAxis(axis: string): void;
  46987. /**
  46988. * Enables/disables scaling
  46989. * @param enable if scaling should be enabled
  46990. */
  46991. setEnabledScaling(enable: boolean): void;
  46992. private _updateDummy;
  46993. /**
  46994. * Enables a pointer drag behavior on the bounding box of the gizmo
  46995. */
  46996. enableDragBehavior(): void;
  46997. /**
  46998. * Disposes of the gizmo
  46999. */
  47000. dispose(): void;
  47001. /**
  47002. * 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)
  47003. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47004. * @returns the bounding box mesh with the passed in mesh as a child
  47005. */
  47006. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47007. /**
  47008. * CustomMeshes are not supported by this gizmo
  47009. * @param mesh The mesh to replace the default mesh of the gizmo
  47010. */
  47011. setCustomMesh(mesh: Mesh): void;
  47012. }
  47013. }
  47014. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47015. import { Observable } from "babylonjs/Misc/observable";
  47016. import { Nullable } from "babylonjs/types";
  47017. import { Vector3 } from "babylonjs/Maths/math.vector";
  47018. import { Color3 } from "babylonjs/Maths/math.color";
  47019. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47020. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47021. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47022. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47023. import "babylonjs/Meshes/Builders/linesBuilder";
  47024. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47025. /**
  47026. * Single plane rotation gizmo
  47027. */
  47028. export class PlaneRotationGizmo extends Gizmo {
  47029. /**
  47030. * Drag behavior responsible for the gizmos dragging interactions
  47031. */
  47032. dragBehavior: PointerDragBehavior;
  47033. private _pointerObserver;
  47034. /**
  47035. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47036. */
  47037. snapDistance: number;
  47038. /**
  47039. * Event that fires each time the gizmo snaps to a new location.
  47040. * * snapDistance is the the change in distance
  47041. */
  47042. onSnapObservable: Observable<{
  47043. snapDistance: number;
  47044. }>;
  47045. private _isEnabled;
  47046. private _parent;
  47047. /**
  47048. * Creates a PlaneRotationGizmo
  47049. * @param gizmoLayer The utility layer the gizmo will be added to
  47050. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47051. * @param color The color of the gizmo
  47052. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47053. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47054. */
  47055. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47056. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47057. /**
  47058. * If the gizmo is enabled
  47059. */
  47060. isEnabled: boolean;
  47061. /**
  47062. * Disposes of the gizmo
  47063. */
  47064. dispose(): void;
  47065. }
  47066. }
  47067. declare module "babylonjs/Gizmos/rotationGizmo" {
  47068. import { Observable } from "babylonjs/Misc/observable";
  47069. import { Nullable } from "babylonjs/types";
  47070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47071. import { Mesh } from "babylonjs/Meshes/mesh";
  47072. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47073. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47074. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47075. /**
  47076. * Gizmo that enables rotating a mesh along 3 axis
  47077. */
  47078. export class RotationGizmo extends Gizmo {
  47079. /**
  47080. * Internal gizmo used for interactions on the x axis
  47081. */
  47082. xGizmo: PlaneRotationGizmo;
  47083. /**
  47084. * Internal gizmo used for interactions on the y axis
  47085. */
  47086. yGizmo: PlaneRotationGizmo;
  47087. /**
  47088. * Internal gizmo used for interactions on the z axis
  47089. */
  47090. zGizmo: PlaneRotationGizmo;
  47091. /** Fires an event when any of it's sub gizmos are dragged */
  47092. onDragStartObservable: Observable<unknown>;
  47093. /** Fires an event when any of it's sub gizmos are released from dragging */
  47094. onDragEndObservable: Observable<unknown>;
  47095. private _meshAttached;
  47096. attachedMesh: Nullable<AbstractMesh>;
  47097. /**
  47098. * Creates a RotationGizmo
  47099. * @param gizmoLayer The utility layer the gizmo will be added to
  47100. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47101. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47102. */
  47103. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47104. updateGizmoRotationToMatchAttachedMesh: boolean;
  47105. /**
  47106. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47107. */
  47108. snapDistance: number;
  47109. /**
  47110. * Ratio for the scale of the gizmo (Default: 1)
  47111. */
  47112. scaleRatio: number;
  47113. /**
  47114. * Disposes of the gizmo
  47115. */
  47116. dispose(): void;
  47117. /**
  47118. * CustomMeshes are not supported by this gizmo
  47119. * @param mesh The mesh to replace the default mesh of the gizmo
  47120. */
  47121. setCustomMesh(mesh: Mesh): void;
  47122. }
  47123. }
  47124. declare module "babylonjs/Gizmos/gizmoManager" {
  47125. import { Observable } from "babylonjs/Misc/observable";
  47126. import { Nullable } from "babylonjs/types";
  47127. import { Scene, IDisposable } from "babylonjs/scene";
  47128. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47129. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47130. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47131. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47132. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47133. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47134. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47135. /**
  47136. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47137. */
  47138. export class GizmoManager implements IDisposable {
  47139. private scene;
  47140. /**
  47141. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47142. */
  47143. gizmos: {
  47144. positionGizmo: Nullable<PositionGizmo>;
  47145. rotationGizmo: Nullable<RotationGizmo>;
  47146. scaleGizmo: Nullable<ScaleGizmo>;
  47147. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47148. };
  47149. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47150. clearGizmoOnEmptyPointerEvent: boolean;
  47151. /** Fires an event when the manager is attached to a mesh */
  47152. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47153. private _gizmosEnabled;
  47154. private _pointerObserver;
  47155. private _attachedMesh;
  47156. private _boundingBoxColor;
  47157. private _defaultUtilityLayer;
  47158. private _defaultKeepDepthUtilityLayer;
  47159. /**
  47160. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47161. */
  47162. boundingBoxDragBehavior: SixDofDragBehavior;
  47163. /**
  47164. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47165. */
  47166. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47167. /**
  47168. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47169. */
  47170. usePointerToAttachGizmos: boolean;
  47171. /**
  47172. * Utility layer that the bounding box gizmo belongs to
  47173. */
  47174. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47175. /**
  47176. * Utility layer that all gizmos besides bounding box belong to
  47177. */
  47178. readonly utilityLayer: UtilityLayerRenderer;
  47179. /**
  47180. * Instatiates a gizmo manager
  47181. * @param scene the scene to overlay the gizmos on top of
  47182. */
  47183. constructor(scene: Scene);
  47184. /**
  47185. * Attaches a set of gizmos to the specified mesh
  47186. * @param mesh The mesh the gizmo's should be attached to
  47187. */
  47188. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47189. /**
  47190. * If the position gizmo is enabled
  47191. */
  47192. positionGizmoEnabled: boolean;
  47193. /**
  47194. * If the rotation gizmo is enabled
  47195. */
  47196. rotationGizmoEnabled: boolean;
  47197. /**
  47198. * If the scale gizmo is enabled
  47199. */
  47200. scaleGizmoEnabled: boolean;
  47201. /**
  47202. * If the boundingBox gizmo is enabled
  47203. */
  47204. boundingBoxGizmoEnabled: boolean;
  47205. /**
  47206. * Disposes of the gizmo manager
  47207. */
  47208. dispose(): void;
  47209. }
  47210. }
  47211. declare module "babylonjs/Lights/directionalLight" {
  47212. import { Camera } from "babylonjs/Cameras/camera";
  47213. import { Scene } from "babylonjs/scene";
  47214. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47216. import { Light } from "babylonjs/Lights/light";
  47217. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47218. import { Effect } from "babylonjs/Materials/effect";
  47219. /**
  47220. * A directional light is defined by a direction (what a surprise!).
  47221. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47222. * 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.
  47223. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47224. */
  47225. export class DirectionalLight extends ShadowLight {
  47226. private _shadowFrustumSize;
  47227. /**
  47228. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47229. */
  47230. /**
  47231. * Specifies a fix frustum size for the shadow generation.
  47232. */
  47233. shadowFrustumSize: number;
  47234. private _shadowOrthoScale;
  47235. /**
  47236. * Gets the shadow projection scale against the optimal computed one.
  47237. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47238. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47239. */
  47240. /**
  47241. * Sets the shadow projection scale against the optimal computed one.
  47242. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47243. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47244. */
  47245. shadowOrthoScale: number;
  47246. /**
  47247. * Automatically compute the projection matrix to best fit (including all the casters)
  47248. * on each frame.
  47249. */
  47250. autoUpdateExtends: boolean;
  47251. private _orthoLeft;
  47252. private _orthoRight;
  47253. private _orthoTop;
  47254. private _orthoBottom;
  47255. /**
  47256. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47257. * The directional light is emitted from everywhere in the given direction.
  47258. * It can cast shadows.
  47259. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47260. * @param name The friendly name of the light
  47261. * @param direction The direction of the light
  47262. * @param scene The scene the light belongs to
  47263. */
  47264. constructor(name: string, direction: Vector3, scene: Scene);
  47265. /**
  47266. * Returns the string "DirectionalLight".
  47267. * @return The class name
  47268. */
  47269. getClassName(): string;
  47270. /**
  47271. * Returns the integer 1.
  47272. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47273. */
  47274. getTypeID(): number;
  47275. /**
  47276. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47277. * Returns the DirectionalLight Shadow projection matrix.
  47278. */
  47279. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47280. /**
  47281. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47282. * Returns the DirectionalLight Shadow projection matrix.
  47283. */
  47284. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47285. /**
  47286. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47287. * Returns the DirectionalLight Shadow projection matrix.
  47288. */
  47289. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47290. protected _buildUniformLayout(): void;
  47291. /**
  47292. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47293. * @param effect The effect to update
  47294. * @param lightIndex The index of the light in the effect to update
  47295. * @returns The directional light
  47296. */
  47297. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47298. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47299. /**
  47300. * Gets the minZ used for shadow according to both the scene and the light.
  47301. *
  47302. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47303. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47304. * @param activeCamera The camera we are returning the min for
  47305. * @returns the depth min z
  47306. */
  47307. getDepthMinZ(activeCamera: Camera): number;
  47308. /**
  47309. * Gets the maxZ used for shadow according to both the scene and the light.
  47310. *
  47311. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47312. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47313. * @param activeCamera The camera we are returning the max for
  47314. * @returns the depth max z
  47315. */
  47316. getDepthMaxZ(activeCamera: Camera): number;
  47317. /**
  47318. * Prepares the list of defines specific to the light type.
  47319. * @param defines the list of defines
  47320. * @param lightIndex defines the index of the light for the effect
  47321. */
  47322. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47323. }
  47324. }
  47325. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47326. import { Mesh } from "babylonjs/Meshes/mesh";
  47327. /**
  47328. * Class containing static functions to help procedurally build meshes
  47329. */
  47330. export class HemisphereBuilder {
  47331. /**
  47332. * Creates a hemisphere mesh
  47333. * @param name defines the name of the mesh
  47334. * @param options defines the options used to create the mesh
  47335. * @param scene defines the hosting scene
  47336. * @returns the hemisphere mesh
  47337. */
  47338. static CreateHemisphere(name: string, options: {
  47339. segments?: number;
  47340. diameter?: number;
  47341. sideOrientation?: number;
  47342. }, scene: any): Mesh;
  47343. }
  47344. }
  47345. declare module "babylonjs/Lights/spotLight" {
  47346. import { Nullable } from "babylonjs/types";
  47347. import { Scene } from "babylonjs/scene";
  47348. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47350. import { Effect } from "babylonjs/Materials/effect";
  47351. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47352. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47353. /**
  47354. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47355. * These values define a cone of light starting from the position, emitting toward the direction.
  47356. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47357. * and the exponent defines the speed of the decay of the light with distance (reach).
  47358. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47359. */
  47360. export class SpotLight extends ShadowLight {
  47361. private _angle;
  47362. private _innerAngle;
  47363. private _cosHalfAngle;
  47364. private _lightAngleScale;
  47365. private _lightAngleOffset;
  47366. /**
  47367. * Gets the cone angle of the spot light in Radians.
  47368. */
  47369. /**
  47370. * Sets the cone angle of the spot light in Radians.
  47371. */
  47372. angle: number;
  47373. /**
  47374. * Only used in gltf falloff mode, this defines the angle where
  47375. * the directional falloff will start before cutting at angle which could be seen
  47376. * as outer angle.
  47377. */
  47378. /**
  47379. * Only used in gltf falloff mode, this defines the angle where
  47380. * the directional falloff will start before cutting at angle which could be seen
  47381. * as outer angle.
  47382. */
  47383. innerAngle: number;
  47384. private _shadowAngleScale;
  47385. /**
  47386. * Allows scaling the angle of the light for shadow generation only.
  47387. */
  47388. /**
  47389. * Allows scaling the angle of the light for shadow generation only.
  47390. */
  47391. shadowAngleScale: number;
  47392. /**
  47393. * The light decay speed with the distance from the emission spot.
  47394. */
  47395. exponent: number;
  47396. private _projectionTextureMatrix;
  47397. /**
  47398. * Allows reading the projecton texture
  47399. */
  47400. readonly projectionTextureMatrix: Matrix;
  47401. protected _projectionTextureLightNear: number;
  47402. /**
  47403. * Gets the near clip of the Spotlight for texture projection.
  47404. */
  47405. /**
  47406. * Sets the near clip of the Spotlight for texture projection.
  47407. */
  47408. projectionTextureLightNear: number;
  47409. protected _projectionTextureLightFar: number;
  47410. /**
  47411. * Gets the far clip of the Spotlight for texture projection.
  47412. */
  47413. /**
  47414. * Sets the far clip of the Spotlight for texture projection.
  47415. */
  47416. projectionTextureLightFar: number;
  47417. protected _projectionTextureUpDirection: Vector3;
  47418. /**
  47419. * Gets the Up vector of the Spotlight for texture projection.
  47420. */
  47421. /**
  47422. * Sets the Up vector of the Spotlight for texture projection.
  47423. */
  47424. projectionTextureUpDirection: Vector3;
  47425. private _projectionTexture;
  47426. /**
  47427. * Gets the projection texture of the light.
  47428. */
  47429. /**
  47430. * Sets the projection texture of the light.
  47431. */
  47432. projectionTexture: Nullable<BaseTexture>;
  47433. private _projectionTextureViewLightDirty;
  47434. private _projectionTextureProjectionLightDirty;
  47435. private _projectionTextureDirty;
  47436. private _projectionTextureViewTargetVector;
  47437. private _projectionTextureViewLightMatrix;
  47438. private _projectionTextureProjectionLightMatrix;
  47439. private _projectionTextureScalingMatrix;
  47440. /**
  47441. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47442. * It can cast shadows.
  47443. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47444. * @param name The light friendly name
  47445. * @param position The position of the spot light in the scene
  47446. * @param direction The direction of the light in the scene
  47447. * @param angle The cone angle of the light in Radians
  47448. * @param exponent The light decay speed with the distance from the emission spot
  47449. * @param scene The scene the lights belongs to
  47450. */
  47451. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47452. /**
  47453. * Returns the string "SpotLight".
  47454. * @returns the class name
  47455. */
  47456. getClassName(): string;
  47457. /**
  47458. * Returns the integer 2.
  47459. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47460. */
  47461. getTypeID(): number;
  47462. /**
  47463. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47464. */
  47465. protected _setDirection(value: Vector3): void;
  47466. /**
  47467. * Overrides the position setter to recompute the projection texture view light Matrix.
  47468. */
  47469. protected _setPosition(value: Vector3): void;
  47470. /**
  47471. * 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.
  47472. * Returns the SpotLight.
  47473. */
  47474. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47475. protected _computeProjectionTextureViewLightMatrix(): void;
  47476. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47477. /**
  47478. * Main function for light texture projection matrix computing.
  47479. */
  47480. protected _computeProjectionTextureMatrix(): void;
  47481. protected _buildUniformLayout(): void;
  47482. private _computeAngleValues;
  47483. /**
  47484. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47485. * @param effect The effect to update
  47486. * @param lightIndex The index of the light in the effect to update
  47487. * @returns The spot light
  47488. */
  47489. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47490. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47491. /**
  47492. * Disposes the light and the associated resources.
  47493. */
  47494. dispose(): void;
  47495. /**
  47496. * Prepares the list of defines specific to the light type.
  47497. * @param defines the list of defines
  47498. * @param lightIndex defines the index of the light for the effect
  47499. */
  47500. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47501. }
  47502. }
  47503. declare module "babylonjs/Gizmos/lightGizmo" {
  47504. import { Nullable } from "babylonjs/types";
  47505. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47506. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47507. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47508. import { Light } from "babylonjs/Lights/light";
  47509. /**
  47510. * Gizmo that enables viewing a light
  47511. */
  47512. export class LightGizmo extends Gizmo {
  47513. private _lightMesh;
  47514. private _material;
  47515. private cachedPosition;
  47516. private cachedForward;
  47517. /**
  47518. * Creates a LightGizmo
  47519. * @param gizmoLayer The utility layer the gizmo will be added to
  47520. */
  47521. constructor(gizmoLayer?: UtilityLayerRenderer);
  47522. private _light;
  47523. /**
  47524. * The light that the gizmo is attached to
  47525. */
  47526. light: Nullable<Light>;
  47527. /**
  47528. * Gets the material used to render the light gizmo
  47529. */
  47530. readonly material: StandardMaterial;
  47531. /**
  47532. * @hidden
  47533. * Updates the gizmo to match the attached mesh's position/rotation
  47534. */
  47535. protected _update(): void;
  47536. private static _Scale;
  47537. /**
  47538. * Creates the lines for a light mesh
  47539. */
  47540. private static _createLightLines;
  47541. /**
  47542. * Disposes of the light gizmo
  47543. */
  47544. dispose(): void;
  47545. private static _CreateHemisphericLightMesh;
  47546. private static _CreatePointLightMesh;
  47547. private static _CreateSpotLightMesh;
  47548. private static _CreateDirectionalLightMesh;
  47549. }
  47550. }
  47551. declare module "babylonjs/Gizmos/index" {
  47552. export * from "babylonjs/Gizmos/axisDragGizmo";
  47553. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47554. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47555. export * from "babylonjs/Gizmos/gizmo";
  47556. export * from "babylonjs/Gizmos/gizmoManager";
  47557. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47558. export * from "babylonjs/Gizmos/positionGizmo";
  47559. export * from "babylonjs/Gizmos/rotationGizmo";
  47560. export * from "babylonjs/Gizmos/scaleGizmo";
  47561. export * from "babylonjs/Gizmos/lightGizmo";
  47562. export * from "babylonjs/Gizmos/planeDragGizmo";
  47563. }
  47564. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47565. /** @hidden */
  47566. export var backgroundFragmentDeclaration: {
  47567. name: string;
  47568. shader: string;
  47569. };
  47570. }
  47571. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47572. /** @hidden */
  47573. export var backgroundUboDeclaration: {
  47574. name: string;
  47575. shader: string;
  47576. };
  47577. }
  47578. declare module "babylonjs/Shaders/background.fragment" {
  47579. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47580. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47581. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47582. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47583. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47584. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47585. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47586. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47587. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47588. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47589. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47590. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47591. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47592. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47593. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47594. /** @hidden */
  47595. export var backgroundPixelShader: {
  47596. name: string;
  47597. shader: string;
  47598. };
  47599. }
  47600. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47601. /** @hidden */
  47602. export var backgroundVertexDeclaration: {
  47603. name: string;
  47604. shader: string;
  47605. };
  47606. }
  47607. declare module "babylonjs/Shaders/background.vertex" {
  47608. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47609. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47610. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47611. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47612. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47613. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47614. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47615. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47616. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47617. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47618. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47619. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47620. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47621. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47622. /** @hidden */
  47623. export var backgroundVertexShader: {
  47624. name: string;
  47625. shader: string;
  47626. };
  47627. }
  47628. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47629. import { Nullable, int, float } from "babylonjs/types";
  47630. import { Scene } from "babylonjs/scene";
  47631. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47632. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47634. import { Mesh } from "babylonjs/Meshes/mesh";
  47635. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47636. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47637. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47639. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47640. import { Color3 } from "babylonjs/Maths/math.color";
  47641. import "babylonjs/Shaders/background.fragment";
  47642. import "babylonjs/Shaders/background.vertex";
  47643. /**
  47644. * Background material used to create an efficient environement around your scene.
  47645. */
  47646. export class BackgroundMaterial extends PushMaterial {
  47647. /**
  47648. * Standard reflectance value at parallel view angle.
  47649. */
  47650. static StandardReflectance0: number;
  47651. /**
  47652. * Standard reflectance value at grazing angle.
  47653. */
  47654. static StandardReflectance90: number;
  47655. protected _primaryColor: Color3;
  47656. /**
  47657. * Key light Color (multiply against the environement texture)
  47658. */
  47659. primaryColor: Color3;
  47660. protected __perceptualColor: Nullable<Color3>;
  47661. /**
  47662. * Experimental Internal Use Only.
  47663. *
  47664. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47665. * This acts as a helper to set the primary color to a more "human friendly" value.
  47666. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47667. * output color as close as possible from the chosen value.
  47668. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47669. * part of lighting setup.)
  47670. */
  47671. _perceptualColor: Nullable<Color3>;
  47672. protected _primaryColorShadowLevel: float;
  47673. /**
  47674. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47675. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47676. */
  47677. primaryColorShadowLevel: float;
  47678. protected _primaryColorHighlightLevel: float;
  47679. /**
  47680. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47681. * The primary color is used at the level chosen to define what the white area would look.
  47682. */
  47683. primaryColorHighlightLevel: float;
  47684. protected _reflectionTexture: Nullable<BaseTexture>;
  47685. /**
  47686. * Reflection Texture used in the material.
  47687. * Should be author in a specific way for the best result (refer to the documentation).
  47688. */
  47689. reflectionTexture: Nullable<BaseTexture>;
  47690. protected _reflectionBlur: float;
  47691. /**
  47692. * Reflection Texture level of blur.
  47693. *
  47694. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47695. * texture twice.
  47696. */
  47697. reflectionBlur: float;
  47698. protected _diffuseTexture: Nullable<BaseTexture>;
  47699. /**
  47700. * Diffuse Texture used in the material.
  47701. * Should be author in a specific way for the best result (refer to the documentation).
  47702. */
  47703. diffuseTexture: Nullable<BaseTexture>;
  47704. protected _shadowLights: Nullable<IShadowLight[]>;
  47705. /**
  47706. * Specify the list of lights casting shadow on the material.
  47707. * All scene shadow lights will be included if null.
  47708. */
  47709. shadowLights: Nullable<IShadowLight[]>;
  47710. protected _shadowLevel: float;
  47711. /**
  47712. * Helps adjusting the shadow to a softer level if required.
  47713. * 0 means black shadows and 1 means no shadows.
  47714. */
  47715. shadowLevel: float;
  47716. protected _sceneCenter: Vector3;
  47717. /**
  47718. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47719. * It is usually zero but might be interesting to modify according to your setup.
  47720. */
  47721. sceneCenter: Vector3;
  47722. protected _opacityFresnel: boolean;
  47723. /**
  47724. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47725. * This helps ensuring a nice transition when the camera goes under the ground.
  47726. */
  47727. opacityFresnel: boolean;
  47728. protected _reflectionFresnel: boolean;
  47729. /**
  47730. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47731. * This helps adding a mirror texture on the ground.
  47732. */
  47733. reflectionFresnel: boolean;
  47734. protected _reflectionFalloffDistance: number;
  47735. /**
  47736. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47737. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47738. */
  47739. reflectionFalloffDistance: number;
  47740. protected _reflectionAmount: number;
  47741. /**
  47742. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47743. */
  47744. reflectionAmount: number;
  47745. protected _reflectionReflectance0: number;
  47746. /**
  47747. * This specifies the weight of the reflection at grazing angle.
  47748. */
  47749. reflectionReflectance0: number;
  47750. protected _reflectionReflectance90: number;
  47751. /**
  47752. * This specifies the weight of the reflection at a perpendicular point of view.
  47753. */
  47754. reflectionReflectance90: number;
  47755. /**
  47756. * Sets the reflection reflectance fresnel values according to the default standard
  47757. * empirically know to work well :-)
  47758. */
  47759. reflectionStandardFresnelWeight: number;
  47760. protected _useRGBColor: boolean;
  47761. /**
  47762. * Helps to directly use the maps channels instead of their level.
  47763. */
  47764. useRGBColor: boolean;
  47765. protected _enableNoise: boolean;
  47766. /**
  47767. * This helps reducing the banding effect that could occur on the background.
  47768. */
  47769. enableNoise: boolean;
  47770. /**
  47771. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47772. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47773. * Recommended to be keep at 1.0 except for special cases.
  47774. */
  47775. fovMultiplier: number;
  47776. private _fovMultiplier;
  47777. /**
  47778. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47779. */
  47780. useEquirectangularFOV: boolean;
  47781. private _maxSimultaneousLights;
  47782. /**
  47783. * Number of Simultaneous lights allowed on the material.
  47784. */
  47785. maxSimultaneousLights: int;
  47786. /**
  47787. * Default configuration related to image processing available in the Background Material.
  47788. */
  47789. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47790. /**
  47791. * Keep track of the image processing observer to allow dispose and replace.
  47792. */
  47793. private _imageProcessingObserver;
  47794. /**
  47795. * Attaches a new image processing configuration to the PBR Material.
  47796. * @param configuration (if null the scene configuration will be use)
  47797. */
  47798. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47799. /**
  47800. * Gets the image processing configuration used either in this material.
  47801. */
  47802. /**
  47803. * Sets the Default image processing configuration used either in the this material.
  47804. *
  47805. * If sets to null, the scene one is in use.
  47806. */
  47807. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47808. /**
  47809. * Gets wether the color curves effect is enabled.
  47810. */
  47811. /**
  47812. * Sets wether the color curves effect is enabled.
  47813. */
  47814. cameraColorCurvesEnabled: boolean;
  47815. /**
  47816. * Gets wether the color grading effect is enabled.
  47817. */
  47818. /**
  47819. * Gets wether the color grading effect is enabled.
  47820. */
  47821. cameraColorGradingEnabled: boolean;
  47822. /**
  47823. * Gets wether tonemapping is enabled or not.
  47824. */
  47825. /**
  47826. * Sets wether tonemapping is enabled or not
  47827. */
  47828. cameraToneMappingEnabled: boolean;
  47829. /**
  47830. * The camera exposure used on this material.
  47831. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47832. * This corresponds to a photographic exposure.
  47833. */
  47834. /**
  47835. * The camera exposure used on this material.
  47836. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47837. * This corresponds to a photographic exposure.
  47838. */
  47839. cameraExposure: float;
  47840. /**
  47841. * Gets The camera contrast used on this material.
  47842. */
  47843. /**
  47844. * Sets The camera contrast used on this material.
  47845. */
  47846. cameraContrast: float;
  47847. /**
  47848. * Gets the Color Grading 2D Lookup Texture.
  47849. */
  47850. /**
  47851. * Sets the Color Grading 2D Lookup Texture.
  47852. */
  47853. cameraColorGradingTexture: Nullable<BaseTexture>;
  47854. /**
  47855. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47856. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47857. * 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;
  47858. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47859. */
  47860. /**
  47861. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47862. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47863. * 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;
  47864. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47865. */
  47866. cameraColorCurves: Nullable<ColorCurves>;
  47867. /**
  47868. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47869. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47870. */
  47871. switchToBGR: boolean;
  47872. private _renderTargets;
  47873. private _reflectionControls;
  47874. private _white;
  47875. private _primaryShadowColor;
  47876. private _primaryHighlightColor;
  47877. /**
  47878. * Instantiates a Background Material in the given scene
  47879. * @param name The friendly name of the material
  47880. * @param scene The scene to add the material to
  47881. */
  47882. constructor(name: string, scene: Scene);
  47883. /**
  47884. * Gets a boolean indicating that current material needs to register RTT
  47885. */
  47886. readonly hasRenderTargetTextures: boolean;
  47887. /**
  47888. * The entire material has been created in order to prevent overdraw.
  47889. * @returns false
  47890. */
  47891. needAlphaTesting(): boolean;
  47892. /**
  47893. * The entire material has been created in order to prevent overdraw.
  47894. * @returns true if blending is enable
  47895. */
  47896. needAlphaBlending(): boolean;
  47897. /**
  47898. * Checks wether the material is ready to be rendered for a given mesh.
  47899. * @param mesh The mesh to render
  47900. * @param subMesh The submesh to check against
  47901. * @param useInstances Specify wether or not the material is used with instances
  47902. * @returns true if all the dependencies are ready (Textures, Effects...)
  47903. */
  47904. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47905. /**
  47906. * Compute the primary color according to the chosen perceptual color.
  47907. */
  47908. private _computePrimaryColorFromPerceptualColor;
  47909. /**
  47910. * Compute the highlights and shadow colors according to their chosen levels.
  47911. */
  47912. private _computePrimaryColors;
  47913. /**
  47914. * Build the uniform buffer used in the material.
  47915. */
  47916. buildUniformLayout(): void;
  47917. /**
  47918. * Unbind the material.
  47919. */
  47920. unbind(): void;
  47921. /**
  47922. * Bind only the world matrix to the material.
  47923. * @param world The world matrix to bind.
  47924. */
  47925. bindOnlyWorldMatrix(world: Matrix): void;
  47926. /**
  47927. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47928. * @param world The world matrix to bind.
  47929. * @param subMesh The submesh to bind for.
  47930. */
  47931. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47932. /**
  47933. * Checks to see if a texture is used in the material.
  47934. * @param texture - Base texture to use.
  47935. * @returns - Boolean specifying if a texture is used in the material.
  47936. */
  47937. hasTexture(texture: BaseTexture): boolean;
  47938. /**
  47939. * Dispose the material.
  47940. * @param forceDisposeEffect Force disposal of the associated effect.
  47941. * @param forceDisposeTextures Force disposal of the associated textures.
  47942. */
  47943. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47944. /**
  47945. * Clones the material.
  47946. * @param name The cloned name.
  47947. * @returns The cloned material.
  47948. */
  47949. clone(name: string): BackgroundMaterial;
  47950. /**
  47951. * Serializes the current material to its JSON representation.
  47952. * @returns The JSON representation.
  47953. */
  47954. serialize(): any;
  47955. /**
  47956. * Gets the class name of the material
  47957. * @returns "BackgroundMaterial"
  47958. */
  47959. getClassName(): string;
  47960. /**
  47961. * Parse a JSON input to create back a background material.
  47962. * @param source The JSON data to parse
  47963. * @param scene The scene to create the parsed material in
  47964. * @param rootUrl The root url of the assets the material depends upon
  47965. * @returns the instantiated BackgroundMaterial.
  47966. */
  47967. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47968. }
  47969. }
  47970. declare module "babylonjs/Helpers/environmentHelper" {
  47971. import { Observable } from "babylonjs/Misc/observable";
  47972. import { Nullable } from "babylonjs/types";
  47973. import { Scene } from "babylonjs/scene";
  47974. import { Vector3 } from "babylonjs/Maths/math.vector";
  47975. import { Color3 } from "babylonjs/Maths/math.color";
  47976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47977. import { Mesh } from "babylonjs/Meshes/mesh";
  47978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47979. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47980. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47981. import "babylonjs/Meshes/Builders/planeBuilder";
  47982. import "babylonjs/Meshes/Builders/boxBuilder";
  47983. /**
  47984. * Represents the different options available during the creation of
  47985. * a Environment helper.
  47986. *
  47987. * This can control the default ground, skybox and image processing setup of your scene.
  47988. */
  47989. export interface IEnvironmentHelperOptions {
  47990. /**
  47991. * Specifies wether or not to create a ground.
  47992. * True by default.
  47993. */
  47994. createGround: boolean;
  47995. /**
  47996. * Specifies the ground size.
  47997. * 15 by default.
  47998. */
  47999. groundSize: number;
  48000. /**
  48001. * The texture used on the ground for the main color.
  48002. * Comes from the BabylonJS CDN by default.
  48003. *
  48004. * Remarks: Can be either a texture or a url.
  48005. */
  48006. groundTexture: string | BaseTexture;
  48007. /**
  48008. * The color mixed in the ground texture by default.
  48009. * BabylonJS clearColor by default.
  48010. */
  48011. groundColor: Color3;
  48012. /**
  48013. * Specifies the ground opacity.
  48014. * 1 by default.
  48015. */
  48016. groundOpacity: number;
  48017. /**
  48018. * Enables the ground to receive shadows.
  48019. * True by default.
  48020. */
  48021. enableGroundShadow: boolean;
  48022. /**
  48023. * Helps preventing the shadow to be fully black on the ground.
  48024. * 0.5 by default.
  48025. */
  48026. groundShadowLevel: number;
  48027. /**
  48028. * Creates a mirror texture attach to the ground.
  48029. * false by default.
  48030. */
  48031. enableGroundMirror: boolean;
  48032. /**
  48033. * Specifies the ground mirror size ratio.
  48034. * 0.3 by default as the default kernel is 64.
  48035. */
  48036. groundMirrorSizeRatio: number;
  48037. /**
  48038. * Specifies the ground mirror blur kernel size.
  48039. * 64 by default.
  48040. */
  48041. groundMirrorBlurKernel: number;
  48042. /**
  48043. * Specifies the ground mirror visibility amount.
  48044. * 1 by default
  48045. */
  48046. groundMirrorAmount: number;
  48047. /**
  48048. * Specifies the ground mirror reflectance weight.
  48049. * This uses the standard weight of the background material to setup the fresnel effect
  48050. * of the mirror.
  48051. * 1 by default.
  48052. */
  48053. groundMirrorFresnelWeight: number;
  48054. /**
  48055. * Specifies the ground mirror Falloff distance.
  48056. * This can helps reducing the size of the reflection.
  48057. * 0 by Default.
  48058. */
  48059. groundMirrorFallOffDistance: number;
  48060. /**
  48061. * Specifies the ground mirror texture type.
  48062. * Unsigned Int by Default.
  48063. */
  48064. groundMirrorTextureType: number;
  48065. /**
  48066. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48067. * the shown objects.
  48068. */
  48069. groundYBias: number;
  48070. /**
  48071. * Specifies wether or not to create a skybox.
  48072. * True by default.
  48073. */
  48074. createSkybox: boolean;
  48075. /**
  48076. * Specifies the skybox size.
  48077. * 20 by default.
  48078. */
  48079. skyboxSize: number;
  48080. /**
  48081. * The texture used on the skybox for the main color.
  48082. * Comes from the BabylonJS CDN by default.
  48083. *
  48084. * Remarks: Can be either a texture or a url.
  48085. */
  48086. skyboxTexture: string | BaseTexture;
  48087. /**
  48088. * The color mixed in the skybox texture by default.
  48089. * BabylonJS clearColor by default.
  48090. */
  48091. skyboxColor: Color3;
  48092. /**
  48093. * The background rotation around the Y axis of the scene.
  48094. * This helps aligning the key lights of your scene with the background.
  48095. * 0 by default.
  48096. */
  48097. backgroundYRotation: number;
  48098. /**
  48099. * Compute automatically the size of the elements to best fit with the scene.
  48100. */
  48101. sizeAuto: boolean;
  48102. /**
  48103. * Default position of the rootMesh if autoSize is not true.
  48104. */
  48105. rootPosition: Vector3;
  48106. /**
  48107. * Sets up the image processing in the scene.
  48108. * true by default.
  48109. */
  48110. setupImageProcessing: boolean;
  48111. /**
  48112. * The texture used as your environment texture in the scene.
  48113. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48114. *
  48115. * Remarks: Can be either a texture or a url.
  48116. */
  48117. environmentTexture: string | BaseTexture;
  48118. /**
  48119. * The value of the exposure to apply to the scene.
  48120. * 0.6 by default if setupImageProcessing is true.
  48121. */
  48122. cameraExposure: number;
  48123. /**
  48124. * The value of the contrast to apply to the scene.
  48125. * 1.6 by default if setupImageProcessing is true.
  48126. */
  48127. cameraContrast: number;
  48128. /**
  48129. * Specifies wether or not tonemapping should be enabled in the scene.
  48130. * true by default if setupImageProcessing is true.
  48131. */
  48132. toneMappingEnabled: boolean;
  48133. }
  48134. /**
  48135. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48136. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48137. * It also helps with the default setup of your imageProcessing configuration.
  48138. */
  48139. export class EnvironmentHelper {
  48140. /**
  48141. * Default ground texture URL.
  48142. */
  48143. private static _groundTextureCDNUrl;
  48144. /**
  48145. * Default skybox texture URL.
  48146. */
  48147. private static _skyboxTextureCDNUrl;
  48148. /**
  48149. * Default environment texture URL.
  48150. */
  48151. private static _environmentTextureCDNUrl;
  48152. /**
  48153. * Creates the default options for the helper.
  48154. */
  48155. private static _getDefaultOptions;
  48156. private _rootMesh;
  48157. /**
  48158. * Gets the root mesh created by the helper.
  48159. */
  48160. readonly rootMesh: Mesh;
  48161. private _skybox;
  48162. /**
  48163. * Gets the skybox created by the helper.
  48164. */
  48165. readonly skybox: Nullable<Mesh>;
  48166. private _skyboxTexture;
  48167. /**
  48168. * Gets the skybox texture created by the helper.
  48169. */
  48170. readonly skyboxTexture: Nullable<BaseTexture>;
  48171. private _skyboxMaterial;
  48172. /**
  48173. * Gets the skybox material created by the helper.
  48174. */
  48175. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48176. private _ground;
  48177. /**
  48178. * Gets the ground mesh created by the helper.
  48179. */
  48180. readonly ground: Nullable<Mesh>;
  48181. private _groundTexture;
  48182. /**
  48183. * Gets the ground texture created by the helper.
  48184. */
  48185. readonly groundTexture: Nullable<BaseTexture>;
  48186. private _groundMirror;
  48187. /**
  48188. * Gets the ground mirror created by the helper.
  48189. */
  48190. readonly groundMirror: Nullable<MirrorTexture>;
  48191. /**
  48192. * Gets the ground mirror render list to helps pushing the meshes
  48193. * you wish in the ground reflection.
  48194. */
  48195. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48196. private _groundMaterial;
  48197. /**
  48198. * Gets the ground material created by the helper.
  48199. */
  48200. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48201. /**
  48202. * Stores the creation options.
  48203. */
  48204. private readonly _scene;
  48205. private _options;
  48206. /**
  48207. * This observable will be notified with any error during the creation of the environment,
  48208. * mainly texture creation errors.
  48209. */
  48210. onErrorObservable: Observable<{
  48211. message?: string;
  48212. exception?: any;
  48213. }>;
  48214. /**
  48215. * constructor
  48216. * @param options Defines the options we want to customize the helper
  48217. * @param scene The scene to add the material to
  48218. */
  48219. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48220. /**
  48221. * Updates the background according to the new options
  48222. * @param options
  48223. */
  48224. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48225. /**
  48226. * Sets the primary color of all the available elements.
  48227. * @param color the main color to affect to the ground and the background
  48228. */
  48229. setMainColor(color: Color3): void;
  48230. /**
  48231. * Setup the image processing according to the specified options.
  48232. */
  48233. private _setupImageProcessing;
  48234. /**
  48235. * Setup the environment texture according to the specified options.
  48236. */
  48237. private _setupEnvironmentTexture;
  48238. /**
  48239. * Setup the background according to the specified options.
  48240. */
  48241. private _setupBackground;
  48242. /**
  48243. * Get the scene sizes according to the setup.
  48244. */
  48245. private _getSceneSize;
  48246. /**
  48247. * Setup the ground according to the specified options.
  48248. */
  48249. private _setupGround;
  48250. /**
  48251. * Setup the ground material according to the specified options.
  48252. */
  48253. private _setupGroundMaterial;
  48254. /**
  48255. * Setup the ground diffuse texture according to the specified options.
  48256. */
  48257. private _setupGroundDiffuseTexture;
  48258. /**
  48259. * Setup the ground mirror texture according to the specified options.
  48260. */
  48261. private _setupGroundMirrorTexture;
  48262. /**
  48263. * Setup the ground to receive the mirror texture.
  48264. */
  48265. private _setupMirrorInGroundMaterial;
  48266. /**
  48267. * Setup the skybox according to the specified options.
  48268. */
  48269. private _setupSkybox;
  48270. /**
  48271. * Setup the skybox material according to the specified options.
  48272. */
  48273. private _setupSkyboxMaterial;
  48274. /**
  48275. * Setup the skybox reflection texture according to the specified options.
  48276. */
  48277. private _setupSkyboxReflectionTexture;
  48278. private _errorHandler;
  48279. /**
  48280. * Dispose all the elements created by the Helper.
  48281. */
  48282. dispose(): void;
  48283. }
  48284. }
  48285. declare module "babylonjs/Helpers/photoDome" {
  48286. import { Observable } from "babylonjs/Misc/observable";
  48287. import { Nullable } from "babylonjs/types";
  48288. import { Scene } from "babylonjs/scene";
  48289. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48290. import { Mesh } from "babylonjs/Meshes/mesh";
  48291. import { Texture } from "babylonjs/Materials/Textures/texture";
  48292. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48293. import "babylonjs/Meshes/Builders/sphereBuilder";
  48294. /**
  48295. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48296. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48297. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48298. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48299. */
  48300. export class PhotoDome extends TransformNode {
  48301. /**
  48302. * Define the image as a Monoscopic panoramic 360 image.
  48303. */
  48304. static readonly MODE_MONOSCOPIC: number;
  48305. /**
  48306. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48307. */
  48308. static readonly MODE_TOPBOTTOM: number;
  48309. /**
  48310. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48311. */
  48312. static readonly MODE_SIDEBYSIDE: number;
  48313. private _useDirectMapping;
  48314. /**
  48315. * The texture being displayed on the sphere
  48316. */
  48317. protected _photoTexture: Texture;
  48318. /**
  48319. * Gets or sets the texture being displayed on the sphere
  48320. */
  48321. photoTexture: Texture;
  48322. /**
  48323. * Observable raised when an error occured while loading the 360 image
  48324. */
  48325. onLoadErrorObservable: Observable<string>;
  48326. /**
  48327. * The skybox material
  48328. */
  48329. protected _material: BackgroundMaterial;
  48330. /**
  48331. * The surface used for the skybox
  48332. */
  48333. protected _mesh: Mesh;
  48334. /**
  48335. * Gets the mesh used for the skybox.
  48336. */
  48337. readonly mesh: Mesh;
  48338. /**
  48339. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48340. * Also see the options.resolution property.
  48341. */
  48342. fovMultiplier: number;
  48343. private _imageMode;
  48344. /**
  48345. * Gets or set the current video mode for the video. It can be:
  48346. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48347. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48348. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48349. */
  48350. imageMode: number;
  48351. /**
  48352. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48353. * @param name Element's name, child elements will append suffixes for their own names.
  48354. * @param urlsOfPhoto defines the url of the photo to display
  48355. * @param options defines an object containing optional or exposed sub element properties
  48356. * @param onError defines a callback called when an error occured while loading the texture
  48357. */
  48358. constructor(name: string, urlOfPhoto: string, options: {
  48359. resolution?: number;
  48360. size?: number;
  48361. useDirectMapping?: boolean;
  48362. faceForward?: boolean;
  48363. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48364. private _onBeforeCameraRenderObserver;
  48365. private _changeImageMode;
  48366. /**
  48367. * Releases resources associated with this node.
  48368. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48369. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48370. */
  48371. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48372. }
  48373. }
  48374. declare module "babylonjs/Misc/rgbdTextureTools" {
  48375. import "babylonjs/Shaders/rgbdDecode.fragment";
  48376. import { Texture } from "babylonjs/Materials/Textures/texture";
  48377. /**
  48378. * Class used to host RGBD texture specific utilities
  48379. */
  48380. export class RGBDTextureTools {
  48381. /**
  48382. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48383. * @param texture the texture to expand.
  48384. */
  48385. static ExpandRGBDTexture(texture: Texture): void;
  48386. }
  48387. }
  48388. declare module "babylonjs/Misc/brdfTextureTools" {
  48389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48390. import { Scene } from "babylonjs/scene";
  48391. /**
  48392. * Class used to host texture specific utilities
  48393. */
  48394. export class BRDFTextureTools {
  48395. /**
  48396. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48397. * @param scene defines the hosting scene
  48398. * @returns the environment BRDF texture
  48399. */
  48400. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48401. private static _environmentBRDFBase64Texture;
  48402. }
  48403. }
  48404. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48405. import { Nullable } from "babylonjs/types";
  48406. import { Color3 } from "babylonjs/Maths/math.color";
  48407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48408. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48409. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48410. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48411. import { Engine } from "babylonjs/Engines/engine";
  48412. import { Scene } from "babylonjs/scene";
  48413. /**
  48414. * @hidden
  48415. */
  48416. export interface IMaterialClearCoatDefines {
  48417. CLEARCOAT: boolean;
  48418. CLEARCOAT_DEFAULTIOR: boolean;
  48419. CLEARCOAT_TEXTURE: boolean;
  48420. CLEARCOAT_TEXTUREDIRECTUV: number;
  48421. CLEARCOAT_BUMP: boolean;
  48422. CLEARCOAT_BUMPDIRECTUV: number;
  48423. CLEARCOAT_TINT: boolean;
  48424. CLEARCOAT_TINT_TEXTURE: boolean;
  48425. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48426. /** @hidden */
  48427. _areTexturesDirty: boolean;
  48428. }
  48429. /**
  48430. * Define the code related to the clear coat parameters of the pbr material.
  48431. */
  48432. export class PBRClearCoatConfiguration {
  48433. /**
  48434. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48435. * The default fits with a polyurethane material.
  48436. */
  48437. private static readonly _DefaultIndexOfRefraction;
  48438. private _isEnabled;
  48439. /**
  48440. * Defines if the clear coat is enabled in the material.
  48441. */
  48442. isEnabled: boolean;
  48443. /**
  48444. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48445. */
  48446. intensity: number;
  48447. /**
  48448. * Defines the clear coat layer roughness.
  48449. */
  48450. roughness: number;
  48451. private _indexOfRefraction;
  48452. /**
  48453. * Defines the index of refraction of the clear coat.
  48454. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48455. * The default fits with a polyurethane material.
  48456. * Changing the default value is more performance intensive.
  48457. */
  48458. indexOfRefraction: number;
  48459. private _texture;
  48460. /**
  48461. * Stores the clear coat values in a texture.
  48462. */
  48463. texture: Nullable<BaseTexture>;
  48464. private _bumpTexture;
  48465. /**
  48466. * Define the clear coat specific bump texture.
  48467. */
  48468. bumpTexture: Nullable<BaseTexture>;
  48469. private _isTintEnabled;
  48470. /**
  48471. * Defines if the clear coat tint is enabled in the material.
  48472. */
  48473. isTintEnabled: boolean;
  48474. /**
  48475. * Defines the clear coat tint of the material.
  48476. * This is only use if tint is enabled
  48477. */
  48478. tintColor: Color3;
  48479. /**
  48480. * Defines the distance at which the tint color should be found in the
  48481. * clear coat media.
  48482. * This is only use if tint is enabled
  48483. */
  48484. tintColorAtDistance: number;
  48485. /**
  48486. * Defines the clear coat layer thickness.
  48487. * This is only use if tint is enabled
  48488. */
  48489. tintThickness: number;
  48490. private _tintTexture;
  48491. /**
  48492. * Stores the clear tint values in a texture.
  48493. * rgb is tint
  48494. * a is a thickness factor
  48495. */
  48496. tintTexture: Nullable<BaseTexture>;
  48497. /** @hidden */
  48498. private _internalMarkAllSubMeshesAsTexturesDirty;
  48499. /** @hidden */
  48500. _markAllSubMeshesAsTexturesDirty(): void;
  48501. /**
  48502. * Instantiate a new istance of clear coat configuration.
  48503. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48504. */
  48505. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48506. /**
  48507. * Gets wehter the submesh is ready to be used or not.
  48508. * @param defines the list of "defines" to update.
  48509. * @param scene defines the scene the material belongs to.
  48510. * @param engine defines the engine the material belongs to.
  48511. * @param disableBumpMap defines wether the material disables bump or not.
  48512. * @returns - boolean indicating that the submesh is ready or not.
  48513. */
  48514. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48515. /**
  48516. * Checks to see if a texture is used in the material.
  48517. * @param defines the list of "defines" to update.
  48518. * @param scene defines the scene to the material belongs to.
  48519. */
  48520. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48521. /**
  48522. * Binds the material data.
  48523. * @param uniformBuffer defines the Uniform buffer to fill in.
  48524. * @param scene defines the scene the material belongs to.
  48525. * @param engine defines the engine the material belongs to.
  48526. * @param disableBumpMap defines wether the material disables bump or not.
  48527. * @param isFrozen defines wether the material is frozen or not.
  48528. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48529. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48530. */
  48531. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48532. /**
  48533. * Checks to see if a texture is used in the material.
  48534. * @param texture - Base texture to use.
  48535. * @returns - Boolean specifying if a texture is used in the material.
  48536. */
  48537. hasTexture(texture: BaseTexture): boolean;
  48538. /**
  48539. * Returns an array of the actively used textures.
  48540. * @param activeTextures Array of BaseTextures
  48541. */
  48542. getActiveTextures(activeTextures: BaseTexture[]): void;
  48543. /**
  48544. * Returns the animatable textures.
  48545. * @param animatables Array of animatable textures.
  48546. */
  48547. getAnimatables(animatables: IAnimatable[]): void;
  48548. /**
  48549. * Disposes the resources of the material.
  48550. * @param forceDisposeTextures - Forces the disposal of all textures.
  48551. */
  48552. dispose(forceDisposeTextures?: boolean): void;
  48553. /**
  48554. * Get the current class name of the texture useful for serialization or dynamic coding.
  48555. * @returns "PBRClearCoatConfiguration"
  48556. */
  48557. getClassName(): string;
  48558. /**
  48559. * Add fallbacks to the effect fallbacks list.
  48560. * @param defines defines the Base texture to use.
  48561. * @param fallbacks defines the current fallback list.
  48562. * @param currentRank defines the current fallback rank.
  48563. * @returns the new fallback rank.
  48564. */
  48565. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48566. /**
  48567. * Add the required uniforms to the current list.
  48568. * @param uniforms defines the current uniform list.
  48569. */
  48570. static AddUniforms(uniforms: string[]): void;
  48571. /**
  48572. * Add the required samplers to the current list.
  48573. * @param samplers defines the current sampler list.
  48574. */
  48575. static AddSamplers(samplers: string[]): void;
  48576. /**
  48577. * Add the required uniforms to the current buffer.
  48578. * @param uniformBuffer defines the current uniform buffer.
  48579. */
  48580. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48581. /**
  48582. * Makes a duplicate of the current configuration into another one.
  48583. * @param clearCoatConfiguration define the config where to copy the info
  48584. */
  48585. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48586. /**
  48587. * Serializes this clear coat configuration.
  48588. * @returns - An object with the serialized config.
  48589. */
  48590. serialize(): any;
  48591. /**
  48592. * Parses a anisotropy Configuration from a serialized object.
  48593. * @param source - Serialized object.
  48594. * @param scene Defines the scene we are parsing for
  48595. * @param rootUrl Defines the rootUrl to load from
  48596. */
  48597. parse(source: any, scene: Scene, rootUrl: string): void;
  48598. }
  48599. }
  48600. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48601. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48603. import { Vector2 } from "babylonjs/Maths/math.vector";
  48604. import { Scene } from "babylonjs/scene";
  48605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48606. import { Nullable } from "babylonjs/types";
  48607. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48608. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48609. /**
  48610. * @hidden
  48611. */
  48612. export interface IMaterialAnisotropicDefines {
  48613. ANISOTROPIC: boolean;
  48614. ANISOTROPIC_TEXTURE: boolean;
  48615. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48616. MAINUV1: boolean;
  48617. _areTexturesDirty: boolean;
  48618. _needUVs: boolean;
  48619. }
  48620. /**
  48621. * Define the code related to the anisotropic parameters of the pbr material.
  48622. */
  48623. export class PBRAnisotropicConfiguration {
  48624. private _isEnabled;
  48625. /**
  48626. * Defines if the anisotropy is enabled in the material.
  48627. */
  48628. isEnabled: boolean;
  48629. /**
  48630. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48631. */
  48632. intensity: number;
  48633. /**
  48634. * Defines if the effect is along the tangents, bitangents or in between.
  48635. * By default, the effect is "strectching" the highlights along the tangents.
  48636. */
  48637. direction: Vector2;
  48638. private _texture;
  48639. /**
  48640. * Stores the anisotropy values in a texture.
  48641. * rg is direction (like normal from -1 to 1)
  48642. * b is a intensity
  48643. */
  48644. texture: Nullable<BaseTexture>;
  48645. /** @hidden */
  48646. private _internalMarkAllSubMeshesAsTexturesDirty;
  48647. /** @hidden */
  48648. _markAllSubMeshesAsTexturesDirty(): void;
  48649. /**
  48650. * Instantiate a new istance of anisotropy configuration.
  48651. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48652. */
  48653. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48654. /**
  48655. * Specifies that the submesh is ready to be used.
  48656. * @param defines the list of "defines" to update.
  48657. * @param scene defines the scene the material belongs to.
  48658. * @returns - boolean indicating that the submesh is ready or not.
  48659. */
  48660. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48661. /**
  48662. * Checks to see if a texture is used in the material.
  48663. * @param defines the list of "defines" to update.
  48664. * @param mesh the mesh we are preparing the defines for.
  48665. * @param scene defines the scene the material belongs to.
  48666. */
  48667. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48668. /**
  48669. * Binds the material data.
  48670. * @param uniformBuffer defines the Uniform buffer to fill in.
  48671. * @param scene defines the scene the material belongs to.
  48672. * @param isFrozen defines wether the material is frozen or not.
  48673. */
  48674. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48675. /**
  48676. * Checks to see if a texture is used in the material.
  48677. * @param texture - Base texture to use.
  48678. * @returns - Boolean specifying if a texture is used in the material.
  48679. */
  48680. hasTexture(texture: BaseTexture): boolean;
  48681. /**
  48682. * Returns an array of the actively used textures.
  48683. * @param activeTextures Array of BaseTextures
  48684. */
  48685. getActiveTextures(activeTextures: BaseTexture[]): void;
  48686. /**
  48687. * Returns the animatable textures.
  48688. * @param animatables Array of animatable textures.
  48689. */
  48690. getAnimatables(animatables: IAnimatable[]): void;
  48691. /**
  48692. * Disposes the resources of the material.
  48693. * @param forceDisposeTextures - Forces the disposal of all textures.
  48694. */
  48695. dispose(forceDisposeTextures?: boolean): void;
  48696. /**
  48697. * Get the current class name of the texture useful for serialization or dynamic coding.
  48698. * @returns "PBRAnisotropicConfiguration"
  48699. */
  48700. getClassName(): string;
  48701. /**
  48702. * Add fallbacks to the effect fallbacks list.
  48703. * @param defines defines the Base texture to use.
  48704. * @param fallbacks defines the current fallback list.
  48705. * @param currentRank defines the current fallback rank.
  48706. * @returns the new fallback rank.
  48707. */
  48708. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48709. /**
  48710. * Add the required uniforms to the current list.
  48711. * @param uniforms defines the current uniform list.
  48712. */
  48713. static AddUniforms(uniforms: string[]): void;
  48714. /**
  48715. * Add the required uniforms to the current buffer.
  48716. * @param uniformBuffer defines the current uniform buffer.
  48717. */
  48718. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48719. /**
  48720. * Add the required samplers to the current list.
  48721. * @param samplers defines the current sampler list.
  48722. */
  48723. static AddSamplers(samplers: string[]): void;
  48724. /**
  48725. * Makes a duplicate of the current configuration into another one.
  48726. * @param anisotropicConfiguration define the config where to copy the info
  48727. */
  48728. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48729. /**
  48730. * Serializes this anisotropy configuration.
  48731. * @returns - An object with the serialized config.
  48732. */
  48733. serialize(): any;
  48734. /**
  48735. * Parses a anisotropy Configuration from a serialized object.
  48736. * @param source - Serialized object.
  48737. * @param scene Defines the scene we are parsing for
  48738. * @param rootUrl Defines the rootUrl to load from
  48739. */
  48740. parse(source: any, scene: Scene, rootUrl: string): void;
  48741. }
  48742. }
  48743. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48744. import { Scene } from "babylonjs/scene";
  48745. /**
  48746. * @hidden
  48747. */
  48748. export interface IMaterialBRDFDefines {
  48749. BRDF_V_HEIGHT_CORRELATED: boolean;
  48750. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48751. SPHERICAL_HARMONICS: boolean;
  48752. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48753. /** @hidden */
  48754. _areMiscDirty: boolean;
  48755. }
  48756. /**
  48757. * Define the code related to the BRDF parameters of the pbr material.
  48758. */
  48759. export class PBRBRDFConfiguration {
  48760. /**
  48761. * Default value used for the energy conservation.
  48762. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48763. */
  48764. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48765. /**
  48766. * Default value used for the Smith Visibility Height Correlated mode.
  48767. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48768. */
  48769. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48770. /**
  48771. * Default value used for the IBL diffuse part.
  48772. * This can help switching back to the polynomials mode globally which is a tiny bit
  48773. * less GPU intensive at the drawback of a lower quality.
  48774. */
  48775. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48776. /**
  48777. * Default value used for activating energy conservation for the specular workflow.
  48778. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48779. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48780. */
  48781. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48782. private _useEnergyConservation;
  48783. /**
  48784. * Defines if the material uses energy conservation.
  48785. */
  48786. useEnergyConservation: boolean;
  48787. private _useSmithVisibilityHeightCorrelated;
  48788. /**
  48789. * LEGACY Mode set to false
  48790. * Defines if the material uses height smith correlated visibility term.
  48791. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48792. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48793. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48794. * Not relying on height correlated will also disable energy conservation.
  48795. */
  48796. useSmithVisibilityHeightCorrelated: boolean;
  48797. private _useSphericalHarmonics;
  48798. /**
  48799. * LEGACY Mode set to false
  48800. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48801. * diffuse part of the IBL.
  48802. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48803. * to the ground truth.
  48804. */
  48805. useSphericalHarmonics: boolean;
  48806. private _useSpecularGlossinessInputEnergyConservation;
  48807. /**
  48808. * Defines if the material uses energy conservation, when the specular workflow is active.
  48809. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48810. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48811. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48812. */
  48813. useSpecularGlossinessInputEnergyConservation: boolean;
  48814. /** @hidden */
  48815. private _internalMarkAllSubMeshesAsMiscDirty;
  48816. /** @hidden */
  48817. _markAllSubMeshesAsMiscDirty(): void;
  48818. /**
  48819. * Instantiate a new istance of clear coat configuration.
  48820. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48821. */
  48822. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48823. /**
  48824. * Checks to see if a texture is used in the material.
  48825. * @param defines the list of "defines" to update.
  48826. */
  48827. prepareDefines(defines: IMaterialBRDFDefines): void;
  48828. /**
  48829. * Get the current class name of the texture useful for serialization or dynamic coding.
  48830. * @returns "PBRClearCoatConfiguration"
  48831. */
  48832. getClassName(): string;
  48833. /**
  48834. * Makes a duplicate of the current configuration into another one.
  48835. * @param brdfConfiguration define the config where to copy the info
  48836. */
  48837. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48838. /**
  48839. * Serializes this BRDF configuration.
  48840. * @returns - An object with the serialized config.
  48841. */
  48842. serialize(): any;
  48843. /**
  48844. * Parses a anisotropy Configuration from a serialized object.
  48845. * @param source - Serialized object.
  48846. * @param scene Defines the scene we are parsing for
  48847. * @param rootUrl Defines the rootUrl to load from
  48848. */
  48849. parse(source: any, scene: Scene, rootUrl: string): void;
  48850. }
  48851. }
  48852. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48853. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48854. import { Color3 } from "babylonjs/Maths/math.color";
  48855. import { Scene } from "babylonjs/scene";
  48856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48857. import { Nullable } from "babylonjs/types";
  48858. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48859. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48860. /**
  48861. * @hidden
  48862. */
  48863. export interface IMaterialSheenDefines {
  48864. SHEEN: boolean;
  48865. SHEEN_TEXTURE: boolean;
  48866. SHEEN_TEXTUREDIRECTUV: number;
  48867. SHEEN_LINKWITHALBEDO: boolean;
  48868. /** @hidden */
  48869. _areTexturesDirty: boolean;
  48870. }
  48871. /**
  48872. * Define the code related to the Sheen parameters of the pbr material.
  48873. */
  48874. export class PBRSheenConfiguration {
  48875. private _isEnabled;
  48876. /**
  48877. * Defines if the material uses sheen.
  48878. */
  48879. isEnabled: boolean;
  48880. private _linkSheenWithAlbedo;
  48881. /**
  48882. * Defines if the sheen is linked to the sheen color.
  48883. */
  48884. linkSheenWithAlbedo: boolean;
  48885. /**
  48886. * Defines the sheen intensity.
  48887. */
  48888. intensity: number;
  48889. /**
  48890. * Defines the sheen color.
  48891. */
  48892. color: Color3;
  48893. private _texture;
  48894. /**
  48895. * Stores the sheen tint values in a texture.
  48896. * rgb is tint
  48897. * a is a intensity
  48898. */
  48899. texture: Nullable<BaseTexture>;
  48900. /** @hidden */
  48901. private _internalMarkAllSubMeshesAsTexturesDirty;
  48902. /** @hidden */
  48903. _markAllSubMeshesAsTexturesDirty(): void;
  48904. /**
  48905. * Instantiate a new istance of clear coat configuration.
  48906. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48907. */
  48908. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48909. /**
  48910. * Specifies that the submesh is ready to be used.
  48911. * @param defines the list of "defines" to update.
  48912. * @param scene defines the scene the material belongs to.
  48913. * @returns - boolean indicating that the submesh is ready or not.
  48914. */
  48915. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48916. /**
  48917. * Checks to see if a texture is used in the material.
  48918. * @param defines the list of "defines" to update.
  48919. * @param scene defines the scene the material belongs to.
  48920. */
  48921. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48922. /**
  48923. * Binds the material data.
  48924. * @param uniformBuffer defines the Uniform buffer to fill in.
  48925. * @param scene defines the scene the material belongs to.
  48926. * @param isFrozen defines wether the material is frozen or not.
  48927. */
  48928. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48929. /**
  48930. * Checks to see if a texture is used in the material.
  48931. * @param texture - Base texture to use.
  48932. * @returns - Boolean specifying if a texture is used in the material.
  48933. */
  48934. hasTexture(texture: BaseTexture): boolean;
  48935. /**
  48936. * Returns an array of the actively used textures.
  48937. * @param activeTextures Array of BaseTextures
  48938. */
  48939. getActiveTextures(activeTextures: BaseTexture[]): void;
  48940. /**
  48941. * Returns the animatable textures.
  48942. * @param animatables Array of animatable textures.
  48943. */
  48944. getAnimatables(animatables: IAnimatable[]): void;
  48945. /**
  48946. * Disposes the resources of the material.
  48947. * @param forceDisposeTextures - Forces the disposal of all textures.
  48948. */
  48949. dispose(forceDisposeTextures?: boolean): void;
  48950. /**
  48951. * Get the current class name of the texture useful for serialization or dynamic coding.
  48952. * @returns "PBRSheenConfiguration"
  48953. */
  48954. getClassName(): string;
  48955. /**
  48956. * Add fallbacks to the effect fallbacks list.
  48957. * @param defines defines the Base texture to use.
  48958. * @param fallbacks defines the current fallback list.
  48959. * @param currentRank defines the current fallback rank.
  48960. * @returns the new fallback rank.
  48961. */
  48962. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48963. /**
  48964. * Add the required uniforms to the current list.
  48965. * @param uniforms defines the current uniform list.
  48966. */
  48967. static AddUniforms(uniforms: string[]): void;
  48968. /**
  48969. * Add the required uniforms to the current buffer.
  48970. * @param uniformBuffer defines the current uniform buffer.
  48971. */
  48972. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48973. /**
  48974. * Add the required samplers to the current list.
  48975. * @param samplers defines the current sampler list.
  48976. */
  48977. static AddSamplers(samplers: string[]): void;
  48978. /**
  48979. * Makes a duplicate of the current configuration into another one.
  48980. * @param sheenConfiguration define the config where to copy the info
  48981. */
  48982. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48983. /**
  48984. * Serializes this BRDF configuration.
  48985. * @returns - An object with the serialized config.
  48986. */
  48987. serialize(): any;
  48988. /**
  48989. * Parses a anisotropy Configuration from a serialized object.
  48990. * @param source - Serialized object.
  48991. * @param scene Defines the scene we are parsing for
  48992. * @param rootUrl Defines the rootUrl to load from
  48993. */
  48994. parse(source: any, scene: Scene, rootUrl: string): void;
  48995. }
  48996. }
  48997. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48998. import { Nullable } from "babylonjs/types";
  48999. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49000. import { Color3 } from "babylonjs/Maths/math.color";
  49001. import { SmartArray } from "babylonjs/Misc/smartArray";
  49002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49003. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49004. import { Effect } from "babylonjs/Materials/effect";
  49005. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49006. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49007. import { Engine } from "babylonjs/Engines/engine";
  49008. import { Scene } from "babylonjs/scene";
  49009. /**
  49010. * @hidden
  49011. */
  49012. export interface IMaterialSubSurfaceDefines {
  49013. SUBSURFACE: boolean;
  49014. SS_REFRACTION: boolean;
  49015. SS_TRANSLUCENCY: boolean;
  49016. SS_SCATERRING: boolean;
  49017. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49018. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49019. SS_REFRACTIONMAP_3D: boolean;
  49020. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49021. SS_LODINREFRACTIONALPHA: boolean;
  49022. SS_GAMMAREFRACTION: boolean;
  49023. SS_RGBDREFRACTION: boolean;
  49024. SS_LINEARSPECULARREFRACTION: boolean;
  49025. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49026. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49027. /** @hidden */
  49028. _areTexturesDirty: boolean;
  49029. }
  49030. /**
  49031. * Define the code related to the sub surface parameters of the pbr material.
  49032. */
  49033. export class PBRSubSurfaceConfiguration {
  49034. private _isRefractionEnabled;
  49035. /**
  49036. * Defines if the refraction is enabled in the material.
  49037. */
  49038. isRefractionEnabled: boolean;
  49039. private _isTranslucencyEnabled;
  49040. /**
  49041. * Defines if the translucency is enabled in the material.
  49042. */
  49043. isTranslucencyEnabled: boolean;
  49044. private _isScatteringEnabled;
  49045. /**
  49046. * Defines the refraction intensity of the material.
  49047. * The refraction when enabled replaces the Diffuse part of the material.
  49048. * The intensity helps transitionning between diffuse and refraction.
  49049. */
  49050. refractionIntensity: number;
  49051. /**
  49052. * Defines the translucency intensity of the material.
  49053. * When translucency has been enabled, this defines how much of the "translucency"
  49054. * is addded to the diffuse part of the material.
  49055. */
  49056. translucencyIntensity: number;
  49057. /**
  49058. * Defines the scattering intensity of the material.
  49059. * When scattering has been enabled, this defines how much of the "scattered light"
  49060. * is addded to the diffuse part of the material.
  49061. */
  49062. scatteringIntensity: number;
  49063. private _thicknessTexture;
  49064. /**
  49065. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49066. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49067. * 0 would mean minimumThickness
  49068. * 1 would mean maximumThickness
  49069. * The other channels might be use as a mask to vary the different effects intensity.
  49070. */
  49071. thicknessTexture: Nullable<BaseTexture>;
  49072. private _refractionTexture;
  49073. /**
  49074. * Defines the texture to use for refraction.
  49075. */
  49076. refractionTexture: Nullable<BaseTexture>;
  49077. private _indexOfRefraction;
  49078. /**
  49079. * Defines the index of refraction used in the material.
  49080. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49081. */
  49082. indexOfRefraction: number;
  49083. private _invertRefractionY;
  49084. /**
  49085. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49086. */
  49087. invertRefractionY: boolean;
  49088. private _linkRefractionWithTransparency;
  49089. /**
  49090. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49091. * Materials half opaque for instance using refraction could benefit from this control.
  49092. */
  49093. linkRefractionWithTransparency: boolean;
  49094. /**
  49095. * Defines the minimum thickness stored in the thickness map.
  49096. * If no thickness map is defined, this value will be used to simulate thickness.
  49097. */
  49098. minimumThickness: number;
  49099. /**
  49100. * Defines the maximum thickness stored in the thickness map.
  49101. */
  49102. maximumThickness: number;
  49103. /**
  49104. * Defines the volume tint of the material.
  49105. * This is used for both translucency and scattering.
  49106. */
  49107. tintColor: Color3;
  49108. /**
  49109. * Defines the distance at which the tint color should be found in the media.
  49110. * This is used for refraction only.
  49111. */
  49112. tintColorAtDistance: number;
  49113. /**
  49114. * Defines how far each channel transmit through the media.
  49115. * It is defined as a color to simplify it selection.
  49116. */
  49117. diffusionDistance: Color3;
  49118. private _useMaskFromThicknessTexture;
  49119. /**
  49120. * Stores the intensity of the different subsurface effects in the thickness texture.
  49121. * * the green channel is the translucency intensity.
  49122. * * the blue channel is the scattering intensity.
  49123. * * the alpha channel is the refraction intensity.
  49124. */
  49125. useMaskFromThicknessTexture: boolean;
  49126. /** @hidden */
  49127. private _internalMarkAllSubMeshesAsTexturesDirty;
  49128. /** @hidden */
  49129. _markAllSubMeshesAsTexturesDirty(): void;
  49130. /**
  49131. * Instantiate a new istance of sub surface configuration.
  49132. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49133. */
  49134. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49135. /**
  49136. * Gets wehter the submesh is ready to be used or not.
  49137. * @param defines the list of "defines" to update.
  49138. * @param scene defines the scene the material belongs to.
  49139. * @returns - boolean indicating that the submesh is ready or not.
  49140. */
  49141. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49142. /**
  49143. * Checks to see if a texture is used in the material.
  49144. * @param defines the list of "defines" to update.
  49145. * @param scene defines the scene to the material belongs to.
  49146. */
  49147. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49148. /**
  49149. * Binds the material data.
  49150. * @param uniformBuffer defines the Uniform buffer to fill in.
  49151. * @param scene defines the scene the material belongs to.
  49152. * @param engine defines the engine the material belongs to.
  49153. * @param isFrozen defines wether the material is frozen or not.
  49154. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49155. */
  49156. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49157. /**
  49158. * Unbinds the material from the mesh.
  49159. * @param activeEffect defines the effect that should be unbound from.
  49160. * @returns true if unbound, otherwise false
  49161. */
  49162. unbind(activeEffect: Effect): boolean;
  49163. /**
  49164. * Returns the texture used for refraction or null if none is used.
  49165. * @param scene defines the scene the material belongs to.
  49166. * @returns - Refraction texture if present. If no refraction texture and refraction
  49167. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49168. */
  49169. private _getRefractionTexture;
  49170. /**
  49171. * Returns true if alpha blending should be disabled.
  49172. */
  49173. readonly disableAlphaBlending: boolean;
  49174. /**
  49175. * Fills the list of render target textures.
  49176. * @param renderTargets the list of render targets to update
  49177. */
  49178. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49179. /**
  49180. * Checks to see if a texture is used in the material.
  49181. * @param texture - Base texture to use.
  49182. * @returns - Boolean specifying if a texture is used in the material.
  49183. */
  49184. hasTexture(texture: BaseTexture): boolean;
  49185. /**
  49186. * Gets a boolean indicating that current material needs to register RTT
  49187. * @returns true if this uses a render target otherwise false.
  49188. */
  49189. hasRenderTargetTextures(): boolean;
  49190. /**
  49191. * Returns an array of the actively used textures.
  49192. * @param activeTextures Array of BaseTextures
  49193. */
  49194. getActiveTextures(activeTextures: BaseTexture[]): void;
  49195. /**
  49196. * Returns the animatable textures.
  49197. * @param animatables Array of animatable textures.
  49198. */
  49199. getAnimatables(animatables: IAnimatable[]): void;
  49200. /**
  49201. * Disposes the resources of the material.
  49202. * @param forceDisposeTextures - Forces the disposal of all textures.
  49203. */
  49204. dispose(forceDisposeTextures?: boolean): void;
  49205. /**
  49206. * Get the current class name of the texture useful for serialization or dynamic coding.
  49207. * @returns "PBRSubSurfaceConfiguration"
  49208. */
  49209. getClassName(): string;
  49210. /**
  49211. * Add fallbacks to the effect fallbacks list.
  49212. * @param defines defines the Base texture to use.
  49213. * @param fallbacks defines the current fallback list.
  49214. * @param currentRank defines the current fallback rank.
  49215. * @returns the new fallback rank.
  49216. */
  49217. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49218. /**
  49219. * Add the required uniforms to the current list.
  49220. * @param uniforms defines the current uniform list.
  49221. */
  49222. static AddUniforms(uniforms: string[]): void;
  49223. /**
  49224. * Add the required samplers to the current list.
  49225. * @param samplers defines the current sampler list.
  49226. */
  49227. static AddSamplers(samplers: string[]): void;
  49228. /**
  49229. * Add the required uniforms to the current buffer.
  49230. * @param uniformBuffer defines the current uniform buffer.
  49231. */
  49232. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49233. /**
  49234. * Makes a duplicate of the current configuration into another one.
  49235. * @param configuration define the config where to copy the info
  49236. */
  49237. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49238. /**
  49239. * Serializes this Sub Surface configuration.
  49240. * @returns - An object with the serialized config.
  49241. */
  49242. serialize(): any;
  49243. /**
  49244. * Parses a anisotropy Configuration from a serialized object.
  49245. * @param source - Serialized object.
  49246. * @param scene Defines the scene we are parsing for
  49247. * @param rootUrl Defines the rootUrl to load from
  49248. */
  49249. parse(source: any, scene: Scene, rootUrl: string): void;
  49250. }
  49251. }
  49252. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49253. /** @hidden */
  49254. export var pbrFragmentDeclaration: {
  49255. name: string;
  49256. shader: string;
  49257. };
  49258. }
  49259. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49260. /** @hidden */
  49261. export var pbrUboDeclaration: {
  49262. name: string;
  49263. shader: string;
  49264. };
  49265. }
  49266. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49267. /** @hidden */
  49268. export var pbrFragmentExtraDeclaration: {
  49269. name: string;
  49270. shader: string;
  49271. };
  49272. }
  49273. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49274. /** @hidden */
  49275. export var pbrFragmentSamplersDeclaration: {
  49276. name: string;
  49277. shader: string;
  49278. };
  49279. }
  49280. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49281. /** @hidden */
  49282. export var pbrHelperFunctions: {
  49283. name: string;
  49284. shader: string;
  49285. };
  49286. }
  49287. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49288. /** @hidden */
  49289. export var harmonicsFunctions: {
  49290. name: string;
  49291. shader: string;
  49292. };
  49293. }
  49294. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49295. /** @hidden */
  49296. export var pbrDirectLightingSetupFunctions: {
  49297. name: string;
  49298. shader: string;
  49299. };
  49300. }
  49301. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49302. /** @hidden */
  49303. export var pbrDirectLightingFalloffFunctions: {
  49304. name: string;
  49305. shader: string;
  49306. };
  49307. }
  49308. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49309. /** @hidden */
  49310. export var pbrBRDFFunctions: {
  49311. name: string;
  49312. shader: string;
  49313. };
  49314. }
  49315. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49316. /** @hidden */
  49317. export var pbrDirectLightingFunctions: {
  49318. name: string;
  49319. shader: string;
  49320. };
  49321. }
  49322. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49323. /** @hidden */
  49324. export var pbrIBLFunctions: {
  49325. name: string;
  49326. shader: string;
  49327. };
  49328. }
  49329. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49330. /** @hidden */
  49331. export var pbrDebug: {
  49332. name: string;
  49333. shader: string;
  49334. };
  49335. }
  49336. declare module "babylonjs/Shaders/pbr.fragment" {
  49337. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49338. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49339. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49340. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49341. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49342. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49343. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49344. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49345. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49346. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49347. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49348. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49349. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49350. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49351. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49352. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49353. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49354. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49355. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49356. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49357. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49358. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49359. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49360. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49361. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49362. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49363. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49364. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49365. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49366. /** @hidden */
  49367. export var pbrPixelShader: {
  49368. name: string;
  49369. shader: string;
  49370. };
  49371. }
  49372. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49373. /** @hidden */
  49374. export var pbrVertexDeclaration: {
  49375. name: string;
  49376. shader: string;
  49377. };
  49378. }
  49379. declare module "babylonjs/Shaders/pbr.vertex" {
  49380. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49381. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49382. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49383. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49384. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49385. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49386. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49387. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49388. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49389. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49390. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49392. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49393. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49394. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49395. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49396. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49397. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49398. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49399. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49400. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49401. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49402. /** @hidden */
  49403. export var pbrVertexShader: {
  49404. name: string;
  49405. shader: string;
  49406. };
  49407. }
  49408. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49409. import { Nullable } from "babylonjs/types";
  49410. import { Scene } from "babylonjs/scene";
  49411. import { Matrix } from "babylonjs/Maths/math.vector";
  49412. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49414. import { Mesh } from "babylonjs/Meshes/mesh";
  49415. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49416. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49417. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49418. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49419. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49420. import { Color3 } from "babylonjs/Maths/math.color";
  49421. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49422. import { Material } from "babylonjs/Materials/material";
  49423. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49424. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49426. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49427. import "babylonjs/Shaders/pbr.fragment";
  49428. import "babylonjs/Shaders/pbr.vertex";
  49429. /**
  49430. * Manages the defines for the PBR Material.
  49431. * @hidden
  49432. */
  49433. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49434. PBR: boolean;
  49435. MAINUV1: boolean;
  49436. MAINUV2: boolean;
  49437. UV1: boolean;
  49438. UV2: boolean;
  49439. ALBEDO: boolean;
  49440. ALBEDODIRECTUV: number;
  49441. VERTEXCOLOR: boolean;
  49442. AMBIENT: boolean;
  49443. AMBIENTDIRECTUV: number;
  49444. AMBIENTINGRAYSCALE: boolean;
  49445. OPACITY: boolean;
  49446. VERTEXALPHA: boolean;
  49447. OPACITYDIRECTUV: number;
  49448. OPACITYRGB: boolean;
  49449. ALPHATEST: boolean;
  49450. DEPTHPREPASS: boolean;
  49451. ALPHABLEND: boolean;
  49452. ALPHAFROMALBEDO: boolean;
  49453. ALPHATESTVALUE: string;
  49454. SPECULAROVERALPHA: boolean;
  49455. RADIANCEOVERALPHA: boolean;
  49456. ALPHAFRESNEL: boolean;
  49457. LINEARALPHAFRESNEL: boolean;
  49458. PREMULTIPLYALPHA: boolean;
  49459. EMISSIVE: boolean;
  49460. EMISSIVEDIRECTUV: number;
  49461. REFLECTIVITY: boolean;
  49462. REFLECTIVITYDIRECTUV: number;
  49463. SPECULARTERM: boolean;
  49464. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49465. MICROSURFACEAUTOMATIC: boolean;
  49466. LODBASEDMICROSFURACE: boolean;
  49467. MICROSURFACEMAP: boolean;
  49468. MICROSURFACEMAPDIRECTUV: number;
  49469. METALLICWORKFLOW: boolean;
  49470. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49471. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49472. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49473. AOSTOREINMETALMAPRED: boolean;
  49474. ENVIRONMENTBRDF: boolean;
  49475. ENVIRONMENTBRDF_RGBD: boolean;
  49476. NORMAL: boolean;
  49477. TANGENT: boolean;
  49478. BUMP: boolean;
  49479. BUMPDIRECTUV: number;
  49480. OBJECTSPACE_NORMALMAP: boolean;
  49481. PARALLAX: boolean;
  49482. PARALLAXOCCLUSION: boolean;
  49483. NORMALXYSCALE: boolean;
  49484. LIGHTMAP: boolean;
  49485. LIGHTMAPDIRECTUV: number;
  49486. USELIGHTMAPASSHADOWMAP: boolean;
  49487. GAMMALIGHTMAP: boolean;
  49488. RGBDLIGHTMAP: boolean;
  49489. REFLECTION: boolean;
  49490. REFLECTIONMAP_3D: boolean;
  49491. REFLECTIONMAP_SPHERICAL: boolean;
  49492. REFLECTIONMAP_PLANAR: boolean;
  49493. REFLECTIONMAP_CUBIC: boolean;
  49494. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49495. REFLECTIONMAP_PROJECTION: boolean;
  49496. REFLECTIONMAP_SKYBOX: boolean;
  49497. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49498. REFLECTIONMAP_EXPLICIT: boolean;
  49499. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49500. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49501. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49502. INVERTCUBICMAP: boolean;
  49503. USESPHERICALFROMREFLECTIONMAP: boolean;
  49504. USEIRRADIANCEMAP: boolean;
  49505. SPHERICAL_HARMONICS: boolean;
  49506. USESPHERICALINVERTEX: boolean;
  49507. REFLECTIONMAP_OPPOSITEZ: boolean;
  49508. LODINREFLECTIONALPHA: boolean;
  49509. GAMMAREFLECTION: boolean;
  49510. RGBDREFLECTION: boolean;
  49511. LINEARSPECULARREFLECTION: boolean;
  49512. RADIANCEOCCLUSION: boolean;
  49513. HORIZONOCCLUSION: boolean;
  49514. INSTANCES: boolean;
  49515. NUM_BONE_INFLUENCERS: number;
  49516. BonesPerMesh: number;
  49517. BONETEXTURE: boolean;
  49518. NONUNIFORMSCALING: boolean;
  49519. MORPHTARGETS: boolean;
  49520. MORPHTARGETS_NORMAL: boolean;
  49521. MORPHTARGETS_TANGENT: boolean;
  49522. MORPHTARGETS_UV: boolean;
  49523. NUM_MORPH_INFLUENCERS: number;
  49524. IMAGEPROCESSING: boolean;
  49525. VIGNETTE: boolean;
  49526. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49527. VIGNETTEBLENDMODEOPAQUE: boolean;
  49528. TONEMAPPING: boolean;
  49529. TONEMAPPING_ACES: boolean;
  49530. CONTRAST: boolean;
  49531. COLORCURVES: boolean;
  49532. COLORGRADING: boolean;
  49533. COLORGRADING3D: boolean;
  49534. SAMPLER3DGREENDEPTH: boolean;
  49535. SAMPLER3DBGRMAP: boolean;
  49536. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49537. EXPOSURE: boolean;
  49538. MULTIVIEW: boolean;
  49539. USEPHYSICALLIGHTFALLOFF: boolean;
  49540. USEGLTFLIGHTFALLOFF: boolean;
  49541. TWOSIDEDLIGHTING: boolean;
  49542. SHADOWFLOAT: boolean;
  49543. CLIPPLANE: boolean;
  49544. CLIPPLANE2: boolean;
  49545. CLIPPLANE3: boolean;
  49546. CLIPPLANE4: boolean;
  49547. POINTSIZE: boolean;
  49548. FOG: boolean;
  49549. LOGARITHMICDEPTH: boolean;
  49550. FORCENORMALFORWARD: boolean;
  49551. SPECULARAA: boolean;
  49552. CLEARCOAT: boolean;
  49553. CLEARCOAT_DEFAULTIOR: boolean;
  49554. CLEARCOAT_TEXTURE: boolean;
  49555. CLEARCOAT_TEXTUREDIRECTUV: number;
  49556. CLEARCOAT_BUMP: boolean;
  49557. CLEARCOAT_BUMPDIRECTUV: number;
  49558. CLEARCOAT_TINT: boolean;
  49559. CLEARCOAT_TINT_TEXTURE: boolean;
  49560. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49561. ANISOTROPIC: boolean;
  49562. ANISOTROPIC_TEXTURE: boolean;
  49563. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49564. BRDF_V_HEIGHT_CORRELATED: boolean;
  49565. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49566. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49567. SHEEN: boolean;
  49568. SHEEN_TEXTURE: boolean;
  49569. SHEEN_TEXTUREDIRECTUV: number;
  49570. SHEEN_LINKWITHALBEDO: boolean;
  49571. SUBSURFACE: boolean;
  49572. SS_REFRACTION: boolean;
  49573. SS_TRANSLUCENCY: boolean;
  49574. SS_SCATERRING: boolean;
  49575. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49576. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49577. SS_REFRACTIONMAP_3D: boolean;
  49578. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49579. SS_LODINREFRACTIONALPHA: boolean;
  49580. SS_GAMMAREFRACTION: boolean;
  49581. SS_RGBDREFRACTION: boolean;
  49582. SS_LINEARSPECULARREFRACTION: boolean;
  49583. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49584. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49585. UNLIT: boolean;
  49586. DEBUGMODE: number;
  49587. /**
  49588. * Initializes the PBR Material defines.
  49589. */
  49590. constructor();
  49591. /**
  49592. * Resets the PBR Material defines.
  49593. */
  49594. reset(): void;
  49595. }
  49596. /**
  49597. * The Physically based material base class of BJS.
  49598. *
  49599. * This offers the main features of a standard PBR material.
  49600. * For more information, please refer to the documentation :
  49601. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49602. */
  49603. export abstract class PBRBaseMaterial extends PushMaterial {
  49604. /**
  49605. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49606. */
  49607. static readonly PBRMATERIAL_OPAQUE: number;
  49608. /**
  49609. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49610. */
  49611. static readonly PBRMATERIAL_ALPHATEST: number;
  49612. /**
  49613. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49614. */
  49615. static readonly PBRMATERIAL_ALPHABLEND: number;
  49616. /**
  49617. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49618. * They are also discarded below the alpha cutoff threshold to improve performances.
  49619. */
  49620. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49621. /**
  49622. * Defines the default value of how much AO map is occluding the analytical lights
  49623. * (point spot...).
  49624. */
  49625. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49626. /**
  49627. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49628. */
  49629. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49630. /**
  49631. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49632. * to enhance interoperability with other engines.
  49633. */
  49634. static readonly LIGHTFALLOFF_GLTF: number;
  49635. /**
  49636. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49637. * to enhance interoperability with other materials.
  49638. */
  49639. static readonly LIGHTFALLOFF_STANDARD: number;
  49640. /**
  49641. * Intensity of the direct lights e.g. the four lights available in your scene.
  49642. * This impacts both the direct diffuse and specular highlights.
  49643. */
  49644. protected _directIntensity: number;
  49645. /**
  49646. * Intensity of the emissive part of the material.
  49647. * This helps controlling the emissive effect without modifying the emissive color.
  49648. */
  49649. protected _emissiveIntensity: number;
  49650. /**
  49651. * Intensity of the environment e.g. how much the environment will light the object
  49652. * either through harmonics for rough material or through the refelction for shiny ones.
  49653. */
  49654. protected _environmentIntensity: number;
  49655. /**
  49656. * This is a special control allowing the reduction of the specular highlights coming from the
  49657. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49658. */
  49659. protected _specularIntensity: number;
  49660. /**
  49661. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49662. */
  49663. private _lightingInfos;
  49664. /**
  49665. * Debug Control allowing disabling the bump map on this material.
  49666. */
  49667. protected _disableBumpMap: boolean;
  49668. /**
  49669. * AKA Diffuse Texture in standard nomenclature.
  49670. */
  49671. protected _albedoTexture: Nullable<BaseTexture>;
  49672. /**
  49673. * AKA Occlusion Texture in other nomenclature.
  49674. */
  49675. protected _ambientTexture: Nullable<BaseTexture>;
  49676. /**
  49677. * AKA Occlusion Texture Intensity in other nomenclature.
  49678. */
  49679. protected _ambientTextureStrength: number;
  49680. /**
  49681. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49682. * 1 means it completely occludes it
  49683. * 0 mean it has no impact
  49684. */
  49685. protected _ambientTextureImpactOnAnalyticalLights: number;
  49686. /**
  49687. * Stores the alpha values in a texture.
  49688. */
  49689. protected _opacityTexture: Nullable<BaseTexture>;
  49690. /**
  49691. * Stores the reflection values in a texture.
  49692. */
  49693. protected _reflectionTexture: Nullable<BaseTexture>;
  49694. /**
  49695. * Stores the emissive values in a texture.
  49696. */
  49697. protected _emissiveTexture: Nullable<BaseTexture>;
  49698. /**
  49699. * AKA Specular texture in other nomenclature.
  49700. */
  49701. protected _reflectivityTexture: Nullable<BaseTexture>;
  49702. /**
  49703. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49704. */
  49705. protected _metallicTexture: Nullable<BaseTexture>;
  49706. /**
  49707. * Specifies the metallic scalar of the metallic/roughness workflow.
  49708. * Can also be used to scale the metalness values of the metallic texture.
  49709. */
  49710. protected _metallic: Nullable<number>;
  49711. /**
  49712. * Specifies the roughness scalar of the metallic/roughness workflow.
  49713. * Can also be used to scale the roughness values of the metallic texture.
  49714. */
  49715. protected _roughness: Nullable<number>;
  49716. /**
  49717. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49718. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49719. */
  49720. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49721. /**
  49722. * Stores surface normal data used to displace a mesh in a texture.
  49723. */
  49724. protected _bumpTexture: Nullable<BaseTexture>;
  49725. /**
  49726. * Stores the pre-calculated light information of a mesh in a texture.
  49727. */
  49728. protected _lightmapTexture: Nullable<BaseTexture>;
  49729. /**
  49730. * The color of a material in ambient lighting.
  49731. */
  49732. protected _ambientColor: Color3;
  49733. /**
  49734. * AKA Diffuse Color in other nomenclature.
  49735. */
  49736. protected _albedoColor: Color3;
  49737. /**
  49738. * AKA Specular Color in other nomenclature.
  49739. */
  49740. protected _reflectivityColor: Color3;
  49741. /**
  49742. * The color applied when light is reflected from a material.
  49743. */
  49744. protected _reflectionColor: Color3;
  49745. /**
  49746. * The color applied when light is emitted from a material.
  49747. */
  49748. protected _emissiveColor: Color3;
  49749. /**
  49750. * AKA Glossiness in other nomenclature.
  49751. */
  49752. protected _microSurface: number;
  49753. /**
  49754. * Specifies that the material will use the light map as a show map.
  49755. */
  49756. protected _useLightmapAsShadowmap: boolean;
  49757. /**
  49758. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49759. * makes the reflect vector face the model (under horizon).
  49760. */
  49761. protected _useHorizonOcclusion: boolean;
  49762. /**
  49763. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49764. * too much the area relying on ambient texture to define their ambient occlusion.
  49765. */
  49766. protected _useRadianceOcclusion: boolean;
  49767. /**
  49768. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49769. */
  49770. protected _useAlphaFromAlbedoTexture: boolean;
  49771. /**
  49772. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49773. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49774. */
  49775. protected _useSpecularOverAlpha: boolean;
  49776. /**
  49777. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49778. */
  49779. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49780. /**
  49781. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49782. */
  49783. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49784. /**
  49785. * Specifies if the metallic texture contains the roughness information in its green channel.
  49786. */
  49787. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49788. /**
  49789. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49790. */
  49791. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49792. /**
  49793. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49794. */
  49795. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49796. /**
  49797. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49798. */
  49799. protected _useAmbientInGrayScale: boolean;
  49800. /**
  49801. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49802. * The material will try to infer what glossiness each pixel should be.
  49803. */
  49804. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49805. /**
  49806. * Defines the falloff type used in this material.
  49807. * It by default is Physical.
  49808. */
  49809. protected _lightFalloff: number;
  49810. /**
  49811. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49812. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49813. */
  49814. protected _useRadianceOverAlpha: boolean;
  49815. /**
  49816. * Allows using an object space normal map (instead of tangent space).
  49817. */
  49818. protected _useObjectSpaceNormalMap: boolean;
  49819. /**
  49820. * Allows using the bump map in parallax mode.
  49821. */
  49822. protected _useParallax: boolean;
  49823. /**
  49824. * Allows using the bump map in parallax occlusion mode.
  49825. */
  49826. protected _useParallaxOcclusion: boolean;
  49827. /**
  49828. * Controls the scale bias of the parallax mode.
  49829. */
  49830. protected _parallaxScaleBias: number;
  49831. /**
  49832. * If sets to true, disables all the lights affecting the material.
  49833. */
  49834. protected _disableLighting: boolean;
  49835. /**
  49836. * Number of Simultaneous lights allowed on the material.
  49837. */
  49838. protected _maxSimultaneousLights: number;
  49839. /**
  49840. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49841. */
  49842. protected _invertNormalMapX: boolean;
  49843. /**
  49844. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49845. */
  49846. protected _invertNormalMapY: boolean;
  49847. /**
  49848. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49849. */
  49850. protected _twoSidedLighting: boolean;
  49851. /**
  49852. * Defines the alpha limits in alpha test mode.
  49853. */
  49854. protected _alphaCutOff: number;
  49855. /**
  49856. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49857. */
  49858. protected _forceAlphaTest: boolean;
  49859. /**
  49860. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49861. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49862. */
  49863. protected _useAlphaFresnel: boolean;
  49864. /**
  49865. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49866. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49867. */
  49868. protected _useLinearAlphaFresnel: boolean;
  49869. /**
  49870. * The transparency mode of the material.
  49871. */
  49872. protected _transparencyMode: Nullable<number>;
  49873. /**
  49874. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49875. * from cos thetav and roughness:
  49876. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49877. */
  49878. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49879. /**
  49880. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49881. */
  49882. protected _forceIrradianceInFragment: boolean;
  49883. /**
  49884. * Force normal to face away from face.
  49885. */
  49886. protected _forceNormalForward: boolean;
  49887. /**
  49888. * Enables specular anti aliasing in the PBR shader.
  49889. * It will both interacts on the Geometry for analytical and IBL lighting.
  49890. * It also prefilter the roughness map based on the bump values.
  49891. */
  49892. protected _enableSpecularAntiAliasing: boolean;
  49893. /**
  49894. * Default configuration related to image processing available in the PBR Material.
  49895. */
  49896. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49897. /**
  49898. * Keep track of the image processing observer to allow dispose and replace.
  49899. */
  49900. private _imageProcessingObserver;
  49901. /**
  49902. * Attaches a new image processing configuration to the PBR Material.
  49903. * @param configuration
  49904. */
  49905. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49906. /**
  49907. * Stores the available render targets.
  49908. */
  49909. private _renderTargets;
  49910. /**
  49911. * Sets the global ambient color for the material used in lighting calculations.
  49912. */
  49913. private _globalAmbientColor;
  49914. /**
  49915. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49916. */
  49917. private _useLogarithmicDepth;
  49918. /**
  49919. * If set to true, no lighting calculations will be applied.
  49920. */
  49921. private _unlit;
  49922. private _debugMode;
  49923. /**
  49924. * @hidden
  49925. * This is reserved for the inspector.
  49926. * Defines the material debug mode.
  49927. * It helps seeing only some components of the material while troubleshooting.
  49928. */
  49929. debugMode: number;
  49930. /**
  49931. * @hidden
  49932. * This is reserved for the inspector.
  49933. * Specify from where on screen the debug mode should start.
  49934. * The value goes from -1 (full screen) to 1 (not visible)
  49935. * It helps with side by side comparison against the final render
  49936. * This defaults to -1
  49937. */
  49938. private debugLimit;
  49939. /**
  49940. * @hidden
  49941. * This is reserved for the inspector.
  49942. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49943. * You can use the factor to better multiply the final value.
  49944. */
  49945. private debugFactor;
  49946. /**
  49947. * Defines the clear coat layer parameters for the material.
  49948. */
  49949. readonly clearCoat: PBRClearCoatConfiguration;
  49950. /**
  49951. * Defines the anisotropic parameters for the material.
  49952. */
  49953. readonly anisotropy: PBRAnisotropicConfiguration;
  49954. /**
  49955. * Defines the BRDF parameters for the material.
  49956. */
  49957. readonly brdf: PBRBRDFConfiguration;
  49958. /**
  49959. * Defines the Sheen parameters for the material.
  49960. */
  49961. readonly sheen: PBRSheenConfiguration;
  49962. /**
  49963. * Defines the SubSurface parameters for the material.
  49964. */
  49965. readonly subSurface: PBRSubSurfaceConfiguration;
  49966. /**
  49967. * Custom callback helping to override the default shader used in the material.
  49968. */
  49969. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49970. protected _rebuildInParallel: boolean;
  49971. /**
  49972. * Instantiates a new PBRMaterial instance.
  49973. *
  49974. * @param name The material name
  49975. * @param scene The scene the material will be use in.
  49976. */
  49977. constructor(name: string, scene: Scene);
  49978. /**
  49979. * Gets a boolean indicating that current material needs to register RTT
  49980. */
  49981. readonly hasRenderTargetTextures: boolean;
  49982. /**
  49983. * Gets the name of the material class.
  49984. */
  49985. getClassName(): string;
  49986. /**
  49987. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49988. */
  49989. /**
  49990. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49991. */
  49992. useLogarithmicDepth: boolean;
  49993. /**
  49994. * Gets the current transparency mode.
  49995. */
  49996. /**
  49997. * Sets the transparency mode of the material.
  49998. *
  49999. * | Value | Type | Description |
  50000. * | ----- | ----------------------------------- | ----------- |
  50001. * | 0 | OPAQUE | |
  50002. * | 1 | ALPHATEST | |
  50003. * | 2 | ALPHABLEND | |
  50004. * | 3 | ALPHATESTANDBLEND | |
  50005. *
  50006. */
  50007. transparencyMode: Nullable<number>;
  50008. /**
  50009. * Returns true if alpha blending should be disabled.
  50010. */
  50011. private readonly _disableAlphaBlending;
  50012. /**
  50013. * Specifies whether or not this material should be rendered in alpha blend mode.
  50014. */
  50015. needAlphaBlending(): boolean;
  50016. /**
  50017. * Specifies if the mesh will require alpha blending.
  50018. * @param mesh - BJS mesh.
  50019. */
  50020. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50021. /**
  50022. * Specifies whether or not this material should be rendered in alpha test mode.
  50023. */
  50024. needAlphaTesting(): boolean;
  50025. /**
  50026. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50027. */
  50028. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50029. /**
  50030. * Gets the texture used for the alpha test.
  50031. */
  50032. getAlphaTestTexture(): Nullable<BaseTexture>;
  50033. /**
  50034. * Specifies that the submesh is ready to be used.
  50035. * @param mesh - BJS mesh.
  50036. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50037. * @param useInstances - Specifies that instances should be used.
  50038. * @returns - boolean indicating that the submesh is ready or not.
  50039. */
  50040. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50041. /**
  50042. * Specifies if the material uses metallic roughness workflow.
  50043. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50044. */
  50045. isMetallicWorkflow(): boolean;
  50046. private _prepareEffect;
  50047. private _prepareDefines;
  50048. /**
  50049. * Force shader compilation
  50050. */
  50051. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50052. clipPlane: boolean;
  50053. }>): void;
  50054. /**
  50055. * Initializes the uniform buffer layout for the shader.
  50056. */
  50057. buildUniformLayout(): void;
  50058. /**
  50059. * Unbinds the material from the mesh
  50060. */
  50061. unbind(): void;
  50062. /**
  50063. * Binds the submesh data.
  50064. * @param world - The world matrix.
  50065. * @param mesh - The BJS mesh.
  50066. * @param subMesh - A submesh of the BJS mesh.
  50067. */
  50068. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50069. /**
  50070. * Returns the animatable textures.
  50071. * @returns - Array of animatable textures.
  50072. */
  50073. getAnimatables(): IAnimatable[];
  50074. /**
  50075. * Returns the texture used for reflections.
  50076. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50077. */
  50078. private _getReflectionTexture;
  50079. /**
  50080. * Returns an array of the actively used textures.
  50081. * @returns - Array of BaseTextures
  50082. */
  50083. getActiveTextures(): BaseTexture[];
  50084. /**
  50085. * Checks to see if a texture is used in the material.
  50086. * @param texture - Base texture to use.
  50087. * @returns - Boolean specifying if a texture is used in the material.
  50088. */
  50089. hasTexture(texture: BaseTexture): boolean;
  50090. /**
  50091. * Disposes the resources of the material.
  50092. * @param forceDisposeEffect - Forces the disposal of effects.
  50093. * @param forceDisposeTextures - Forces the disposal of all textures.
  50094. */
  50095. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50096. }
  50097. }
  50098. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50099. import { Nullable } from "babylonjs/types";
  50100. import { Scene } from "babylonjs/scene";
  50101. import { Color3 } from "babylonjs/Maths/math.color";
  50102. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50103. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50105. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50106. /**
  50107. * The Physically based material of BJS.
  50108. *
  50109. * This offers the main features of a standard PBR material.
  50110. * For more information, please refer to the documentation :
  50111. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50112. */
  50113. export class PBRMaterial extends PBRBaseMaterial {
  50114. /**
  50115. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50116. */
  50117. static readonly PBRMATERIAL_OPAQUE: number;
  50118. /**
  50119. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50120. */
  50121. static readonly PBRMATERIAL_ALPHATEST: number;
  50122. /**
  50123. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50124. */
  50125. static readonly PBRMATERIAL_ALPHABLEND: number;
  50126. /**
  50127. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50128. * They are also discarded below the alpha cutoff threshold to improve performances.
  50129. */
  50130. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50131. /**
  50132. * Defines the default value of how much AO map is occluding the analytical lights
  50133. * (point spot...).
  50134. */
  50135. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50136. /**
  50137. * Intensity of the direct lights e.g. the four lights available in your scene.
  50138. * This impacts both the direct diffuse and specular highlights.
  50139. */
  50140. directIntensity: number;
  50141. /**
  50142. * Intensity of the emissive part of the material.
  50143. * This helps controlling the emissive effect without modifying the emissive color.
  50144. */
  50145. emissiveIntensity: number;
  50146. /**
  50147. * Intensity of the environment e.g. how much the environment will light the object
  50148. * either through harmonics for rough material or through the refelction for shiny ones.
  50149. */
  50150. environmentIntensity: number;
  50151. /**
  50152. * This is a special control allowing the reduction of the specular highlights coming from the
  50153. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50154. */
  50155. specularIntensity: number;
  50156. /**
  50157. * Debug Control allowing disabling the bump map on this material.
  50158. */
  50159. disableBumpMap: boolean;
  50160. /**
  50161. * AKA Diffuse Texture in standard nomenclature.
  50162. */
  50163. albedoTexture: BaseTexture;
  50164. /**
  50165. * AKA Occlusion Texture in other nomenclature.
  50166. */
  50167. ambientTexture: BaseTexture;
  50168. /**
  50169. * AKA Occlusion Texture Intensity in other nomenclature.
  50170. */
  50171. ambientTextureStrength: number;
  50172. /**
  50173. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50174. * 1 means it completely occludes it
  50175. * 0 mean it has no impact
  50176. */
  50177. ambientTextureImpactOnAnalyticalLights: number;
  50178. /**
  50179. * Stores the alpha values in a texture.
  50180. */
  50181. opacityTexture: BaseTexture;
  50182. /**
  50183. * Stores the reflection values in a texture.
  50184. */
  50185. reflectionTexture: Nullable<BaseTexture>;
  50186. /**
  50187. * Stores the emissive values in a texture.
  50188. */
  50189. emissiveTexture: BaseTexture;
  50190. /**
  50191. * AKA Specular texture in other nomenclature.
  50192. */
  50193. reflectivityTexture: BaseTexture;
  50194. /**
  50195. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50196. */
  50197. metallicTexture: BaseTexture;
  50198. /**
  50199. * Specifies the metallic scalar of the metallic/roughness workflow.
  50200. * Can also be used to scale the metalness values of the metallic texture.
  50201. */
  50202. metallic: Nullable<number>;
  50203. /**
  50204. * Specifies the roughness scalar of the metallic/roughness workflow.
  50205. * Can also be used to scale the roughness values of the metallic texture.
  50206. */
  50207. roughness: Nullable<number>;
  50208. /**
  50209. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50210. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50211. */
  50212. microSurfaceTexture: BaseTexture;
  50213. /**
  50214. * Stores surface normal data used to displace a mesh in a texture.
  50215. */
  50216. bumpTexture: BaseTexture;
  50217. /**
  50218. * Stores the pre-calculated light information of a mesh in a texture.
  50219. */
  50220. lightmapTexture: BaseTexture;
  50221. /**
  50222. * Stores the refracted light information in a texture.
  50223. */
  50224. refractionTexture: Nullable<BaseTexture>;
  50225. /**
  50226. * The color of a material in ambient lighting.
  50227. */
  50228. ambientColor: Color3;
  50229. /**
  50230. * AKA Diffuse Color in other nomenclature.
  50231. */
  50232. albedoColor: Color3;
  50233. /**
  50234. * AKA Specular Color in other nomenclature.
  50235. */
  50236. reflectivityColor: Color3;
  50237. /**
  50238. * The color reflected from the material.
  50239. */
  50240. reflectionColor: Color3;
  50241. /**
  50242. * The color emitted from the material.
  50243. */
  50244. emissiveColor: Color3;
  50245. /**
  50246. * AKA Glossiness in other nomenclature.
  50247. */
  50248. microSurface: number;
  50249. /**
  50250. * source material index of refraction (IOR)' / 'destination material IOR.
  50251. */
  50252. indexOfRefraction: number;
  50253. /**
  50254. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50255. */
  50256. invertRefractionY: boolean;
  50257. /**
  50258. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50259. * Materials half opaque for instance using refraction could benefit from this control.
  50260. */
  50261. linkRefractionWithTransparency: boolean;
  50262. /**
  50263. * If true, the light map contains occlusion information instead of lighting info.
  50264. */
  50265. useLightmapAsShadowmap: boolean;
  50266. /**
  50267. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50268. */
  50269. useAlphaFromAlbedoTexture: boolean;
  50270. /**
  50271. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50272. */
  50273. forceAlphaTest: boolean;
  50274. /**
  50275. * Defines the alpha limits in alpha test mode.
  50276. */
  50277. alphaCutOff: number;
  50278. /**
  50279. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50280. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50281. */
  50282. useSpecularOverAlpha: boolean;
  50283. /**
  50284. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50285. */
  50286. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50287. /**
  50288. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50289. */
  50290. useRoughnessFromMetallicTextureAlpha: boolean;
  50291. /**
  50292. * Specifies if the metallic texture contains the roughness information in its green channel.
  50293. */
  50294. useRoughnessFromMetallicTextureGreen: boolean;
  50295. /**
  50296. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50297. */
  50298. useMetallnessFromMetallicTextureBlue: boolean;
  50299. /**
  50300. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50301. */
  50302. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50303. /**
  50304. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50305. */
  50306. useAmbientInGrayScale: boolean;
  50307. /**
  50308. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50309. * The material will try to infer what glossiness each pixel should be.
  50310. */
  50311. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50312. /**
  50313. * BJS is using an harcoded light falloff based on a manually sets up range.
  50314. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50315. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50316. */
  50317. /**
  50318. * BJS is using an harcoded light falloff based on a manually sets up range.
  50319. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50320. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50321. */
  50322. usePhysicalLightFalloff: boolean;
  50323. /**
  50324. * In order to support the falloff compatibility with gltf, a special mode has been added
  50325. * to reproduce the gltf light falloff.
  50326. */
  50327. /**
  50328. * In order to support the falloff compatibility with gltf, a special mode has been added
  50329. * to reproduce the gltf light falloff.
  50330. */
  50331. useGLTFLightFalloff: boolean;
  50332. /**
  50333. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50334. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50335. */
  50336. useRadianceOverAlpha: boolean;
  50337. /**
  50338. * Allows using an object space normal map (instead of tangent space).
  50339. */
  50340. useObjectSpaceNormalMap: boolean;
  50341. /**
  50342. * Allows using the bump map in parallax mode.
  50343. */
  50344. useParallax: boolean;
  50345. /**
  50346. * Allows using the bump map in parallax occlusion mode.
  50347. */
  50348. useParallaxOcclusion: boolean;
  50349. /**
  50350. * Controls the scale bias of the parallax mode.
  50351. */
  50352. parallaxScaleBias: number;
  50353. /**
  50354. * If sets to true, disables all the lights affecting the material.
  50355. */
  50356. disableLighting: boolean;
  50357. /**
  50358. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50359. */
  50360. forceIrradianceInFragment: boolean;
  50361. /**
  50362. * Number of Simultaneous lights allowed on the material.
  50363. */
  50364. maxSimultaneousLights: number;
  50365. /**
  50366. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50367. */
  50368. invertNormalMapX: boolean;
  50369. /**
  50370. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50371. */
  50372. invertNormalMapY: boolean;
  50373. /**
  50374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50375. */
  50376. twoSidedLighting: boolean;
  50377. /**
  50378. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50379. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50380. */
  50381. useAlphaFresnel: boolean;
  50382. /**
  50383. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50384. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50385. */
  50386. useLinearAlphaFresnel: boolean;
  50387. /**
  50388. * Let user defines the brdf lookup texture used for IBL.
  50389. * A default 8bit version is embedded but you could point at :
  50390. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50391. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50392. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50393. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50394. */
  50395. environmentBRDFTexture: Nullable<BaseTexture>;
  50396. /**
  50397. * Force normal to face away from face.
  50398. */
  50399. forceNormalForward: boolean;
  50400. /**
  50401. * Enables specular anti aliasing in the PBR shader.
  50402. * It will both interacts on the Geometry for analytical and IBL lighting.
  50403. * It also prefilter the roughness map based on the bump values.
  50404. */
  50405. enableSpecularAntiAliasing: boolean;
  50406. /**
  50407. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50408. * makes the reflect vector face the model (under horizon).
  50409. */
  50410. useHorizonOcclusion: boolean;
  50411. /**
  50412. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50413. * too much the area relying on ambient texture to define their ambient occlusion.
  50414. */
  50415. useRadianceOcclusion: boolean;
  50416. /**
  50417. * If set to true, no lighting calculations will be applied.
  50418. */
  50419. unlit: boolean;
  50420. /**
  50421. * Gets the image processing configuration used either in this material.
  50422. */
  50423. /**
  50424. * Sets the Default image processing configuration used either in the this material.
  50425. *
  50426. * If sets to null, the scene one is in use.
  50427. */
  50428. imageProcessingConfiguration: ImageProcessingConfiguration;
  50429. /**
  50430. * Gets wether the color curves effect is enabled.
  50431. */
  50432. /**
  50433. * Sets wether the color curves effect is enabled.
  50434. */
  50435. cameraColorCurvesEnabled: boolean;
  50436. /**
  50437. * Gets wether the color grading effect is enabled.
  50438. */
  50439. /**
  50440. * Gets wether the color grading effect is enabled.
  50441. */
  50442. cameraColorGradingEnabled: boolean;
  50443. /**
  50444. * Gets wether tonemapping is enabled or not.
  50445. */
  50446. /**
  50447. * Sets wether tonemapping is enabled or not
  50448. */
  50449. cameraToneMappingEnabled: boolean;
  50450. /**
  50451. * The camera exposure used on this material.
  50452. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50453. * This corresponds to a photographic exposure.
  50454. */
  50455. /**
  50456. * The camera exposure used on this material.
  50457. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50458. * This corresponds to a photographic exposure.
  50459. */
  50460. cameraExposure: number;
  50461. /**
  50462. * Gets The camera contrast used on this material.
  50463. */
  50464. /**
  50465. * Sets The camera contrast used on this material.
  50466. */
  50467. cameraContrast: number;
  50468. /**
  50469. * Gets the Color Grading 2D Lookup Texture.
  50470. */
  50471. /**
  50472. * Sets the Color Grading 2D Lookup Texture.
  50473. */
  50474. cameraColorGradingTexture: Nullable<BaseTexture>;
  50475. /**
  50476. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50477. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50478. * 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;
  50479. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50480. */
  50481. /**
  50482. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50483. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50484. * 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;
  50485. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50486. */
  50487. cameraColorCurves: Nullable<ColorCurves>;
  50488. /**
  50489. * Instantiates a new PBRMaterial instance.
  50490. *
  50491. * @param name The material name
  50492. * @param scene The scene the material will be use in.
  50493. */
  50494. constructor(name: string, scene: Scene);
  50495. /**
  50496. * Returns the name of this material class.
  50497. */
  50498. getClassName(): string;
  50499. /**
  50500. * Makes a duplicate of the current material.
  50501. * @param name - name to use for the new material.
  50502. */
  50503. clone(name: string): PBRMaterial;
  50504. /**
  50505. * Serializes this PBR Material.
  50506. * @returns - An object with the serialized material.
  50507. */
  50508. serialize(): any;
  50509. /**
  50510. * Parses a PBR Material from a serialized object.
  50511. * @param source - Serialized object.
  50512. * @param scene - BJS scene instance.
  50513. * @param rootUrl - url for the scene object
  50514. * @returns - PBRMaterial
  50515. */
  50516. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50517. }
  50518. }
  50519. declare module "babylonjs/Misc/dds" {
  50520. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50522. import { Nullable } from "babylonjs/types";
  50523. import { Scene } from "babylonjs/scene";
  50524. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50525. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50526. /**
  50527. * Direct draw surface info
  50528. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50529. */
  50530. export interface DDSInfo {
  50531. /**
  50532. * Width of the texture
  50533. */
  50534. width: number;
  50535. /**
  50536. * Width of the texture
  50537. */
  50538. height: number;
  50539. /**
  50540. * Number of Mipmaps for the texture
  50541. * @see https://en.wikipedia.org/wiki/Mipmap
  50542. */
  50543. mipmapCount: number;
  50544. /**
  50545. * If the textures format is a known fourCC format
  50546. * @see https://www.fourcc.org/
  50547. */
  50548. isFourCC: boolean;
  50549. /**
  50550. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50551. */
  50552. isRGB: boolean;
  50553. /**
  50554. * If the texture is a lumincance format
  50555. */
  50556. isLuminance: boolean;
  50557. /**
  50558. * If this is a cube texture
  50559. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50560. */
  50561. isCube: boolean;
  50562. /**
  50563. * If the texture is a compressed format eg. FOURCC_DXT1
  50564. */
  50565. isCompressed: boolean;
  50566. /**
  50567. * The dxgiFormat of the texture
  50568. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50569. */
  50570. dxgiFormat: number;
  50571. /**
  50572. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50573. */
  50574. textureType: number;
  50575. /**
  50576. * Sphericle polynomial created for the dds texture
  50577. */
  50578. sphericalPolynomial?: SphericalPolynomial;
  50579. }
  50580. /**
  50581. * Class used to provide DDS decompression tools
  50582. */
  50583. export class DDSTools {
  50584. /**
  50585. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50586. */
  50587. static StoreLODInAlphaChannel: boolean;
  50588. /**
  50589. * Gets DDS information from an array buffer
  50590. * @param arrayBuffer defines the array buffer to read data from
  50591. * @returns the DDS information
  50592. */
  50593. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50594. private static _FloatView;
  50595. private static _Int32View;
  50596. private static _ToHalfFloat;
  50597. private static _FromHalfFloat;
  50598. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50599. private static _GetHalfFloatRGBAArrayBuffer;
  50600. private static _GetFloatRGBAArrayBuffer;
  50601. private static _GetFloatAsUIntRGBAArrayBuffer;
  50602. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50603. private static _GetRGBAArrayBuffer;
  50604. private static _ExtractLongWordOrder;
  50605. private static _GetRGBArrayBuffer;
  50606. private static _GetLuminanceArrayBuffer;
  50607. /**
  50608. * Uploads DDS Levels to a Babylon Texture
  50609. * @hidden
  50610. */
  50611. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50612. }
  50613. module "babylonjs/Engines/thinEngine" {
  50614. interface ThinEngine {
  50615. /**
  50616. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50617. * @param rootUrl defines the url where the file to load is located
  50618. * @param scene defines the current scene
  50619. * @param lodScale defines scale to apply to the mip map selection
  50620. * @param lodOffset defines offset to apply to the mip map selection
  50621. * @param onLoad defines an optional callback raised when the texture is loaded
  50622. * @param onError defines an optional callback raised if there is an issue to load the texture
  50623. * @param format defines the format of the data
  50624. * @param forcedExtension defines the extension to use to pick the right loader
  50625. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50626. * @returns the cube texture as an InternalTexture
  50627. */
  50628. 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;
  50629. }
  50630. }
  50631. }
  50632. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50633. import { Nullable } from "babylonjs/types";
  50634. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50635. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50636. /**
  50637. * Implementation of the DDS Texture Loader.
  50638. * @hidden
  50639. */
  50640. export class _DDSTextureLoader implements IInternalTextureLoader {
  50641. /**
  50642. * Defines wether the loader supports cascade loading the different faces.
  50643. */
  50644. readonly supportCascades: boolean;
  50645. /**
  50646. * This returns if the loader support the current file information.
  50647. * @param extension defines the file extension of the file being loaded
  50648. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50649. * @param fallback defines the fallback internal texture if any
  50650. * @param isBase64 defines whether the texture is encoded as a base64
  50651. * @param isBuffer defines whether the texture data are stored as a buffer
  50652. * @returns true if the loader can load the specified file
  50653. */
  50654. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50655. /**
  50656. * Transform the url before loading if required.
  50657. * @param rootUrl the url of the texture
  50658. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50659. * @returns the transformed texture
  50660. */
  50661. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50662. /**
  50663. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50664. * @param rootUrl the url of the texture
  50665. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50666. * @returns the fallback texture
  50667. */
  50668. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50669. /**
  50670. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50671. * @param data contains the texture data
  50672. * @param texture defines the BabylonJS internal texture
  50673. * @param createPolynomials will be true if polynomials have been requested
  50674. * @param onLoad defines the callback to trigger once the texture is ready
  50675. * @param onError defines the callback to trigger in case of error
  50676. */
  50677. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50678. /**
  50679. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50680. * @param data contains the texture data
  50681. * @param texture defines the BabylonJS internal texture
  50682. * @param callback defines the method to call once ready to upload
  50683. */
  50684. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50685. }
  50686. }
  50687. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50688. import { Nullable } from "babylonjs/types";
  50689. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50690. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50691. /**
  50692. * Implementation of the ENV Texture Loader.
  50693. * @hidden
  50694. */
  50695. export class _ENVTextureLoader implements IInternalTextureLoader {
  50696. /**
  50697. * Defines wether the loader supports cascade loading the different faces.
  50698. */
  50699. readonly supportCascades: boolean;
  50700. /**
  50701. * This returns if the loader support the current file information.
  50702. * @param extension defines the file extension of the file being loaded
  50703. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50704. * @param fallback defines the fallback internal texture if any
  50705. * @param isBase64 defines whether the texture is encoded as a base64
  50706. * @param isBuffer defines whether the texture data are stored as a buffer
  50707. * @returns true if the loader can load the specified file
  50708. */
  50709. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50710. /**
  50711. * Transform the url before loading if required.
  50712. * @param rootUrl the url of the texture
  50713. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50714. * @returns the transformed texture
  50715. */
  50716. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50717. /**
  50718. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50719. * @param rootUrl the url of the texture
  50720. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50721. * @returns the fallback texture
  50722. */
  50723. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50724. /**
  50725. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50726. * @param data contains the texture data
  50727. * @param texture defines the BabylonJS internal texture
  50728. * @param createPolynomials will be true if polynomials have been requested
  50729. * @param onLoad defines the callback to trigger once the texture is ready
  50730. * @param onError defines the callback to trigger in case of error
  50731. */
  50732. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50733. /**
  50734. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50735. * @param data contains the texture data
  50736. * @param texture defines the BabylonJS internal texture
  50737. * @param callback defines the method to call once ready to upload
  50738. */
  50739. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50740. }
  50741. }
  50742. declare module "babylonjs/Misc/khronosTextureContainer" {
  50743. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50744. /**
  50745. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50746. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50747. */
  50748. export class KhronosTextureContainer {
  50749. /** contents of the KTX container file */
  50750. arrayBuffer: any;
  50751. private static HEADER_LEN;
  50752. private static COMPRESSED_2D;
  50753. private static COMPRESSED_3D;
  50754. private static TEX_2D;
  50755. private static TEX_3D;
  50756. /**
  50757. * Gets the openGL type
  50758. */
  50759. glType: number;
  50760. /**
  50761. * Gets the openGL type size
  50762. */
  50763. glTypeSize: number;
  50764. /**
  50765. * Gets the openGL format
  50766. */
  50767. glFormat: number;
  50768. /**
  50769. * Gets the openGL internal format
  50770. */
  50771. glInternalFormat: number;
  50772. /**
  50773. * Gets the base internal format
  50774. */
  50775. glBaseInternalFormat: number;
  50776. /**
  50777. * Gets image width in pixel
  50778. */
  50779. pixelWidth: number;
  50780. /**
  50781. * Gets image height in pixel
  50782. */
  50783. pixelHeight: number;
  50784. /**
  50785. * Gets image depth in pixels
  50786. */
  50787. pixelDepth: number;
  50788. /**
  50789. * Gets the number of array elements
  50790. */
  50791. numberOfArrayElements: number;
  50792. /**
  50793. * Gets the number of faces
  50794. */
  50795. numberOfFaces: number;
  50796. /**
  50797. * Gets the number of mipmap levels
  50798. */
  50799. numberOfMipmapLevels: number;
  50800. /**
  50801. * Gets the bytes of key value data
  50802. */
  50803. bytesOfKeyValueData: number;
  50804. /**
  50805. * Gets the load type
  50806. */
  50807. loadType: number;
  50808. /**
  50809. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50810. */
  50811. isInvalid: boolean;
  50812. /**
  50813. * Creates a new KhronosTextureContainer
  50814. * @param arrayBuffer contents of the KTX container file
  50815. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50816. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50817. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50818. */
  50819. constructor(
  50820. /** contents of the KTX container file */
  50821. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50822. /**
  50823. * Uploads KTX content to a Babylon Texture.
  50824. * It is assumed that the texture has already been created & is currently bound
  50825. * @hidden
  50826. */
  50827. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50828. private _upload2DCompressedLevels;
  50829. }
  50830. }
  50831. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50832. import { Nullable } from "babylonjs/types";
  50833. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50834. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50835. /**
  50836. * Implementation of the KTX Texture Loader.
  50837. * @hidden
  50838. */
  50839. export class _KTXTextureLoader implements IInternalTextureLoader {
  50840. /**
  50841. * Defines wether the loader supports cascade loading the different faces.
  50842. */
  50843. readonly supportCascades: boolean;
  50844. /**
  50845. * This returns if the loader support the current file information.
  50846. * @param extension defines the file extension of the file being loaded
  50847. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50848. * @param fallback defines the fallback internal texture if any
  50849. * @param isBase64 defines whether the texture is encoded as a base64
  50850. * @param isBuffer defines whether the texture data are stored as a buffer
  50851. * @returns true if the loader can load the specified file
  50852. */
  50853. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50854. /**
  50855. * Transform the url before loading if required.
  50856. * @param rootUrl the url of the texture
  50857. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50858. * @returns the transformed texture
  50859. */
  50860. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50861. /**
  50862. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50863. * @param rootUrl the url of the texture
  50864. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50865. * @returns the fallback texture
  50866. */
  50867. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50868. /**
  50869. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50870. * @param data contains the texture data
  50871. * @param texture defines the BabylonJS internal texture
  50872. * @param createPolynomials will be true if polynomials have been requested
  50873. * @param onLoad defines the callback to trigger once the texture is ready
  50874. * @param onError defines the callback to trigger in case of error
  50875. */
  50876. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50877. /**
  50878. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50879. * @param data contains the texture data
  50880. * @param texture defines the BabylonJS internal texture
  50881. * @param callback defines the method to call once ready to upload
  50882. */
  50883. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50884. }
  50885. }
  50886. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50887. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50888. import { Scene } from "babylonjs/scene";
  50889. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50890. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50891. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50892. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50893. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50894. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50896. /**
  50897. * Options for the default xr helper
  50898. */
  50899. export class WebXRDefaultExperienceOptions {
  50900. /**
  50901. * Floor meshes that should be used for teleporting
  50902. */
  50903. floorMeshes: Array<AbstractMesh>;
  50904. }
  50905. /**
  50906. * Default experience which provides a similar setup to the previous webVRExperience
  50907. */
  50908. export class WebXRDefaultExperience {
  50909. /**
  50910. * Base experience
  50911. */
  50912. baseExperience: WebXRExperienceHelper;
  50913. /**
  50914. * Input experience extension
  50915. */
  50916. input: WebXRInput;
  50917. /**
  50918. * Loads the controller models
  50919. */
  50920. controllerModelLoader: WebXRControllerModelLoader;
  50921. /**
  50922. * Enables laser pointer and selection
  50923. */
  50924. pointerSelection: WebXRControllerPointerSelection;
  50925. /**
  50926. * Enables teleportation
  50927. */
  50928. teleportation: WebXRControllerTeleportation;
  50929. /**
  50930. * Enables ui for enetering/exiting xr
  50931. */
  50932. enterExitUI: WebXREnterExitUI;
  50933. /**
  50934. * Default output canvas xr should render to
  50935. */
  50936. outputCanvas: WebXRManagedOutputCanvas;
  50937. /**
  50938. * Creates the default xr experience
  50939. * @param scene scene
  50940. * @param options options for basic configuration
  50941. * @returns resulting WebXRDefaultExperience
  50942. */
  50943. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50944. private constructor();
  50945. /**
  50946. * DIsposes of the experience helper
  50947. */
  50948. dispose(): void;
  50949. }
  50950. }
  50951. declare module "babylonjs/Helpers/sceneHelpers" {
  50952. import { Nullable } from "babylonjs/types";
  50953. import { Mesh } from "babylonjs/Meshes/mesh";
  50954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50955. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50956. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50957. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50958. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50959. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50960. import "babylonjs/Meshes/Builders/boxBuilder";
  50961. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50962. /** @hidden */
  50963. export var _forceSceneHelpersToBundle: boolean;
  50964. module "babylonjs/scene" {
  50965. interface Scene {
  50966. /**
  50967. * Creates a default light for the scene.
  50968. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50969. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50970. */
  50971. createDefaultLight(replace?: boolean): void;
  50972. /**
  50973. * Creates a default camera for the scene.
  50974. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50975. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50976. * @param replace has default false, when true replaces the active camera in the scene
  50977. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50978. */
  50979. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50980. /**
  50981. * Creates a default camera and a default light.
  50982. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50983. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50984. * @param replace has the default false, when true replaces the active camera/light in the scene
  50985. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50986. */
  50987. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50988. /**
  50989. * Creates a new sky box
  50990. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50991. * @param environmentTexture defines the texture to use as environment texture
  50992. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50993. * @param scale defines the overall scale of the skybox
  50994. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50995. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50996. * @returns a new mesh holding the sky box
  50997. */
  50998. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50999. /**
  51000. * Creates a new environment
  51001. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51002. * @param options defines the options you can use to configure the environment
  51003. * @returns the new EnvironmentHelper
  51004. */
  51005. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51006. /**
  51007. * Creates a new VREXperienceHelper
  51008. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51009. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51010. * @returns a new VREXperienceHelper
  51011. */
  51012. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51013. /**
  51014. * Creates a new WebXRDefaultExperience
  51015. * @see http://doc.babylonjs.com/how_to/webxr
  51016. * @param options experience options
  51017. * @returns a promise for a new WebXRDefaultExperience
  51018. */
  51019. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51020. }
  51021. }
  51022. }
  51023. declare module "babylonjs/Helpers/videoDome" {
  51024. import { Scene } from "babylonjs/scene";
  51025. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51026. import { Mesh } from "babylonjs/Meshes/mesh";
  51027. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51028. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51029. import "babylonjs/Meshes/Builders/sphereBuilder";
  51030. /**
  51031. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51032. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51033. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51034. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51035. */
  51036. export class VideoDome extends TransformNode {
  51037. /**
  51038. * Define the video source as a Monoscopic panoramic 360 video.
  51039. */
  51040. static readonly MODE_MONOSCOPIC: number;
  51041. /**
  51042. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51043. */
  51044. static readonly MODE_TOPBOTTOM: number;
  51045. /**
  51046. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51047. */
  51048. static readonly MODE_SIDEBYSIDE: number;
  51049. private _halfDome;
  51050. private _useDirectMapping;
  51051. /**
  51052. * The video texture being displayed on the sphere
  51053. */
  51054. protected _videoTexture: VideoTexture;
  51055. /**
  51056. * Gets the video texture being displayed on the sphere
  51057. */
  51058. readonly videoTexture: VideoTexture;
  51059. /**
  51060. * The skybox material
  51061. */
  51062. protected _material: BackgroundMaterial;
  51063. /**
  51064. * The surface used for the skybox
  51065. */
  51066. protected _mesh: Mesh;
  51067. /**
  51068. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51069. */
  51070. private _halfDomeMask;
  51071. /**
  51072. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51073. * Also see the options.resolution property.
  51074. */
  51075. fovMultiplier: number;
  51076. private _videoMode;
  51077. /**
  51078. * Gets or set the current video mode for the video. It can be:
  51079. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51080. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51081. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51082. */
  51083. videoMode: number;
  51084. /**
  51085. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51086. *
  51087. */
  51088. /**
  51089. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51090. */
  51091. halfDome: boolean;
  51092. /**
  51093. * Oberserver used in Stereoscopic VR Mode.
  51094. */
  51095. private _onBeforeCameraRenderObserver;
  51096. /**
  51097. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51098. * @param name Element's name, child elements will append suffixes for their own names.
  51099. * @param urlsOrVideo defines the url(s) or the video element to use
  51100. * @param options An object containing optional or exposed sub element properties
  51101. */
  51102. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51103. resolution?: number;
  51104. clickToPlay?: boolean;
  51105. autoPlay?: boolean;
  51106. loop?: boolean;
  51107. size?: number;
  51108. poster?: string;
  51109. faceForward?: boolean;
  51110. useDirectMapping?: boolean;
  51111. halfDomeMode?: boolean;
  51112. }, scene: Scene);
  51113. private _changeVideoMode;
  51114. /**
  51115. * Releases resources associated with this node.
  51116. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51117. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51118. */
  51119. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51120. }
  51121. }
  51122. declare module "babylonjs/Helpers/index" {
  51123. export * from "babylonjs/Helpers/environmentHelper";
  51124. export * from "babylonjs/Helpers/photoDome";
  51125. export * from "babylonjs/Helpers/sceneHelpers";
  51126. export * from "babylonjs/Helpers/videoDome";
  51127. }
  51128. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51129. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51130. import { IDisposable } from "babylonjs/scene";
  51131. import { Engine } from "babylonjs/Engines/engine";
  51132. /**
  51133. * This class can be used to get instrumentation data from a Babylon engine
  51134. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51135. */
  51136. export class EngineInstrumentation implements IDisposable {
  51137. /**
  51138. * Define the instrumented engine.
  51139. */
  51140. engine: Engine;
  51141. private _captureGPUFrameTime;
  51142. private _gpuFrameTimeToken;
  51143. private _gpuFrameTime;
  51144. private _captureShaderCompilationTime;
  51145. private _shaderCompilationTime;
  51146. private _onBeginFrameObserver;
  51147. private _onEndFrameObserver;
  51148. private _onBeforeShaderCompilationObserver;
  51149. private _onAfterShaderCompilationObserver;
  51150. /**
  51151. * Gets the perf counter used for GPU frame time
  51152. */
  51153. readonly gpuFrameTimeCounter: PerfCounter;
  51154. /**
  51155. * Gets the GPU frame time capture status
  51156. */
  51157. /**
  51158. * Enable or disable the GPU frame time capture
  51159. */
  51160. captureGPUFrameTime: boolean;
  51161. /**
  51162. * Gets the perf counter used for shader compilation time
  51163. */
  51164. readonly shaderCompilationTimeCounter: PerfCounter;
  51165. /**
  51166. * Gets the shader compilation time capture status
  51167. */
  51168. /**
  51169. * Enable or disable the shader compilation time capture
  51170. */
  51171. captureShaderCompilationTime: boolean;
  51172. /**
  51173. * Instantiates a new engine instrumentation.
  51174. * This class can be used to get instrumentation data from a Babylon engine
  51175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51176. * @param engine Defines the engine to instrument
  51177. */
  51178. constructor(
  51179. /**
  51180. * Define the instrumented engine.
  51181. */
  51182. engine: Engine);
  51183. /**
  51184. * Dispose and release associated resources.
  51185. */
  51186. dispose(): void;
  51187. }
  51188. }
  51189. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51190. import { Scene, IDisposable } from "babylonjs/scene";
  51191. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51192. /**
  51193. * This class can be used to get instrumentation data from a Babylon engine
  51194. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51195. */
  51196. export class SceneInstrumentation implements IDisposable {
  51197. /**
  51198. * Defines the scene to instrument
  51199. */
  51200. scene: Scene;
  51201. private _captureActiveMeshesEvaluationTime;
  51202. private _activeMeshesEvaluationTime;
  51203. private _captureRenderTargetsRenderTime;
  51204. private _renderTargetsRenderTime;
  51205. private _captureFrameTime;
  51206. private _frameTime;
  51207. private _captureRenderTime;
  51208. private _renderTime;
  51209. private _captureInterFrameTime;
  51210. private _interFrameTime;
  51211. private _captureParticlesRenderTime;
  51212. private _particlesRenderTime;
  51213. private _captureSpritesRenderTime;
  51214. private _spritesRenderTime;
  51215. private _capturePhysicsTime;
  51216. private _physicsTime;
  51217. private _captureAnimationsTime;
  51218. private _animationsTime;
  51219. private _captureCameraRenderTime;
  51220. private _cameraRenderTime;
  51221. private _onBeforeActiveMeshesEvaluationObserver;
  51222. private _onAfterActiveMeshesEvaluationObserver;
  51223. private _onBeforeRenderTargetsRenderObserver;
  51224. private _onAfterRenderTargetsRenderObserver;
  51225. private _onAfterRenderObserver;
  51226. private _onBeforeDrawPhaseObserver;
  51227. private _onAfterDrawPhaseObserver;
  51228. private _onBeforeAnimationsObserver;
  51229. private _onBeforeParticlesRenderingObserver;
  51230. private _onAfterParticlesRenderingObserver;
  51231. private _onBeforeSpritesRenderingObserver;
  51232. private _onAfterSpritesRenderingObserver;
  51233. private _onBeforePhysicsObserver;
  51234. private _onAfterPhysicsObserver;
  51235. private _onAfterAnimationsObserver;
  51236. private _onBeforeCameraRenderObserver;
  51237. private _onAfterCameraRenderObserver;
  51238. /**
  51239. * Gets the perf counter used for active meshes evaluation time
  51240. */
  51241. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51242. /**
  51243. * Gets the active meshes evaluation time capture status
  51244. */
  51245. /**
  51246. * Enable or disable the active meshes evaluation time capture
  51247. */
  51248. captureActiveMeshesEvaluationTime: boolean;
  51249. /**
  51250. * Gets the perf counter used for render targets render time
  51251. */
  51252. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51253. /**
  51254. * Gets the render targets render time capture status
  51255. */
  51256. /**
  51257. * Enable or disable the render targets render time capture
  51258. */
  51259. captureRenderTargetsRenderTime: boolean;
  51260. /**
  51261. * Gets the perf counter used for particles render time
  51262. */
  51263. readonly particlesRenderTimeCounter: PerfCounter;
  51264. /**
  51265. * Gets the particles render time capture status
  51266. */
  51267. /**
  51268. * Enable or disable the particles render time capture
  51269. */
  51270. captureParticlesRenderTime: boolean;
  51271. /**
  51272. * Gets the perf counter used for sprites render time
  51273. */
  51274. readonly spritesRenderTimeCounter: PerfCounter;
  51275. /**
  51276. * Gets the sprites render time capture status
  51277. */
  51278. /**
  51279. * Enable or disable the sprites render time capture
  51280. */
  51281. captureSpritesRenderTime: boolean;
  51282. /**
  51283. * Gets the perf counter used for physics time
  51284. */
  51285. readonly physicsTimeCounter: PerfCounter;
  51286. /**
  51287. * Gets the physics time capture status
  51288. */
  51289. /**
  51290. * Enable or disable the physics time capture
  51291. */
  51292. capturePhysicsTime: boolean;
  51293. /**
  51294. * Gets the perf counter used for animations time
  51295. */
  51296. readonly animationsTimeCounter: PerfCounter;
  51297. /**
  51298. * Gets the animations time capture status
  51299. */
  51300. /**
  51301. * Enable or disable the animations time capture
  51302. */
  51303. captureAnimationsTime: boolean;
  51304. /**
  51305. * Gets the perf counter used for frame time capture
  51306. */
  51307. readonly frameTimeCounter: PerfCounter;
  51308. /**
  51309. * Gets the frame time capture status
  51310. */
  51311. /**
  51312. * Enable or disable the frame time capture
  51313. */
  51314. captureFrameTime: boolean;
  51315. /**
  51316. * Gets the perf counter used for inter-frames time capture
  51317. */
  51318. readonly interFrameTimeCounter: PerfCounter;
  51319. /**
  51320. * Gets the inter-frames time capture status
  51321. */
  51322. /**
  51323. * Enable or disable the inter-frames time capture
  51324. */
  51325. captureInterFrameTime: boolean;
  51326. /**
  51327. * Gets the perf counter used for render time capture
  51328. */
  51329. readonly renderTimeCounter: PerfCounter;
  51330. /**
  51331. * Gets the render time capture status
  51332. */
  51333. /**
  51334. * Enable or disable the render time capture
  51335. */
  51336. captureRenderTime: boolean;
  51337. /**
  51338. * Gets the perf counter used for camera render time capture
  51339. */
  51340. readonly cameraRenderTimeCounter: PerfCounter;
  51341. /**
  51342. * Gets the camera render time capture status
  51343. */
  51344. /**
  51345. * Enable or disable the camera render time capture
  51346. */
  51347. captureCameraRenderTime: boolean;
  51348. /**
  51349. * Gets the perf counter used for draw calls
  51350. */
  51351. readonly drawCallsCounter: PerfCounter;
  51352. /**
  51353. * Instantiates a new scene instrumentation.
  51354. * This class can be used to get instrumentation data from a Babylon engine
  51355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51356. * @param scene Defines the scene to instrument
  51357. */
  51358. constructor(
  51359. /**
  51360. * Defines the scene to instrument
  51361. */
  51362. scene: Scene);
  51363. /**
  51364. * Dispose and release associated resources.
  51365. */
  51366. dispose(): void;
  51367. }
  51368. }
  51369. declare module "babylonjs/Instrumentation/index" {
  51370. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51371. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51372. export * from "babylonjs/Instrumentation/timeToken";
  51373. }
  51374. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51375. /** @hidden */
  51376. export var glowMapGenerationPixelShader: {
  51377. name: string;
  51378. shader: string;
  51379. };
  51380. }
  51381. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51382. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51383. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51384. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51385. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51386. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51387. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51388. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51389. /** @hidden */
  51390. export var glowMapGenerationVertexShader: {
  51391. name: string;
  51392. shader: string;
  51393. };
  51394. }
  51395. declare module "babylonjs/Layers/effectLayer" {
  51396. import { Observable } from "babylonjs/Misc/observable";
  51397. import { Nullable } from "babylonjs/types";
  51398. import { Camera } from "babylonjs/Cameras/camera";
  51399. import { Scene } from "babylonjs/scene";
  51400. import { ISize } from "babylonjs/Maths/math.size";
  51401. import { Color4 } from "babylonjs/Maths/math.color";
  51402. import { Engine } from "babylonjs/Engines/engine";
  51403. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51404. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51405. import { Mesh } from "babylonjs/Meshes/mesh";
  51406. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51407. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51408. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51409. import { Effect } from "babylonjs/Materials/effect";
  51410. import { Material } from "babylonjs/Materials/material";
  51411. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51412. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51413. /**
  51414. * Effect layer options. This helps customizing the behaviour
  51415. * of the effect layer.
  51416. */
  51417. export interface IEffectLayerOptions {
  51418. /**
  51419. * Multiplication factor apply to the canvas size to compute the render target size
  51420. * used to generated the objects (the smaller the faster).
  51421. */
  51422. mainTextureRatio: number;
  51423. /**
  51424. * Enforces a fixed size texture to ensure effect stability across devices.
  51425. */
  51426. mainTextureFixedSize?: number;
  51427. /**
  51428. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51429. */
  51430. alphaBlendingMode: number;
  51431. /**
  51432. * The camera attached to the layer.
  51433. */
  51434. camera: Nullable<Camera>;
  51435. /**
  51436. * The rendering group to draw the layer in.
  51437. */
  51438. renderingGroupId: number;
  51439. }
  51440. /**
  51441. * The effect layer Helps adding post process effect blended with the main pass.
  51442. *
  51443. * This can be for instance use to generate glow or higlight effects on the scene.
  51444. *
  51445. * The effect layer class can not be used directly and is intented to inherited from to be
  51446. * customized per effects.
  51447. */
  51448. export abstract class EffectLayer {
  51449. private _vertexBuffers;
  51450. private _indexBuffer;
  51451. private _cachedDefines;
  51452. private _effectLayerMapGenerationEffect;
  51453. private _effectLayerOptions;
  51454. private _mergeEffect;
  51455. protected _scene: Scene;
  51456. protected _engine: Engine;
  51457. protected _maxSize: number;
  51458. protected _mainTextureDesiredSize: ISize;
  51459. protected _mainTexture: RenderTargetTexture;
  51460. protected _shouldRender: boolean;
  51461. protected _postProcesses: PostProcess[];
  51462. protected _textures: BaseTexture[];
  51463. protected _emissiveTextureAndColor: {
  51464. texture: Nullable<BaseTexture>;
  51465. color: Color4;
  51466. };
  51467. /**
  51468. * The name of the layer
  51469. */
  51470. name: string;
  51471. /**
  51472. * The clear color of the texture used to generate the glow map.
  51473. */
  51474. neutralColor: Color4;
  51475. /**
  51476. * Specifies wether the highlight layer is enabled or not.
  51477. */
  51478. isEnabled: boolean;
  51479. /**
  51480. * Gets the camera attached to the layer.
  51481. */
  51482. readonly camera: Nullable<Camera>;
  51483. /**
  51484. * Gets the rendering group id the layer should render in.
  51485. */
  51486. renderingGroupId: number;
  51487. /**
  51488. * An event triggered when the effect layer has been disposed.
  51489. */
  51490. onDisposeObservable: Observable<EffectLayer>;
  51491. /**
  51492. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51493. */
  51494. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51495. /**
  51496. * An event triggered when the generated texture is being merged in the scene.
  51497. */
  51498. onBeforeComposeObservable: Observable<EffectLayer>;
  51499. /**
  51500. * An event triggered when the generated texture has been merged in the scene.
  51501. */
  51502. onAfterComposeObservable: Observable<EffectLayer>;
  51503. /**
  51504. * An event triggered when the efffect layer changes its size.
  51505. */
  51506. onSizeChangedObservable: Observable<EffectLayer>;
  51507. /** @hidden */
  51508. static _SceneComponentInitialization: (scene: Scene) => void;
  51509. /**
  51510. * Instantiates a new effect Layer and references it in the scene.
  51511. * @param name The name of the layer
  51512. * @param scene The scene to use the layer in
  51513. */
  51514. constructor(
  51515. /** The Friendly of the effect in the scene */
  51516. name: string, scene: Scene);
  51517. /**
  51518. * Get the effect name of the layer.
  51519. * @return The effect name
  51520. */
  51521. abstract getEffectName(): string;
  51522. /**
  51523. * Checks for the readiness of the element composing the layer.
  51524. * @param subMesh the mesh to check for
  51525. * @param useInstances specify wether or not to use instances to render the mesh
  51526. * @return true if ready otherwise, false
  51527. */
  51528. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51529. /**
  51530. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51531. * @returns true if the effect requires stencil during the main canvas render pass.
  51532. */
  51533. abstract needStencil(): boolean;
  51534. /**
  51535. * Create the merge effect. This is the shader use to blit the information back
  51536. * to the main canvas at the end of the scene rendering.
  51537. * @returns The effect containing the shader used to merge the effect on the main canvas
  51538. */
  51539. protected abstract _createMergeEffect(): Effect;
  51540. /**
  51541. * Creates the render target textures and post processes used in the effect layer.
  51542. */
  51543. protected abstract _createTextureAndPostProcesses(): void;
  51544. /**
  51545. * Implementation specific of rendering the generating effect on the main canvas.
  51546. * @param effect The effect used to render through
  51547. */
  51548. protected abstract _internalRender(effect: Effect): void;
  51549. /**
  51550. * Sets the required values for both the emissive texture and and the main color.
  51551. */
  51552. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51553. /**
  51554. * Free any resources and references associated to a mesh.
  51555. * Internal use
  51556. * @param mesh The mesh to free.
  51557. */
  51558. abstract _disposeMesh(mesh: Mesh): void;
  51559. /**
  51560. * Serializes this layer (Glow or Highlight for example)
  51561. * @returns a serialized layer object
  51562. */
  51563. abstract serialize?(): any;
  51564. /**
  51565. * Initializes the effect layer with the required options.
  51566. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51567. */
  51568. protected _init(options: Partial<IEffectLayerOptions>): void;
  51569. /**
  51570. * Generates the index buffer of the full screen quad blending to the main canvas.
  51571. */
  51572. private _generateIndexBuffer;
  51573. /**
  51574. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51575. */
  51576. private _generateVertexBuffer;
  51577. /**
  51578. * Sets the main texture desired size which is the closest power of two
  51579. * of the engine canvas size.
  51580. */
  51581. private _setMainTextureSize;
  51582. /**
  51583. * Creates the main texture for the effect layer.
  51584. */
  51585. protected _createMainTexture(): void;
  51586. /**
  51587. * Adds specific effects defines.
  51588. * @param defines The defines to add specifics to.
  51589. */
  51590. protected _addCustomEffectDefines(defines: string[]): void;
  51591. /**
  51592. * Checks for the readiness of the element composing the layer.
  51593. * @param subMesh the mesh to check for
  51594. * @param useInstances specify wether or not to use instances to render the mesh
  51595. * @param emissiveTexture the associated emissive texture used to generate the glow
  51596. * @return true if ready otherwise, false
  51597. */
  51598. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51599. /**
  51600. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51601. */
  51602. render(): void;
  51603. /**
  51604. * Determine if a given mesh will be used in the current effect.
  51605. * @param mesh mesh to test
  51606. * @returns true if the mesh will be used
  51607. */
  51608. hasMesh(mesh: AbstractMesh): boolean;
  51609. /**
  51610. * Returns true if the layer contains information to display, otherwise false.
  51611. * @returns true if the glow layer should be rendered
  51612. */
  51613. shouldRender(): boolean;
  51614. /**
  51615. * Returns true if the mesh should render, otherwise false.
  51616. * @param mesh The mesh to render
  51617. * @returns true if it should render otherwise false
  51618. */
  51619. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51620. /**
  51621. * Returns true if the mesh can be rendered, otherwise false.
  51622. * @param mesh The mesh to render
  51623. * @param material The material used on the mesh
  51624. * @returns true if it can be rendered otherwise false
  51625. */
  51626. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51627. /**
  51628. * Returns true if the mesh should render, otherwise false.
  51629. * @param mesh The mesh to render
  51630. * @returns true if it should render otherwise false
  51631. */
  51632. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51633. /**
  51634. * Renders the submesh passed in parameter to the generation map.
  51635. */
  51636. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51637. /**
  51638. * Rebuild the required buffers.
  51639. * @hidden Internal use only.
  51640. */
  51641. _rebuild(): void;
  51642. /**
  51643. * Dispose only the render target textures and post process.
  51644. */
  51645. private _disposeTextureAndPostProcesses;
  51646. /**
  51647. * Dispose the highlight layer and free resources.
  51648. */
  51649. dispose(): void;
  51650. /**
  51651. * Gets the class name of the effect layer
  51652. * @returns the string with the class name of the effect layer
  51653. */
  51654. getClassName(): string;
  51655. /**
  51656. * Creates an effect layer from parsed effect layer data
  51657. * @param parsedEffectLayer defines effect layer data
  51658. * @param scene defines the current scene
  51659. * @param rootUrl defines the root URL containing the effect layer information
  51660. * @returns a parsed effect Layer
  51661. */
  51662. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51663. }
  51664. }
  51665. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51666. import { Scene } from "babylonjs/scene";
  51667. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51668. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51669. import { AbstractScene } from "babylonjs/abstractScene";
  51670. module "babylonjs/abstractScene" {
  51671. interface AbstractScene {
  51672. /**
  51673. * The list of effect layers (highlights/glow) added to the scene
  51674. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51675. * @see http://doc.babylonjs.com/how_to/glow_layer
  51676. */
  51677. effectLayers: Array<EffectLayer>;
  51678. /**
  51679. * Removes the given effect layer from this scene.
  51680. * @param toRemove defines the effect layer to remove
  51681. * @returns the index of the removed effect layer
  51682. */
  51683. removeEffectLayer(toRemove: EffectLayer): number;
  51684. /**
  51685. * Adds the given effect layer to this scene
  51686. * @param newEffectLayer defines the effect layer to add
  51687. */
  51688. addEffectLayer(newEffectLayer: EffectLayer): void;
  51689. }
  51690. }
  51691. /**
  51692. * Defines the layer scene component responsible to manage any effect layers
  51693. * in a given scene.
  51694. */
  51695. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51696. /**
  51697. * The component name helpfull to identify the component in the list of scene components.
  51698. */
  51699. readonly name: string;
  51700. /**
  51701. * The scene the component belongs to.
  51702. */
  51703. scene: Scene;
  51704. private _engine;
  51705. private _renderEffects;
  51706. private _needStencil;
  51707. private _previousStencilState;
  51708. /**
  51709. * Creates a new instance of the component for the given scene
  51710. * @param scene Defines the scene to register the component in
  51711. */
  51712. constructor(scene: Scene);
  51713. /**
  51714. * Registers the component in a given scene
  51715. */
  51716. register(): void;
  51717. /**
  51718. * Rebuilds the elements related to this component in case of
  51719. * context lost for instance.
  51720. */
  51721. rebuild(): void;
  51722. /**
  51723. * Serializes the component data to the specified json object
  51724. * @param serializationObject The object to serialize to
  51725. */
  51726. serialize(serializationObject: any): void;
  51727. /**
  51728. * Adds all the elements from the container to the scene
  51729. * @param container the container holding the elements
  51730. */
  51731. addFromContainer(container: AbstractScene): void;
  51732. /**
  51733. * Removes all the elements in the container from the scene
  51734. * @param container contains the elements to remove
  51735. * @param dispose if the removed element should be disposed (default: false)
  51736. */
  51737. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51738. /**
  51739. * Disposes the component and the associated ressources.
  51740. */
  51741. dispose(): void;
  51742. private _isReadyForMesh;
  51743. private _renderMainTexture;
  51744. private _setStencil;
  51745. private _setStencilBack;
  51746. private _draw;
  51747. private _drawCamera;
  51748. private _drawRenderingGroup;
  51749. }
  51750. }
  51751. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51752. /** @hidden */
  51753. export var glowMapMergePixelShader: {
  51754. name: string;
  51755. shader: string;
  51756. };
  51757. }
  51758. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51759. /** @hidden */
  51760. export var glowMapMergeVertexShader: {
  51761. name: string;
  51762. shader: string;
  51763. };
  51764. }
  51765. declare module "babylonjs/Layers/glowLayer" {
  51766. import { Nullable } from "babylonjs/types";
  51767. import { Camera } from "babylonjs/Cameras/camera";
  51768. import { Scene } from "babylonjs/scene";
  51769. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51771. import { Mesh } from "babylonjs/Meshes/mesh";
  51772. import { Texture } from "babylonjs/Materials/Textures/texture";
  51773. import { Effect } from "babylonjs/Materials/effect";
  51774. import { Material } from "babylonjs/Materials/material";
  51775. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51776. import { Color4 } from "babylonjs/Maths/math.color";
  51777. import "babylonjs/Shaders/glowMapMerge.fragment";
  51778. import "babylonjs/Shaders/glowMapMerge.vertex";
  51779. import "babylonjs/Layers/effectLayerSceneComponent";
  51780. module "babylonjs/abstractScene" {
  51781. interface AbstractScene {
  51782. /**
  51783. * Return a the first highlight layer of the scene with a given name.
  51784. * @param name The name of the highlight layer to look for.
  51785. * @return The highlight layer if found otherwise null.
  51786. */
  51787. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51788. }
  51789. }
  51790. /**
  51791. * Glow layer options. This helps customizing the behaviour
  51792. * of the glow layer.
  51793. */
  51794. export interface IGlowLayerOptions {
  51795. /**
  51796. * Multiplication factor apply to the canvas size to compute the render target size
  51797. * used to generated the glowing objects (the smaller the faster).
  51798. */
  51799. mainTextureRatio: number;
  51800. /**
  51801. * Enforces a fixed size texture to ensure resize independant blur.
  51802. */
  51803. mainTextureFixedSize?: number;
  51804. /**
  51805. * How big is the kernel of the blur texture.
  51806. */
  51807. blurKernelSize: number;
  51808. /**
  51809. * The camera attached to the layer.
  51810. */
  51811. camera: Nullable<Camera>;
  51812. /**
  51813. * Enable MSAA by chosing the number of samples.
  51814. */
  51815. mainTextureSamples?: number;
  51816. /**
  51817. * The rendering group to draw the layer in.
  51818. */
  51819. renderingGroupId: number;
  51820. }
  51821. /**
  51822. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51823. *
  51824. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51825. * glowy meshes to your scene.
  51826. *
  51827. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51828. */
  51829. export class GlowLayer extends EffectLayer {
  51830. /**
  51831. * Effect Name of the layer.
  51832. */
  51833. static readonly EffectName: string;
  51834. /**
  51835. * The default blur kernel size used for the glow.
  51836. */
  51837. static DefaultBlurKernelSize: number;
  51838. /**
  51839. * The default texture size ratio used for the glow.
  51840. */
  51841. static DefaultTextureRatio: number;
  51842. /**
  51843. * Sets the kernel size of the blur.
  51844. */
  51845. /**
  51846. * Gets the kernel size of the blur.
  51847. */
  51848. blurKernelSize: number;
  51849. /**
  51850. * Sets the glow intensity.
  51851. */
  51852. /**
  51853. * Gets the glow intensity.
  51854. */
  51855. intensity: number;
  51856. private _options;
  51857. private _intensity;
  51858. private _horizontalBlurPostprocess1;
  51859. private _verticalBlurPostprocess1;
  51860. private _horizontalBlurPostprocess2;
  51861. private _verticalBlurPostprocess2;
  51862. private _blurTexture1;
  51863. private _blurTexture2;
  51864. private _postProcesses1;
  51865. private _postProcesses2;
  51866. private _includedOnlyMeshes;
  51867. private _excludedMeshes;
  51868. /**
  51869. * Callback used to let the user override the color selection on a per mesh basis
  51870. */
  51871. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51872. /**
  51873. * Callback used to let the user override the texture selection on a per mesh basis
  51874. */
  51875. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51876. /**
  51877. * Instantiates a new glow Layer and references it to the scene.
  51878. * @param name The name of the layer
  51879. * @param scene The scene to use the layer in
  51880. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51881. */
  51882. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51883. /**
  51884. * Get the effect name of the layer.
  51885. * @return The effect name
  51886. */
  51887. getEffectName(): string;
  51888. /**
  51889. * Create the merge effect. This is the shader use to blit the information back
  51890. * to the main canvas at the end of the scene rendering.
  51891. */
  51892. protected _createMergeEffect(): Effect;
  51893. /**
  51894. * Creates the render target textures and post processes used in the glow layer.
  51895. */
  51896. protected _createTextureAndPostProcesses(): void;
  51897. /**
  51898. * Checks for the readiness of the element composing the layer.
  51899. * @param subMesh the mesh to check for
  51900. * @param useInstances specify wether or not to use instances to render the mesh
  51901. * @param emissiveTexture the associated emissive texture used to generate the glow
  51902. * @return true if ready otherwise, false
  51903. */
  51904. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51905. /**
  51906. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51907. */
  51908. needStencil(): boolean;
  51909. /**
  51910. * Returns true if the mesh can be rendered, otherwise false.
  51911. * @param mesh The mesh to render
  51912. * @param material The material used on the mesh
  51913. * @returns true if it can be rendered otherwise false
  51914. */
  51915. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51916. /**
  51917. * Implementation specific of rendering the generating effect on the main canvas.
  51918. * @param effect The effect used to render through
  51919. */
  51920. protected _internalRender(effect: Effect): void;
  51921. /**
  51922. * Sets the required values for both the emissive texture and and the main color.
  51923. */
  51924. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51925. /**
  51926. * Returns true if the mesh should render, otherwise false.
  51927. * @param mesh The mesh to render
  51928. * @returns true if it should render otherwise false
  51929. */
  51930. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51931. /**
  51932. * Adds specific effects defines.
  51933. * @param defines The defines to add specifics to.
  51934. */
  51935. protected _addCustomEffectDefines(defines: string[]): void;
  51936. /**
  51937. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51938. * @param mesh The mesh to exclude from the glow layer
  51939. */
  51940. addExcludedMesh(mesh: Mesh): void;
  51941. /**
  51942. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51943. * @param mesh The mesh to remove
  51944. */
  51945. removeExcludedMesh(mesh: Mesh): void;
  51946. /**
  51947. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51948. * @param mesh The mesh to include in the glow layer
  51949. */
  51950. addIncludedOnlyMesh(mesh: Mesh): void;
  51951. /**
  51952. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51953. * @param mesh The mesh to remove
  51954. */
  51955. removeIncludedOnlyMesh(mesh: Mesh): void;
  51956. /**
  51957. * Determine if a given mesh will be used in the glow layer
  51958. * @param mesh The mesh to test
  51959. * @returns true if the mesh will be highlighted by the current glow layer
  51960. */
  51961. hasMesh(mesh: AbstractMesh): boolean;
  51962. /**
  51963. * Free any resources and references associated to a mesh.
  51964. * Internal use
  51965. * @param mesh The mesh to free.
  51966. * @hidden
  51967. */
  51968. _disposeMesh(mesh: Mesh): void;
  51969. /**
  51970. * Gets the class name of the effect layer
  51971. * @returns the string with the class name of the effect layer
  51972. */
  51973. getClassName(): string;
  51974. /**
  51975. * Serializes this glow layer
  51976. * @returns a serialized glow layer object
  51977. */
  51978. serialize(): any;
  51979. /**
  51980. * Creates a Glow Layer from parsed glow layer data
  51981. * @param parsedGlowLayer defines glow layer data
  51982. * @param scene defines the current scene
  51983. * @param rootUrl defines the root URL containing the glow layer information
  51984. * @returns a parsed Glow Layer
  51985. */
  51986. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51987. }
  51988. }
  51989. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51990. /** @hidden */
  51991. export var glowBlurPostProcessPixelShader: {
  51992. name: string;
  51993. shader: string;
  51994. };
  51995. }
  51996. declare module "babylonjs/Layers/highlightLayer" {
  51997. import { Observable } from "babylonjs/Misc/observable";
  51998. import { Nullable } from "babylonjs/types";
  51999. import { Camera } from "babylonjs/Cameras/camera";
  52000. import { Scene } from "babylonjs/scene";
  52001. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52003. import { Mesh } from "babylonjs/Meshes/mesh";
  52004. import { Effect } from "babylonjs/Materials/effect";
  52005. import { Material } from "babylonjs/Materials/material";
  52006. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52007. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52008. import "babylonjs/Shaders/glowMapMerge.fragment";
  52009. import "babylonjs/Shaders/glowMapMerge.vertex";
  52010. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52011. module "babylonjs/abstractScene" {
  52012. interface AbstractScene {
  52013. /**
  52014. * Return a the first highlight layer of the scene with a given name.
  52015. * @param name The name of the highlight layer to look for.
  52016. * @return The highlight layer if found otherwise null.
  52017. */
  52018. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52019. }
  52020. }
  52021. /**
  52022. * Highlight layer options. This helps customizing the behaviour
  52023. * of the highlight layer.
  52024. */
  52025. export interface IHighlightLayerOptions {
  52026. /**
  52027. * Multiplication factor apply to the canvas size to compute the render target size
  52028. * used to generated the glowing objects (the smaller the faster).
  52029. */
  52030. mainTextureRatio: number;
  52031. /**
  52032. * Enforces a fixed size texture to ensure resize independant blur.
  52033. */
  52034. mainTextureFixedSize?: number;
  52035. /**
  52036. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52037. * of the picture to blur (the smaller the faster).
  52038. */
  52039. blurTextureSizeRatio: number;
  52040. /**
  52041. * How big in texel of the blur texture is the vertical blur.
  52042. */
  52043. blurVerticalSize: number;
  52044. /**
  52045. * How big in texel of the blur texture is the horizontal blur.
  52046. */
  52047. blurHorizontalSize: number;
  52048. /**
  52049. * Alpha blending mode used to apply the blur. Default is combine.
  52050. */
  52051. alphaBlendingMode: number;
  52052. /**
  52053. * The camera attached to the layer.
  52054. */
  52055. camera: Nullable<Camera>;
  52056. /**
  52057. * Should we display highlight as a solid stroke?
  52058. */
  52059. isStroke?: boolean;
  52060. /**
  52061. * The rendering group to draw the layer in.
  52062. */
  52063. renderingGroupId: number;
  52064. }
  52065. /**
  52066. * The highlight layer Helps adding a glow effect around a mesh.
  52067. *
  52068. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52069. * glowy meshes to your scene.
  52070. *
  52071. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52072. */
  52073. export class HighlightLayer extends EffectLayer {
  52074. name: string;
  52075. /**
  52076. * Effect Name of the highlight layer.
  52077. */
  52078. static readonly EffectName: string;
  52079. /**
  52080. * The neutral color used during the preparation of the glow effect.
  52081. * This is black by default as the blend operation is a blend operation.
  52082. */
  52083. static NeutralColor: Color4;
  52084. /**
  52085. * Stencil value used for glowing meshes.
  52086. */
  52087. static GlowingMeshStencilReference: number;
  52088. /**
  52089. * Stencil value used for the other meshes in the scene.
  52090. */
  52091. static NormalMeshStencilReference: number;
  52092. /**
  52093. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52094. */
  52095. innerGlow: boolean;
  52096. /**
  52097. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52098. */
  52099. outerGlow: boolean;
  52100. /**
  52101. * Specifies the horizontal size of the blur.
  52102. */
  52103. /**
  52104. * Gets the horizontal size of the blur.
  52105. */
  52106. blurHorizontalSize: number;
  52107. /**
  52108. * Specifies the vertical size of the blur.
  52109. */
  52110. /**
  52111. * Gets the vertical size of the blur.
  52112. */
  52113. blurVerticalSize: number;
  52114. /**
  52115. * An event triggered when the highlight layer is being blurred.
  52116. */
  52117. onBeforeBlurObservable: Observable<HighlightLayer>;
  52118. /**
  52119. * An event triggered when the highlight layer has been blurred.
  52120. */
  52121. onAfterBlurObservable: Observable<HighlightLayer>;
  52122. private _instanceGlowingMeshStencilReference;
  52123. private _options;
  52124. private _downSamplePostprocess;
  52125. private _horizontalBlurPostprocess;
  52126. private _verticalBlurPostprocess;
  52127. private _blurTexture;
  52128. private _meshes;
  52129. private _excludedMeshes;
  52130. /**
  52131. * Instantiates a new highlight Layer and references it to the scene..
  52132. * @param name The name of the layer
  52133. * @param scene The scene to use the layer in
  52134. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52135. */
  52136. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52137. /**
  52138. * Get the effect name of the layer.
  52139. * @return The effect name
  52140. */
  52141. getEffectName(): string;
  52142. /**
  52143. * Create the merge effect. This is the shader use to blit the information back
  52144. * to the main canvas at the end of the scene rendering.
  52145. */
  52146. protected _createMergeEffect(): Effect;
  52147. /**
  52148. * Creates the render target textures and post processes used in the highlight layer.
  52149. */
  52150. protected _createTextureAndPostProcesses(): void;
  52151. /**
  52152. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52153. */
  52154. needStencil(): boolean;
  52155. /**
  52156. * Checks for the readiness of the element composing the layer.
  52157. * @param subMesh the mesh to check for
  52158. * @param useInstances specify wether or not to use instances to render the mesh
  52159. * @param emissiveTexture the associated emissive texture used to generate the glow
  52160. * @return true if ready otherwise, false
  52161. */
  52162. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52163. /**
  52164. * Implementation specific of rendering the generating effect on the main canvas.
  52165. * @param effect The effect used to render through
  52166. */
  52167. protected _internalRender(effect: Effect): void;
  52168. /**
  52169. * Returns true if the layer contains information to display, otherwise false.
  52170. */
  52171. shouldRender(): boolean;
  52172. /**
  52173. * Returns true if the mesh should render, otherwise false.
  52174. * @param mesh The mesh to render
  52175. * @returns true if it should render otherwise false
  52176. */
  52177. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52178. /**
  52179. * Sets the required values for both the emissive texture and and the main color.
  52180. */
  52181. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52182. /**
  52183. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52184. * @param mesh The mesh to exclude from the highlight layer
  52185. */
  52186. addExcludedMesh(mesh: Mesh): void;
  52187. /**
  52188. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52189. * @param mesh The mesh to highlight
  52190. */
  52191. removeExcludedMesh(mesh: Mesh): void;
  52192. /**
  52193. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52194. * @param mesh mesh to test
  52195. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52196. */
  52197. hasMesh(mesh: AbstractMesh): boolean;
  52198. /**
  52199. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52200. * @param mesh The mesh to highlight
  52201. * @param color The color of the highlight
  52202. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52203. */
  52204. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52205. /**
  52206. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52207. * @param mesh The mesh to highlight
  52208. */
  52209. removeMesh(mesh: Mesh): void;
  52210. /**
  52211. * Force the stencil to the normal expected value for none glowing parts
  52212. */
  52213. private _defaultStencilReference;
  52214. /**
  52215. * Free any resources and references associated to a mesh.
  52216. * Internal use
  52217. * @param mesh The mesh to free.
  52218. * @hidden
  52219. */
  52220. _disposeMesh(mesh: Mesh): void;
  52221. /**
  52222. * Dispose the highlight layer and free resources.
  52223. */
  52224. dispose(): void;
  52225. /**
  52226. * Gets the class name of the effect layer
  52227. * @returns the string with the class name of the effect layer
  52228. */
  52229. getClassName(): string;
  52230. /**
  52231. * Serializes this Highlight layer
  52232. * @returns a serialized Highlight layer object
  52233. */
  52234. serialize(): any;
  52235. /**
  52236. * Creates a Highlight layer from parsed Highlight layer data
  52237. * @param parsedHightlightLayer defines the Highlight layer data
  52238. * @param scene defines the current scene
  52239. * @param rootUrl defines the root URL containing the Highlight layer information
  52240. * @returns a parsed Highlight layer
  52241. */
  52242. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52243. }
  52244. }
  52245. declare module "babylonjs/Layers/layerSceneComponent" {
  52246. import { Scene } from "babylonjs/scene";
  52247. import { ISceneComponent } from "babylonjs/sceneComponent";
  52248. import { Layer } from "babylonjs/Layers/layer";
  52249. import { AbstractScene } from "babylonjs/abstractScene";
  52250. module "babylonjs/abstractScene" {
  52251. interface AbstractScene {
  52252. /**
  52253. * The list of layers (background and foreground) of the scene
  52254. */
  52255. layers: Array<Layer>;
  52256. }
  52257. }
  52258. /**
  52259. * Defines the layer scene component responsible to manage any layers
  52260. * in a given scene.
  52261. */
  52262. export class LayerSceneComponent implements ISceneComponent {
  52263. /**
  52264. * The component name helpfull to identify the component in the list of scene components.
  52265. */
  52266. readonly name: string;
  52267. /**
  52268. * The scene the component belongs to.
  52269. */
  52270. scene: Scene;
  52271. private _engine;
  52272. /**
  52273. * Creates a new instance of the component for the given scene
  52274. * @param scene Defines the scene to register the component in
  52275. */
  52276. constructor(scene: Scene);
  52277. /**
  52278. * Registers the component in a given scene
  52279. */
  52280. register(): void;
  52281. /**
  52282. * Rebuilds the elements related to this component in case of
  52283. * context lost for instance.
  52284. */
  52285. rebuild(): void;
  52286. /**
  52287. * Disposes the component and the associated ressources.
  52288. */
  52289. dispose(): void;
  52290. private _draw;
  52291. private _drawCameraPredicate;
  52292. private _drawCameraBackground;
  52293. private _drawCameraForeground;
  52294. private _drawRenderTargetPredicate;
  52295. private _drawRenderTargetBackground;
  52296. private _drawRenderTargetForeground;
  52297. /**
  52298. * Adds all the elements from the container to the scene
  52299. * @param container the container holding the elements
  52300. */
  52301. addFromContainer(container: AbstractScene): void;
  52302. /**
  52303. * Removes all the elements in the container from the scene
  52304. * @param container contains the elements to remove
  52305. * @param dispose if the removed element should be disposed (default: false)
  52306. */
  52307. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52308. }
  52309. }
  52310. declare module "babylonjs/Shaders/layer.fragment" {
  52311. /** @hidden */
  52312. export var layerPixelShader: {
  52313. name: string;
  52314. shader: string;
  52315. };
  52316. }
  52317. declare module "babylonjs/Shaders/layer.vertex" {
  52318. /** @hidden */
  52319. export var layerVertexShader: {
  52320. name: string;
  52321. shader: string;
  52322. };
  52323. }
  52324. declare module "babylonjs/Layers/layer" {
  52325. import { Observable } from "babylonjs/Misc/observable";
  52326. import { Nullable } from "babylonjs/types";
  52327. import { Scene } from "babylonjs/scene";
  52328. import { Vector2 } from "babylonjs/Maths/math.vector";
  52329. import { Color4 } from "babylonjs/Maths/math.color";
  52330. import { Texture } from "babylonjs/Materials/Textures/texture";
  52331. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52332. import "babylonjs/Shaders/layer.fragment";
  52333. import "babylonjs/Shaders/layer.vertex";
  52334. /**
  52335. * This represents a full screen 2d layer.
  52336. * This can be useful to display a picture in the background of your scene for instance.
  52337. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52338. */
  52339. export class Layer {
  52340. /**
  52341. * Define the name of the layer.
  52342. */
  52343. name: string;
  52344. /**
  52345. * Define the texture the layer should display.
  52346. */
  52347. texture: Nullable<Texture>;
  52348. /**
  52349. * Is the layer in background or foreground.
  52350. */
  52351. isBackground: boolean;
  52352. /**
  52353. * Define the color of the layer (instead of texture).
  52354. */
  52355. color: Color4;
  52356. /**
  52357. * Define the scale of the layer in order to zoom in out of the texture.
  52358. */
  52359. scale: Vector2;
  52360. /**
  52361. * Define an offset for the layer in order to shift the texture.
  52362. */
  52363. offset: Vector2;
  52364. /**
  52365. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52366. */
  52367. alphaBlendingMode: number;
  52368. /**
  52369. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52370. * Alpha test will not mix with the background color in case of transparency.
  52371. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52372. */
  52373. alphaTest: boolean;
  52374. /**
  52375. * Define a mask to restrict the layer to only some of the scene cameras.
  52376. */
  52377. layerMask: number;
  52378. /**
  52379. * Define the list of render target the layer is visible into.
  52380. */
  52381. renderTargetTextures: RenderTargetTexture[];
  52382. /**
  52383. * Define if the layer is only used in renderTarget or if it also
  52384. * renders in the main frame buffer of the canvas.
  52385. */
  52386. renderOnlyInRenderTargetTextures: boolean;
  52387. private _scene;
  52388. private _vertexBuffers;
  52389. private _indexBuffer;
  52390. private _effect;
  52391. private _alphaTestEffect;
  52392. /**
  52393. * An event triggered when the layer is disposed.
  52394. */
  52395. onDisposeObservable: Observable<Layer>;
  52396. private _onDisposeObserver;
  52397. /**
  52398. * Back compatibility with callback before the onDisposeObservable existed.
  52399. * The set callback will be triggered when the layer has been disposed.
  52400. */
  52401. onDispose: () => void;
  52402. /**
  52403. * An event triggered before rendering the scene
  52404. */
  52405. onBeforeRenderObservable: Observable<Layer>;
  52406. private _onBeforeRenderObserver;
  52407. /**
  52408. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52409. * The set callback will be triggered just before rendering the layer.
  52410. */
  52411. onBeforeRender: () => void;
  52412. /**
  52413. * An event triggered after rendering the scene
  52414. */
  52415. onAfterRenderObservable: Observable<Layer>;
  52416. private _onAfterRenderObserver;
  52417. /**
  52418. * Back compatibility with callback before the onAfterRenderObservable existed.
  52419. * The set callback will be triggered just after rendering the layer.
  52420. */
  52421. onAfterRender: () => void;
  52422. /**
  52423. * Instantiates a new layer.
  52424. * This represents a full screen 2d layer.
  52425. * This can be useful to display a picture in the background of your scene for instance.
  52426. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52427. * @param name Define the name of the layer in the scene
  52428. * @param imgUrl Define the url of the texture to display in the layer
  52429. * @param scene Define the scene the layer belongs to
  52430. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52431. * @param color Defines a color for the layer
  52432. */
  52433. constructor(
  52434. /**
  52435. * Define the name of the layer.
  52436. */
  52437. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52438. private _createIndexBuffer;
  52439. /** @hidden */
  52440. _rebuild(): void;
  52441. /**
  52442. * Renders the layer in the scene.
  52443. */
  52444. render(): void;
  52445. /**
  52446. * Disposes and releases the associated ressources.
  52447. */
  52448. dispose(): void;
  52449. }
  52450. }
  52451. declare module "babylonjs/Layers/index" {
  52452. export * from "babylonjs/Layers/effectLayer";
  52453. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52454. export * from "babylonjs/Layers/glowLayer";
  52455. export * from "babylonjs/Layers/highlightLayer";
  52456. export * from "babylonjs/Layers/layer";
  52457. export * from "babylonjs/Layers/layerSceneComponent";
  52458. }
  52459. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52460. /** @hidden */
  52461. export var lensFlarePixelShader: {
  52462. name: string;
  52463. shader: string;
  52464. };
  52465. }
  52466. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52467. /** @hidden */
  52468. export var lensFlareVertexShader: {
  52469. name: string;
  52470. shader: string;
  52471. };
  52472. }
  52473. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52474. import { Scene } from "babylonjs/scene";
  52475. import { Vector3 } from "babylonjs/Maths/math.vector";
  52476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52477. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52478. import "babylonjs/Shaders/lensFlare.fragment";
  52479. import "babylonjs/Shaders/lensFlare.vertex";
  52480. import { Viewport } from "babylonjs/Maths/math.viewport";
  52481. /**
  52482. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52483. * It is usually composed of several `lensFlare`.
  52484. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52485. */
  52486. export class LensFlareSystem {
  52487. /**
  52488. * Define the name of the lens flare system
  52489. */
  52490. name: string;
  52491. /**
  52492. * List of lens flares used in this system.
  52493. */
  52494. lensFlares: LensFlare[];
  52495. /**
  52496. * Define a limit from the border the lens flare can be visible.
  52497. */
  52498. borderLimit: number;
  52499. /**
  52500. * Define a viewport border we do not want to see the lens flare in.
  52501. */
  52502. viewportBorder: number;
  52503. /**
  52504. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52505. */
  52506. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52507. /**
  52508. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52509. */
  52510. layerMask: number;
  52511. /**
  52512. * Define the id of the lens flare system in the scene.
  52513. * (equal to name by default)
  52514. */
  52515. id: string;
  52516. private _scene;
  52517. private _emitter;
  52518. private _vertexBuffers;
  52519. private _indexBuffer;
  52520. private _effect;
  52521. private _positionX;
  52522. private _positionY;
  52523. private _isEnabled;
  52524. /** @hidden */
  52525. static _SceneComponentInitialization: (scene: Scene) => void;
  52526. /**
  52527. * Instantiates a lens flare system.
  52528. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52529. * It is usually composed of several `lensFlare`.
  52530. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52531. * @param name Define the name of the lens flare system in the scene
  52532. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52533. * @param scene Define the scene the lens flare system belongs to
  52534. */
  52535. constructor(
  52536. /**
  52537. * Define the name of the lens flare system
  52538. */
  52539. name: string, emitter: any, scene: Scene);
  52540. /**
  52541. * Define if the lens flare system is enabled.
  52542. */
  52543. isEnabled: boolean;
  52544. /**
  52545. * Get the scene the effects belongs to.
  52546. * @returns the scene holding the lens flare system
  52547. */
  52548. getScene(): Scene;
  52549. /**
  52550. * Get the emitter of the lens flare system.
  52551. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52552. * @returns the emitter of the lens flare system
  52553. */
  52554. getEmitter(): any;
  52555. /**
  52556. * Set the emitter of the lens flare system.
  52557. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52558. * @param newEmitter Define the new emitter of the system
  52559. */
  52560. setEmitter(newEmitter: any): void;
  52561. /**
  52562. * Get the lens flare system emitter position.
  52563. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52564. * @returns the position
  52565. */
  52566. getEmitterPosition(): Vector3;
  52567. /**
  52568. * @hidden
  52569. */
  52570. computeEffectivePosition(globalViewport: Viewport): boolean;
  52571. /** @hidden */
  52572. _isVisible(): boolean;
  52573. /**
  52574. * @hidden
  52575. */
  52576. render(): boolean;
  52577. /**
  52578. * Dispose and release the lens flare with its associated resources.
  52579. */
  52580. dispose(): void;
  52581. /**
  52582. * Parse a lens flare system from a JSON repressentation
  52583. * @param parsedLensFlareSystem Define the JSON to parse
  52584. * @param scene Define the scene the parsed system should be instantiated in
  52585. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52586. * @returns the parsed system
  52587. */
  52588. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52589. /**
  52590. * Serialize the current Lens Flare System into a JSON representation.
  52591. * @returns the serialized JSON
  52592. */
  52593. serialize(): any;
  52594. }
  52595. }
  52596. declare module "babylonjs/LensFlares/lensFlare" {
  52597. import { Nullable } from "babylonjs/types";
  52598. import { Color3 } from "babylonjs/Maths/math.color";
  52599. import { Texture } from "babylonjs/Materials/Textures/texture";
  52600. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52601. /**
  52602. * This represents one of the lens effect in a `lensFlareSystem`.
  52603. * It controls one of the indiviual texture used in the effect.
  52604. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52605. */
  52606. export class LensFlare {
  52607. /**
  52608. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52609. */
  52610. size: number;
  52611. /**
  52612. * 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.
  52613. */
  52614. position: number;
  52615. /**
  52616. * Define the lens color.
  52617. */
  52618. color: Color3;
  52619. /**
  52620. * Define the lens texture.
  52621. */
  52622. texture: Nullable<Texture>;
  52623. /**
  52624. * Define the alpha mode to render this particular lens.
  52625. */
  52626. alphaMode: number;
  52627. private _system;
  52628. /**
  52629. * Creates a new Lens Flare.
  52630. * This represents one of the lens effect in a `lensFlareSystem`.
  52631. * It controls one of the indiviual texture used in the effect.
  52632. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52633. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52634. * @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.
  52635. * @param color Define the lens color
  52636. * @param imgUrl Define the lens texture url
  52637. * @param system Define the `lensFlareSystem` this flare is part of
  52638. * @returns The newly created Lens Flare
  52639. */
  52640. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52641. /**
  52642. * Instantiates a new Lens Flare.
  52643. * This represents one of the lens effect in a `lensFlareSystem`.
  52644. * It controls one of the indiviual texture used in the effect.
  52645. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52646. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52647. * @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.
  52648. * @param color Define the lens color
  52649. * @param imgUrl Define the lens texture url
  52650. * @param system Define the `lensFlareSystem` this flare is part of
  52651. */
  52652. constructor(
  52653. /**
  52654. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52655. */
  52656. size: number,
  52657. /**
  52658. * 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.
  52659. */
  52660. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52661. /**
  52662. * Dispose and release the lens flare with its associated resources.
  52663. */
  52664. dispose(): void;
  52665. }
  52666. }
  52667. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52668. import { Nullable } from "babylonjs/types";
  52669. import { Scene } from "babylonjs/scene";
  52670. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52671. import { AbstractScene } from "babylonjs/abstractScene";
  52672. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52673. module "babylonjs/abstractScene" {
  52674. interface AbstractScene {
  52675. /**
  52676. * The list of lens flare system added to the scene
  52677. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52678. */
  52679. lensFlareSystems: Array<LensFlareSystem>;
  52680. /**
  52681. * Removes the given lens flare system from this scene.
  52682. * @param toRemove The lens flare system to remove
  52683. * @returns The index of the removed lens flare system
  52684. */
  52685. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52686. /**
  52687. * Adds the given lens flare system to this scene
  52688. * @param newLensFlareSystem The lens flare system to add
  52689. */
  52690. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52691. /**
  52692. * Gets a lens flare system using its name
  52693. * @param name defines the name to look for
  52694. * @returns the lens flare system or null if not found
  52695. */
  52696. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52697. /**
  52698. * Gets a lens flare system using its id
  52699. * @param id defines the id to look for
  52700. * @returns the lens flare system or null if not found
  52701. */
  52702. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52703. }
  52704. }
  52705. /**
  52706. * Defines the lens flare scene component responsible to manage any lens flares
  52707. * in a given scene.
  52708. */
  52709. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52710. /**
  52711. * The component name helpfull to identify the component in the list of scene components.
  52712. */
  52713. readonly name: string;
  52714. /**
  52715. * The scene the component belongs to.
  52716. */
  52717. scene: Scene;
  52718. /**
  52719. * Creates a new instance of the component for the given scene
  52720. * @param scene Defines the scene to register the component in
  52721. */
  52722. constructor(scene: Scene);
  52723. /**
  52724. * Registers the component in a given scene
  52725. */
  52726. register(): void;
  52727. /**
  52728. * Rebuilds the elements related to this component in case of
  52729. * context lost for instance.
  52730. */
  52731. rebuild(): void;
  52732. /**
  52733. * Adds all the elements from the container to the scene
  52734. * @param container the container holding the elements
  52735. */
  52736. addFromContainer(container: AbstractScene): void;
  52737. /**
  52738. * Removes all the elements in the container from the scene
  52739. * @param container contains the elements to remove
  52740. * @param dispose if the removed element should be disposed (default: false)
  52741. */
  52742. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52743. /**
  52744. * Serializes the component data to the specified json object
  52745. * @param serializationObject The object to serialize to
  52746. */
  52747. serialize(serializationObject: any): void;
  52748. /**
  52749. * Disposes the component and the associated ressources.
  52750. */
  52751. dispose(): void;
  52752. private _draw;
  52753. }
  52754. }
  52755. declare module "babylonjs/LensFlares/index" {
  52756. export * from "babylonjs/LensFlares/lensFlare";
  52757. export * from "babylonjs/LensFlares/lensFlareSystem";
  52758. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52759. }
  52760. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52761. import { Scene } from "babylonjs/scene";
  52762. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52763. import { AbstractScene } from "babylonjs/abstractScene";
  52764. /**
  52765. * Defines the shadow generator component responsible to manage any shadow generators
  52766. * in a given scene.
  52767. */
  52768. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52769. /**
  52770. * The component name helpfull to identify the component in the list of scene components.
  52771. */
  52772. readonly name: string;
  52773. /**
  52774. * The scene the component belongs to.
  52775. */
  52776. scene: Scene;
  52777. /**
  52778. * Creates a new instance of the component for the given scene
  52779. * @param scene Defines the scene to register the component in
  52780. */
  52781. constructor(scene: Scene);
  52782. /**
  52783. * Registers the component in a given scene
  52784. */
  52785. register(): void;
  52786. /**
  52787. * Rebuilds the elements related to this component in case of
  52788. * context lost for instance.
  52789. */
  52790. rebuild(): void;
  52791. /**
  52792. * Serializes the component data to the specified json object
  52793. * @param serializationObject The object to serialize to
  52794. */
  52795. serialize(serializationObject: any): void;
  52796. /**
  52797. * Adds all the elements from the container to the scene
  52798. * @param container the container holding the elements
  52799. */
  52800. addFromContainer(container: AbstractScene): void;
  52801. /**
  52802. * Removes all the elements in the container from the scene
  52803. * @param container contains the elements to remove
  52804. * @param dispose if the removed element should be disposed (default: false)
  52805. */
  52806. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52807. /**
  52808. * Rebuilds the elements related to this component in case of
  52809. * context lost for instance.
  52810. */
  52811. dispose(): void;
  52812. private _gatherRenderTargets;
  52813. }
  52814. }
  52815. declare module "babylonjs/Lights/Shadows/index" {
  52816. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52817. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52818. }
  52819. declare module "babylonjs/Lights/pointLight" {
  52820. import { Scene } from "babylonjs/scene";
  52821. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52823. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52824. import { Effect } from "babylonjs/Materials/effect";
  52825. /**
  52826. * A point light is a light defined by an unique point in world space.
  52827. * The light is emitted in every direction from this point.
  52828. * A good example of a point light is a standard light bulb.
  52829. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52830. */
  52831. export class PointLight extends ShadowLight {
  52832. private _shadowAngle;
  52833. /**
  52834. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52835. * This specifies what angle the shadow will use to be created.
  52836. *
  52837. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52838. */
  52839. /**
  52840. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52841. * This specifies what angle the shadow will use to be created.
  52842. *
  52843. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52844. */
  52845. shadowAngle: number;
  52846. /**
  52847. * Gets the direction if it has been set.
  52848. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52849. */
  52850. /**
  52851. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52852. */
  52853. direction: Vector3;
  52854. /**
  52855. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52856. * A PointLight emits the light in every direction.
  52857. * It can cast shadows.
  52858. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52859. * ```javascript
  52860. * var pointLight = new PointLight("pl", camera.position, scene);
  52861. * ```
  52862. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52863. * @param name The light friendly name
  52864. * @param position The position of the point light in the scene
  52865. * @param scene The scene the lights belongs to
  52866. */
  52867. constructor(name: string, position: Vector3, scene: Scene);
  52868. /**
  52869. * Returns the string "PointLight"
  52870. * @returns the class name
  52871. */
  52872. getClassName(): string;
  52873. /**
  52874. * Returns the integer 0.
  52875. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52876. */
  52877. getTypeID(): number;
  52878. /**
  52879. * Specifies wether or not the shadowmap should be a cube texture.
  52880. * @returns true if the shadowmap needs to be a cube texture.
  52881. */
  52882. needCube(): boolean;
  52883. /**
  52884. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52885. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52886. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52887. */
  52888. getShadowDirection(faceIndex?: number): Vector3;
  52889. /**
  52890. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52891. * - fov = PI / 2
  52892. * - aspect ratio : 1.0
  52893. * - z-near and far equal to the active camera minZ and maxZ.
  52894. * Returns the PointLight.
  52895. */
  52896. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52897. protected _buildUniformLayout(): void;
  52898. /**
  52899. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52900. * @param effect The effect to update
  52901. * @param lightIndex The index of the light in the effect to update
  52902. * @returns The point light
  52903. */
  52904. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52905. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52906. /**
  52907. * Prepares the list of defines specific to the light type.
  52908. * @param defines the list of defines
  52909. * @param lightIndex defines the index of the light for the effect
  52910. */
  52911. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52912. }
  52913. }
  52914. declare module "babylonjs/Lights/index" {
  52915. export * from "babylonjs/Lights/light";
  52916. export * from "babylonjs/Lights/shadowLight";
  52917. export * from "babylonjs/Lights/Shadows/index";
  52918. export * from "babylonjs/Lights/directionalLight";
  52919. export * from "babylonjs/Lights/hemisphericLight";
  52920. export * from "babylonjs/Lights/pointLight";
  52921. export * from "babylonjs/Lights/spotLight";
  52922. }
  52923. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52924. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52925. /**
  52926. * Header information of HDR texture files.
  52927. */
  52928. export interface HDRInfo {
  52929. /**
  52930. * The height of the texture in pixels.
  52931. */
  52932. height: number;
  52933. /**
  52934. * The width of the texture in pixels.
  52935. */
  52936. width: number;
  52937. /**
  52938. * The index of the beginning of the data in the binary file.
  52939. */
  52940. dataPosition: number;
  52941. }
  52942. /**
  52943. * This groups tools to convert HDR texture to native colors array.
  52944. */
  52945. export class HDRTools {
  52946. private static Ldexp;
  52947. private static Rgbe2float;
  52948. private static readStringLine;
  52949. /**
  52950. * Reads header information from an RGBE texture stored in a native array.
  52951. * More information on this format are available here:
  52952. * https://en.wikipedia.org/wiki/RGBE_image_format
  52953. *
  52954. * @param uint8array The binary file stored in native array.
  52955. * @return The header information.
  52956. */
  52957. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52958. /**
  52959. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52960. * This RGBE texture needs to store the information as a panorama.
  52961. *
  52962. * More information on this format are available here:
  52963. * https://en.wikipedia.org/wiki/RGBE_image_format
  52964. *
  52965. * @param buffer The binary file stored in an array buffer.
  52966. * @param size The expected size of the extracted cubemap.
  52967. * @return The Cube Map information.
  52968. */
  52969. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52970. /**
  52971. * Returns the pixels data extracted from an RGBE texture.
  52972. * This pixels will be stored left to right up to down in the R G B order in one array.
  52973. *
  52974. * More information on this format are available here:
  52975. * https://en.wikipedia.org/wiki/RGBE_image_format
  52976. *
  52977. * @param uint8array The binary file stored in an array buffer.
  52978. * @param hdrInfo The header information of the file.
  52979. * @return The pixels data in RGB right to left up to down order.
  52980. */
  52981. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52982. private static RGBE_ReadPixels_RLE;
  52983. }
  52984. }
  52985. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52986. import { Nullable } from "babylonjs/types";
  52987. import { Scene } from "babylonjs/scene";
  52988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52989. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52990. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52991. /**
  52992. * This represents a texture coming from an HDR input.
  52993. *
  52994. * The only supported format is currently panorama picture stored in RGBE format.
  52995. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52996. */
  52997. export class HDRCubeTexture extends BaseTexture {
  52998. private static _facesMapping;
  52999. private _generateHarmonics;
  53000. private _noMipmap;
  53001. private _textureMatrix;
  53002. private _size;
  53003. private _onLoad;
  53004. private _onError;
  53005. /**
  53006. * The texture URL.
  53007. */
  53008. url: string;
  53009. /**
  53010. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53011. */
  53012. coordinatesMode: number;
  53013. protected _isBlocking: boolean;
  53014. /**
  53015. * Sets wether or not the texture is blocking during loading.
  53016. */
  53017. /**
  53018. * Gets wether or not the texture is blocking during loading.
  53019. */
  53020. isBlocking: boolean;
  53021. protected _rotationY: number;
  53022. /**
  53023. * Sets texture matrix rotation angle around Y axis in radians.
  53024. */
  53025. /**
  53026. * Gets texture matrix rotation angle around Y axis radians.
  53027. */
  53028. rotationY: number;
  53029. /**
  53030. * Gets or sets the center of the bounding box associated with the cube texture
  53031. * It must define where the camera used to render the texture was set
  53032. */
  53033. boundingBoxPosition: Vector3;
  53034. private _boundingBoxSize;
  53035. /**
  53036. * Gets or sets the size of the bounding box associated with the cube texture
  53037. * When defined, the cubemap will switch to local mode
  53038. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53039. * @example https://www.babylonjs-playground.com/#RNASML
  53040. */
  53041. boundingBoxSize: Vector3;
  53042. /**
  53043. * Instantiates an HDRTexture from the following parameters.
  53044. *
  53045. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53046. * @param scene The scene the texture will be used in
  53047. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53048. * @param noMipmap Forces to not generate the mipmap if true
  53049. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53050. * @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)
  53051. * @param reserved Reserved flag for internal use.
  53052. */
  53053. 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>);
  53054. /**
  53055. * Get the current class name of the texture useful for serialization or dynamic coding.
  53056. * @returns "HDRCubeTexture"
  53057. */
  53058. getClassName(): string;
  53059. /**
  53060. * Occurs when the file is raw .hdr file.
  53061. */
  53062. private loadTexture;
  53063. clone(): HDRCubeTexture;
  53064. delayLoad(): void;
  53065. /**
  53066. * Get the texture reflection matrix used to rotate/transform the reflection.
  53067. * @returns the reflection matrix
  53068. */
  53069. getReflectionTextureMatrix(): Matrix;
  53070. /**
  53071. * Set the texture reflection matrix used to rotate/transform the reflection.
  53072. * @param value Define the reflection matrix to set
  53073. */
  53074. setReflectionTextureMatrix(value: Matrix): void;
  53075. /**
  53076. * Parses a JSON representation of an HDR Texture in order to create the texture
  53077. * @param parsedTexture Define the JSON representation
  53078. * @param scene Define the scene the texture should be created in
  53079. * @param rootUrl Define the root url in case we need to load relative dependencies
  53080. * @returns the newly created texture after parsing
  53081. */
  53082. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53083. serialize(): any;
  53084. }
  53085. }
  53086. declare module "babylonjs/Physics/physicsEngine" {
  53087. import { Nullable } from "babylonjs/types";
  53088. import { Vector3 } from "babylonjs/Maths/math.vector";
  53089. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53090. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53091. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53092. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53093. /**
  53094. * Class used to control physics engine
  53095. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53096. */
  53097. export class PhysicsEngine implements IPhysicsEngine {
  53098. private _physicsPlugin;
  53099. /**
  53100. * Global value used to control the smallest number supported by the simulation
  53101. */
  53102. static Epsilon: number;
  53103. private _impostors;
  53104. private _joints;
  53105. /**
  53106. * Gets the gravity vector used by the simulation
  53107. */
  53108. gravity: Vector3;
  53109. /**
  53110. * Factory used to create the default physics plugin.
  53111. * @returns The default physics plugin
  53112. */
  53113. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53114. /**
  53115. * Creates a new Physics Engine
  53116. * @param gravity defines the gravity vector used by the simulation
  53117. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53118. */
  53119. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53120. /**
  53121. * Sets the gravity vector used by the simulation
  53122. * @param gravity defines the gravity vector to use
  53123. */
  53124. setGravity(gravity: Vector3): void;
  53125. /**
  53126. * Set the time step of the physics engine.
  53127. * Default is 1/60.
  53128. * To slow it down, enter 1/600 for example.
  53129. * To speed it up, 1/30
  53130. * @param newTimeStep defines the new timestep to apply to this world.
  53131. */
  53132. setTimeStep(newTimeStep?: number): void;
  53133. /**
  53134. * Get the time step of the physics engine.
  53135. * @returns the current time step
  53136. */
  53137. getTimeStep(): number;
  53138. /**
  53139. * Release all resources
  53140. */
  53141. dispose(): void;
  53142. /**
  53143. * Gets the name of the current physics plugin
  53144. * @returns the name of the plugin
  53145. */
  53146. getPhysicsPluginName(): string;
  53147. /**
  53148. * Adding a new impostor for the impostor tracking.
  53149. * This will be done by the impostor itself.
  53150. * @param impostor the impostor to add
  53151. */
  53152. addImpostor(impostor: PhysicsImpostor): void;
  53153. /**
  53154. * Remove an impostor from the engine.
  53155. * This impostor and its mesh will not longer be updated by the physics engine.
  53156. * @param impostor the impostor to remove
  53157. */
  53158. removeImpostor(impostor: PhysicsImpostor): void;
  53159. /**
  53160. * Add a joint to the physics engine
  53161. * @param mainImpostor defines the main impostor to which the joint is added.
  53162. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53163. * @param joint defines the joint that will connect both impostors.
  53164. */
  53165. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53166. /**
  53167. * Removes a joint from the simulation
  53168. * @param mainImpostor defines the impostor used with the joint
  53169. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53170. * @param joint defines the joint to remove
  53171. */
  53172. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53173. /**
  53174. * Called by the scene. No need to call it.
  53175. * @param delta defines the timespam between frames
  53176. */
  53177. _step(delta: number): void;
  53178. /**
  53179. * Gets the current plugin used to run the simulation
  53180. * @returns current plugin
  53181. */
  53182. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53183. /**
  53184. * Gets the list of physic impostors
  53185. * @returns an array of PhysicsImpostor
  53186. */
  53187. getImpostors(): Array<PhysicsImpostor>;
  53188. /**
  53189. * Gets the impostor for a physics enabled object
  53190. * @param object defines the object impersonated by the impostor
  53191. * @returns the PhysicsImpostor or null if not found
  53192. */
  53193. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53194. /**
  53195. * Gets the impostor for a physics body object
  53196. * @param body defines physics body used by the impostor
  53197. * @returns the PhysicsImpostor or null if not found
  53198. */
  53199. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53200. /**
  53201. * Does a raycast in the physics world
  53202. * @param from when should the ray start?
  53203. * @param to when should the ray end?
  53204. * @returns PhysicsRaycastResult
  53205. */
  53206. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53207. }
  53208. }
  53209. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53210. import { Nullable } from "babylonjs/types";
  53211. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53213. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53214. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53215. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53216. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53217. /** @hidden */
  53218. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53219. private _useDeltaForWorldStep;
  53220. world: any;
  53221. name: string;
  53222. private _physicsMaterials;
  53223. private _fixedTimeStep;
  53224. private _cannonRaycastResult;
  53225. private _raycastResult;
  53226. private _physicsBodysToRemoveAfterStep;
  53227. BJSCANNON: any;
  53228. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53229. setGravity(gravity: Vector3): void;
  53230. setTimeStep(timeStep: number): void;
  53231. getTimeStep(): number;
  53232. executeStep(delta: number): void;
  53233. private _removeMarkedPhysicsBodiesFromWorld;
  53234. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53235. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53236. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53237. private _processChildMeshes;
  53238. removePhysicsBody(impostor: PhysicsImpostor): void;
  53239. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53240. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53241. private _addMaterial;
  53242. private _checkWithEpsilon;
  53243. private _createShape;
  53244. private _createHeightmap;
  53245. private _minus90X;
  53246. private _plus90X;
  53247. private _tmpPosition;
  53248. private _tmpDeltaPosition;
  53249. private _tmpUnityRotation;
  53250. private _updatePhysicsBodyTransformation;
  53251. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53252. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53253. isSupported(): boolean;
  53254. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53255. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53256. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53257. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53258. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53259. getBodyMass(impostor: PhysicsImpostor): number;
  53260. getBodyFriction(impostor: PhysicsImpostor): number;
  53261. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53262. getBodyRestitution(impostor: PhysicsImpostor): number;
  53263. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53264. sleepBody(impostor: PhysicsImpostor): void;
  53265. wakeUpBody(impostor: PhysicsImpostor): void;
  53266. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53267. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53268. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53269. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53270. getRadius(impostor: PhysicsImpostor): number;
  53271. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53272. dispose(): void;
  53273. private _extendNamespace;
  53274. /**
  53275. * Does a raycast in the physics world
  53276. * @param from when should the ray start?
  53277. * @param to when should the ray end?
  53278. * @returns PhysicsRaycastResult
  53279. */
  53280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53281. }
  53282. }
  53283. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53284. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53285. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53286. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53288. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53289. import { Nullable } from "babylonjs/types";
  53290. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53291. /** @hidden */
  53292. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53293. world: any;
  53294. name: string;
  53295. BJSOIMO: any;
  53296. private _raycastResult;
  53297. constructor(iterations?: number, oimoInjection?: any);
  53298. setGravity(gravity: Vector3): void;
  53299. setTimeStep(timeStep: number): void;
  53300. getTimeStep(): number;
  53301. private _tmpImpostorsArray;
  53302. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53303. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53304. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53305. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53306. private _tmpPositionVector;
  53307. removePhysicsBody(impostor: PhysicsImpostor): void;
  53308. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53309. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53310. isSupported(): boolean;
  53311. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53312. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53314. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53315. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53316. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53317. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53318. getBodyMass(impostor: PhysicsImpostor): number;
  53319. getBodyFriction(impostor: PhysicsImpostor): number;
  53320. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53321. getBodyRestitution(impostor: PhysicsImpostor): number;
  53322. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53323. sleepBody(impostor: PhysicsImpostor): void;
  53324. wakeUpBody(impostor: PhysicsImpostor): void;
  53325. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53326. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53327. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53328. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53329. getRadius(impostor: PhysicsImpostor): number;
  53330. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53331. dispose(): void;
  53332. /**
  53333. * Does a raycast in the physics world
  53334. * @param from when should the ray start?
  53335. * @param to when should the ray end?
  53336. * @returns PhysicsRaycastResult
  53337. */
  53338. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53339. }
  53340. }
  53341. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53342. import { Nullable } from "babylonjs/types";
  53343. import { Scene } from "babylonjs/scene";
  53344. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53345. import { Color4 } from "babylonjs/Maths/math.color";
  53346. import { Mesh } from "babylonjs/Meshes/mesh";
  53347. /**
  53348. * Class containing static functions to help procedurally build meshes
  53349. */
  53350. export class RibbonBuilder {
  53351. /**
  53352. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53353. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53354. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53355. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53356. * * 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
  53357. * * 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
  53358. * * 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
  53359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53362. * * 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
  53363. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53364. * * 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
  53365. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53367. * @param name defines the name of the mesh
  53368. * @param options defines the options used to create the mesh
  53369. * @param scene defines the hosting scene
  53370. * @returns the ribbon mesh
  53371. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53372. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53373. */
  53374. static CreateRibbon(name: string, options: {
  53375. pathArray: Vector3[][];
  53376. closeArray?: boolean;
  53377. closePath?: boolean;
  53378. offset?: number;
  53379. updatable?: boolean;
  53380. sideOrientation?: number;
  53381. frontUVs?: Vector4;
  53382. backUVs?: Vector4;
  53383. instance?: Mesh;
  53384. invertUV?: boolean;
  53385. uvs?: Vector2[];
  53386. colors?: Color4[];
  53387. }, scene?: Nullable<Scene>): Mesh;
  53388. }
  53389. }
  53390. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53391. import { Nullable } from "babylonjs/types";
  53392. import { Scene } from "babylonjs/scene";
  53393. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53394. import { Mesh } from "babylonjs/Meshes/mesh";
  53395. /**
  53396. * Class containing static functions to help procedurally build meshes
  53397. */
  53398. export class ShapeBuilder {
  53399. /**
  53400. * 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.
  53401. * * 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.
  53402. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53403. * * 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.
  53404. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53405. * * 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
  53406. * * 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
  53407. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53412. * @param name defines the name of the mesh
  53413. * @param options defines the options used to create the mesh
  53414. * @param scene defines the hosting scene
  53415. * @returns the extruded shape mesh
  53416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53418. */
  53419. static ExtrudeShape(name: string, options: {
  53420. shape: Vector3[];
  53421. path: Vector3[];
  53422. scale?: number;
  53423. rotation?: number;
  53424. cap?: number;
  53425. updatable?: boolean;
  53426. sideOrientation?: number;
  53427. frontUVs?: Vector4;
  53428. backUVs?: Vector4;
  53429. instance?: Mesh;
  53430. invertUV?: boolean;
  53431. }, scene?: Nullable<Scene>): Mesh;
  53432. /**
  53433. * Creates an custom extruded shape mesh.
  53434. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53435. * * 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.
  53436. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53437. * * 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
  53438. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53439. * * 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
  53440. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53441. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53442. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53443. * * 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
  53444. * * 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
  53445. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53448. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53450. * @param name defines the name of the mesh
  53451. * @param options defines the options used to create the mesh
  53452. * @param scene defines the hosting scene
  53453. * @returns the custom extruded shape mesh
  53454. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53455. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53457. */
  53458. static ExtrudeShapeCustom(name: string, options: {
  53459. shape: Vector3[];
  53460. path: Vector3[];
  53461. scaleFunction?: any;
  53462. rotationFunction?: any;
  53463. ribbonCloseArray?: boolean;
  53464. ribbonClosePath?: boolean;
  53465. cap?: number;
  53466. updatable?: boolean;
  53467. sideOrientation?: number;
  53468. frontUVs?: Vector4;
  53469. backUVs?: Vector4;
  53470. instance?: Mesh;
  53471. invertUV?: boolean;
  53472. }, scene?: Nullable<Scene>): Mesh;
  53473. private static _ExtrudeShapeGeneric;
  53474. }
  53475. }
  53476. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53477. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53478. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53479. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53480. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53481. import { Nullable } from "babylonjs/types";
  53482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53483. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53484. /**
  53485. * AmmoJS Physics plugin
  53486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53487. * @see https://github.com/kripken/ammo.js/
  53488. */
  53489. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53490. private _useDeltaForWorldStep;
  53491. /**
  53492. * Reference to the Ammo library
  53493. */
  53494. bjsAMMO: any;
  53495. /**
  53496. * Created ammoJS world which physics bodies are added to
  53497. */
  53498. world: any;
  53499. /**
  53500. * Name of the plugin
  53501. */
  53502. name: string;
  53503. private _timeStep;
  53504. private _fixedTimeStep;
  53505. private _maxSteps;
  53506. private _tmpQuaternion;
  53507. private _tmpAmmoTransform;
  53508. private _tmpAmmoQuaternion;
  53509. private _tmpAmmoConcreteContactResultCallback;
  53510. private _collisionConfiguration;
  53511. private _dispatcher;
  53512. private _overlappingPairCache;
  53513. private _solver;
  53514. private _softBodySolver;
  53515. private _tmpAmmoVectorA;
  53516. private _tmpAmmoVectorB;
  53517. private _tmpAmmoVectorC;
  53518. private _tmpAmmoVectorD;
  53519. private _tmpContactCallbackResult;
  53520. private _tmpAmmoVectorRCA;
  53521. private _tmpAmmoVectorRCB;
  53522. private _raycastResult;
  53523. private static readonly DISABLE_COLLISION_FLAG;
  53524. private static readonly KINEMATIC_FLAG;
  53525. private static readonly DISABLE_DEACTIVATION_FLAG;
  53526. /**
  53527. * Initializes the ammoJS plugin
  53528. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53529. * @param ammoInjection can be used to inject your own ammo reference
  53530. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53531. */
  53532. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53533. /**
  53534. * Sets the gravity of the physics world (m/(s^2))
  53535. * @param gravity Gravity to set
  53536. */
  53537. setGravity(gravity: Vector3): void;
  53538. /**
  53539. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53540. * @param timeStep timestep to use in seconds
  53541. */
  53542. setTimeStep(timeStep: number): void;
  53543. /**
  53544. * 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)
  53545. * @param fixedTimeStep fixedTimeStep to use in seconds
  53546. */
  53547. setFixedTimeStep(fixedTimeStep: number): void;
  53548. /**
  53549. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53550. * @param maxSteps the maximum number of steps by the physics engine per frame
  53551. */
  53552. setMaxSteps(maxSteps: number): void;
  53553. /**
  53554. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53555. * @returns the current timestep in seconds
  53556. */
  53557. getTimeStep(): number;
  53558. private _isImpostorInContact;
  53559. private _isImpostorPairInContact;
  53560. private _stepSimulation;
  53561. /**
  53562. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53563. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53564. * After the step the babylon meshes are set to the position of the physics imposters
  53565. * @param delta amount of time to step forward
  53566. * @param impostors array of imposters to update before/after the step
  53567. */
  53568. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53569. /**
  53570. * Update babylon mesh to match physics world object
  53571. * @param impostor imposter to match
  53572. */
  53573. private _afterSoftStep;
  53574. /**
  53575. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53576. * @param impostor imposter to match
  53577. */
  53578. private _ropeStep;
  53579. /**
  53580. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53581. * @param impostor imposter to match
  53582. */
  53583. private _softbodyOrClothStep;
  53584. private _tmpVector;
  53585. private _tmpMatrix;
  53586. /**
  53587. * Applies an impulse on the imposter
  53588. * @param impostor imposter to apply impulse to
  53589. * @param force amount of force to be applied to the imposter
  53590. * @param contactPoint the location to apply the impulse on the imposter
  53591. */
  53592. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53593. /**
  53594. * Applies a force on the imposter
  53595. * @param impostor imposter to apply force
  53596. * @param force amount of force to be applied to the imposter
  53597. * @param contactPoint the location to apply the force on the imposter
  53598. */
  53599. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53600. /**
  53601. * Creates a physics body using the plugin
  53602. * @param impostor the imposter to create the physics body on
  53603. */
  53604. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53605. /**
  53606. * Removes the physics body from the imposter and disposes of the body's memory
  53607. * @param impostor imposter to remove the physics body from
  53608. */
  53609. removePhysicsBody(impostor: PhysicsImpostor): void;
  53610. /**
  53611. * Generates a joint
  53612. * @param impostorJoint the imposter joint to create the joint with
  53613. */
  53614. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53615. /**
  53616. * Removes a joint
  53617. * @param impostorJoint the imposter joint to remove the joint from
  53618. */
  53619. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53620. private _addMeshVerts;
  53621. /**
  53622. * Initialise the soft body vertices to match its object's (mesh) vertices
  53623. * Softbody vertices (nodes) are in world space and to match this
  53624. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53625. * @param impostor to create the softbody for
  53626. */
  53627. private _softVertexData;
  53628. /**
  53629. * Create an impostor's soft body
  53630. * @param impostor to create the softbody for
  53631. */
  53632. private _createSoftbody;
  53633. /**
  53634. * Create cloth for an impostor
  53635. * @param impostor to create the softbody for
  53636. */
  53637. private _createCloth;
  53638. /**
  53639. * Create rope for an impostor
  53640. * @param impostor to create the softbody for
  53641. */
  53642. private _createRope;
  53643. private _addHullVerts;
  53644. private _createShape;
  53645. /**
  53646. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53647. * @param impostor imposter containing the physics body and babylon object
  53648. */
  53649. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53650. /**
  53651. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53652. * @param impostor imposter containing the physics body and babylon object
  53653. * @param newPosition new position
  53654. * @param newRotation new rotation
  53655. */
  53656. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53657. /**
  53658. * If this plugin is supported
  53659. * @returns true if its supported
  53660. */
  53661. isSupported(): boolean;
  53662. /**
  53663. * Sets the linear velocity of the physics body
  53664. * @param impostor imposter to set the velocity on
  53665. * @param velocity velocity to set
  53666. */
  53667. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53668. /**
  53669. * Sets the angular velocity of the physics body
  53670. * @param impostor imposter to set the velocity on
  53671. * @param velocity velocity to set
  53672. */
  53673. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53674. /**
  53675. * gets the linear velocity
  53676. * @param impostor imposter to get linear velocity from
  53677. * @returns linear velocity
  53678. */
  53679. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53680. /**
  53681. * gets the angular velocity
  53682. * @param impostor imposter to get angular velocity from
  53683. * @returns angular velocity
  53684. */
  53685. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53686. /**
  53687. * Sets the mass of physics body
  53688. * @param impostor imposter to set the mass on
  53689. * @param mass mass to set
  53690. */
  53691. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53692. /**
  53693. * Gets the mass of the physics body
  53694. * @param impostor imposter to get the mass from
  53695. * @returns mass
  53696. */
  53697. getBodyMass(impostor: PhysicsImpostor): number;
  53698. /**
  53699. * Gets friction of the impostor
  53700. * @param impostor impostor to get friction from
  53701. * @returns friction value
  53702. */
  53703. getBodyFriction(impostor: PhysicsImpostor): number;
  53704. /**
  53705. * Sets friction of the impostor
  53706. * @param impostor impostor to set friction on
  53707. * @param friction friction value
  53708. */
  53709. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53710. /**
  53711. * Gets restitution of the impostor
  53712. * @param impostor impostor to get restitution from
  53713. * @returns restitution value
  53714. */
  53715. getBodyRestitution(impostor: PhysicsImpostor): number;
  53716. /**
  53717. * Sets resitution of the impostor
  53718. * @param impostor impostor to set resitution on
  53719. * @param restitution resitution value
  53720. */
  53721. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53722. /**
  53723. * Gets pressure inside the impostor
  53724. * @param impostor impostor to get pressure from
  53725. * @returns pressure value
  53726. */
  53727. getBodyPressure(impostor: PhysicsImpostor): number;
  53728. /**
  53729. * Sets pressure inside a soft body impostor
  53730. * Cloth and rope must remain 0 pressure
  53731. * @param impostor impostor to set pressure on
  53732. * @param pressure pressure value
  53733. */
  53734. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53735. /**
  53736. * Gets stiffness of the impostor
  53737. * @param impostor impostor to get stiffness from
  53738. * @returns pressure value
  53739. */
  53740. getBodyStiffness(impostor: PhysicsImpostor): number;
  53741. /**
  53742. * Sets stiffness of the impostor
  53743. * @param impostor impostor to set stiffness on
  53744. * @param stiffness stiffness value from 0 to 1
  53745. */
  53746. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53747. /**
  53748. * Gets velocityIterations of the impostor
  53749. * @param impostor impostor to get velocity iterations from
  53750. * @returns velocityIterations value
  53751. */
  53752. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53753. /**
  53754. * Sets velocityIterations of the impostor
  53755. * @param impostor impostor to set velocity iterations on
  53756. * @param velocityIterations velocityIterations value
  53757. */
  53758. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53759. /**
  53760. * Gets positionIterations of the impostor
  53761. * @param impostor impostor to get position iterations from
  53762. * @returns positionIterations value
  53763. */
  53764. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53765. /**
  53766. * Sets positionIterations of the impostor
  53767. * @param impostor impostor to set position on
  53768. * @param positionIterations positionIterations value
  53769. */
  53770. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53771. /**
  53772. * Append an anchor to a cloth object
  53773. * @param impostor is the cloth impostor to add anchor to
  53774. * @param otherImpostor is the rigid impostor to anchor to
  53775. * @param width ratio across width from 0 to 1
  53776. * @param height ratio up height from 0 to 1
  53777. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53778. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53779. */
  53780. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53781. /**
  53782. * Append an hook to a rope object
  53783. * @param impostor is the rope impostor to add hook to
  53784. * @param otherImpostor is the rigid impostor to hook to
  53785. * @param length ratio along the rope from 0 to 1
  53786. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53787. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53788. */
  53789. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53790. /**
  53791. * Sleeps the physics body and stops it from being active
  53792. * @param impostor impostor to sleep
  53793. */
  53794. sleepBody(impostor: PhysicsImpostor): void;
  53795. /**
  53796. * Activates the physics body
  53797. * @param impostor impostor to activate
  53798. */
  53799. wakeUpBody(impostor: PhysicsImpostor): void;
  53800. /**
  53801. * Updates the distance parameters of the joint
  53802. * @param joint joint to update
  53803. * @param maxDistance maximum distance of the joint
  53804. * @param minDistance minimum distance of the joint
  53805. */
  53806. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53807. /**
  53808. * Sets a motor on the joint
  53809. * @param joint joint to set motor on
  53810. * @param speed speed of the motor
  53811. * @param maxForce maximum force of the motor
  53812. * @param motorIndex index of the motor
  53813. */
  53814. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53815. /**
  53816. * Sets the motors limit
  53817. * @param joint joint to set limit on
  53818. * @param upperLimit upper limit
  53819. * @param lowerLimit lower limit
  53820. */
  53821. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53822. /**
  53823. * Syncs the position and rotation of a mesh with the impostor
  53824. * @param mesh mesh to sync
  53825. * @param impostor impostor to update the mesh with
  53826. */
  53827. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53828. /**
  53829. * Gets the radius of the impostor
  53830. * @param impostor impostor to get radius from
  53831. * @returns the radius
  53832. */
  53833. getRadius(impostor: PhysicsImpostor): number;
  53834. /**
  53835. * Gets the box size of the impostor
  53836. * @param impostor impostor to get box size from
  53837. * @param result the resulting box size
  53838. */
  53839. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53840. /**
  53841. * Disposes of the impostor
  53842. */
  53843. dispose(): void;
  53844. /**
  53845. * Does a raycast in the physics world
  53846. * @param from when should the ray start?
  53847. * @param to when should the ray end?
  53848. * @returns PhysicsRaycastResult
  53849. */
  53850. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53851. }
  53852. }
  53853. declare module "babylonjs/Probes/reflectionProbe" {
  53854. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53855. import { Vector3 } from "babylonjs/Maths/math.vector";
  53856. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53857. import { Nullable } from "babylonjs/types";
  53858. import { Scene } from "babylonjs/scene";
  53859. module "babylonjs/abstractScene" {
  53860. interface AbstractScene {
  53861. /**
  53862. * The list of reflection probes added to the scene
  53863. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53864. */
  53865. reflectionProbes: Array<ReflectionProbe>;
  53866. /**
  53867. * Removes the given reflection probe from this scene.
  53868. * @param toRemove The reflection probe to remove
  53869. * @returns The index of the removed reflection probe
  53870. */
  53871. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53872. /**
  53873. * Adds the given reflection probe to this scene.
  53874. * @param newReflectionProbe The reflection probe to add
  53875. */
  53876. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53877. }
  53878. }
  53879. /**
  53880. * Class used to generate realtime reflection / refraction cube textures
  53881. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53882. */
  53883. export class ReflectionProbe {
  53884. /** defines the name of the probe */
  53885. name: string;
  53886. private _scene;
  53887. private _renderTargetTexture;
  53888. private _projectionMatrix;
  53889. private _viewMatrix;
  53890. private _target;
  53891. private _add;
  53892. private _attachedMesh;
  53893. private _invertYAxis;
  53894. /** Gets or sets probe position (center of the cube map) */
  53895. position: Vector3;
  53896. /**
  53897. * Creates a new reflection probe
  53898. * @param name defines the name of the probe
  53899. * @param size defines the texture resolution (for each face)
  53900. * @param scene defines the hosting scene
  53901. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53902. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53903. */
  53904. constructor(
  53905. /** defines the name of the probe */
  53906. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53907. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53908. samples: number;
  53909. /** Gets or sets the refresh rate to use (on every frame by default) */
  53910. refreshRate: number;
  53911. /**
  53912. * Gets the hosting scene
  53913. * @returns a Scene
  53914. */
  53915. getScene(): Scene;
  53916. /** Gets the internal CubeTexture used to render to */
  53917. readonly cubeTexture: RenderTargetTexture;
  53918. /** Gets the list of meshes to render */
  53919. readonly renderList: Nullable<AbstractMesh[]>;
  53920. /**
  53921. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53922. * @param mesh defines the mesh to attach to
  53923. */
  53924. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53925. /**
  53926. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53927. * @param renderingGroupId The rendering group id corresponding to its index
  53928. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53929. */
  53930. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53931. /**
  53932. * Clean all associated resources
  53933. */
  53934. dispose(): void;
  53935. /**
  53936. * Converts the reflection probe information to a readable string for debug purpose.
  53937. * @param fullDetails Supports for multiple levels of logging within scene loading
  53938. * @returns the human readable reflection probe info
  53939. */
  53940. toString(fullDetails?: boolean): string;
  53941. /**
  53942. * Get the class name of the relfection probe.
  53943. * @returns "ReflectionProbe"
  53944. */
  53945. getClassName(): string;
  53946. /**
  53947. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53948. * @returns The JSON representation of the texture
  53949. */
  53950. serialize(): any;
  53951. /**
  53952. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53953. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53954. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53955. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53956. * @returns The parsed reflection probe if successful
  53957. */
  53958. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53959. }
  53960. }
  53961. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53962. /** @hidden */
  53963. export var _BabylonLoaderRegistered: boolean;
  53964. }
  53965. declare module "babylonjs/Loading/Plugins/index" {
  53966. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53967. }
  53968. declare module "babylonjs/Loading/index" {
  53969. export * from "babylonjs/Loading/loadingScreen";
  53970. export * from "babylonjs/Loading/Plugins/index";
  53971. export * from "babylonjs/Loading/sceneLoader";
  53972. export * from "babylonjs/Loading/sceneLoaderFlags";
  53973. }
  53974. declare module "babylonjs/Materials/Background/index" {
  53975. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53976. }
  53977. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53978. import { Scene } from "babylonjs/scene";
  53979. import { Color3 } from "babylonjs/Maths/math.color";
  53980. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53982. /**
  53983. * The Physically based simple base material of BJS.
  53984. *
  53985. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53986. * It is used as the base class for both the specGloss and metalRough conventions.
  53987. */
  53988. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53989. /**
  53990. * Number of Simultaneous lights allowed on the material.
  53991. */
  53992. maxSimultaneousLights: number;
  53993. /**
  53994. * If sets to true, disables all the lights affecting the material.
  53995. */
  53996. disableLighting: boolean;
  53997. /**
  53998. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53999. */
  54000. environmentTexture: BaseTexture;
  54001. /**
  54002. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54003. */
  54004. invertNormalMapX: boolean;
  54005. /**
  54006. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54007. */
  54008. invertNormalMapY: boolean;
  54009. /**
  54010. * Normal map used in the model.
  54011. */
  54012. normalTexture: BaseTexture;
  54013. /**
  54014. * Emissivie color used to self-illuminate the model.
  54015. */
  54016. emissiveColor: Color3;
  54017. /**
  54018. * Emissivie texture used to self-illuminate the model.
  54019. */
  54020. emissiveTexture: BaseTexture;
  54021. /**
  54022. * Occlusion Channel Strenght.
  54023. */
  54024. occlusionStrength: number;
  54025. /**
  54026. * Occlusion Texture of the material (adding extra occlusion effects).
  54027. */
  54028. occlusionTexture: BaseTexture;
  54029. /**
  54030. * Defines the alpha limits in alpha test mode.
  54031. */
  54032. alphaCutOff: number;
  54033. /**
  54034. * Gets the current double sided mode.
  54035. */
  54036. /**
  54037. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54038. */
  54039. doubleSided: boolean;
  54040. /**
  54041. * Stores the pre-calculated light information of a mesh in a texture.
  54042. */
  54043. lightmapTexture: BaseTexture;
  54044. /**
  54045. * If true, the light map contains occlusion information instead of lighting info.
  54046. */
  54047. useLightmapAsShadowmap: boolean;
  54048. /**
  54049. * Instantiates a new PBRMaterial instance.
  54050. *
  54051. * @param name The material name
  54052. * @param scene The scene the material will be use in.
  54053. */
  54054. constructor(name: string, scene: Scene);
  54055. getClassName(): string;
  54056. }
  54057. }
  54058. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54059. import { Scene } from "babylonjs/scene";
  54060. import { Color3 } from "babylonjs/Maths/math.color";
  54061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54062. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54063. /**
  54064. * The PBR material of BJS following the metal roughness convention.
  54065. *
  54066. * This fits to the PBR convention in the GLTF definition:
  54067. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54068. */
  54069. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54070. /**
  54071. * The base color has two different interpretations depending on the value of metalness.
  54072. * When the material is a metal, the base color is the specific measured reflectance value
  54073. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54074. * of the material.
  54075. */
  54076. baseColor: Color3;
  54077. /**
  54078. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54079. * well as opacity information in the alpha channel.
  54080. */
  54081. baseTexture: BaseTexture;
  54082. /**
  54083. * Specifies the metallic scalar value of the material.
  54084. * Can also be used to scale the metalness values of the metallic texture.
  54085. */
  54086. metallic: number;
  54087. /**
  54088. * Specifies the roughness scalar value of the material.
  54089. * Can also be used to scale the roughness values of the metallic texture.
  54090. */
  54091. roughness: number;
  54092. /**
  54093. * Texture containing both the metallic value in the B channel and the
  54094. * roughness value in the G channel to keep better precision.
  54095. */
  54096. metallicRoughnessTexture: BaseTexture;
  54097. /**
  54098. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54099. *
  54100. * @param name The material name
  54101. * @param scene The scene the material will be use in.
  54102. */
  54103. constructor(name: string, scene: Scene);
  54104. /**
  54105. * Return the currrent class name of the material.
  54106. */
  54107. getClassName(): string;
  54108. /**
  54109. * Makes a duplicate of the current material.
  54110. * @param name - name to use for the new material.
  54111. */
  54112. clone(name: string): PBRMetallicRoughnessMaterial;
  54113. /**
  54114. * Serialize the material to a parsable JSON object.
  54115. */
  54116. serialize(): any;
  54117. /**
  54118. * Parses a JSON object correponding to the serialize function.
  54119. */
  54120. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54121. }
  54122. }
  54123. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54124. import { Scene } from "babylonjs/scene";
  54125. import { Color3 } from "babylonjs/Maths/math.color";
  54126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54127. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54128. /**
  54129. * The PBR material of BJS following the specular glossiness convention.
  54130. *
  54131. * This fits to the PBR convention in the GLTF definition:
  54132. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54133. */
  54134. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54135. /**
  54136. * Specifies the diffuse color of the material.
  54137. */
  54138. diffuseColor: Color3;
  54139. /**
  54140. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54141. * channel.
  54142. */
  54143. diffuseTexture: BaseTexture;
  54144. /**
  54145. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54146. */
  54147. specularColor: Color3;
  54148. /**
  54149. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54150. */
  54151. glossiness: number;
  54152. /**
  54153. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54154. */
  54155. specularGlossinessTexture: BaseTexture;
  54156. /**
  54157. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54158. *
  54159. * @param name The material name
  54160. * @param scene The scene the material will be use in.
  54161. */
  54162. constructor(name: string, scene: Scene);
  54163. /**
  54164. * Return the currrent class name of the material.
  54165. */
  54166. getClassName(): string;
  54167. /**
  54168. * Makes a duplicate of the current material.
  54169. * @param name - name to use for the new material.
  54170. */
  54171. clone(name: string): PBRSpecularGlossinessMaterial;
  54172. /**
  54173. * Serialize the material to a parsable JSON object.
  54174. */
  54175. serialize(): any;
  54176. /**
  54177. * Parses a JSON object correponding to the serialize function.
  54178. */
  54179. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54180. }
  54181. }
  54182. declare module "babylonjs/Materials/PBR/index" {
  54183. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54184. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54185. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54186. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54187. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54188. }
  54189. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54190. import { Nullable } from "babylonjs/types";
  54191. import { Scene } from "babylonjs/scene";
  54192. import { Matrix } from "babylonjs/Maths/math.vector";
  54193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54194. /**
  54195. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54196. * It can help converting any input color in a desired output one. This can then be used to create effects
  54197. * from sepia, black and white to sixties or futuristic rendering...
  54198. *
  54199. * The only supported format is currently 3dl.
  54200. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54201. */
  54202. export class ColorGradingTexture extends BaseTexture {
  54203. /**
  54204. * The current texture matrix. (will always be identity in color grading texture)
  54205. */
  54206. private _textureMatrix;
  54207. /**
  54208. * The texture URL.
  54209. */
  54210. url: string;
  54211. /**
  54212. * Empty line regex stored for GC.
  54213. */
  54214. private static _noneEmptyLineRegex;
  54215. private _engine;
  54216. /**
  54217. * Instantiates a ColorGradingTexture from the following parameters.
  54218. *
  54219. * @param url The location of the color gradind data (currently only supporting 3dl)
  54220. * @param scene The scene the texture will be used in
  54221. */
  54222. constructor(url: string, scene: Scene);
  54223. /**
  54224. * Returns the texture matrix used in most of the material.
  54225. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54226. */
  54227. getTextureMatrix(): Matrix;
  54228. /**
  54229. * Occurs when the file being loaded is a .3dl LUT file.
  54230. */
  54231. private load3dlTexture;
  54232. /**
  54233. * Starts the loading process of the texture.
  54234. */
  54235. private loadTexture;
  54236. /**
  54237. * Clones the color gradind texture.
  54238. */
  54239. clone(): ColorGradingTexture;
  54240. /**
  54241. * Called during delayed load for textures.
  54242. */
  54243. delayLoad(): void;
  54244. /**
  54245. * Parses a color grading texture serialized by Babylon.
  54246. * @param parsedTexture The texture information being parsedTexture
  54247. * @param scene The scene to load the texture in
  54248. * @param rootUrl The root url of the data assets to load
  54249. * @return A color gradind texture
  54250. */
  54251. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54252. /**
  54253. * Serializes the LUT texture to json format.
  54254. */
  54255. serialize(): any;
  54256. }
  54257. }
  54258. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54259. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54260. import { Scene } from "babylonjs/scene";
  54261. import { Nullable } from "babylonjs/types";
  54262. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54263. /**
  54264. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54265. */
  54266. export class EquiRectangularCubeTexture extends BaseTexture {
  54267. /** The six faces of the cube. */
  54268. private static _FacesMapping;
  54269. private _noMipmap;
  54270. private _onLoad;
  54271. private _onError;
  54272. /** The size of the cubemap. */
  54273. private _size;
  54274. /** The buffer of the image. */
  54275. private _buffer;
  54276. /** The width of the input image. */
  54277. private _width;
  54278. /** The height of the input image. */
  54279. private _height;
  54280. /** The URL to the image. */
  54281. url: string;
  54282. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54283. coordinatesMode: number;
  54284. /**
  54285. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54286. * @param url The location of the image
  54287. * @param scene The scene the texture will be used in
  54288. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54289. * @param noMipmap Forces to not generate the mipmap if true
  54290. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54291. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54292. * @param onLoad — defines a callback called when texture is loaded
  54293. * @param onError — defines a callback called if there is an error
  54294. */
  54295. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54296. /**
  54297. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54298. */
  54299. private loadImage;
  54300. /**
  54301. * Convert the image buffer into a cubemap and create a CubeTexture.
  54302. */
  54303. private loadTexture;
  54304. /**
  54305. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54306. * @param buffer The ArrayBuffer that should be converted.
  54307. * @returns The buffer as Float32Array.
  54308. */
  54309. private getFloat32ArrayFromArrayBuffer;
  54310. /**
  54311. * Get the current class name of the texture useful for serialization or dynamic coding.
  54312. * @returns "EquiRectangularCubeTexture"
  54313. */
  54314. getClassName(): string;
  54315. /**
  54316. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54317. * @returns A clone of the current EquiRectangularCubeTexture.
  54318. */
  54319. clone(): EquiRectangularCubeTexture;
  54320. }
  54321. }
  54322. declare module "babylonjs/Misc/tga" {
  54323. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54324. /**
  54325. * Based on jsTGALoader - Javascript loader for TGA file
  54326. * By Vincent Thibault
  54327. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54328. */
  54329. export class TGATools {
  54330. private static _TYPE_INDEXED;
  54331. private static _TYPE_RGB;
  54332. private static _TYPE_GREY;
  54333. private static _TYPE_RLE_INDEXED;
  54334. private static _TYPE_RLE_RGB;
  54335. private static _TYPE_RLE_GREY;
  54336. private static _ORIGIN_MASK;
  54337. private static _ORIGIN_SHIFT;
  54338. private static _ORIGIN_BL;
  54339. private static _ORIGIN_BR;
  54340. private static _ORIGIN_UL;
  54341. private static _ORIGIN_UR;
  54342. /**
  54343. * Gets the header of a TGA file
  54344. * @param data defines the TGA data
  54345. * @returns the header
  54346. */
  54347. static GetTGAHeader(data: Uint8Array): any;
  54348. /**
  54349. * Uploads TGA content to a Babylon Texture
  54350. * @hidden
  54351. */
  54352. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54353. /** @hidden */
  54354. 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;
  54355. /** @hidden */
  54356. 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;
  54357. /** @hidden */
  54358. 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;
  54359. /** @hidden */
  54360. 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;
  54361. /** @hidden */
  54362. 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;
  54363. /** @hidden */
  54364. 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;
  54365. }
  54366. }
  54367. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54368. import { Nullable } from "babylonjs/types";
  54369. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54370. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54371. /**
  54372. * Implementation of the TGA Texture Loader.
  54373. * @hidden
  54374. */
  54375. export class _TGATextureLoader implements IInternalTextureLoader {
  54376. /**
  54377. * Defines wether the loader supports cascade loading the different faces.
  54378. */
  54379. readonly supportCascades: boolean;
  54380. /**
  54381. * This returns if the loader support the current file information.
  54382. * @param extension defines the file extension of the file being loaded
  54383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54384. * @param fallback defines the fallback internal texture if any
  54385. * @param isBase64 defines whether the texture is encoded as a base64
  54386. * @param isBuffer defines whether the texture data are stored as a buffer
  54387. * @returns true if the loader can load the specified file
  54388. */
  54389. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54390. /**
  54391. * Transform the url before loading if required.
  54392. * @param rootUrl the url of the texture
  54393. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54394. * @returns the transformed texture
  54395. */
  54396. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54397. /**
  54398. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54399. * @param rootUrl the url of the texture
  54400. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54401. * @returns the fallback texture
  54402. */
  54403. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54404. /**
  54405. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54406. * @param data contains the texture data
  54407. * @param texture defines the BabylonJS internal texture
  54408. * @param createPolynomials will be true if polynomials have been requested
  54409. * @param onLoad defines the callback to trigger once the texture is ready
  54410. * @param onError defines the callback to trigger in case of error
  54411. */
  54412. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54413. /**
  54414. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54415. * @param data contains the texture data
  54416. * @param texture defines the BabylonJS internal texture
  54417. * @param callback defines the method to call once ready to upload
  54418. */
  54419. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54420. }
  54421. }
  54422. declare module "babylonjs/Misc/basis" {
  54423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54424. /**
  54425. * Info about the .basis files
  54426. */
  54427. class BasisFileInfo {
  54428. /**
  54429. * If the file has alpha
  54430. */
  54431. hasAlpha: boolean;
  54432. /**
  54433. * Info about each image of the basis file
  54434. */
  54435. images: Array<{
  54436. levels: Array<{
  54437. width: number;
  54438. height: number;
  54439. transcodedPixels: ArrayBufferView;
  54440. }>;
  54441. }>;
  54442. }
  54443. /**
  54444. * Result of transcoding a basis file
  54445. */
  54446. class TranscodeResult {
  54447. /**
  54448. * Info about the .basis file
  54449. */
  54450. fileInfo: BasisFileInfo;
  54451. /**
  54452. * Format to use when loading the file
  54453. */
  54454. format: number;
  54455. }
  54456. /**
  54457. * Configuration options for the Basis transcoder
  54458. */
  54459. export class BasisTranscodeConfiguration {
  54460. /**
  54461. * Supported compression formats used to determine the supported output format of the transcoder
  54462. */
  54463. supportedCompressionFormats?: {
  54464. /**
  54465. * etc1 compression format
  54466. */
  54467. etc1?: boolean;
  54468. /**
  54469. * s3tc compression format
  54470. */
  54471. s3tc?: boolean;
  54472. /**
  54473. * pvrtc compression format
  54474. */
  54475. pvrtc?: boolean;
  54476. /**
  54477. * etc2 compression format
  54478. */
  54479. etc2?: boolean;
  54480. };
  54481. /**
  54482. * If mipmap levels should be loaded for transcoded images (Default: true)
  54483. */
  54484. loadMipmapLevels?: boolean;
  54485. /**
  54486. * Index of a single image to load (Default: all images)
  54487. */
  54488. loadSingleImage?: number;
  54489. }
  54490. /**
  54491. * Used to load .Basis files
  54492. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54493. */
  54494. export class BasisTools {
  54495. private static _IgnoreSupportedFormats;
  54496. /**
  54497. * URL to use when loading the basis transcoder
  54498. */
  54499. static JSModuleURL: string;
  54500. /**
  54501. * URL to use when loading the wasm module for the transcoder
  54502. */
  54503. static WasmModuleURL: string;
  54504. /**
  54505. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54506. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54507. * @returns internal format corresponding to the Basis format
  54508. */
  54509. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54510. private static _WorkerPromise;
  54511. private static _Worker;
  54512. private static _actionId;
  54513. private static _CreateWorkerAsync;
  54514. /**
  54515. * Transcodes a loaded image file to compressed pixel data
  54516. * @param imageData image data to transcode
  54517. * @param config configuration options for the transcoding
  54518. * @returns a promise resulting in the transcoded image
  54519. */
  54520. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54521. /**
  54522. * Loads a texture from the transcode result
  54523. * @param texture texture load to
  54524. * @param transcodeResult the result of transcoding the basis file to load from
  54525. */
  54526. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54527. }
  54528. }
  54529. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54530. import { Nullable } from "babylonjs/types";
  54531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54532. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54533. /**
  54534. * Loader for .basis file format
  54535. */
  54536. export class _BasisTextureLoader implements IInternalTextureLoader {
  54537. /**
  54538. * Defines whether the loader supports cascade loading the different faces.
  54539. */
  54540. readonly supportCascades: boolean;
  54541. /**
  54542. * This returns if the loader support the current file information.
  54543. * @param extension defines the file extension of the file being loaded
  54544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54545. * @param fallback defines the fallback internal texture if any
  54546. * @param isBase64 defines whether the texture is encoded as a base64
  54547. * @param isBuffer defines whether the texture data are stored as a buffer
  54548. * @returns true if the loader can load the specified file
  54549. */
  54550. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54551. /**
  54552. * Transform the url before loading if required.
  54553. * @param rootUrl the url of the texture
  54554. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54555. * @returns the transformed texture
  54556. */
  54557. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54558. /**
  54559. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54560. * @param rootUrl the url of the texture
  54561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54562. * @returns the fallback texture
  54563. */
  54564. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54565. /**
  54566. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54567. * @param data contains the texture data
  54568. * @param texture defines the BabylonJS internal texture
  54569. * @param createPolynomials will be true if polynomials have been requested
  54570. * @param onLoad defines the callback to trigger once the texture is ready
  54571. * @param onError defines the callback to trigger in case of error
  54572. */
  54573. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54574. /**
  54575. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54576. * @param data contains the texture data
  54577. * @param texture defines the BabylonJS internal texture
  54578. * @param callback defines the method to call once ready to upload
  54579. */
  54580. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54581. }
  54582. }
  54583. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54584. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54585. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54586. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54587. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54588. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54589. }
  54590. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54591. import { Scene } from "babylonjs/scene";
  54592. import { Texture } from "babylonjs/Materials/Textures/texture";
  54593. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54594. /**
  54595. * 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.
  54596. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54597. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54598. */
  54599. export class CustomProceduralTexture extends ProceduralTexture {
  54600. private _animate;
  54601. private _time;
  54602. private _config;
  54603. private _texturePath;
  54604. /**
  54605. * Instantiates a new Custom Procedural Texture.
  54606. * 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.
  54607. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54608. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54609. * @param name Define the name of the texture
  54610. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54611. * @param size Define the size of the texture to create
  54612. * @param scene Define the scene the texture belongs to
  54613. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54614. * @param generateMipMaps Define if the texture should creates mip maps or not
  54615. */
  54616. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54617. private _loadJson;
  54618. /**
  54619. * Is the texture ready to be used ? (rendered at least once)
  54620. * @returns true if ready, otherwise, false.
  54621. */
  54622. isReady(): boolean;
  54623. /**
  54624. * Render the texture to its associated render target.
  54625. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54626. */
  54627. render(useCameraPostProcess?: boolean): void;
  54628. /**
  54629. * Update the list of dependant textures samplers in the shader.
  54630. */
  54631. updateTextures(): void;
  54632. /**
  54633. * Update the uniform values of the procedural texture in the shader.
  54634. */
  54635. updateShaderUniforms(): void;
  54636. /**
  54637. * Define if the texture animates or not.
  54638. */
  54639. animate: boolean;
  54640. }
  54641. }
  54642. declare module "babylonjs/Shaders/noise.fragment" {
  54643. /** @hidden */
  54644. export var noisePixelShader: {
  54645. name: string;
  54646. shader: string;
  54647. };
  54648. }
  54649. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54650. import { Nullable } from "babylonjs/types";
  54651. import { Scene } from "babylonjs/scene";
  54652. import { Texture } from "babylonjs/Materials/Textures/texture";
  54653. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54654. import "babylonjs/Shaders/noise.fragment";
  54655. /**
  54656. * Class used to generate noise procedural textures
  54657. */
  54658. export class NoiseProceduralTexture extends ProceduralTexture {
  54659. private _time;
  54660. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54661. brightness: number;
  54662. /** Defines the number of octaves to process */
  54663. octaves: number;
  54664. /** Defines the level of persistence (0.8 by default) */
  54665. persistence: number;
  54666. /** Gets or sets animation speed factor (default is 1) */
  54667. animationSpeedFactor: number;
  54668. /**
  54669. * Creates a new NoiseProceduralTexture
  54670. * @param name defines the name fo the texture
  54671. * @param size defines the size of the texture (default is 256)
  54672. * @param scene defines the hosting scene
  54673. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54674. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54675. */
  54676. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54677. private _updateShaderUniforms;
  54678. protected _getDefines(): string;
  54679. /** Generate the current state of the procedural texture */
  54680. render(useCameraPostProcess?: boolean): void;
  54681. /**
  54682. * Serializes this noise procedural texture
  54683. * @returns a serialized noise procedural texture object
  54684. */
  54685. serialize(): any;
  54686. /**
  54687. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54688. * @param parsedTexture defines parsed texture data
  54689. * @param scene defines the current scene
  54690. * @param rootUrl defines the root URL containing noise procedural texture information
  54691. * @returns a parsed NoiseProceduralTexture
  54692. */
  54693. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54694. }
  54695. }
  54696. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54697. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54698. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54699. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54700. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54701. }
  54702. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54703. import { Nullable } from "babylonjs/types";
  54704. import { Scene } from "babylonjs/scene";
  54705. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54706. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54707. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54708. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54709. /**
  54710. * Raw cube texture where the raw buffers are passed in
  54711. */
  54712. export class RawCubeTexture extends CubeTexture {
  54713. /**
  54714. * Creates a cube texture where the raw buffers are passed in.
  54715. * @param scene defines the scene the texture is attached to
  54716. * @param data defines the array of data to use to create each face
  54717. * @param size defines the size of the textures
  54718. * @param format defines the format of the data
  54719. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54720. * @param generateMipMaps defines if the engine should generate the mip levels
  54721. * @param invertY defines if data must be stored with Y axis inverted
  54722. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54723. * @param compression defines the compression used (null by default)
  54724. */
  54725. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54726. /**
  54727. * Updates the raw cube texture.
  54728. * @param data defines the data to store
  54729. * @param format defines the data format
  54730. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54731. * @param invertY defines if data must be stored with Y axis inverted
  54732. * @param compression defines the compression used (null by default)
  54733. * @param level defines which level of the texture to update
  54734. */
  54735. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54736. /**
  54737. * Updates a raw cube texture with RGBD encoded data.
  54738. * @param data defines the array of data [mipmap][face] to use to create each face
  54739. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54740. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54741. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54742. * @returns a promsie that resolves when the operation is complete
  54743. */
  54744. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54745. /**
  54746. * Clones the raw cube texture.
  54747. * @return a new cube texture
  54748. */
  54749. clone(): CubeTexture;
  54750. /** @hidden */
  54751. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54752. }
  54753. }
  54754. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54755. import { Scene } from "babylonjs/scene";
  54756. import { Texture } from "babylonjs/Materials/Textures/texture";
  54757. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54758. /**
  54759. * Class used to store 3D textures containing user data
  54760. */
  54761. export class RawTexture3D extends Texture {
  54762. /** Gets or sets the texture format to use */
  54763. format: number;
  54764. private _engine;
  54765. /**
  54766. * Create a new RawTexture3D
  54767. * @param data defines the data of the texture
  54768. * @param width defines the width of the texture
  54769. * @param height defines the height of the texture
  54770. * @param depth defines the depth of the texture
  54771. * @param format defines the texture format to use
  54772. * @param scene defines the hosting scene
  54773. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54774. * @param invertY defines if texture must be stored with Y axis inverted
  54775. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54776. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54777. */
  54778. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54779. /** Gets or sets the texture format to use */
  54780. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54781. /**
  54782. * Update the texture with new data
  54783. * @param data defines the data to store in the texture
  54784. */
  54785. update(data: ArrayBufferView): void;
  54786. }
  54787. }
  54788. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54789. import { Scene } from "babylonjs/scene";
  54790. import { Plane } from "babylonjs/Maths/math.plane";
  54791. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54792. /**
  54793. * Creates a refraction texture used by refraction channel of the standard material.
  54794. * It is like a mirror but to see through a material.
  54795. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54796. */
  54797. export class RefractionTexture extends RenderTargetTexture {
  54798. /**
  54799. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54800. * 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.
  54801. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54802. */
  54803. refractionPlane: Plane;
  54804. /**
  54805. * Define how deep under the surface we should see.
  54806. */
  54807. depth: number;
  54808. /**
  54809. * Creates a refraction texture used by refraction channel of the standard material.
  54810. * It is like a mirror but to see through a material.
  54811. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54812. * @param name Define the texture name
  54813. * @param size Define the size of the underlying texture
  54814. * @param scene Define the scene the refraction belongs to
  54815. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54816. */
  54817. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54818. /**
  54819. * Clone the refraction texture.
  54820. * @returns the cloned texture
  54821. */
  54822. clone(): RefractionTexture;
  54823. /**
  54824. * Serialize the texture to a JSON representation you could use in Parse later on
  54825. * @returns the serialized JSON representation
  54826. */
  54827. serialize(): any;
  54828. }
  54829. }
  54830. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54831. import { Nullable } from "babylonjs/types";
  54832. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54833. import { Matrix } from "babylonjs/Maths/math.vector";
  54834. import { Engine } from "babylonjs/Engines/engine";
  54835. import { Scene } from "babylonjs/scene";
  54836. /**
  54837. * Defines the options related to the creation of an HtmlElementTexture
  54838. */
  54839. export interface IHtmlElementTextureOptions {
  54840. /**
  54841. * Defines wether mip maps should be created or not.
  54842. */
  54843. generateMipMaps?: boolean;
  54844. /**
  54845. * Defines the sampling mode of the texture.
  54846. */
  54847. samplingMode?: number;
  54848. /**
  54849. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54850. */
  54851. engine: Nullable<Engine>;
  54852. /**
  54853. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54854. */
  54855. scene: Nullable<Scene>;
  54856. }
  54857. /**
  54858. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54859. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54860. * is automatically managed.
  54861. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54862. * in your application.
  54863. *
  54864. * As the update is not automatic, you need to call them manually.
  54865. */
  54866. export class HtmlElementTexture extends BaseTexture {
  54867. /**
  54868. * The texture URL.
  54869. */
  54870. element: HTMLVideoElement | HTMLCanvasElement;
  54871. private static readonly DefaultOptions;
  54872. private _textureMatrix;
  54873. private _engine;
  54874. private _isVideo;
  54875. private _generateMipMaps;
  54876. private _samplingMode;
  54877. /**
  54878. * Instantiates a HtmlElementTexture from the following parameters.
  54879. *
  54880. * @param name Defines the name of the texture
  54881. * @param element Defines the video or canvas the texture is filled with
  54882. * @param options Defines the other none mandatory texture creation options
  54883. */
  54884. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54885. private _createInternalTexture;
  54886. /**
  54887. * Returns the texture matrix used in most of the material.
  54888. */
  54889. getTextureMatrix(): Matrix;
  54890. /**
  54891. * Updates the content of the texture.
  54892. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54893. */
  54894. update(invertY?: Nullable<boolean>): void;
  54895. }
  54896. }
  54897. declare module "babylonjs/Materials/Textures/index" {
  54898. export * from "babylonjs/Materials/Textures/baseTexture";
  54899. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54900. export * from "babylonjs/Materials/Textures/cubeTexture";
  54901. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54902. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54903. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54904. export * from "babylonjs/Materials/Textures/internalTexture";
  54905. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54906. export * from "babylonjs/Materials/Textures/Loaders/index";
  54907. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54908. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54909. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54910. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54911. export * from "babylonjs/Materials/Textures/rawTexture";
  54912. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54913. export * from "babylonjs/Materials/Textures/refractionTexture";
  54914. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54915. export * from "babylonjs/Materials/Textures/texture";
  54916. export * from "babylonjs/Materials/Textures/videoTexture";
  54917. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54918. }
  54919. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54920. /**
  54921. * Enum used to define the target of a block
  54922. */
  54923. export enum NodeMaterialBlockTargets {
  54924. /** Vertex shader */
  54925. Vertex = 1,
  54926. /** Fragment shader */
  54927. Fragment = 2,
  54928. /** Neutral */
  54929. Neutral = 4,
  54930. /** Vertex and Fragment */
  54931. VertexAndFragment = 3
  54932. }
  54933. }
  54934. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54935. /**
  54936. * Defines the kind of connection point for node based material
  54937. */
  54938. export enum NodeMaterialBlockConnectionPointTypes {
  54939. /** Float */
  54940. Float = 1,
  54941. /** Int */
  54942. Int = 2,
  54943. /** Vector2 */
  54944. Vector2 = 4,
  54945. /** Vector3 */
  54946. Vector3 = 8,
  54947. /** Vector4 */
  54948. Vector4 = 16,
  54949. /** Color3 */
  54950. Color3 = 32,
  54951. /** Color4 */
  54952. Color4 = 64,
  54953. /** Matrix */
  54954. Matrix = 128,
  54955. /** Detect type based on connection */
  54956. AutoDetect = 1024,
  54957. /** Output type that will be defined by input type */
  54958. BasedOnInput = 2048
  54959. }
  54960. }
  54961. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54962. /**
  54963. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54964. */
  54965. export enum NodeMaterialBlockConnectionPointMode {
  54966. /** Value is an uniform */
  54967. Uniform = 0,
  54968. /** Value is a mesh attribute */
  54969. Attribute = 1,
  54970. /** Value is a varying between vertex and fragment shaders */
  54971. Varying = 2,
  54972. /** Mode is undefined */
  54973. Undefined = 3
  54974. }
  54975. }
  54976. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54977. /**
  54978. * Enum used to define system values e.g. values automatically provided by the system
  54979. */
  54980. export enum NodeMaterialSystemValues {
  54981. /** World */
  54982. World = 1,
  54983. /** View */
  54984. View = 2,
  54985. /** Projection */
  54986. Projection = 3,
  54987. /** ViewProjection */
  54988. ViewProjection = 4,
  54989. /** WorldView */
  54990. WorldView = 5,
  54991. /** WorldViewProjection */
  54992. WorldViewProjection = 6,
  54993. /** CameraPosition */
  54994. CameraPosition = 7,
  54995. /** Fog Color */
  54996. FogColor = 8,
  54997. /** Delta time */
  54998. DeltaTime = 9
  54999. }
  55000. }
  55001. declare module "babylonjs/Materials/Node/Enums/index" {
  55002. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55003. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55004. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55005. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55006. }
  55007. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55009. /**
  55010. * Root class for all node material optimizers
  55011. */
  55012. export class NodeMaterialOptimizer {
  55013. /**
  55014. * Function used to optimize a NodeMaterial graph
  55015. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55016. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55017. */
  55018. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55019. }
  55020. }
  55021. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55025. import { Scene } from "babylonjs/scene";
  55026. /**
  55027. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55028. */
  55029. export class TransformBlock extends NodeMaterialBlock {
  55030. /**
  55031. * Defines the value to use to complement W value to transform it to a Vector4
  55032. */
  55033. complementW: number;
  55034. /**
  55035. * Defines the value to use to complement z value to transform it to a Vector4
  55036. */
  55037. complementZ: number;
  55038. /**
  55039. * Creates a new TransformBlock
  55040. * @param name defines the block name
  55041. */
  55042. constructor(name: string);
  55043. /**
  55044. * Gets the current class name
  55045. * @returns the class name
  55046. */
  55047. getClassName(): string;
  55048. /**
  55049. * Gets the vector input
  55050. */
  55051. readonly vector: NodeMaterialConnectionPoint;
  55052. /**
  55053. * Gets the output component
  55054. */
  55055. readonly output: NodeMaterialConnectionPoint;
  55056. /**
  55057. * Gets the matrix transform input
  55058. */
  55059. readonly transform: NodeMaterialConnectionPoint;
  55060. protected _buildBlock(state: NodeMaterialBuildState): this;
  55061. serialize(): any;
  55062. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55063. protected _dumpPropertiesCode(): string;
  55064. }
  55065. }
  55066. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55070. /**
  55071. * Block used to output the vertex position
  55072. */
  55073. export class VertexOutputBlock extends NodeMaterialBlock {
  55074. /**
  55075. * Creates a new VertexOutputBlock
  55076. * @param name defines the block name
  55077. */
  55078. constructor(name: string);
  55079. /**
  55080. * Gets the current class name
  55081. * @returns the class name
  55082. */
  55083. getClassName(): string;
  55084. /**
  55085. * Gets the vector input component
  55086. */
  55087. readonly vector: NodeMaterialConnectionPoint;
  55088. protected _buildBlock(state: NodeMaterialBuildState): this;
  55089. }
  55090. }
  55091. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55092. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55093. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55094. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55095. /**
  55096. * Block used to output the final color
  55097. */
  55098. export class FragmentOutputBlock extends NodeMaterialBlock {
  55099. /**
  55100. * Create a new FragmentOutputBlock
  55101. * @param name defines the block name
  55102. */
  55103. constructor(name: string);
  55104. /**
  55105. * Gets the current class name
  55106. * @returns the class name
  55107. */
  55108. getClassName(): string;
  55109. /**
  55110. * Gets the rgba input component
  55111. */
  55112. readonly rgba: NodeMaterialConnectionPoint;
  55113. /**
  55114. * Gets the rgb input component
  55115. */
  55116. readonly rgb: NodeMaterialConnectionPoint;
  55117. /**
  55118. * Gets the a input component
  55119. */
  55120. readonly a: NodeMaterialConnectionPoint;
  55121. protected _buildBlock(state: NodeMaterialBuildState): this;
  55122. }
  55123. }
  55124. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55130. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55131. import { Effect } from "babylonjs/Materials/effect";
  55132. import { Mesh } from "babylonjs/Meshes/mesh";
  55133. import { Nullable } from "babylonjs/types";
  55134. import { Scene } from "babylonjs/scene";
  55135. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55136. /**
  55137. * Block used to read a reflection texture from a sampler
  55138. */
  55139. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55140. private _define3DName;
  55141. private _defineCubicName;
  55142. private _defineExplicitName;
  55143. private _defineProjectionName;
  55144. private _defineLocalCubicName;
  55145. private _defineSphericalName;
  55146. private _definePlanarName;
  55147. private _defineEquirectangularName;
  55148. private _defineMirroredEquirectangularFixedName;
  55149. private _defineEquirectangularFixedName;
  55150. private _defineSkyboxName;
  55151. private _cubeSamplerName;
  55152. private _2DSamplerName;
  55153. private _positionUVWName;
  55154. private _directionWName;
  55155. private _reflectionCoordsName;
  55156. private _reflection2DCoordsName;
  55157. private _reflectionColorName;
  55158. private _reflectionMatrixName;
  55159. /**
  55160. * Gets or sets the texture associated with the node
  55161. */
  55162. texture: Nullable<BaseTexture>;
  55163. /**
  55164. * Create a new TextureBlock
  55165. * @param name defines the block name
  55166. */
  55167. constructor(name: string);
  55168. /**
  55169. * Gets the current class name
  55170. * @returns the class name
  55171. */
  55172. getClassName(): string;
  55173. /**
  55174. * Gets the world position input component
  55175. */
  55176. readonly position: NodeMaterialConnectionPoint;
  55177. /**
  55178. * Gets the world position input component
  55179. */
  55180. readonly worldPosition: NodeMaterialConnectionPoint;
  55181. /**
  55182. * Gets the world normal input component
  55183. */
  55184. readonly worldNormal: NodeMaterialConnectionPoint;
  55185. /**
  55186. * Gets the world input component
  55187. */
  55188. readonly world: NodeMaterialConnectionPoint;
  55189. /**
  55190. * Gets the camera (or eye) position component
  55191. */
  55192. readonly cameraPosition: NodeMaterialConnectionPoint;
  55193. /**
  55194. * Gets the view input component
  55195. */
  55196. readonly view: NodeMaterialConnectionPoint;
  55197. /**
  55198. * Gets the rgb output component
  55199. */
  55200. readonly rgb: NodeMaterialConnectionPoint;
  55201. /**
  55202. * Gets the r output component
  55203. */
  55204. readonly r: NodeMaterialConnectionPoint;
  55205. /**
  55206. * Gets the g output component
  55207. */
  55208. readonly g: NodeMaterialConnectionPoint;
  55209. /**
  55210. * Gets the b output component
  55211. */
  55212. readonly b: NodeMaterialConnectionPoint;
  55213. autoConfigure(material: NodeMaterial): void;
  55214. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55215. isReady(): boolean;
  55216. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55217. private _injectVertexCode;
  55218. private _writeOutput;
  55219. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55220. serialize(): any;
  55221. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55222. }
  55223. }
  55224. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55225. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55226. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55227. import { Scene } from "babylonjs/scene";
  55228. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55229. import { Matrix } from "babylonjs/Maths/math.vector";
  55230. import { Mesh } from "babylonjs/Meshes/mesh";
  55231. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55232. import { Observable } from "babylonjs/Misc/observable";
  55233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55234. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55235. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55236. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55237. import { Nullable } from "babylonjs/types";
  55238. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55239. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55240. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55241. /**
  55242. * Interface used to configure the node material editor
  55243. */
  55244. export interface INodeMaterialEditorOptions {
  55245. /** Define the URl to load node editor script */
  55246. editorURL?: string;
  55247. }
  55248. /** @hidden */
  55249. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55250. /** BONES */
  55251. NUM_BONE_INFLUENCERS: number;
  55252. BonesPerMesh: number;
  55253. BONETEXTURE: boolean;
  55254. /** MORPH TARGETS */
  55255. MORPHTARGETS: boolean;
  55256. MORPHTARGETS_NORMAL: boolean;
  55257. MORPHTARGETS_TANGENT: boolean;
  55258. MORPHTARGETS_UV: boolean;
  55259. NUM_MORPH_INFLUENCERS: number;
  55260. /** IMAGE PROCESSING */
  55261. IMAGEPROCESSING: boolean;
  55262. VIGNETTE: boolean;
  55263. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55264. VIGNETTEBLENDMODEOPAQUE: boolean;
  55265. TONEMAPPING: boolean;
  55266. TONEMAPPING_ACES: boolean;
  55267. CONTRAST: boolean;
  55268. EXPOSURE: boolean;
  55269. COLORCURVES: boolean;
  55270. COLORGRADING: boolean;
  55271. COLORGRADING3D: boolean;
  55272. SAMPLER3DGREENDEPTH: boolean;
  55273. SAMPLER3DBGRMAP: boolean;
  55274. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55275. /** MISC. */
  55276. BUMPDIRECTUV: number;
  55277. constructor();
  55278. setValue(name: string, value: boolean): void;
  55279. }
  55280. /**
  55281. * Class used to configure NodeMaterial
  55282. */
  55283. export interface INodeMaterialOptions {
  55284. /**
  55285. * Defines if blocks should emit comments
  55286. */
  55287. emitComments: boolean;
  55288. }
  55289. /**
  55290. * Class used to create a node based material built by assembling shader blocks
  55291. */
  55292. export class NodeMaterial extends PushMaterial {
  55293. private static _BuildIdGenerator;
  55294. private _options;
  55295. private _vertexCompilationState;
  55296. private _fragmentCompilationState;
  55297. private _sharedData;
  55298. private _buildId;
  55299. private _buildWasSuccessful;
  55300. private _cachedWorldViewMatrix;
  55301. private _cachedWorldViewProjectionMatrix;
  55302. private _optimizers;
  55303. private _animationFrame;
  55304. /** Define the URl to load node editor script */
  55305. static EditorURL: string;
  55306. private BJSNODEMATERIALEDITOR;
  55307. /** Get the inspector from bundle or global */
  55308. private _getGlobalNodeMaterialEditor;
  55309. /**
  55310. * 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)
  55311. */
  55312. ignoreAlpha: boolean;
  55313. /**
  55314. * Defines the maximum number of lights that can be used in the material
  55315. */
  55316. maxSimultaneousLights: number;
  55317. /**
  55318. * Observable raised when the material is built
  55319. */
  55320. onBuildObservable: Observable<NodeMaterial>;
  55321. /**
  55322. * Gets or sets the root nodes of the material vertex shader
  55323. */
  55324. _vertexOutputNodes: NodeMaterialBlock[];
  55325. /**
  55326. * Gets or sets the root nodes of the material fragment (pixel) shader
  55327. */
  55328. _fragmentOutputNodes: NodeMaterialBlock[];
  55329. /** Gets or sets options to control the node material overall behavior */
  55330. options: INodeMaterialOptions;
  55331. /**
  55332. * Default configuration related to image processing available in the standard Material.
  55333. */
  55334. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55335. /**
  55336. * Gets the image processing configuration used either in this material.
  55337. */
  55338. /**
  55339. * Sets the Default image processing configuration used either in the this material.
  55340. *
  55341. * If sets to null, the scene one is in use.
  55342. */
  55343. imageProcessingConfiguration: ImageProcessingConfiguration;
  55344. /**
  55345. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55346. */
  55347. attachedBlocks: NodeMaterialBlock[];
  55348. /**
  55349. * Create a new node based material
  55350. * @param name defines the material name
  55351. * @param scene defines the hosting scene
  55352. * @param options defines creation option
  55353. */
  55354. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55355. /**
  55356. * Gets the current class name of the material e.g. "NodeMaterial"
  55357. * @returns the class name
  55358. */
  55359. getClassName(): string;
  55360. /**
  55361. * Keep track of the image processing observer to allow dispose and replace.
  55362. */
  55363. private _imageProcessingObserver;
  55364. /**
  55365. * Attaches a new image processing configuration to the Standard Material.
  55366. * @param configuration
  55367. */
  55368. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55369. /**
  55370. * Get a block by its name
  55371. * @param name defines the name of the block to retrieve
  55372. * @returns the required block or null if not found
  55373. */
  55374. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55375. /**
  55376. * Get a block by its name
  55377. * @param predicate defines the predicate used to find the good candidate
  55378. * @returns the required block or null if not found
  55379. */
  55380. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55381. /**
  55382. * Get an input block by its name
  55383. * @param predicate defines the predicate used to find the good candidate
  55384. * @returns the required input block or null if not found
  55385. */
  55386. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55387. /**
  55388. * Gets the list of input blocks attached to this material
  55389. * @returns an array of InputBlocks
  55390. */
  55391. getInputBlocks(): InputBlock[];
  55392. /**
  55393. * Adds a new optimizer to the list of optimizers
  55394. * @param optimizer defines the optimizers to add
  55395. * @returns the current material
  55396. */
  55397. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55398. /**
  55399. * Remove an optimizer from the list of optimizers
  55400. * @param optimizer defines the optimizers to remove
  55401. * @returns the current material
  55402. */
  55403. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55404. /**
  55405. * Add a new block to the list of output nodes
  55406. * @param node defines the node to add
  55407. * @returns the current material
  55408. */
  55409. addOutputNode(node: NodeMaterialBlock): this;
  55410. /**
  55411. * Remove a block from the list of root nodes
  55412. * @param node defines the node to remove
  55413. * @returns the current material
  55414. */
  55415. removeOutputNode(node: NodeMaterialBlock): this;
  55416. private _addVertexOutputNode;
  55417. private _removeVertexOutputNode;
  55418. private _addFragmentOutputNode;
  55419. private _removeFragmentOutputNode;
  55420. /**
  55421. * Specifies if the material will require alpha blending
  55422. * @returns a boolean specifying if alpha blending is needed
  55423. */
  55424. needAlphaBlending(): boolean;
  55425. /**
  55426. * Specifies if this material should be rendered in alpha test mode
  55427. * @returns a boolean specifying if an alpha test is needed.
  55428. */
  55429. needAlphaTesting(): boolean;
  55430. private _initializeBlock;
  55431. private _resetDualBlocks;
  55432. /**
  55433. * Build the material and generates the inner effect
  55434. * @param verbose defines if the build should log activity
  55435. */
  55436. build(verbose?: boolean): void;
  55437. /**
  55438. * Runs an otpimization phase to try to improve the shader code
  55439. */
  55440. optimize(): void;
  55441. private _prepareDefinesForAttributes;
  55442. /**
  55443. * Get if the submesh is ready to be used and all its information available.
  55444. * Child classes can use it to update shaders
  55445. * @param mesh defines the mesh to check
  55446. * @param subMesh defines which submesh to check
  55447. * @param useInstances specifies that instances should be used
  55448. * @returns a boolean indicating that the submesh is ready or not
  55449. */
  55450. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55451. /**
  55452. * Get a string representing the shaders built by the current node graph
  55453. */
  55454. readonly compiledShaders: string;
  55455. /**
  55456. * Binds the world matrix to the material
  55457. * @param world defines the world transformation matrix
  55458. */
  55459. bindOnlyWorldMatrix(world: Matrix): void;
  55460. /**
  55461. * Binds the submesh to this material by preparing the effect and shader to draw
  55462. * @param world defines the world transformation matrix
  55463. * @param mesh defines the mesh containing the submesh
  55464. * @param subMesh defines the submesh to bind the material to
  55465. */
  55466. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55467. /**
  55468. * Gets the active textures from the material
  55469. * @returns an array of textures
  55470. */
  55471. getActiveTextures(): BaseTexture[];
  55472. /**
  55473. * Gets the list of texture blocks
  55474. * @returns an array of texture blocks
  55475. */
  55476. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55477. /**
  55478. * Specifies if the material uses a texture
  55479. * @param texture defines the texture to check against the material
  55480. * @returns a boolean specifying if the material uses the texture
  55481. */
  55482. hasTexture(texture: BaseTexture): boolean;
  55483. /**
  55484. * Disposes the material
  55485. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55486. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55487. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55488. */
  55489. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55490. /** Creates the node editor window. */
  55491. private _createNodeEditor;
  55492. /**
  55493. * Launch the node material editor
  55494. * @param config Define the configuration of the editor
  55495. * @return a promise fulfilled when the node editor is visible
  55496. */
  55497. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55498. /**
  55499. * Clear the current material
  55500. */
  55501. clear(): void;
  55502. /**
  55503. * Clear the current material and set it to a default state
  55504. */
  55505. setToDefault(): void;
  55506. /**
  55507. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55508. * @param url defines the url to load from
  55509. * @returns a promise that will fullfil when the material is fully loaded
  55510. */
  55511. loadAsync(url: string): Promise<unknown>;
  55512. private _gatherBlocks;
  55513. /**
  55514. * Generate a string containing the code declaration required to create an equivalent of this material
  55515. * @returns a string
  55516. */
  55517. generateCode(): string;
  55518. /**
  55519. * Serializes this material in a JSON representation
  55520. * @returns the serialized material object
  55521. */
  55522. serialize(): any;
  55523. private _restoreConnections;
  55524. /**
  55525. * Clear the current graph and load a new one from a serialization object
  55526. * @param source defines the JSON representation of the material
  55527. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55528. */
  55529. loadFromSerialization(source: any, rootUrl?: string): void;
  55530. /**
  55531. * Creates a node material from parsed material data
  55532. * @param source defines the JSON representation of the material
  55533. * @param scene defines the hosting scene
  55534. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55535. * @returns a new node material
  55536. */
  55537. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55538. /**
  55539. * Creates a new node material set to default basic configuration
  55540. * @param name defines the name of the material
  55541. * @param scene defines the hosting scene
  55542. * @returns a new NodeMaterial
  55543. */
  55544. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55545. }
  55546. }
  55547. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55550. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55553. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55554. import { Effect } from "babylonjs/Materials/effect";
  55555. import { Mesh } from "babylonjs/Meshes/mesh";
  55556. import { Nullable } from "babylonjs/types";
  55557. import { Texture } from "babylonjs/Materials/Textures/texture";
  55558. import { Scene } from "babylonjs/scene";
  55559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55560. /**
  55561. * Block used to read a texture from a sampler
  55562. */
  55563. export class TextureBlock extends NodeMaterialBlock {
  55564. private _defineName;
  55565. private _linearDefineName;
  55566. private _samplerName;
  55567. private _transformedUVName;
  55568. private _textureTransformName;
  55569. private _textureInfoName;
  55570. private _mainUVName;
  55571. private _mainUVDefineName;
  55572. /**
  55573. * Gets or sets the texture associated with the node
  55574. */
  55575. texture: Nullable<Texture>;
  55576. /**
  55577. * Create a new TextureBlock
  55578. * @param name defines the block name
  55579. */
  55580. constructor(name: string);
  55581. /**
  55582. * Gets the current class name
  55583. * @returns the class name
  55584. */
  55585. getClassName(): string;
  55586. /**
  55587. * Gets the uv input component
  55588. */
  55589. readonly uv: NodeMaterialConnectionPoint;
  55590. /**
  55591. * Gets the rgba output component
  55592. */
  55593. readonly rgba: NodeMaterialConnectionPoint;
  55594. /**
  55595. * Gets the rgb output component
  55596. */
  55597. readonly rgb: NodeMaterialConnectionPoint;
  55598. /**
  55599. * Gets the r output component
  55600. */
  55601. readonly r: NodeMaterialConnectionPoint;
  55602. /**
  55603. * Gets the g output component
  55604. */
  55605. readonly g: NodeMaterialConnectionPoint;
  55606. /**
  55607. * Gets the b output component
  55608. */
  55609. readonly b: NodeMaterialConnectionPoint;
  55610. /**
  55611. * Gets the a output component
  55612. */
  55613. readonly a: NodeMaterialConnectionPoint;
  55614. readonly target: NodeMaterialBlockTargets;
  55615. autoConfigure(material: NodeMaterial): void;
  55616. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55618. isReady(): boolean;
  55619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55620. private readonly _isMixed;
  55621. private _injectVertexCode;
  55622. private _writeOutput;
  55623. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55624. protected _dumpPropertiesCode(): string;
  55625. serialize(): any;
  55626. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55627. }
  55628. }
  55629. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55632. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55633. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55634. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55635. import { Scene } from "babylonjs/scene";
  55636. /**
  55637. * Class used to store shared data between 2 NodeMaterialBuildState
  55638. */
  55639. export class NodeMaterialBuildStateSharedData {
  55640. /**
  55641. * Gets the list of emitted varyings
  55642. */
  55643. temps: string[];
  55644. /**
  55645. * Gets the list of emitted varyings
  55646. */
  55647. varyings: string[];
  55648. /**
  55649. * Gets the varying declaration string
  55650. */
  55651. varyingDeclaration: string;
  55652. /**
  55653. * Input blocks
  55654. */
  55655. inputBlocks: InputBlock[];
  55656. /**
  55657. * Input blocks
  55658. */
  55659. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55660. /**
  55661. * Bindable blocks (Blocks that need to set data to the effect)
  55662. */
  55663. bindableBlocks: NodeMaterialBlock[];
  55664. /**
  55665. * List of blocks that can provide a compilation fallback
  55666. */
  55667. blocksWithFallbacks: NodeMaterialBlock[];
  55668. /**
  55669. * List of blocks that can provide a define update
  55670. */
  55671. blocksWithDefines: NodeMaterialBlock[];
  55672. /**
  55673. * List of blocks that can provide a repeatable content
  55674. */
  55675. repeatableContentBlocks: NodeMaterialBlock[];
  55676. /**
  55677. * List of blocks that can provide a dynamic list of uniforms
  55678. */
  55679. dynamicUniformBlocks: NodeMaterialBlock[];
  55680. /**
  55681. * List of blocks that can block the isReady function for the material
  55682. */
  55683. blockingBlocks: NodeMaterialBlock[];
  55684. /**
  55685. * Gets the list of animated inputs
  55686. */
  55687. animatedInputs: InputBlock[];
  55688. /**
  55689. * Build Id used to avoid multiple recompilations
  55690. */
  55691. buildId: number;
  55692. /** List of emitted variables */
  55693. variableNames: {
  55694. [key: string]: number;
  55695. };
  55696. /** List of emitted defines */
  55697. defineNames: {
  55698. [key: string]: number;
  55699. };
  55700. /** Should emit comments? */
  55701. emitComments: boolean;
  55702. /** Emit build activity */
  55703. verbose: boolean;
  55704. /** Gets or sets the hosting scene */
  55705. scene: Scene;
  55706. /**
  55707. * Gets the compilation hints emitted at compilation time
  55708. */
  55709. hints: {
  55710. needWorldViewMatrix: boolean;
  55711. needWorldViewProjectionMatrix: boolean;
  55712. needAlphaBlending: boolean;
  55713. needAlphaTesting: boolean;
  55714. };
  55715. /**
  55716. * List of compilation checks
  55717. */
  55718. checks: {
  55719. emitVertex: boolean;
  55720. emitFragment: boolean;
  55721. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55722. };
  55723. /** Creates a new shared data */
  55724. constructor();
  55725. /**
  55726. * Emits console errors and exceptions if there is a failing check
  55727. */
  55728. emitErrors(): void;
  55729. }
  55730. }
  55731. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55732. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55733. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55734. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55735. /**
  55736. * Class used to store node based material build state
  55737. */
  55738. export class NodeMaterialBuildState {
  55739. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55740. supportUniformBuffers: boolean;
  55741. /**
  55742. * Gets the list of emitted attributes
  55743. */
  55744. attributes: string[];
  55745. /**
  55746. * Gets the list of emitted uniforms
  55747. */
  55748. uniforms: string[];
  55749. /**
  55750. * Gets the list of emitted constants
  55751. */
  55752. constants: string[];
  55753. /**
  55754. * Gets the list of emitted uniform buffers
  55755. */
  55756. uniformBuffers: string[];
  55757. /**
  55758. * Gets the list of emitted samplers
  55759. */
  55760. samplers: string[];
  55761. /**
  55762. * Gets the list of emitted functions
  55763. */
  55764. functions: {
  55765. [key: string]: string;
  55766. };
  55767. /**
  55768. * Gets the list of emitted extensions
  55769. */
  55770. extensions: {
  55771. [key: string]: string;
  55772. };
  55773. /**
  55774. * Gets the target of the compilation state
  55775. */
  55776. target: NodeMaterialBlockTargets;
  55777. /**
  55778. * Gets the list of emitted counters
  55779. */
  55780. counters: {
  55781. [key: string]: number;
  55782. };
  55783. /**
  55784. * Shared data between multiple NodeMaterialBuildState instances
  55785. */
  55786. sharedData: NodeMaterialBuildStateSharedData;
  55787. /** @hidden */
  55788. _vertexState: NodeMaterialBuildState;
  55789. /** @hidden */
  55790. _attributeDeclaration: string;
  55791. /** @hidden */
  55792. _uniformDeclaration: string;
  55793. /** @hidden */
  55794. _constantDeclaration: string;
  55795. /** @hidden */
  55796. _samplerDeclaration: string;
  55797. /** @hidden */
  55798. _varyingTransfer: string;
  55799. private _repeatableContentAnchorIndex;
  55800. /** @hidden */
  55801. _builtCompilationString: string;
  55802. /**
  55803. * Gets the emitted compilation strings
  55804. */
  55805. compilationString: string;
  55806. /**
  55807. * Finalize the compilation strings
  55808. * @param state defines the current compilation state
  55809. */
  55810. finalize(state: NodeMaterialBuildState): void;
  55811. /** @hidden */
  55812. readonly _repeatableContentAnchor: string;
  55813. /** @hidden */
  55814. _getFreeVariableName(prefix: string): string;
  55815. /** @hidden */
  55816. _getFreeDefineName(prefix: string): string;
  55817. /** @hidden */
  55818. _excludeVariableName(name: string): void;
  55819. /** @hidden */
  55820. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55821. /** @hidden */
  55822. _emitExtension(name: string, extension: string): void;
  55823. /** @hidden */
  55824. _emitFunction(name: string, code: string, comments: string): void;
  55825. /** @hidden */
  55826. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55827. replaceStrings?: {
  55828. search: RegExp;
  55829. replace: string;
  55830. }[];
  55831. repeatKey?: string;
  55832. }): string;
  55833. /** @hidden */
  55834. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55835. repeatKey?: string;
  55836. removeAttributes?: boolean;
  55837. removeUniforms?: boolean;
  55838. removeVaryings?: boolean;
  55839. removeIfDef?: boolean;
  55840. replaceStrings?: {
  55841. search: RegExp;
  55842. replace: string;
  55843. }[];
  55844. }, storeKey?: string): void;
  55845. /** @hidden */
  55846. _registerTempVariable(name: string): boolean;
  55847. /** @hidden */
  55848. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55849. /** @hidden */
  55850. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55851. /** @hidden */
  55852. _emitFloat(value: number): string;
  55853. }
  55854. }
  55855. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55856. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55858. import { Nullable } from "babylonjs/types";
  55859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55860. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55861. import { Effect } from "babylonjs/Materials/effect";
  55862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55863. import { Mesh } from "babylonjs/Meshes/mesh";
  55864. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55865. import { Scene } from "babylonjs/scene";
  55866. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55867. /**
  55868. * Defines a block that can be used inside a node based material
  55869. */
  55870. export class NodeMaterialBlock {
  55871. private _buildId;
  55872. private _buildTarget;
  55873. private _target;
  55874. private _isFinalMerger;
  55875. private _isInput;
  55876. /** @hidden */
  55877. _codeVariableName: string;
  55878. /** @hidden */
  55879. _inputs: NodeMaterialConnectionPoint[];
  55880. /** @hidden */
  55881. _outputs: NodeMaterialConnectionPoint[];
  55882. /** @hidden */
  55883. _preparationId: number;
  55884. /**
  55885. * Gets or sets the name of the block
  55886. */
  55887. name: string;
  55888. /**
  55889. * Gets or sets the unique id of the node
  55890. */
  55891. uniqueId: number;
  55892. /**
  55893. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55894. */
  55895. readonly isFinalMerger: boolean;
  55896. /**
  55897. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55898. */
  55899. readonly isInput: boolean;
  55900. /**
  55901. * Gets or sets the build Id
  55902. */
  55903. buildId: number;
  55904. /**
  55905. * Gets or sets the target of the block
  55906. */
  55907. target: NodeMaterialBlockTargets;
  55908. /**
  55909. * Gets the list of input points
  55910. */
  55911. readonly inputs: NodeMaterialConnectionPoint[];
  55912. /** Gets the list of output points */
  55913. readonly outputs: NodeMaterialConnectionPoint[];
  55914. /**
  55915. * Find an input by its name
  55916. * @param name defines the name of the input to look for
  55917. * @returns the input or null if not found
  55918. */
  55919. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55920. /**
  55921. * Find an output by its name
  55922. * @param name defines the name of the outputto look for
  55923. * @returns the output or null if not found
  55924. */
  55925. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55926. /**
  55927. * Creates a new NodeMaterialBlock
  55928. * @param name defines the block name
  55929. * @param target defines the target of that block (Vertex by default)
  55930. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55931. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55932. */
  55933. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55934. /**
  55935. * Initialize the block and prepare the context for build
  55936. * @param state defines the state that will be used for the build
  55937. */
  55938. initialize(state: NodeMaterialBuildState): void;
  55939. /**
  55940. * Bind data to effect. Will only be called for blocks with isBindable === true
  55941. * @param effect defines the effect to bind data to
  55942. * @param nodeMaterial defines the hosting NodeMaterial
  55943. * @param mesh defines the mesh that will be rendered
  55944. */
  55945. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55946. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55947. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55948. protected _writeFloat(value: number): string;
  55949. /**
  55950. * Gets the current class name e.g. "NodeMaterialBlock"
  55951. * @returns the class name
  55952. */
  55953. getClassName(): string;
  55954. /**
  55955. * Register a new input. Must be called inside a block constructor
  55956. * @param name defines the connection point name
  55957. * @param type defines the connection point type
  55958. * @param isOptional defines a boolean indicating that this input can be omitted
  55959. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55960. * @returns the current block
  55961. */
  55962. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55963. /**
  55964. * Register a new output. Must be called inside a block constructor
  55965. * @param name defines the connection point name
  55966. * @param type defines the connection point type
  55967. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55968. * @returns the current block
  55969. */
  55970. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55971. /**
  55972. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55973. * @param forOutput defines an optional connection point to check compatibility with
  55974. * @returns the first available input or null
  55975. */
  55976. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55977. /**
  55978. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55979. * @param forBlock defines an optional block to check compatibility with
  55980. * @returns the first available input or null
  55981. */
  55982. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55983. /**
  55984. * Gets the sibling of the given output
  55985. * @param current defines the current output
  55986. * @returns the next output in the list or null
  55987. */
  55988. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55989. /**
  55990. * Connect current block with another block
  55991. * @param other defines the block to connect with
  55992. * @param options define the various options to help pick the right connections
  55993. * @returns the current block
  55994. */
  55995. connectTo(other: NodeMaterialBlock, options?: {
  55996. input?: string;
  55997. output?: string;
  55998. outputSwizzle?: string;
  55999. }): this | undefined;
  56000. protected _buildBlock(state: NodeMaterialBuildState): void;
  56001. /**
  56002. * Add uniforms, samplers and uniform buffers at compilation time
  56003. * @param state defines the state to update
  56004. * @param nodeMaterial defines the node material requesting the update
  56005. * @param defines defines the material defines to update
  56006. */
  56007. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56008. /**
  56009. * Add potential fallbacks if shader compilation fails
  56010. * @param mesh defines the mesh to be rendered
  56011. * @param fallbacks defines the current prioritized list of fallbacks
  56012. */
  56013. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56014. /**
  56015. * Initialize defines for shader compilation
  56016. * @param mesh defines the mesh to be rendered
  56017. * @param nodeMaterial defines the node material requesting the update
  56018. * @param defines defines the material defines to update
  56019. * @param useInstances specifies that instances should be used
  56020. */
  56021. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56022. /**
  56023. * Update defines for shader compilation
  56024. * @param mesh defines the mesh to be rendered
  56025. * @param nodeMaterial defines the node material requesting the update
  56026. * @param defines defines the material defines to update
  56027. * @param useInstances specifies that instances should be used
  56028. */
  56029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56030. /**
  56031. * Lets the block try to connect some inputs automatically
  56032. * @param material defines the hosting NodeMaterial
  56033. */
  56034. autoConfigure(material: NodeMaterial): void;
  56035. /**
  56036. * Function called when a block is declared as repeatable content generator
  56037. * @param vertexShaderState defines the current compilation state for the vertex shader
  56038. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56039. * @param mesh defines the mesh to be rendered
  56040. * @param defines defines the material defines to update
  56041. */
  56042. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56043. /**
  56044. * Checks if the block is ready
  56045. * @param mesh defines the mesh to be rendered
  56046. * @param nodeMaterial defines the node material requesting the update
  56047. * @param defines defines the material defines to update
  56048. * @param useInstances specifies that instances should be used
  56049. * @returns true if the block is ready
  56050. */
  56051. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56052. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56053. private _processBuild;
  56054. /**
  56055. * Compile the current node and generate the shader code
  56056. * @param state defines the current compilation state (uniforms, samplers, current string)
  56057. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56058. * @returns true if already built
  56059. */
  56060. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56061. protected _inputRename(name: string): string;
  56062. protected _outputRename(name: string): string;
  56063. protected _dumpPropertiesCode(): string;
  56064. /** @hidden */
  56065. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56066. /**
  56067. * Clone the current block to a new identical block
  56068. * @param scene defines the hosting scene
  56069. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56070. * @returns a copy of the current block
  56071. */
  56072. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56073. /**
  56074. * Serializes this block in a JSON representation
  56075. * @returns the serialized block object
  56076. */
  56077. serialize(): any;
  56078. /** @hidden */
  56079. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56080. }
  56081. }
  56082. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56083. /**
  56084. * Enum defining the type of animations supported by InputBlock
  56085. */
  56086. export enum AnimatedInputBlockTypes {
  56087. /** No animation */
  56088. None = 0,
  56089. /** Time based animation. Will only work for floats */
  56090. Time = 1
  56091. }
  56092. }
  56093. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56095. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56096. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56097. import { Nullable } from "babylonjs/types";
  56098. import { Effect } from "babylonjs/Materials/effect";
  56099. import { Matrix } from "babylonjs/Maths/math.vector";
  56100. import { Scene } from "babylonjs/scene";
  56101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56103. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56104. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56105. /**
  56106. * Block used to expose an input value
  56107. */
  56108. export class InputBlock extends NodeMaterialBlock {
  56109. private _mode;
  56110. private _associatedVariableName;
  56111. private _storedValue;
  56112. private _valueCallback;
  56113. private _type;
  56114. private _animationType;
  56115. /** Gets or set a value used to limit the range of float values */
  56116. min: number;
  56117. /** Gets or set a value used to limit the range of float values */
  56118. max: number;
  56119. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56120. matrixMode: number;
  56121. /** @hidden */
  56122. _systemValue: Nullable<NodeMaterialSystemValues>;
  56123. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56124. visibleInInspector: boolean;
  56125. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56126. isConstant: boolean;
  56127. /**
  56128. * Gets or sets the connection point type (default is float)
  56129. */
  56130. readonly type: NodeMaterialBlockConnectionPointTypes;
  56131. /**
  56132. * Creates a new InputBlock
  56133. * @param name defines the block name
  56134. * @param target defines the target of that block (Vertex by default)
  56135. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56136. */
  56137. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56138. /**
  56139. * Gets the output component
  56140. */
  56141. readonly output: NodeMaterialConnectionPoint;
  56142. /**
  56143. * Set the source of this connection point to a vertex attribute
  56144. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56145. * @returns the current connection point
  56146. */
  56147. setAsAttribute(attributeName?: string): InputBlock;
  56148. /**
  56149. * Set the source of this connection point to a system value
  56150. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56151. * @returns the current connection point
  56152. */
  56153. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56154. /**
  56155. * Gets or sets the value of that point.
  56156. * Please note that this value will be ignored if valueCallback is defined
  56157. */
  56158. value: any;
  56159. /**
  56160. * Gets or sets a callback used to get the value of that point.
  56161. * Please note that setting this value will force the connection point to ignore the value property
  56162. */
  56163. valueCallback: () => any;
  56164. /**
  56165. * Gets or sets the associated variable name in the shader
  56166. */
  56167. associatedVariableName: string;
  56168. /** Gets or sets the type of animation applied to the input */
  56169. animationType: AnimatedInputBlockTypes;
  56170. /**
  56171. * Gets a boolean indicating that this connection point not defined yet
  56172. */
  56173. readonly isUndefined: boolean;
  56174. /**
  56175. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56176. * In this case the connection point name must be the name of the uniform to use.
  56177. * Can only be set on inputs
  56178. */
  56179. isUniform: boolean;
  56180. /**
  56181. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56182. * In this case the connection point name must be the name of the attribute to use
  56183. * Can only be set on inputs
  56184. */
  56185. isAttribute: boolean;
  56186. /**
  56187. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56188. * Can only be set on exit points
  56189. */
  56190. isVarying: boolean;
  56191. /**
  56192. * Gets a boolean indicating that the current connection point is a system value
  56193. */
  56194. readonly isSystemValue: boolean;
  56195. /**
  56196. * Gets or sets the current well known value or null if not defined as a system value
  56197. */
  56198. systemValue: Nullable<NodeMaterialSystemValues>;
  56199. /**
  56200. * Gets the current class name
  56201. * @returns the class name
  56202. */
  56203. getClassName(): string;
  56204. /**
  56205. * Animate the input if animationType !== None
  56206. * @param scene defines the rendering scene
  56207. */
  56208. animate(scene: Scene): void;
  56209. private _emitDefine;
  56210. initialize(state: NodeMaterialBuildState): void;
  56211. /**
  56212. * Set the input block to its default value (based on its type)
  56213. */
  56214. setDefaultValue(): void;
  56215. private _emitConstant;
  56216. private _emit;
  56217. /** @hidden */
  56218. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56219. /** @hidden */
  56220. _transmit(effect: Effect, scene: Scene): void;
  56221. protected _buildBlock(state: NodeMaterialBuildState): void;
  56222. protected _dumpPropertiesCode(): string;
  56223. serialize(): any;
  56224. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56225. }
  56226. }
  56227. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56228. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56229. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56230. import { Nullable } from "babylonjs/types";
  56231. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56232. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56233. /**
  56234. * Defines a connection point for a block
  56235. */
  56236. export class NodeMaterialConnectionPoint {
  56237. /** @hidden */
  56238. _ownerBlock: NodeMaterialBlock;
  56239. /** @hidden */
  56240. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56241. private _endpoints;
  56242. private _associatedVariableName;
  56243. /** @hidden */
  56244. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56245. /** @hidden */
  56246. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56247. private _type;
  56248. /** @hidden */
  56249. _enforceAssociatedVariableName: boolean;
  56250. /**
  56251. * Gets or sets the additional types supported by this connection point
  56252. */
  56253. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56254. /**
  56255. * Gets or sets the additional types excluded by this connection point
  56256. */
  56257. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56258. /**
  56259. * Gets or sets the associated variable name in the shader
  56260. */
  56261. associatedVariableName: string;
  56262. /**
  56263. * Gets or sets the connection point type (default is float)
  56264. */
  56265. type: NodeMaterialBlockConnectionPointTypes;
  56266. /**
  56267. * Gets or sets the connection point name
  56268. */
  56269. name: string;
  56270. /**
  56271. * Gets or sets a boolean indicating that this connection point can be omitted
  56272. */
  56273. isOptional: boolean;
  56274. /**
  56275. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56276. */
  56277. define: string;
  56278. /** Gets or sets the target of that connection point */
  56279. target: NodeMaterialBlockTargets;
  56280. /**
  56281. * Gets a boolean indicating that the current point is connected
  56282. */
  56283. readonly isConnected: boolean;
  56284. /**
  56285. * Gets a boolean indicating that the current point is connected to an input block
  56286. */
  56287. readonly isConnectedToInputBlock: boolean;
  56288. /**
  56289. * Gets a the connected input block (if any)
  56290. */
  56291. readonly connectInputBlock: Nullable<InputBlock>;
  56292. /** Get the other side of the connection (if any) */
  56293. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56294. /** Get the block that owns this connection point */
  56295. readonly ownerBlock: NodeMaterialBlock;
  56296. /** Get the block connected on the other side of this connection (if any) */
  56297. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56298. /** Get the block connected on the endpoints of this connection (if any) */
  56299. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56300. /** Gets the list of connected endpoints */
  56301. readonly endpoints: NodeMaterialConnectionPoint[];
  56302. /** Gets a boolean indicating if that output point is connected to at least one input */
  56303. readonly hasEndpoints: boolean;
  56304. /**
  56305. * Creates a new connection point
  56306. * @param name defines the connection point name
  56307. * @param ownerBlock defines the block hosting this connection point
  56308. */
  56309. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56310. /**
  56311. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56312. * @returns the class name
  56313. */
  56314. getClassName(): string;
  56315. /**
  56316. * Gets an boolean indicating if the current point can be connected to another point
  56317. * @param connectionPoint defines the other connection point
  56318. * @returns true if the connection is possible
  56319. */
  56320. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56321. /**
  56322. * Connect this point to another connection point
  56323. * @param connectionPoint defines the other connection point
  56324. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56325. * @returns the current connection point
  56326. */
  56327. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56328. /**
  56329. * Disconnect this point from one of his endpoint
  56330. * @param endpoint defines the other connection point
  56331. * @returns the current connection point
  56332. */
  56333. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56334. /**
  56335. * Serializes this point in a JSON representation
  56336. * @returns the serialized point object
  56337. */
  56338. serialize(): any;
  56339. }
  56340. }
  56341. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56344. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56345. import { Mesh } from "babylonjs/Meshes/mesh";
  56346. import { Effect } from "babylonjs/Materials/effect";
  56347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56348. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56349. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56350. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56351. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56352. /**
  56353. * Block used to add support for vertex skinning (bones)
  56354. */
  56355. export class BonesBlock extends NodeMaterialBlock {
  56356. /**
  56357. * Creates a new BonesBlock
  56358. * @param name defines the block name
  56359. */
  56360. constructor(name: string);
  56361. /**
  56362. * Initialize the block and prepare the context for build
  56363. * @param state defines the state that will be used for the build
  56364. */
  56365. initialize(state: NodeMaterialBuildState): void;
  56366. /**
  56367. * Gets the current class name
  56368. * @returns the class name
  56369. */
  56370. getClassName(): string;
  56371. /**
  56372. * Gets the matrix indices input component
  56373. */
  56374. readonly matricesIndices: NodeMaterialConnectionPoint;
  56375. /**
  56376. * Gets the matrix weights input component
  56377. */
  56378. readonly matricesWeights: NodeMaterialConnectionPoint;
  56379. /**
  56380. * Gets the extra matrix indices input component
  56381. */
  56382. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56383. /**
  56384. * Gets the extra matrix weights input component
  56385. */
  56386. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56387. /**
  56388. * Gets the world input component
  56389. */
  56390. readonly world: NodeMaterialConnectionPoint;
  56391. /**
  56392. * Gets the output component
  56393. */
  56394. readonly output: NodeMaterialConnectionPoint;
  56395. autoConfigure(material: NodeMaterial): void;
  56396. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56397. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56398. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56399. protected _buildBlock(state: NodeMaterialBuildState): this;
  56400. }
  56401. }
  56402. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56403. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56405. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56406. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56407. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56408. /**
  56409. * Block used to add support for instances
  56410. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56411. */
  56412. export class InstancesBlock extends NodeMaterialBlock {
  56413. /**
  56414. * Creates a new InstancesBlock
  56415. * @param name defines the block name
  56416. */
  56417. constructor(name: string);
  56418. /**
  56419. * Gets the current class name
  56420. * @returns the class name
  56421. */
  56422. getClassName(): string;
  56423. /**
  56424. * Gets the first world row input component
  56425. */
  56426. readonly world0: NodeMaterialConnectionPoint;
  56427. /**
  56428. * Gets the second world row input component
  56429. */
  56430. readonly world1: NodeMaterialConnectionPoint;
  56431. /**
  56432. * Gets the third world row input component
  56433. */
  56434. readonly world2: NodeMaterialConnectionPoint;
  56435. /**
  56436. * Gets the forth world row input component
  56437. */
  56438. readonly world3: NodeMaterialConnectionPoint;
  56439. /**
  56440. * Gets the world input component
  56441. */
  56442. readonly world: NodeMaterialConnectionPoint;
  56443. /**
  56444. * Gets the output component
  56445. */
  56446. readonly output: NodeMaterialConnectionPoint;
  56447. autoConfigure(material: NodeMaterial): void;
  56448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56449. protected _buildBlock(state: NodeMaterialBuildState): this;
  56450. }
  56451. }
  56452. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56453. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56454. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56457. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56458. import { Effect } from "babylonjs/Materials/effect";
  56459. import { Mesh } from "babylonjs/Meshes/mesh";
  56460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56461. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56462. /**
  56463. * Block used to add morph targets support to vertex shader
  56464. */
  56465. export class MorphTargetsBlock extends NodeMaterialBlock {
  56466. private _repeatableContentAnchor;
  56467. private _repeatebleContentGenerated;
  56468. /**
  56469. * Create a new MorphTargetsBlock
  56470. * @param name defines the block name
  56471. */
  56472. constructor(name: string);
  56473. /**
  56474. * Gets the current class name
  56475. * @returns the class name
  56476. */
  56477. getClassName(): string;
  56478. /**
  56479. * Gets the position input component
  56480. */
  56481. readonly position: NodeMaterialConnectionPoint;
  56482. /**
  56483. * Gets the normal input component
  56484. */
  56485. readonly normal: NodeMaterialConnectionPoint;
  56486. /**
  56487. * Gets the tangent input component
  56488. */
  56489. readonly tangent: NodeMaterialConnectionPoint;
  56490. /**
  56491. * Gets the tangent input component
  56492. */
  56493. readonly uv: NodeMaterialConnectionPoint;
  56494. /**
  56495. * Gets the position output component
  56496. */
  56497. readonly positionOutput: NodeMaterialConnectionPoint;
  56498. /**
  56499. * Gets the normal output component
  56500. */
  56501. readonly normalOutput: NodeMaterialConnectionPoint;
  56502. /**
  56503. * Gets the tangent output component
  56504. */
  56505. readonly tangentOutput: NodeMaterialConnectionPoint;
  56506. /**
  56507. * Gets the tangent output component
  56508. */
  56509. readonly uvOutput: NodeMaterialConnectionPoint;
  56510. initialize(state: NodeMaterialBuildState): void;
  56511. autoConfigure(material: NodeMaterial): void;
  56512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56513. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56514. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56515. protected _buildBlock(state: NodeMaterialBuildState): this;
  56516. }
  56517. }
  56518. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56522. import { Nullable } from "babylonjs/types";
  56523. import { Scene } from "babylonjs/scene";
  56524. import { Effect } from "babylonjs/Materials/effect";
  56525. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56526. import { Mesh } from "babylonjs/Meshes/mesh";
  56527. import { Light } from "babylonjs/Lights/light";
  56528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56529. /**
  56530. * Block used to get data information from a light
  56531. */
  56532. export class LightInformationBlock extends NodeMaterialBlock {
  56533. private _lightDataUniformName;
  56534. private _lightColorUniformName;
  56535. private _lightTypeDefineName;
  56536. /**
  56537. * Gets or sets the light associated with this block
  56538. */
  56539. light: Nullable<Light>;
  56540. /**
  56541. * Creates a new LightInformationBlock
  56542. * @param name defines the block name
  56543. */
  56544. constructor(name: string);
  56545. /**
  56546. * Gets the current class name
  56547. * @returns the class name
  56548. */
  56549. getClassName(): string;
  56550. /**
  56551. * Gets the world position input component
  56552. */
  56553. readonly worldPosition: NodeMaterialConnectionPoint;
  56554. /**
  56555. * Gets the direction output component
  56556. */
  56557. readonly direction: NodeMaterialConnectionPoint;
  56558. /**
  56559. * Gets the direction output component
  56560. */
  56561. readonly color: NodeMaterialConnectionPoint;
  56562. /**
  56563. * Gets the direction output component
  56564. */
  56565. readonly intensity: NodeMaterialConnectionPoint;
  56566. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56567. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56568. protected _buildBlock(state: NodeMaterialBuildState): this;
  56569. serialize(): any;
  56570. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56571. }
  56572. }
  56573. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56574. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56575. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56576. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56577. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56578. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56579. }
  56580. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56581. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56582. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56583. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56585. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56586. import { Effect } from "babylonjs/Materials/effect";
  56587. import { Mesh } from "babylonjs/Meshes/mesh";
  56588. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56589. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56590. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56591. /**
  56592. * Block used to add image processing support to fragment shader
  56593. */
  56594. export class ImageProcessingBlock extends NodeMaterialBlock {
  56595. /**
  56596. * Create a new ImageProcessingBlock
  56597. * @param name defines the block name
  56598. */
  56599. constructor(name: string);
  56600. /**
  56601. * Gets the current class name
  56602. * @returns the class name
  56603. */
  56604. getClassName(): string;
  56605. /**
  56606. * Gets the color input component
  56607. */
  56608. readonly color: NodeMaterialConnectionPoint;
  56609. /**
  56610. * Gets the output component
  56611. */
  56612. readonly output: NodeMaterialConnectionPoint;
  56613. /**
  56614. * Initialize the block and prepare the context for build
  56615. * @param state defines the state that will be used for the build
  56616. */
  56617. initialize(state: NodeMaterialBuildState): void;
  56618. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56620. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56621. protected _buildBlock(state: NodeMaterialBuildState): this;
  56622. }
  56623. }
  56624. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56628. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56630. import { Effect } from "babylonjs/Materials/effect";
  56631. import { Mesh } from "babylonjs/Meshes/mesh";
  56632. import { Scene } from "babylonjs/scene";
  56633. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56634. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56635. /**
  56636. * Block used to pertub normals based on a normal map
  56637. */
  56638. export class PerturbNormalBlock extends NodeMaterialBlock {
  56639. private _tangentSpaceParameterName;
  56640. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56641. invertX: boolean;
  56642. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56643. invertY: boolean;
  56644. /**
  56645. * Create a new PerturbNormalBlock
  56646. * @param name defines the block name
  56647. */
  56648. constructor(name: string);
  56649. /**
  56650. * Gets the current class name
  56651. * @returns the class name
  56652. */
  56653. getClassName(): string;
  56654. /**
  56655. * Gets the world position input component
  56656. */
  56657. readonly worldPosition: NodeMaterialConnectionPoint;
  56658. /**
  56659. * Gets the world normal input component
  56660. */
  56661. readonly worldNormal: NodeMaterialConnectionPoint;
  56662. /**
  56663. * Gets the uv input component
  56664. */
  56665. readonly uv: NodeMaterialConnectionPoint;
  56666. /**
  56667. * Gets the normal map color input component
  56668. */
  56669. readonly normalMapColor: NodeMaterialConnectionPoint;
  56670. /**
  56671. * Gets the strength input component
  56672. */
  56673. readonly strength: NodeMaterialConnectionPoint;
  56674. /**
  56675. * Gets the output component
  56676. */
  56677. readonly output: NodeMaterialConnectionPoint;
  56678. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56679. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56680. autoConfigure(material: NodeMaterial): void;
  56681. protected _buildBlock(state: NodeMaterialBuildState): this;
  56682. protected _dumpPropertiesCode(): string;
  56683. serialize(): any;
  56684. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56685. }
  56686. }
  56687. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56691. /**
  56692. * Block used to discard a pixel if a value is smaller than a cutoff
  56693. */
  56694. export class DiscardBlock extends NodeMaterialBlock {
  56695. /**
  56696. * Create a new DiscardBlock
  56697. * @param name defines the block name
  56698. */
  56699. constructor(name: string);
  56700. /**
  56701. * Gets the current class name
  56702. * @returns the class name
  56703. */
  56704. getClassName(): string;
  56705. /**
  56706. * Gets the color input component
  56707. */
  56708. readonly value: NodeMaterialConnectionPoint;
  56709. /**
  56710. * Gets the cutoff input component
  56711. */
  56712. readonly cutoff: NodeMaterialConnectionPoint;
  56713. protected _buildBlock(state: NodeMaterialBuildState): this;
  56714. }
  56715. }
  56716. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56717. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56718. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56719. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56720. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56721. }
  56722. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56725. import { Mesh } from "babylonjs/Meshes/mesh";
  56726. import { Effect } from "babylonjs/Materials/effect";
  56727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56729. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56730. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56731. /**
  56732. * Block used to add support for scene fog
  56733. */
  56734. export class FogBlock extends NodeMaterialBlock {
  56735. private _fogDistanceName;
  56736. private _fogParameters;
  56737. /**
  56738. * Create a new FogBlock
  56739. * @param name defines the block name
  56740. */
  56741. constructor(name: string);
  56742. /**
  56743. * Gets the current class name
  56744. * @returns the class name
  56745. */
  56746. getClassName(): string;
  56747. /**
  56748. * Gets the world position input component
  56749. */
  56750. readonly worldPosition: NodeMaterialConnectionPoint;
  56751. /**
  56752. * Gets the view input component
  56753. */
  56754. readonly view: NodeMaterialConnectionPoint;
  56755. /**
  56756. * Gets the color input component
  56757. */
  56758. readonly input: NodeMaterialConnectionPoint;
  56759. /**
  56760. * Gets the fog color input component
  56761. */
  56762. readonly fogColor: NodeMaterialConnectionPoint;
  56763. /**
  56764. * Gets the output component
  56765. */
  56766. readonly output: NodeMaterialConnectionPoint;
  56767. autoConfigure(material: NodeMaterial): void;
  56768. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56769. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56770. protected _buildBlock(state: NodeMaterialBuildState): this;
  56771. }
  56772. }
  56773. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56774. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56775. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56778. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56779. import { Effect } from "babylonjs/Materials/effect";
  56780. import { Mesh } from "babylonjs/Meshes/mesh";
  56781. import { Light } from "babylonjs/Lights/light";
  56782. import { Nullable } from "babylonjs/types";
  56783. import { Scene } from "babylonjs/scene";
  56784. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56785. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56786. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56787. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56788. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56789. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56790. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56791. /**
  56792. * Block used to add light in the fragment shader
  56793. */
  56794. export class LightBlock extends NodeMaterialBlock {
  56795. private _lightId;
  56796. /**
  56797. * Gets or sets the light associated with this block
  56798. */
  56799. light: Nullable<Light>;
  56800. /**
  56801. * Create a new LightBlock
  56802. * @param name defines the block name
  56803. */
  56804. constructor(name: string);
  56805. /**
  56806. * Gets the current class name
  56807. * @returns the class name
  56808. */
  56809. getClassName(): string;
  56810. /**
  56811. * Gets the world position input component
  56812. */
  56813. readonly worldPosition: NodeMaterialConnectionPoint;
  56814. /**
  56815. * Gets the world normal input component
  56816. */
  56817. readonly worldNormal: NodeMaterialConnectionPoint;
  56818. /**
  56819. * Gets the camera (or eye) position component
  56820. */
  56821. readonly cameraPosition: NodeMaterialConnectionPoint;
  56822. /**
  56823. * Gets the glossiness component
  56824. */
  56825. readonly glossiness: NodeMaterialConnectionPoint;
  56826. /**
  56827. * Gets the glossinness power component
  56828. */
  56829. readonly glossPower: NodeMaterialConnectionPoint;
  56830. /**
  56831. * Gets the diffuse color component
  56832. */
  56833. readonly diffuseColor: NodeMaterialConnectionPoint;
  56834. /**
  56835. * Gets the specular color component
  56836. */
  56837. readonly specularColor: NodeMaterialConnectionPoint;
  56838. /**
  56839. * Gets the diffuse output component
  56840. */
  56841. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56842. /**
  56843. * Gets the specular output component
  56844. */
  56845. readonly specularOutput: NodeMaterialConnectionPoint;
  56846. autoConfigure(material: NodeMaterial): void;
  56847. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56848. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56849. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56850. private _injectVertexCode;
  56851. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56852. serialize(): any;
  56853. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56854. }
  56855. }
  56856. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56857. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56858. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56859. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56860. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56861. }
  56862. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56863. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56864. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56865. }
  56866. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56870. /**
  56871. * Block used to multiply 2 values
  56872. */
  56873. export class MultiplyBlock extends NodeMaterialBlock {
  56874. /**
  56875. * Creates a new MultiplyBlock
  56876. * @param name defines the block name
  56877. */
  56878. constructor(name: string);
  56879. /**
  56880. * Gets the current class name
  56881. * @returns the class name
  56882. */
  56883. getClassName(): string;
  56884. /**
  56885. * Gets the left operand input component
  56886. */
  56887. readonly left: NodeMaterialConnectionPoint;
  56888. /**
  56889. * Gets the right operand input component
  56890. */
  56891. readonly right: NodeMaterialConnectionPoint;
  56892. /**
  56893. * Gets the output component
  56894. */
  56895. readonly output: NodeMaterialConnectionPoint;
  56896. protected _buildBlock(state: NodeMaterialBuildState): this;
  56897. }
  56898. }
  56899. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56903. /**
  56904. * Block used to add 2 vectors
  56905. */
  56906. export class AddBlock extends NodeMaterialBlock {
  56907. /**
  56908. * Creates a new AddBlock
  56909. * @param name defines the block name
  56910. */
  56911. constructor(name: string);
  56912. /**
  56913. * Gets the current class name
  56914. * @returns the class name
  56915. */
  56916. getClassName(): string;
  56917. /**
  56918. * Gets the left operand input component
  56919. */
  56920. readonly left: NodeMaterialConnectionPoint;
  56921. /**
  56922. * Gets the right operand input component
  56923. */
  56924. readonly right: NodeMaterialConnectionPoint;
  56925. /**
  56926. * Gets the output component
  56927. */
  56928. readonly output: NodeMaterialConnectionPoint;
  56929. protected _buildBlock(state: NodeMaterialBuildState): this;
  56930. }
  56931. }
  56932. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56933. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56934. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56936. /**
  56937. * Block used to scale a vector by a float
  56938. */
  56939. export class ScaleBlock extends NodeMaterialBlock {
  56940. /**
  56941. * Creates a new ScaleBlock
  56942. * @param name defines the block name
  56943. */
  56944. constructor(name: string);
  56945. /**
  56946. * Gets the current class name
  56947. * @returns the class name
  56948. */
  56949. getClassName(): string;
  56950. /**
  56951. * Gets the input component
  56952. */
  56953. readonly input: NodeMaterialConnectionPoint;
  56954. /**
  56955. * Gets the factor input component
  56956. */
  56957. readonly factor: NodeMaterialConnectionPoint;
  56958. /**
  56959. * Gets the output component
  56960. */
  56961. readonly output: NodeMaterialConnectionPoint;
  56962. protected _buildBlock(state: NodeMaterialBuildState): this;
  56963. }
  56964. }
  56965. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56966. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56967. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56968. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56969. import { Scene } from "babylonjs/scene";
  56970. /**
  56971. * Block used to clamp a float
  56972. */
  56973. export class ClampBlock extends NodeMaterialBlock {
  56974. /** Gets or sets the minimum range */
  56975. minimum: number;
  56976. /** Gets or sets the maximum range */
  56977. maximum: number;
  56978. /**
  56979. * Creates a new ClampBlock
  56980. * @param name defines the block name
  56981. */
  56982. constructor(name: string);
  56983. /**
  56984. * Gets the current class name
  56985. * @returns the class name
  56986. */
  56987. getClassName(): string;
  56988. /**
  56989. * Gets the value input component
  56990. */
  56991. readonly value: NodeMaterialConnectionPoint;
  56992. /**
  56993. * Gets the output component
  56994. */
  56995. readonly output: NodeMaterialConnectionPoint;
  56996. protected _buildBlock(state: NodeMaterialBuildState): this;
  56997. protected _dumpPropertiesCode(): string;
  56998. serialize(): any;
  56999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57000. }
  57001. }
  57002. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57003. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57004. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57005. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57006. /**
  57007. * Block used to apply a cross product between 2 vectors
  57008. */
  57009. export class CrossBlock extends NodeMaterialBlock {
  57010. /**
  57011. * Creates a new CrossBlock
  57012. * @param name defines the block name
  57013. */
  57014. constructor(name: string);
  57015. /**
  57016. * Gets the current class name
  57017. * @returns the class name
  57018. */
  57019. getClassName(): string;
  57020. /**
  57021. * Gets the left operand input component
  57022. */
  57023. readonly left: NodeMaterialConnectionPoint;
  57024. /**
  57025. * Gets the right operand input component
  57026. */
  57027. readonly right: NodeMaterialConnectionPoint;
  57028. /**
  57029. * Gets the output component
  57030. */
  57031. readonly output: NodeMaterialConnectionPoint;
  57032. protected _buildBlock(state: NodeMaterialBuildState): this;
  57033. }
  57034. }
  57035. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57039. /**
  57040. * Block used to apply a dot product between 2 vectors
  57041. */
  57042. export class DotBlock extends NodeMaterialBlock {
  57043. /**
  57044. * Creates a new DotBlock
  57045. * @param name defines the block name
  57046. */
  57047. constructor(name: string);
  57048. /**
  57049. * Gets the current class name
  57050. * @returns the class name
  57051. */
  57052. getClassName(): string;
  57053. /**
  57054. * Gets the left operand input component
  57055. */
  57056. readonly left: NodeMaterialConnectionPoint;
  57057. /**
  57058. * Gets the right operand input component
  57059. */
  57060. readonly right: NodeMaterialConnectionPoint;
  57061. /**
  57062. * Gets the output component
  57063. */
  57064. readonly output: NodeMaterialConnectionPoint;
  57065. protected _buildBlock(state: NodeMaterialBuildState): this;
  57066. }
  57067. }
  57068. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57069. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57070. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57071. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57072. import { Vector2 } from "babylonjs/Maths/math.vector";
  57073. import { Scene } from "babylonjs/scene";
  57074. /**
  57075. * Block used to remap a float from a range to a new one
  57076. */
  57077. export class RemapBlock extends NodeMaterialBlock {
  57078. /**
  57079. * Gets or sets the source range
  57080. */
  57081. sourceRange: Vector2;
  57082. /**
  57083. * Gets or sets the target range
  57084. */
  57085. targetRange: Vector2;
  57086. /**
  57087. * Creates a new RemapBlock
  57088. * @param name defines the block name
  57089. */
  57090. constructor(name: string);
  57091. /**
  57092. * Gets the current class name
  57093. * @returns the class name
  57094. */
  57095. getClassName(): string;
  57096. /**
  57097. * Gets the input component
  57098. */
  57099. readonly input: NodeMaterialConnectionPoint;
  57100. /**
  57101. * Gets the source min input component
  57102. */
  57103. readonly sourceMin: NodeMaterialConnectionPoint;
  57104. /**
  57105. * Gets the source max input component
  57106. */
  57107. readonly sourceMax: NodeMaterialConnectionPoint;
  57108. /**
  57109. * Gets the target min input component
  57110. */
  57111. readonly targetMin: NodeMaterialConnectionPoint;
  57112. /**
  57113. * Gets the target max input component
  57114. */
  57115. readonly targetMax: NodeMaterialConnectionPoint;
  57116. /**
  57117. * Gets the output component
  57118. */
  57119. readonly output: NodeMaterialConnectionPoint;
  57120. protected _buildBlock(state: NodeMaterialBuildState): this;
  57121. protected _dumpPropertiesCode(): string;
  57122. serialize(): any;
  57123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57124. }
  57125. }
  57126. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57130. /**
  57131. * Block used to normalize a vector
  57132. */
  57133. export class NormalizeBlock extends NodeMaterialBlock {
  57134. /**
  57135. * Creates a new NormalizeBlock
  57136. * @param name defines the block name
  57137. */
  57138. constructor(name: string);
  57139. /**
  57140. * Gets the current class name
  57141. * @returns the class name
  57142. */
  57143. getClassName(): string;
  57144. /**
  57145. * Gets the input component
  57146. */
  57147. readonly input: NodeMaterialConnectionPoint;
  57148. /**
  57149. * Gets the output component
  57150. */
  57151. readonly output: NodeMaterialConnectionPoint;
  57152. protected _buildBlock(state: NodeMaterialBuildState): this;
  57153. }
  57154. }
  57155. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57159. import { Scene } from "babylonjs/scene";
  57160. /**
  57161. * Operations supported by the Trigonometry block
  57162. */
  57163. export enum TrigonometryBlockOperations {
  57164. /** Cos */
  57165. Cos = 0,
  57166. /** Sin */
  57167. Sin = 1,
  57168. /** Abs */
  57169. Abs = 2,
  57170. /** Exp */
  57171. Exp = 3,
  57172. /** Exp2 */
  57173. Exp2 = 4,
  57174. /** Round */
  57175. Round = 5,
  57176. /** Floor */
  57177. Floor = 6,
  57178. /** Ceiling */
  57179. Ceiling = 7,
  57180. /** Square root */
  57181. Sqrt = 8,
  57182. /** Log */
  57183. Log = 9,
  57184. /** Tangent */
  57185. Tan = 10,
  57186. /** Arc tangent */
  57187. ArcTan = 11,
  57188. /** Arc cosinus */
  57189. ArcCos = 12,
  57190. /** Arc sinus */
  57191. ArcSin = 13,
  57192. /** Fraction */
  57193. Fract = 14,
  57194. /** Sign */
  57195. Sign = 15,
  57196. /** To radians (from degrees) */
  57197. Radians = 16,
  57198. /** To degrees (from radians) */
  57199. Degrees = 17
  57200. }
  57201. /**
  57202. * Block used to apply trigonometry operation to floats
  57203. */
  57204. export class TrigonometryBlock extends NodeMaterialBlock {
  57205. /**
  57206. * Gets or sets the operation applied by the block
  57207. */
  57208. operation: TrigonometryBlockOperations;
  57209. /**
  57210. * Creates a new TrigonometryBlock
  57211. * @param name defines the block name
  57212. */
  57213. constructor(name: string);
  57214. /**
  57215. * Gets the current class name
  57216. * @returns the class name
  57217. */
  57218. getClassName(): string;
  57219. /**
  57220. * Gets the input component
  57221. */
  57222. readonly input: NodeMaterialConnectionPoint;
  57223. /**
  57224. * Gets the output component
  57225. */
  57226. readonly output: NodeMaterialConnectionPoint;
  57227. protected _buildBlock(state: NodeMaterialBuildState): this;
  57228. serialize(): any;
  57229. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57230. }
  57231. }
  57232. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57233. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57234. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57235. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57236. /**
  57237. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57238. */
  57239. export class ColorMergerBlock extends NodeMaterialBlock {
  57240. /**
  57241. * Create a new ColorMergerBlock
  57242. * @param name defines the block name
  57243. */
  57244. constructor(name: string);
  57245. /**
  57246. * Gets the current class name
  57247. * @returns the class name
  57248. */
  57249. getClassName(): string;
  57250. /**
  57251. * Gets the r component (input)
  57252. */
  57253. readonly r: NodeMaterialConnectionPoint;
  57254. /**
  57255. * Gets the g component (input)
  57256. */
  57257. readonly g: NodeMaterialConnectionPoint;
  57258. /**
  57259. * Gets the b component (input)
  57260. */
  57261. readonly b: NodeMaterialConnectionPoint;
  57262. /**
  57263. * Gets the a component (input)
  57264. */
  57265. readonly a: NodeMaterialConnectionPoint;
  57266. /**
  57267. * Gets the rgba component (output)
  57268. */
  57269. readonly rgba: NodeMaterialConnectionPoint;
  57270. /**
  57271. * Gets the rgb component (output)
  57272. */
  57273. readonly rgb: NodeMaterialConnectionPoint;
  57274. protected _buildBlock(state: NodeMaterialBuildState): this;
  57275. }
  57276. }
  57277. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57281. /**
  57282. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57283. */
  57284. export class VectorMergerBlock extends NodeMaterialBlock {
  57285. /**
  57286. * Create a new VectorMergerBlock
  57287. * @param name defines the block name
  57288. */
  57289. constructor(name: string);
  57290. /**
  57291. * Gets the current class name
  57292. * @returns the class name
  57293. */
  57294. getClassName(): string;
  57295. /**
  57296. * Gets the x component (input)
  57297. */
  57298. readonly x: NodeMaterialConnectionPoint;
  57299. /**
  57300. * Gets the y component (input)
  57301. */
  57302. readonly y: NodeMaterialConnectionPoint;
  57303. /**
  57304. * Gets the z component (input)
  57305. */
  57306. readonly z: NodeMaterialConnectionPoint;
  57307. /**
  57308. * Gets the w component (input)
  57309. */
  57310. readonly w: NodeMaterialConnectionPoint;
  57311. /**
  57312. * Gets the xyzw component (output)
  57313. */
  57314. readonly xyzw: NodeMaterialConnectionPoint;
  57315. /**
  57316. * Gets the xyz component (output)
  57317. */
  57318. readonly xyz: NodeMaterialConnectionPoint;
  57319. /**
  57320. * Gets the xy component (output)
  57321. */
  57322. readonly xy: NodeMaterialConnectionPoint;
  57323. protected _buildBlock(state: NodeMaterialBuildState): this;
  57324. }
  57325. }
  57326. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57327. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57328. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57329. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57330. /**
  57331. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57332. */
  57333. export class ColorSplitterBlock extends NodeMaterialBlock {
  57334. /**
  57335. * Create a new ColorSplitterBlock
  57336. * @param name defines the block name
  57337. */
  57338. constructor(name: string);
  57339. /**
  57340. * Gets the current class name
  57341. * @returns the class name
  57342. */
  57343. getClassName(): string;
  57344. /**
  57345. * Gets the rgba component (input)
  57346. */
  57347. readonly rgba: NodeMaterialConnectionPoint;
  57348. /**
  57349. * Gets the rgb component (input)
  57350. */
  57351. readonly rgbIn: NodeMaterialConnectionPoint;
  57352. /**
  57353. * Gets the rgb component (output)
  57354. */
  57355. readonly rgbOut: NodeMaterialConnectionPoint;
  57356. /**
  57357. * Gets the r component (output)
  57358. */
  57359. readonly r: NodeMaterialConnectionPoint;
  57360. /**
  57361. * Gets the g component (output)
  57362. */
  57363. readonly g: NodeMaterialConnectionPoint;
  57364. /**
  57365. * Gets the b component (output)
  57366. */
  57367. readonly b: NodeMaterialConnectionPoint;
  57368. /**
  57369. * Gets the a component (output)
  57370. */
  57371. readonly a: NodeMaterialConnectionPoint;
  57372. protected _inputRename(name: string): string;
  57373. protected _outputRename(name: string): string;
  57374. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57375. }
  57376. }
  57377. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57381. /**
  57382. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57383. */
  57384. export class VectorSplitterBlock extends NodeMaterialBlock {
  57385. /**
  57386. * Create a new VectorSplitterBlock
  57387. * @param name defines the block name
  57388. */
  57389. constructor(name: string);
  57390. /**
  57391. * Gets the current class name
  57392. * @returns the class name
  57393. */
  57394. getClassName(): string;
  57395. /**
  57396. * Gets the xyzw component (input)
  57397. */
  57398. readonly xyzw: NodeMaterialConnectionPoint;
  57399. /**
  57400. * Gets the xyz component (input)
  57401. */
  57402. readonly xyzIn: NodeMaterialConnectionPoint;
  57403. /**
  57404. * Gets the xy component (input)
  57405. */
  57406. readonly xyIn: NodeMaterialConnectionPoint;
  57407. /**
  57408. * Gets the xyz component (output)
  57409. */
  57410. readonly xyzOut: NodeMaterialConnectionPoint;
  57411. /**
  57412. * Gets the xy component (output)
  57413. */
  57414. readonly xyOut: NodeMaterialConnectionPoint;
  57415. /**
  57416. * Gets the x component (output)
  57417. */
  57418. readonly x: NodeMaterialConnectionPoint;
  57419. /**
  57420. * Gets the y component (output)
  57421. */
  57422. readonly y: NodeMaterialConnectionPoint;
  57423. /**
  57424. * Gets the z component (output)
  57425. */
  57426. readonly z: NodeMaterialConnectionPoint;
  57427. /**
  57428. * Gets the w component (output)
  57429. */
  57430. readonly w: NodeMaterialConnectionPoint;
  57431. protected _inputRename(name: string): string;
  57432. protected _outputRename(name: string): string;
  57433. protected _buildBlock(state: NodeMaterialBuildState): this;
  57434. }
  57435. }
  57436. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57437. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57438. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57439. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57440. /**
  57441. * Block used to lerp 2 values
  57442. */
  57443. export class LerpBlock extends NodeMaterialBlock {
  57444. /**
  57445. * Creates a new LerpBlock
  57446. * @param name defines the block name
  57447. */
  57448. constructor(name: string);
  57449. /**
  57450. * Gets the current class name
  57451. * @returns the class name
  57452. */
  57453. getClassName(): string;
  57454. /**
  57455. * Gets the left operand input component
  57456. */
  57457. readonly left: NodeMaterialConnectionPoint;
  57458. /**
  57459. * Gets the right operand input component
  57460. */
  57461. readonly right: NodeMaterialConnectionPoint;
  57462. /**
  57463. * Gets the gradient operand input component
  57464. */
  57465. readonly gradient: NodeMaterialConnectionPoint;
  57466. /**
  57467. * Gets the output component
  57468. */
  57469. readonly output: NodeMaterialConnectionPoint;
  57470. protected _buildBlock(state: NodeMaterialBuildState): this;
  57471. }
  57472. }
  57473. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57477. /**
  57478. * Block used to divide 2 vectors
  57479. */
  57480. export class DivideBlock extends NodeMaterialBlock {
  57481. /**
  57482. * Creates a new DivideBlock
  57483. * @param name defines the block name
  57484. */
  57485. constructor(name: string);
  57486. /**
  57487. * Gets the current class name
  57488. * @returns the class name
  57489. */
  57490. getClassName(): string;
  57491. /**
  57492. * Gets the left operand input component
  57493. */
  57494. readonly left: NodeMaterialConnectionPoint;
  57495. /**
  57496. * Gets the right operand input component
  57497. */
  57498. readonly right: NodeMaterialConnectionPoint;
  57499. /**
  57500. * Gets the output component
  57501. */
  57502. readonly output: NodeMaterialConnectionPoint;
  57503. protected _buildBlock(state: NodeMaterialBuildState): this;
  57504. }
  57505. }
  57506. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57507. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57508. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57509. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57510. /**
  57511. * Block used to subtract 2 vectors
  57512. */
  57513. export class SubtractBlock extends NodeMaterialBlock {
  57514. /**
  57515. * Creates a new SubtractBlock
  57516. * @param name defines the block name
  57517. */
  57518. constructor(name: string);
  57519. /**
  57520. * Gets the current class name
  57521. * @returns the class name
  57522. */
  57523. getClassName(): string;
  57524. /**
  57525. * Gets the left operand input component
  57526. */
  57527. readonly left: NodeMaterialConnectionPoint;
  57528. /**
  57529. * Gets the right operand input component
  57530. */
  57531. readonly right: NodeMaterialConnectionPoint;
  57532. /**
  57533. * Gets the output component
  57534. */
  57535. readonly output: NodeMaterialConnectionPoint;
  57536. protected _buildBlock(state: NodeMaterialBuildState): this;
  57537. }
  57538. }
  57539. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57543. /**
  57544. * Block used to step a value
  57545. */
  57546. export class StepBlock extends NodeMaterialBlock {
  57547. /**
  57548. * Creates a new StepBlock
  57549. * @param name defines the block name
  57550. */
  57551. constructor(name: string);
  57552. /**
  57553. * Gets the current class name
  57554. * @returns the class name
  57555. */
  57556. getClassName(): string;
  57557. /**
  57558. * Gets the value operand input component
  57559. */
  57560. readonly value: NodeMaterialConnectionPoint;
  57561. /**
  57562. * Gets the edge operand input component
  57563. */
  57564. readonly edge: NodeMaterialConnectionPoint;
  57565. /**
  57566. * Gets the output component
  57567. */
  57568. readonly output: NodeMaterialConnectionPoint;
  57569. protected _buildBlock(state: NodeMaterialBuildState): this;
  57570. }
  57571. }
  57572. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57575. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57576. /**
  57577. * Block used to get the opposite (1 - x) of a value
  57578. */
  57579. export class OneMinusBlock extends NodeMaterialBlock {
  57580. /**
  57581. * Creates a new OneMinusBlock
  57582. * @param name defines the block name
  57583. */
  57584. constructor(name: string);
  57585. /**
  57586. * Gets the current class name
  57587. * @returns the class name
  57588. */
  57589. getClassName(): string;
  57590. /**
  57591. * Gets the input component
  57592. */
  57593. readonly input: NodeMaterialConnectionPoint;
  57594. /**
  57595. * Gets the output component
  57596. */
  57597. readonly output: NodeMaterialConnectionPoint;
  57598. protected _buildBlock(state: NodeMaterialBuildState): this;
  57599. }
  57600. }
  57601. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57605. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57606. /**
  57607. * Block used to get the view direction
  57608. */
  57609. export class ViewDirectionBlock extends NodeMaterialBlock {
  57610. /**
  57611. * Creates a new ViewDirectionBlock
  57612. * @param name defines the block name
  57613. */
  57614. constructor(name: string);
  57615. /**
  57616. * Gets the current class name
  57617. * @returns the class name
  57618. */
  57619. getClassName(): string;
  57620. /**
  57621. * Gets the world position component
  57622. */
  57623. readonly worldPosition: NodeMaterialConnectionPoint;
  57624. /**
  57625. * Gets the camera position component
  57626. */
  57627. readonly cameraPosition: NodeMaterialConnectionPoint;
  57628. /**
  57629. * Gets the output component
  57630. */
  57631. readonly output: NodeMaterialConnectionPoint;
  57632. autoConfigure(material: NodeMaterial): void;
  57633. protected _buildBlock(state: NodeMaterialBuildState): this;
  57634. }
  57635. }
  57636. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57637. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57638. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57639. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57640. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57641. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57642. /**
  57643. * Block used to compute fresnel value
  57644. */
  57645. export class FresnelBlock extends NodeMaterialBlock {
  57646. /**
  57647. * Create a new FresnelBlock
  57648. * @param name defines the block name
  57649. */
  57650. constructor(name: string);
  57651. /**
  57652. * Gets the current class name
  57653. * @returns the class name
  57654. */
  57655. getClassName(): string;
  57656. /**
  57657. * Gets the world normal input component
  57658. */
  57659. readonly worldNormal: NodeMaterialConnectionPoint;
  57660. /**
  57661. * Gets the view direction input component
  57662. */
  57663. readonly viewDirection: NodeMaterialConnectionPoint;
  57664. /**
  57665. * Gets the bias input component
  57666. */
  57667. readonly bias: NodeMaterialConnectionPoint;
  57668. /**
  57669. * Gets the camera (or eye) position component
  57670. */
  57671. readonly power: NodeMaterialConnectionPoint;
  57672. /**
  57673. * Gets the fresnel output component
  57674. */
  57675. readonly fresnel: NodeMaterialConnectionPoint;
  57676. autoConfigure(material: NodeMaterial): void;
  57677. protected _buildBlock(state: NodeMaterialBuildState): this;
  57678. }
  57679. }
  57680. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57681. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57682. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57683. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57684. /**
  57685. * Block used to get the max of 2 values
  57686. */
  57687. export class MaxBlock extends NodeMaterialBlock {
  57688. /**
  57689. * Creates a new MaxBlock
  57690. * @param name defines the block name
  57691. */
  57692. constructor(name: string);
  57693. /**
  57694. * Gets the current class name
  57695. * @returns the class name
  57696. */
  57697. getClassName(): string;
  57698. /**
  57699. * Gets the left operand input component
  57700. */
  57701. readonly left: NodeMaterialConnectionPoint;
  57702. /**
  57703. * Gets the right operand input component
  57704. */
  57705. readonly right: NodeMaterialConnectionPoint;
  57706. /**
  57707. * Gets the output component
  57708. */
  57709. readonly output: NodeMaterialConnectionPoint;
  57710. protected _buildBlock(state: NodeMaterialBuildState): this;
  57711. }
  57712. }
  57713. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57715. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57716. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57717. /**
  57718. * Block used to get the min of 2 values
  57719. */
  57720. export class MinBlock extends NodeMaterialBlock {
  57721. /**
  57722. * Creates a new MinBlock
  57723. * @param name defines the block name
  57724. */
  57725. constructor(name: string);
  57726. /**
  57727. * Gets the current class name
  57728. * @returns the class name
  57729. */
  57730. getClassName(): string;
  57731. /**
  57732. * Gets the left operand input component
  57733. */
  57734. readonly left: NodeMaterialConnectionPoint;
  57735. /**
  57736. * Gets the right operand input component
  57737. */
  57738. readonly right: NodeMaterialConnectionPoint;
  57739. /**
  57740. * Gets the output component
  57741. */
  57742. readonly output: NodeMaterialConnectionPoint;
  57743. protected _buildBlock(state: NodeMaterialBuildState): this;
  57744. }
  57745. }
  57746. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57747. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57748. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57749. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57750. /**
  57751. * Block used to get the distance between 2 values
  57752. */
  57753. export class DistanceBlock extends NodeMaterialBlock {
  57754. /**
  57755. * Creates a new DistanceBlock
  57756. * @param name defines the block name
  57757. */
  57758. constructor(name: string);
  57759. /**
  57760. * Gets the current class name
  57761. * @returns the class name
  57762. */
  57763. getClassName(): string;
  57764. /**
  57765. * Gets the left operand input component
  57766. */
  57767. readonly left: NodeMaterialConnectionPoint;
  57768. /**
  57769. * Gets the right operand input component
  57770. */
  57771. readonly right: NodeMaterialConnectionPoint;
  57772. /**
  57773. * Gets the output component
  57774. */
  57775. readonly output: NodeMaterialConnectionPoint;
  57776. protected _buildBlock(state: NodeMaterialBuildState): this;
  57777. }
  57778. }
  57779. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57781. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57783. /**
  57784. * Block used to get the length of a vector
  57785. */
  57786. export class LengthBlock extends NodeMaterialBlock {
  57787. /**
  57788. * Creates a new LengthBlock
  57789. * @param name defines the block name
  57790. */
  57791. constructor(name: string);
  57792. /**
  57793. * Gets the current class name
  57794. * @returns the class name
  57795. */
  57796. getClassName(): string;
  57797. /**
  57798. * Gets the value input component
  57799. */
  57800. readonly value: NodeMaterialConnectionPoint;
  57801. /**
  57802. * Gets the output component
  57803. */
  57804. readonly output: NodeMaterialConnectionPoint;
  57805. protected _buildBlock(state: NodeMaterialBuildState): this;
  57806. }
  57807. }
  57808. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57812. /**
  57813. * Block used to get negative version of a value (i.e. x * -1)
  57814. */
  57815. export class NegateBlock extends NodeMaterialBlock {
  57816. /**
  57817. * Creates a new NegateBlock
  57818. * @param name defines the block name
  57819. */
  57820. constructor(name: string);
  57821. /**
  57822. * Gets the current class name
  57823. * @returns the class name
  57824. */
  57825. getClassName(): string;
  57826. /**
  57827. * Gets the value input component
  57828. */
  57829. readonly value: NodeMaterialConnectionPoint;
  57830. /**
  57831. * Gets the output component
  57832. */
  57833. readonly output: NodeMaterialConnectionPoint;
  57834. protected _buildBlock(state: NodeMaterialBuildState): this;
  57835. }
  57836. }
  57837. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57841. /**
  57842. * Block used to get the value of the first parameter raised to the power of the second
  57843. */
  57844. export class PowBlock extends NodeMaterialBlock {
  57845. /**
  57846. * Creates a new PowBlock
  57847. * @param name defines the block name
  57848. */
  57849. constructor(name: string);
  57850. /**
  57851. * Gets the current class name
  57852. * @returns the class name
  57853. */
  57854. getClassName(): string;
  57855. /**
  57856. * Gets the value operand input component
  57857. */
  57858. readonly value: NodeMaterialConnectionPoint;
  57859. /**
  57860. * Gets the power operand input component
  57861. */
  57862. readonly power: NodeMaterialConnectionPoint;
  57863. /**
  57864. * Gets the output component
  57865. */
  57866. readonly output: NodeMaterialConnectionPoint;
  57867. protected _buildBlock(state: NodeMaterialBuildState): this;
  57868. }
  57869. }
  57870. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57871. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57872. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57873. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57874. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57875. /**
  57876. * Block used to get a random number
  57877. */
  57878. export class RandomNumberBlock extends NodeMaterialBlock {
  57879. /**
  57880. * Creates a new RandomNumberBlock
  57881. * @param name defines the block name
  57882. */
  57883. constructor(name: string);
  57884. /**
  57885. * Gets the current class name
  57886. * @returns the class name
  57887. */
  57888. getClassName(): string;
  57889. /**
  57890. * Gets the seed input component
  57891. */
  57892. readonly seed: NodeMaterialConnectionPoint;
  57893. /**
  57894. * Gets the output component
  57895. */
  57896. readonly output: NodeMaterialConnectionPoint;
  57897. protected _buildBlock(state: NodeMaterialBuildState): this;
  57898. }
  57899. }
  57900. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57904. /**
  57905. * Block used to compute arc tangent of 2 values
  57906. */
  57907. export class ArcTan2Block extends NodeMaterialBlock {
  57908. /**
  57909. * Creates a new ArcTan2Block
  57910. * @param name defines the block name
  57911. */
  57912. constructor(name: string);
  57913. /**
  57914. * Gets the current class name
  57915. * @returns the class name
  57916. */
  57917. getClassName(): string;
  57918. /**
  57919. * Gets the x operand input component
  57920. */
  57921. readonly x: NodeMaterialConnectionPoint;
  57922. /**
  57923. * Gets the y operand input component
  57924. */
  57925. readonly y: NodeMaterialConnectionPoint;
  57926. /**
  57927. * Gets the output component
  57928. */
  57929. readonly output: NodeMaterialConnectionPoint;
  57930. protected _buildBlock(state: NodeMaterialBuildState): this;
  57931. }
  57932. }
  57933. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  57934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57937. /**
  57938. * Block used to smooth step a value
  57939. */
  57940. export class SmoothStepBlock extends NodeMaterialBlock {
  57941. /**
  57942. * Creates a new SmoothStepBlock
  57943. * @param name defines the block name
  57944. */
  57945. constructor(name: string);
  57946. /**
  57947. * Gets the current class name
  57948. * @returns the class name
  57949. */
  57950. getClassName(): string;
  57951. /**
  57952. * Gets the value operand input component
  57953. */
  57954. readonly value: NodeMaterialConnectionPoint;
  57955. /**
  57956. * Gets the first edge operand input component
  57957. */
  57958. readonly edge0: NodeMaterialConnectionPoint;
  57959. /**
  57960. * Gets the second edge operand input component
  57961. */
  57962. readonly edge1: NodeMaterialConnectionPoint;
  57963. /**
  57964. * Gets the output component
  57965. */
  57966. readonly output: NodeMaterialConnectionPoint;
  57967. protected _buildBlock(state: NodeMaterialBuildState): this;
  57968. }
  57969. }
  57970. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  57971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57974. /**
  57975. * Block used to get the reciprocal (1 / x) of a value
  57976. */
  57977. export class ReciprocalBlock extends NodeMaterialBlock {
  57978. /**
  57979. * Creates a new ReciprocalBlock
  57980. * @param name defines the block name
  57981. */
  57982. constructor(name: string);
  57983. /**
  57984. * Gets the current class name
  57985. * @returns the class name
  57986. */
  57987. getClassName(): string;
  57988. /**
  57989. * Gets the input component
  57990. */
  57991. readonly input: NodeMaterialConnectionPoint;
  57992. /**
  57993. * Gets the output component
  57994. */
  57995. readonly output: NodeMaterialConnectionPoint;
  57996. protected _buildBlock(state: NodeMaterialBuildState): this;
  57997. }
  57998. }
  57999. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58003. /**
  58004. * Block used to replace a color by another one
  58005. */
  58006. export class ReplaceColorBlock extends NodeMaterialBlock {
  58007. /**
  58008. * Creates a new ReplaceColorBlock
  58009. * @param name defines the block name
  58010. */
  58011. constructor(name: string);
  58012. /**
  58013. * Gets the current class name
  58014. * @returns the class name
  58015. */
  58016. getClassName(): string;
  58017. /**
  58018. * Gets the value input component
  58019. */
  58020. readonly value: NodeMaterialConnectionPoint;
  58021. /**
  58022. * Gets the reference input component
  58023. */
  58024. readonly reference: NodeMaterialConnectionPoint;
  58025. /**
  58026. * Gets the distance input component
  58027. */
  58028. readonly distance: NodeMaterialConnectionPoint;
  58029. /**
  58030. * Gets the replacement input component
  58031. */
  58032. readonly replacement: NodeMaterialConnectionPoint;
  58033. /**
  58034. * Gets the output component
  58035. */
  58036. readonly output: NodeMaterialConnectionPoint;
  58037. protected _buildBlock(state: NodeMaterialBuildState): this;
  58038. }
  58039. }
  58040. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58044. /**
  58045. * Block used to posterize a value
  58046. * @see https://en.wikipedia.org/wiki/Posterization
  58047. */
  58048. export class PosterizeBlock extends NodeMaterialBlock {
  58049. /**
  58050. * Creates a new PosterizeBlock
  58051. * @param name defines the block name
  58052. */
  58053. constructor(name: string);
  58054. /**
  58055. * Gets the current class name
  58056. * @returns the class name
  58057. */
  58058. getClassName(): string;
  58059. /**
  58060. * Gets the value input component
  58061. */
  58062. readonly value: NodeMaterialConnectionPoint;
  58063. /**
  58064. * Gets the steps input component
  58065. */
  58066. readonly steps: NodeMaterialConnectionPoint;
  58067. /**
  58068. * Gets the output component
  58069. */
  58070. readonly output: NodeMaterialConnectionPoint;
  58071. protected _buildBlock(state: NodeMaterialBuildState): this;
  58072. }
  58073. }
  58074. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58076. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58078. import { Scene } from "babylonjs/scene";
  58079. /**
  58080. * Operations supported by the Wave block
  58081. */
  58082. export enum WaveBlockKind {
  58083. /** SawTooth */
  58084. SawTooth = 0,
  58085. /** Square */
  58086. Square = 1,
  58087. /** Triangle */
  58088. Triangle = 2
  58089. }
  58090. /**
  58091. * Block used to apply wave operation to floats
  58092. */
  58093. export class WaveBlock extends NodeMaterialBlock {
  58094. /**
  58095. * Gets or sets the kibnd of wave to be applied by the block
  58096. */
  58097. kind: WaveBlockKind;
  58098. /**
  58099. * Creates a new WaveBlock
  58100. * @param name defines the block name
  58101. */
  58102. constructor(name: string);
  58103. /**
  58104. * Gets the current class name
  58105. * @returns the class name
  58106. */
  58107. getClassName(): string;
  58108. /**
  58109. * Gets the input component
  58110. */
  58111. readonly input: NodeMaterialConnectionPoint;
  58112. /**
  58113. * Gets the output component
  58114. */
  58115. readonly output: NodeMaterialConnectionPoint;
  58116. protected _buildBlock(state: NodeMaterialBuildState): this;
  58117. serialize(): any;
  58118. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58119. }
  58120. }
  58121. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58125. import { Color3 } from "babylonjs/Maths/math.color";
  58126. import { Scene } from "babylonjs/scene";
  58127. /**
  58128. * Class used to store a color step for the GradientBlock
  58129. */
  58130. export class GradientBlockColorStep {
  58131. /**
  58132. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58133. */
  58134. step: number;
  58135. /**
  58136. * Gets or sets the color associated with this step
  58137. */
  58138. color: Color3;
  58139. /**
  58140. * Creates a new GradientBlockColorStep
  58141. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58142. * @param color defines the color associated with this step
  58143. */
  58144. constructor(
  58145. /**
  58146. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58147. */
  58148. step: number,
  58149. /**
  58150. * Gets or sets the color associated with this step
  58151. */
  58152. color: Color3);
  58153. }
  58154. /**
  58155. * Block used to return a color from a gradient based on an input value between 0 and 1
  58156. */
  58157. export class GradientBlock extends NodeMaterialBlock {
  58158. /**
  58159. * Gets or sets the list of color steps
  58160. */
  58161. colorSteps: GradientBlockColorStep[];
  58162. /**
  58163. * Creates a new GradientBlock
  58164. * @param name defines the block name
  58165. */
  58166. constructor(name: string);
  58167. /**
  58168. * Gets the current class name
  58169. * @returns the class name
  58170. */
  58171. getClassName(): string;
  58172. /**
  58173. * Gets the gradient input component
  58174. */
  58175. readonly gradient: NodeMaterialConnectionPoint;
  58176. /**
  58177. * Gets the output component
  58178. */
  58179. readonly output: NodeMaterialConnectionPoint;
  58180. private _writeColorConstant;
  58181. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58182. serialize(): any;
  58183. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58184. protected _dumpPropertiesCode(): string;
  58185. }
  58186. }
  58187. declare module "babylonjs/Materials/Node/Blocks/index" {
  58188. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58189. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58190. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58191. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58192. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58193. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58194. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58195. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58196. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58197. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58198. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58199. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58200. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58201. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58202. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58203. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58204. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58205. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58206. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58207. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58208. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58209. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58210. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58211. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58212. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58213. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58214. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58215. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58216. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58217. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58218. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58219. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58220. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58221. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58222. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58223. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58224. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58225. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58226. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58227. }
  58228. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58229. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58230. }
  58231. declare module "babylonjs/Materials/Node/index" {
  58232. export * from "babylonjs/Materials/Node/Enums/index";
  58233. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58234. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58235. export * from "babylonjs/Materials/Node/nodeMaterial";
  58236. export * from "babylonjs/Materials/Node/Blocks/index";
  58237. export * from "babylonjs/Materials/Node/Optimizers/index";
  58238. }
  58239. declare module "babylonjs/Materials/effectRenderer" {
  58240. import { Nullable } from "babylonjs/types";
  58241. import { Texture } from "babylonjs/Materials/Textures/texture";
  58242. import { Engine } from "babylonjs/Engines/engine";
  58243. import { Viewport } from "babylonjs/Maths/math.viewport";
  58244. import { Observable } from "babylonjs/Misc/observable";
  58245. import { Effect } from "babylonjs/Materials/effect";
  58246. import "babylonjs/Shaders/postprocess.vertex";
  58247. /**
  58248. * Effect Render Options
  58249. */
  58250. export interface IEffectRendererOptions {
  58251. /**
  58252. * Defines the vertices positions.
  58253. */
  58254. positions?: number[];
  58255. /**
  58256. * Defines the indices.
  58257. */
  58258. indices?: number[];
  58259. }
  58260. /**
  58261. * Helper class to render one or more effects
  58262. */
  58263. export class EffectRenderer {
  58264. private engine;
  58265. private static _DefaultOptions;
  58266. private _vertexBuffers;
  58267. private _indexBuffer;
  58268. private _ringBufferIndex;
  58269. private _ringScreenBuffer;
  58270. private _fullscreenViewport;
  58271. private _getNextFrameBuffer;
  58272. /**
  58273. * Creates an effect renderer
  58274. * @param engine the engine to use for rendering
  58275. * @param options defines the options of the effect renderer
  58276. */
  58277. constructor(engine: Engine, options?: IEffectRendererOptions);
  58278. /**
  58279. * Sets the current viewport in normalized coordinates 0-1
  58280. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58281. */
  58282. setViewport(viewport?: Viewport): void;
  58283. /**
  58284. * Binds the embedded attributes buffer to the effect.
  58285. * @param effect Defines the effect to bind the attributes for
  58286. */
  58287. bindBuffers(effect: Effect): void;
  58288. /**
  58289. * Sets the current effect wrapper to use during draw.
  58290. * The effect needs to be ready before calling this api.
  58291. * This also sets the default full screen position attribute.
  58292. * @param effectWrapper Defines the effect to draw with
  58293. */
  58294. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58295. /**
  58296. * Draws a full screen quad.
  58297. */
  58298. draw(): void;
  58299. /**
  58300. * renders one or more effects to a specified texture
  58301. * @param effectWrappers list of effects to renderer
  58302. * @param outputTexture texture to draw to, if null it will render to the screen
  58303. */
  58304. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58305. /**
  58306. * Disposes of the effect renderer
  58307. */
  58308. dispose(): void;
  58309. }
  58310. /**
  58311. * Options to create an EffectWrapper
  58312. */
  58313. interface EffectWrapperCreationOptions {
  58314. /**
  58315. * Engine to use to create the effect
  58316. */
  58317. engine: Engine;
  58318. /**
  58319. * Fragment shader for the effect
  58320. */
  58321. fragmentShader: string;
  58322. /**
  58323. * Vertex shader for the effect
  58324. */
  58325. vertexShader?: string;
  58326. /**
  58327. * Attributes to use in the shader
  58328. */
  58329. attributeNames?: Array<string>;
  58330. /**
  58331. * Uniforms to use in the shader
  58332. */
  58333. uniformNames?: Array<string>;
  58334. /**
  58335. * Texture sampler names to use in the shader
  58336. */
  58337. samplerNames?: Array<string>;
  58338. /**
  58339. * The friendly name of the effect displayed in Spector.
  58340. */
  58341. name?: string;
  58342. }
  58343. /**
  58344. * Wraps an effect to be used for rendering
  58345. */
  58346. export class EffectWrapper {
  58347. /**
  58348. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58349. */
  58350. onApplyObservable: Observable<{}>;
  58351. /**
  58352. * The underlying effect
  58353. */
  58354. effect: Effect;
  58355. /**
  58356. * Creates an effect to be renderer
  58357. * @param creationOptions options to create the effect
  58358. */
  58359. constructor(creationOptions: EffectWrapperCreationOptions);
  58360. /**
  58361. * Disposes of the effect wrapper
  58362. */
  58363. dispose(): void;
  58364. }
  58365. }
  58366. declare module "babylonjs/Materials/index" {
  58367. export * from "babylonjs/Materials/Background/index";
  58368. export * from "babylonjs/Materials/colorCurves";
  58369. export * from "babylonjs/Materials/iEffectFallbacks";
  58370. export * from "babylonjs/Materials/effectFallbacks";
  58371. export * from "babylonjs/Materials/effect";
  58372. export * from "babylonjs/Materials/fresnelParameters";
  58373. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58374. export * from "babylonjs/Materials/material";
  58375. export * from "babylonjs/Materials/materialDefines";
  58376. export * from "babylonjs/Materials/materialHelper";
  58377. export * from "babylonjs/Materials/multiMaterial";
  58378. export * from "babylonjs/Materials/PBR/index";
  58379. export * from "babylonjs/Materials/pushMaterial";
  58380. export * from "babylonjs/Materials/shaderMaterial";
  58381. export * from "babylonjs/Materials/standardMaterial";
  58382. export * from "babylonjs/Materials/Textures/index";
  58383. export * from "babylonjs/Materials/uniformBuffer";
  58384. export * from "babylonjs/Materials/materialFlags";
  58385. export * from "babylonjs/Materials/Node/index";
  58386. export * from "babylonjs/Materials/effectRenderer";
  58387. }
  58388. declare module "babylonjs/Maths/index" {
  58389. export * from "babylonjs/Maths/math.scalar";
  58390. export * from "babylonjs/Maths/math";
  58391. export * from "babylonjs/Maths/sphericalPolynomial";
  58392. }
  58393. declare module "babylonjs/Misc/workerPool" {
  58394. import { IDisposable } from "babylonjs/scene";
  58395. /**
  58396. * Helper class to push actions to a pool of workers.
  58397. */
  58398. export class WorkerPool implements IDisposable {
  58399. private _workerInfos;
  58400. private _pendingActions;
  58401. /**
  58402. * Constructor
  58403. * @param workers Array of workers to use for actions
  58404. */
  58405. constructor(workers: Array<Worker>);
  58406. /**
  58407. * Terminates all workers and clears any pending actions.
  58408. */
  58409. dispose(): void;
  58410. /**
  58411. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58412. * pended until a worker has completed its action.
  58413. * @param action The action to perform. Call onComplete when the action is complete.
  58414. */
  58415. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58416. private _execute;
  58417. }
  58418. }
  58419. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58420. import { IDisposable } from "babylonjs/scene";
  58421. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58422. /**
  58423. * Configuration for Draco compression
  58424. */
  58425. export interface IDracoCompressionConfiguration {
  58426. /**
  58427. * Configuration for the decoder.
  58428. */
  58429. decoder: {
  58430. /**
  58431. * The url to the WebAssembly module.
  58432. */
  58433. wasmUrl?: string;
  58434. /**
  58435. * The url to the WebAssembly binary.
  58436. */
  58437. wasmBinaryUrl?: string;
  58438. /**
  58439. * The url to the fallback JavaScript module.
  58440. */
  58441. fallbackUrl?: string;
  58442. };
  58443. }
  58444. /**
  58445. * Draco compression (https://google.github.io/draco/)
  58446. *
  58447. * This class wraps the Draco module.
  58448. *
  58449. * **Encoder**
  58450. *
  58451. * The encoder is not currently implemented.
  58452. *
  58453. * **Decoder**
  58454. *
  58455. * 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.
  58456. *
  58457. * To update the configuration, use the following code:
  58458. * ```javascript
  58459. * DracoCompression.Configuration = {
  58460. * decoder: {
  58461. * wasmUrl: "<url to the WebAssembly library>",
  58462. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58463. * fallbackUrl: "<url to the fallback JavaScript library>",
  58464. * }
  58465. * };
  58466. * ```
  58467. *
  58468. * 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.
  58469. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58470. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58471. *
  58472. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58473. * ```javascript
  58474. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58475. * ```
  58476. *
  58477. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58478. */
  58479. export class DracoCompression implements IDisposable {
  58480. private _workerPoolPromise?;
  58481. private _decoderModulePromise?;
  58482. /**
  58483. * The configuration. Defaults to the following urls:
  58484. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58485. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58486. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58487. */
  58488. static Configuration: IDracoCompressionConfiguration;
  58489. /**
  58490. * Returns true if the decoder configuration is available.
  58491. */
  58492. static readonly DecoderAvailable: boolean;
  58493. /**
  58494. * Default number of workers to create when creating the draco compression object.
  58495. */
  58496. static DefaultNumWorkers: number;
  58497. private static GetDefaultNumWorkers;
  58498. private static _Default;
  58499. /**
  58500. * Default instance for the draco compression object.
  58501. */
  58502. static readonly Default: DracoCompression;
  58503. /**
  58504. * Constructor
  58505. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58506. */
  58507. constructor(numWorkers?: number);
  58508. /**
  58509. * Stop all async operations and release resources.
  58510. */
  58511. dispose(): void;
  58512. /**
  58513. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58514. * @returns a promise that resolves when ready
  58515. */
  58516. whenReadyAsync(): Promise<void>;
  58517. /**
  58518. * Decode Draco compressed mesh data to vertex data.
  58519. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58520. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58521. * @returns A promise that resolves with the decoded vertex data
  58522. */
  58523. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58524. [kind: string]: number;
  58525. }): Promise<VertexData>;
  58526. }
  58527. }
  58528. declare module "babylonjs/Meshes/Compression/index" {
  58529. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58530. }
  58531. declare module "babylonjs/Meshes/csg" {
  58532. import { Nullable } from "babylonjs/types";
  58533. import { Scene } from "babylonjs/scene";
  58534. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58535. import { Mesh } from "babylonjs/Meshes/mesh";
  58536. import { Material } from "babylonjs/Materials/material";
  58537. /**
  58538. * Class for building Constructive Solid Geometry
  58539. */
  58540. export class CSG {
  58541. private polygons;
  58542. /**
  58543. * The world matrix
  58544. */
  58545. matrix: Matrix;
  58546. /**
  58547. * Stores the position
  58548. */
  58549. position: Vector3;
  58550. /**
  58551. * Stores the rotation
  58552. */
  58553. rotation: Vector3;
  58554. /**
  58555. * Stores the rotation quaternion
  58556. */
  58557. rotationQuaternion: Nullable<Quaternion>;
  58558. /**
  58559. * Stores the scaling vector
  58560. */
  58561. scaling: Vector3;
  58562. /**
  58563. * Convert the Mesh to CSG
  58564. * @param mesh The Mesh to convert to CSG
  58565. * @returns A new CSG from the Mesh
  58566. */
  58567. static FromMesh(mesh: Mesh): CSG;
  58568. /**
  58569. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58570. * @param polygons Polygons used to construct a CSG solid
  58571. */
  58572. private static FromPolygons;
  58573. /**
  58574. * Clones, or makes a deep copy, of the CSG
  58575. * @returns A new CSG
  58576. */
  58577. clone(): CSG;
  58578. /**
  58579. * Unions this CSG with another CSG
  58580. * @param csg The CSG to union against this CSG
  58581. * @returns The unioned CSG
  58582. */
  58583. union(csg: CSG): CSG;
  58584. /**
  58585. * Unions this CSG with another CSG in place
  58586. * @param csg The CSG to union against this CSG
  58587. */
  58588. unionInPlace(csg: CSG): void;
  58589. /**
  58590. * Subtracts this CSG with another CSG
  58591. * @param csg The CSG to subtract against this CSG
  58592. * @returns A new CSG
  58593. */
  58594. subtract(csg: CSG): CSG;
  58595. /**
  58596. * Subtracts this CSG with another CSG in place
  58597. * @param csg The CSG to subtact against this CSG
  58598. */
  58599. subtractInPlace(csg: CSG): void;
  58600. /**
  58601. * Intersect this CSG with another CSG
  58602. * @param csg The CSG to intersect against this CSG
  58603. * @returns A new CSG
  58604. */
  58605. intersect(csg: CSG): CSG;
  58606. /**
  58607. * Intersects this CSG with another CSG in place
  58608. * @param csg The CSG to intersect against this CSG
  58609. */
  58610. intersectInPlace(csg: CSG): void;
  58611. /**
  58612. * Return a new CSG solid with solid and empty space switched. This solid is
  58613. * not modified.
  58614. * @returns A new CSG solid with solid and empty space switched
  58615. */
  58616. inverse(): CSG;
  58617. /**
  58618. * Inverses the CSG in place
  58619. */
  58620. inverseInPlace(): void;
  58621. /**
  58622. * This is used to keep meshes transformations so they can be restored
  58623. * when we build back a Babylon Mesh
  58624. * NB : All CSG operations are performed in world coordinates
  58625. * @param csg The CSG to copy the transform attributes from
  58626. * @returns This CSG
  58627. */
  58628. copyTransformAttributes(csg: CSG): CSG;
  58629. /**
  58630. * Build Raw mesh from CSG
  58631. * Coordinates here are in world space
  58632. * @param name The name of the mesh geometry
  58633. * @param scene The Scene
  58634. * @param keepSubMeshes Specifies if the submeshes should be kept
  58635. * @returns A new Mesh
  58636. */
  58637. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58638. /**
  58639. * Build Mesh from CSG taking material and transforms into account
  58640. * @param name The name of the Mesh
  58641. * @param material The material of the Mesh
  58642. * @param scene The Scene
  58643. * @param keepSubMeshes Specifies if submeshes should be kept
  58644. * @returns The new Mesh
  58645. */
  58646. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58647. }
  58648. }
  58649. declare module "babylonjs/Meshes/trailMesh" {
  58650. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58651. import { Mesh } from "babylonjs/Meshes/mesh";
  58652. import { Scene } from "babylonjs/scene";
  58653. /**
  58654. * Class used to create a trail following a mesh
  58655. */
  58656. export class TrailMesh extends Mesh {
  58657. private _generator;
  58658. private _autoStart;
  58659. private _running;
  58660. private _diameter;
  58661. private _length;
  58662. private _sectionPolygonPointsCount;
  58663. private _sectionVectors;
  58664. private _sectionNormalVectors;
  58665. private _beforeRenderObserver;
  58666. /**
  58667. * @constructor
  58668. * @param name The value used by scene.getMeshByName() to do a lookup.
  58669. * @param generator The mesh to generate a trail.
  58670. * @param scene The scene to add this mesh to.
  58671. * @param diameter Diameter of trailing mesh. Default is 1.
  58672. * @param length Length of trailing mesh. Default is 60.
  58673. * @param autoStart Automatically start trailing mesh. Default true.
  58674. */
  58675. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58676. /**
  58677. * "TrailMesh"
  58678. * @returns "TrailMesh"
  58679. */
  58680. getClassName(): string;
  58681. private _createMesh;
  58682. /**
  58683. * Start trailing mesh.
  58684. */
  58685. start(): void;
  58686. /**
  58687. * Stop trailing mesh.
  58688. */
  58689. stop(): void;
  58690. /**
  58691. * Update trailing mesh geometry.
  58692. */
  58693. update(): void;
  58694. /**
  58695. * Returns a new TrailMesh object.
  58696. * @param name is a string, the name given to the new mesh
  58697. * @param newGenerator use new generator object for cloned trail mesh
  58698. * @returns a new mesh
  58699. */
  58700. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58701. /**
  58702. * Serializes this trail mesh
  58703. * @param serializationObject object to write serialization to
  58704. */
  58705. serialize(serializationObject: any): void;
  58706. /**
  58707. * Parses a serialized trail mesh
  58708. * @param parsedMesh the serialized mesh
  58709. * @param scene the scene to create the trail mesh in
  58710. * @returns the created trail mesh
  58711. */
  58712. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58713. }
  58714. }
  58715. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58716. import { Nullable } from "babylonjs/types";
  58717. import { Scene } from "babylonjs/scene";
  58718. import { Vector4 } from "babylonjs/Maths/math.vector";
  58719. import { Color4 } from "babylonjs/Maths/math.color";
  58720. import { Mesh } from "babylonjs/Meshes/mesh";
  58721. /**
  58722. * Class containing static functions to help procedurally build meshes
  58723. */
  58724. export class TiledBoxBuilder {
  58725. /**
  58726. * Creates a box mesh
  58727. * 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)
  58728. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58730. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58731. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58732. * @param name defines the name of the mesh
  58733. * @param options defines the options used to create the mesh
  58734. * @param scene defines the hosting scene
  58735. * @returns the box mesh
  58736. */
  58737. static CreateTiledBox(name: string, options: {
  58738. pattern?: number;
  58739. width?: number;
  58740. height?: number;
  58741. depth?: number;
  58742. tileSize?: number;
  58743. tileWidth?: number;
  58744. tileHeight?: number;
  58745. alignHorizontal?: number;
  58746. alignVertical?: number;
  58747. faceUV?: Vector4[];
  58748. faceColors?: Color4[];
  58749. sideOrientation?: number;
  58750. updatable?: boolean;
  58751. }, scene?: Nullable<Scene>): Mesh;
  58752. }
  58753. }
  58754. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58755. import { Vector4 } from "babylonjs/Maths/math.vector";
  58756. import { Mesh } from "babylonjs/Meshes/mesh";
  58757. /**
  58758. * Class containing static functions to help procedurally build meshes
  58759. */
  58760. export class TorusKnotBuilder {
  58761. /**
  58762. * Creates a torus knot mesh
  58763. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58764. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58765. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58766. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58770. * @param name defines the name of the mesh
  58771. * @param options defines the options used to create the mesh
  58772. * @param scene defines the hosting scene
  58773. * @returns the torus knot mesh
  58774. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58775. */
  58776. static CreateTorusKnot(name: string, options: {
  58777. radius?: number;
  58778. tube?: number;
  58779. radialSegments?: number;
  58780. tubularSegments?: number;
  58781. p?: number;
  58782. q?: number;
  58783. updatable?: boolean;
  58784. sideOrientation?: number;
  58785. frontUVs?: Vector4;
  58786. backUVs?: Vector4;
  58787. }, scene: any): Mesh;
  58788. }
  58789. }
  58790. declare module "babylonjs/Meshes/polygonMesh" {
  58791. import { Scene } from "babylonjs/scene";
  58792. import { Vector2 } from "babylonjs/Maths/math.vector";
  58793. import { Mesh } from "babylonjs/Meshes/mesh";
  58794. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58795. import { Path2 } from "babylonjs/Maths/math.path";
  58796. /**
  58797. * Polygon
  58798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58799. */
  58800. export class Polygon {
  58801. /**
  58802. * Creates a rectangle
  58803. * @param xmin bottom X coord
  58804. * @param ymin bottom Y coord
  58805. * @param xmax top X coord
  58806. * @param ymax top Y coord
  58807. * @returns points that make the resulting rectation
  58808. */
  58809. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58810. /**
  58811. * Creates a circle
  58812. * @param radius radius of circle
  58813. * @param cx scale in x
  58814. * @param cy scale in y
  58815. * @param numberOfSides number of sides that make up the circle
  58816. * @returns points that make the resulting circle
  58817. */
  58818. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58819. /**
  58820. * Creates a polygon from input string
  58821. * @param input Input polygon data
  58822. * @returns the parsed points
  58823. */
  58824. static Parse(input: string): Vector2[];
  58825. /**
  58826. * Starts building a polygon from x and y coordinates
  58827. * @param x x coordinate
  58828. * @param y y coordinate
  58829. * @returns the started path2
  58830. */
  58831. static StartingAt(x: number, y: number): Path2;
  58832. }
  58833. /**
  58834. * Builds a polygon
  58835. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58836. */
  58837. export class PolygonMeshBuilder {
  58838. private _points;
  58839. private _outlinepoints;
  58840. private _holes;
  58841. private _name;
  58842. private _scene;
  58843. private _epoints;
  58844. private _eholes;
  58845. private _addToepoint;
  58846. /**
  58847. * Babylon reference to the earcut plugin.
  58848. */
  58849. bjsEarcut: any;
  58850. /**
  58851. * Creates a PolygonMeshBuilder
  58852. * @param name name of the builder
  58853. * @param contours Path of the polygon
  58854. * @param scene scene to add to when creating the mesh
  58855. * @param earcutInjection can be used to inject your own earcut reference
  58856. */
  58857. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58858. /**
  58859. * Adds a whole within the polygon
  58860. * @param hole Array of points defining the hole
  58861. * @returns this
  58862. */
  58863. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58864. /**
  58865. * Creates the polygon
  58866. * @param updatable If the mesh should be updatable
  58867. * @param depth The depth of the mesh created
  58868. * @returns the created mesh
  58869. */
  58870. build(updatable?: boolean, depth?: number): Mesh;
  58871. /**
  58872. * Creates the polygon
  58873. * @param depth The depth of the mesh created
  58874. * @returns the created VertexData
  58875. */
  58876. buildVertexData(depth?: number): VertexData;
  58877. /**
  58878. * Adds a side to the polygon
  58879. * @param positions points that make the polygon
  58880. * @param normals normals of the polygon
  58881. * @param uvs uvs of the polygon
  58882. * @param indices indices of the polygon
  58883. * @param bounds bounds of the polygon
  58884. * @param points points of the polygon
  58885. * @param depth depth of the polygon
  58886. * @param flip flip of the polygon
  58887. */
  58888. private addSide;
  58889. }
  58890. }
  58891. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58892. import { Scene } from "babylonjs/scene";
  58893. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58894. import { Color4 } from "babylonjs/Maths/math.color";
  58895. import { Mesh } from "babylonjs/Meshes/mesh";
  58896. import { Nullable } from "babylonjs/types";
  58897. /**
  58898. * Class containing static functions to help procedurally build meshes
  58899. */
  58900. export class PolygonBuilder {
  58901. /**
  58902. * Creates a polygon mesh
  58903. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58904. * * 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
  58905. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58908. * * Remember you can only change the shape positions, not their number when updating a polygon
  58909. * @param name defines the name of the mesh
  58910. * @param options defines the options used to create the mesh
  58911. * @param scene defines the hosting scene
  58912. * @param earcutInjection can be used to inject your own earcut reference
  58913. * @returns the polygon mesh
  58914. */
  58915. static CreatePolygon(name: string, options: {
  58916. shape: Vector3[];
  58917. holes?: Vector3[][];
  58918. depth?: number;
  58919. faceUV?: Vector4[];
  58920. faceColors?: Color4[];
  58921. updatable?: boolean;
  58922. sideOrientation?: number;
  58923. frontUVs?: Vector4;
  58924. backUVs?: Vector4;
  58925. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58926. /**
  58927. * Creates an extruded polygon mesh, with depth in the Y direction.
  58928. * * 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)
  58929. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58930. * @param name defines the name of the mesh
  58931. * @param options defines the options used to create the mesh
  58932. * @param scene defines the hosting scene
  58933. * @param earcutInjection can be used to inject your own earcut reference
  58934. * @returns the polygon mesh
  58935. */
  58936. static ExtrudePolygon(name: string, options: {
  58937. shape: Vector3[];
  58938. holes?: Vector3[][];
  58939. depth?: number;
  58940. faceUV?: Vector4[];
  58941. faceColors?: Color4[];
  58942. updatable?: boolean;
  58943. sideOrientation?: number;
  58944. frontUVs?: Vector4;
  58945. backUVs?: Vector4;
  58946. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58947. }
  58948. }
  58949. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58950. import { Scene } from "babylonjs/scene";
  58951. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58952. import { Mesh } from "babylonjs/Meshes/mesh";
  58953. import { Nullable } from "babylonjs/types";
  58954. /**
  58955. * Class containing static functions to help procedurally build meshes
  58956. */
  58957. export class LatheBuilder {
  58958. /**
  58959. * Creates lathe mesh.
  58960. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58961. * * 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
  58962. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58963. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58964. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58965. * * 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
  58966. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58967. * * 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
  58968. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58969. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58970. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58972. * @param name defines the name of the mesh
  58973. * @param options defines the options used to create the mesh
  58974. * @param scene defines the hosting scene
  58975. * @returns the lathe mesh
  58976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58977. */
  58978. static CreateLathe(name: string, options: {
  58979. shape: Vector3[];
  58980. radius?: number;
  58981. tessellation?: number;
  58982. clip?: number;
  58983. arc?: number;
  58984. closed?: boolean;
  58985. updatable?: boolean;
  58986. sideOrientation?: number;
  58987. frontUVs?: Vector4;
  58988. backUVs?: Vector4;
  58989. cap?: number;
  58990. invertUV?: boolean;
  58991. }, scene?: Nullable<Scene>): Mesh;
  58992. }
  58993. }
  58994. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58995. import { Nullable } from "babylonjs/types";
  58996. import { Scene } from "babylonjs/scene";
  58997. import { Vector4 } from "babylonjs/Maths/math.vector";
  58998. import { Mesh } from "babylonjs/Meshes/mesh";
  58999. /**
  59000. * Class containing static functions to help procedurally build meshes
  59001. */
  59002. export class TiledPlaneBuilder {
  59003. /**
  59004. * Creates a tiled plane mesh
  59005. * * The parameter `pattern` will, depending on value, do nothing or
  59006. * * * flip (reflect about central vertical) alternate tiles across and up
  59007. * * * flip every tile on alternate rows
  59008. * * * rotate (180 degs) alternate tiles across and up
  59009. * * * rotate every tile on alternate rows
  59010. * * * flip and rotate alternate tiles across and up
  59011. * * * flip and rotate every tile on alternate rows
  59012. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59013. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59015. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59016. * * 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)
  59017. * * 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)
  59018. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59019. * @param name defines the name of the mesh
  59020. * @param options defines the options used to create the mesh
  59021. * @param scene defines the hosting scene
  59022. * @returns the box mesh
  59023. */
  59024. static CreateTiledPlane(name: string, options: {
  59025. pattern?: number;
  59026. tileSize?: number;
  59027. tileWidth?: number;
  59028. tileHeight?: number;
  59029. size?: number;
  59030. width?: number;
  59031. height?: number;
  59032. alignHorizontal?: number;
  59033. alignVertical?: number;
  59034. sideOrientation?: number;
  59035. frontUVs?: Vector4;
  59036. backUVs?: Vector4;
  59037. updatable?: boolean;
  59038. }, scene?: Nullable<Scene>): Mesh;
  59039. }
  59040. }
  59041. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59042. import { Nullable } from "babylonjs/types";
  59043. import { Scene } from "babylonjs/scene";
  59044. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59045. import { Mesh } from "babylonjs/Meshes/mesh";
  59046. /**
  59047. * Class containing static functions to help procedurally build meshes
  59048. */
  59049. export class TubeBuilder {
  59050. /**
  59051. * Creates a tube mesh.
  59052. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59053. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59054. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59055. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59056. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59057. * * 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)
  59058. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59059. * * 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
  59060. * * 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
  59061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59065. * @param name defines the name of the mesh
  59066. * @param options defines the options used to create the mesh
  59067. * @param scene defines the hosting scene
  59068. * @returns the tube mesh
  59069. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59070. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59071. */
  59072. static CreateTube(name: string, options: {
  59073. path: Vector3[];
  59074. radius?: number;
  59075. tessellation?: number;
  59076. radiusFunction?: {
  59077. (i: number, distance: number): number;
  59078. };
  59079. cap?: number;
  59080. arc?: number;
  59081. updatable?: boolean;
  59082. sideOrientation?: number;
  59083. frontUVs?: Vector4;
  59084. backUVs?: Vector4;
  59085. instance?: Mesh;
  59086. invertUV?: boolean;
  59087. }, scene?: Nullable<Scene>): Mesh;
  59088. }
  59089. }
  59090. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59091. import { Scene } from "babylonjs/scene";
  59092. import { Vector4 } from "babylonjs/Maths/math.vector";
  59093. import { Mesh } from "babylonjs/Meshes/mesh";
  59094. import { Nullable } from "babylonjs/types";
  59095. /**
  59096. * Class containing static functions to help procedurally build meshes
  59097. */
  59098. export class IcoSphereBuilder {
  59099. /**
  59100. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59101. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59102. * * 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`)
  59103. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59104. * * 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
  59105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59106. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59108. * @param name defines the name of the mesh
  59109. * @param options defines the options used to create the mesh
  59110. * @param scene defines the hosting scene
  59111. * @returns the icosahedron mesh
  59112. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59113. */
  59114. static CreateIcoSphere(name: string, options: {
  59115. radius?: number;
  59116. radiusX?: number;
  59117. radiusY?: number;
  59118. radiusZ?: number;
  59119. flat?: boolean;
  59120. subdivisions?: number;
  59121. sideOrientation?: number;
  59122. frontUVs?: Vector4;
  59123. backUVs?: Vector4;
  59124. updatable?: boolean;
  59125. }, scene?: Nullable<Scene>): Mesh;
  59126. }
  59127. }
  59128. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59129. import { Vector3 } from "babylonjs/Maths/math.vector";
  59130. import { Mesh } from "babylonjs/Meshes/mesh";
  59131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59132. /**
  59133. * Class containing static functions to help procedurally build meshes
  59134. */
  59135. export class DecalBuilder {
  59136. /**
  59137. * Creates a decal mesh.
  59138. * 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
  59139. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59140. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59141. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59142. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59143. * @param name defines the name of the mesh
  59144. * @param sourceMesh defines the mesh where the decal must be applied
  59145. * @param options defines the options used to create the mesh
  59146. * @param scene defines the hosting scene
  59147. * @returns the decal mesh
  59148. * @see https://doc.babylonjs.com/how_to/decals
  59149. */
  59150. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59151. position?: Vector3;
  59152. normal?: Vector3;
  59153. size?: Vector3;
  59154. angle?: number;
  59155. }): Mesh;
  59156. }
  59157. }
  59158. declare module "babylonjs/Meshes/meshBuilder" {
  59159. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59160. import { Nullable } from "babylonjs/types";
  59161. import { Scene } from "babylonjs/scene";
  59162. import { Mesh } from "babylonjs/Meshes/mesh";
  59163. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59164. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59166. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59167. import { Plane } from "babylonjs/Maths/math.plane";
  59168. /**
  59169. * Class containing static functions to help procedurally build meshes
  59170. */
  59171. export class MeshBuilder {
  59172. /**
  59173. * Creates a box mesh
  59174. * * The parameter `size` sets the size (float) of each box side (default 1)
  59175. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59176. * * 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)
  59177. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59181. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59182. * @param name defines the name of the mesh
  59183. * @param options defines the options used to create the mesh
  59184. * @param scene defines the hosting scene
  59185. * @returns the box mesh
  59186. */
  59187. static CreateBox(name: string, options: {
  59188. size?: number;
  59189. width?: number;
  59190. height?: number;
  59191. depth?: number;
  59192. faceUV?: Vector4[];
  59193. faceColors?: Color4[];
  59194. sideOrientation?: number;
  59195. frontUVs?: Vector4;
  59196. backUVs?: Vector4;
  59197. updatable?: boolean;
  59198. }, scene?: Nullable<Scene>): Mesh;
  59199. /**
  59200. * Creates a tiled box mesh
  59201. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59203. * @param name defines the name of the mesh
  59204. * @param options defines the options used to create the mesh
  59205. * @param scene defines the hosting scene
  59206. * @returns the tiled box mesh
  59207. */
  59208. static CreateTiledBox(name: string, options: {
  59209. pattern?: number;
  59210. size?: number;
  59211. width?: number;
  59212. height?: number;
  59213. depth: number;
  59214. tileSize?: number;
  59215. tileWidth?: number;
  59216. tileHeight?: number;
  59217. faceUV?: Vector4[];
  59218. faceColors?: Color4[];
  59219. alignHorizontal?: number;
  59220. alignVertical?: number;
  59221. sideOrientation?: number;
  59222. updatable?: boolean;
  59223. }, scene?: Nullable<Scene>): Mesh;
  59224. /**
  59225. * Creates a sphere mesh
  59226. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59227. * * 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`)
  59228. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59229. * * 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
  59230. * * 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)
  59231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59234. * @param name defines the name of the mesh
  59235. * @param options defines the options used to create the mesh
  59236. * @param scene defines the hosting scene
  59237. * @returns the sphere mesh
  59238. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59239. */
  59240. static CreateSphere(name: string, options: {
  59241. segments?: number;
  59242. diameter?: number;
  59243. diameterX?: number;
  59244. diameterY?: number;
  59245. diameterZ?: number;
  59246. arc?: number;
  59247. slice?: number;
  59248. sideOrientation?: number;
  59249. frontUVs?: Vector4;
  59250. backUVs?: Vector4;
  59251. updatable?: boolean;
  59252. }, scene?: Nullable<Scene>): Mesh;
  59253. /**
  59254. * Creates a plane polygonal mesh. By default, this is a disc
  59255. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59256. * * 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
  59257. * * 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
  59258. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59261. * @param name defines the name of the mesh
  59262. * @param options defines the options used to create the mesh
  59263. * @param scene defines the hosting scene
  59264. * @returns the plane polygonal mesh
  59265. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59266. */
  59267. static CreateDisc(name: string, options: {
  59268. radius?: number;
  59269. tessellation?: number;
  59270. arc?: number;
  59271. updatable?: boolean;
  59272. sideOrientation?: number;
  59273. frontUVs?: Vector4;
  59274. backUVs?: Vector4;
  59275. }, scene?: Nullable<Scene>): Mesh;
  59276. /**
  59277. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59278. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59279. * * 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`)
  59280. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59281. * * 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
  59282. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59283. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59284. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59285. * @param name defines the name of the mesh
  59286. * @param options defines the options used to create the mesh
  59287. * @param scene defines the hosting scene
  59288. * @returns the icosahedron mesh
  59289. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59290. */
  59291. static CreateIcoSphere(name: string, options: {
  59292. radius?: number;
  59293. radiusX?: number;
  59294. radiusY?: number;
  59295. radiusZ?: number;
  59296. flat?: boolean;
  59297. subdivisions?: number;
  59298. sideOrientation?: number;
  59299. frontUVs?: Vector4;
  59300. backUVs?: Vector4;
  59301. updatable?: boolean;
  59302. }, scene?: Nullable<Scene>): Mesh;
  59303. /**
  59304. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59305. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59306. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59307. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59308. * * 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
  59309. * * 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
  59310. * * 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
  59311. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59312. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59313. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59314. * * 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
  59315. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59316. * * 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
  59317. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59319. * @param name defines the name of the mesh
  59320. * @param options defines the options used to create the mesh
  59321. * @param scene defines the hosting scene
  59322. * @returns the ribbon mesh
  59323. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59324. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59325. */
  59326. static CreateRibbon(name: string, options: {
  59327. pathArray: Vector3[][];
  59328. closeArray?: boolean;
  59329. closePath?: boolean;
  59330. offset?: number;
  59331. updatable?: boolean;
  59332. sideOrientation?: number;
  59333. frontUVs?: Vector4;
  59334. backUVs?: Vector4;
  59335. instance?: Mesh;
  59336. invertUV?: boolean;
  59337. uvs?: Vector2[];
  59338. colors?: Color4[];
  59339. }, scene?: Nullable<Scene>): Mesh;
  59340. /**
  59341. * Creates a cylinder or a cone mesh
  59342. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59343. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59344. * * 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.
  59345. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59346. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59347. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59348. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59349. * * 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).
  59350. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59351. * * 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).
  59352. * * 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
  59353. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59354. * * 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
  59355. * * 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.
  59356. * * If `enclose` is false, a ring surface is one element.
  59357. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59358. * * 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
  59359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59360. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59362. * @param name defines the name of the mesh
  59363. * @param options defines the options used to create the mesh
  59364. * @param scene defines the hosting scene
  59365. * @returns the cylinder mesh
  59366. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59367. */
  59368. static CreateCylinder(name: string, options: {
  59369. height?: number;
  59370. diameterTop?: number;
  59371. diameterBottom?: number;
  59372. diameter?: number;
  59373. tessellation?: number;
  59374. subdivisions?: number;
  59375. arc?: number;
  59376. faceColors?: Color4[];
  59377. faceUV?: Vector4[];
  59378. updatable?: boolean;
  59379. hasRings?: boolean;
  59380. enclose?: boolean;
  59381. cap?: number;
  59382. sideOrientation?: number;
  59383. frontUVs?: Vector4;
  59384. backUVs?: Vector4;
  59385. }, scene?: Nullable<Scene>): Mesh;
  59386. /**
  59387. * Creates a torus mesh
  59388. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59389. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59390. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59394. * @param name defines the name of the mesh
  59395. * @param options defines the options used to create the mesh
  59396. * @param scene defines the hosting scene
  59397. * @returns the torus mesh
  59398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59399. */
  59400. static CreateTorus(name: string, options: {
  59401. diameter?: number;
  59402. thickness?: number;
  59403. tessellation?: number;
  59404. updatable?: boolean;
  59405. sideOrientation?: number;
  59406. frontUVs?: Vector4;
  59407. backUVs?: Vector4;
  59408. }, scene?: Nullable<Scene>): Mesh;
  59409. /**
  59410. * Creates a torus knot mesh
  59411. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59412. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59413. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59414. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59418. * @param name defines the name of the mesh
  59419. * @param options defines the options used to create the mesh
  59420. * @param scene defines the hosting scene
  59421. * @returns the torus knot mesh
  59422. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59423. */
  59424. static CreateTorusKnot(name: string, options: {
  59425. radius?: number;
  59426. tube?: number;
  59427. radialSegments?: number;
  59428. tubularSegments?: number;
  59429. p?: number;
  59430. q?: number;
  59431. updatable?: boolean;
  59432. sideOrientation?: number;
  59433. frontUVs?: Vector4;
  59434. backUVs?: Vector4;
  59435. }, scene?: Nullable<Scene>): Mesh;
  59436. /**
  59437. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59438. * * 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
  59439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59440. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59441. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59442. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59444. * * 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
  59445. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59448. * @param name defines the name of the new line system
  59449. * @param options defines the options used to create the line system
  59450. * @param scene defines the hosting scene
  59451. * @returns a new line system mesh
  59452. */
  59453. static CreateLineSystem(name: string, options: {
  59454. lines: Vector3[][];
  59455. updatable?: boolean;
  59456. instance?: Nullable<LinesMesh>;
  59457. colors?: Nullable<Color4[][]>;
  59458. useVertexAlpha?: boolean;
  59459. }, scene: Nullable<Scene>): LinesMesh;
  59460. /**
  59461. * Creates a line mesh
  59462. * 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
  59463. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59464. * * The parameter `points` is an array successive Vector3
  59465. * * 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
  59466. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59467. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59468. * * When updating an instance, remember that only point positions can change, not the number of points
  59469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59471. * @param name defines the name of the new line system
  59472. * @param options defines the options used to create the line system
  59473. * @param scene defines the hosting scene
  59474. * @returns a new line mesh
  59475. */
  59476. static CreateLines(name: string, options: {
  59477. points: Vector3[];
  59478. updatable?: boolean;
  59479. instance?: Nullable<LinesMesh>;
  59480. colors?: Color4[];
  59481. useVertexAlpha?: boolean;
  59482. }, scene?: Nullable<Scene>): LinesMesh;
  59483. /**
  59484. * Creates a dashed line mesh
  59485. * * 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
  59486. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59487. * * The parameter `points` is an array successive Vector3
  59488. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59489. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59490. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59491. * * 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
  59492. * * When updating an instance, remember that only point positions can change, not the number of points
  59493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59494. * @param name defines the name of the mesh
  59495. * @param options defines the options used to create the mesh
  59496. * @param scene defines the hosting scene
  59497. * @returns the dashed line mesh
  59498. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59499. */
  59500. static CreateDashedLines(name: string, options: {
  59501. points: Vector3[];
  59502. dashSize?: number;
  59503. gapSize?: number;
  59504. dashNb?: number;
  59505. updatable?: boolean;
  59506. instance?: LinesMesh;
  59507. }, scene?: Nullable<Scene>): LinesMesh;
  59508. /**
  59509. * 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.
  59510. * * 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.
  59511. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59512. * * 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.
  59513. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59514. * * 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
  59515. * * 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
  59516. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59518. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59519. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59521. * @param name defines the name of the mesh
  59522. * @param options defines the options used to create the mesh
  59523. * @param scene defines the hosting scene
  59524. * @returns the extruded shape mesh
  59525. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59527. */
  59528. static ExtrudeShape(name: string, options: {
  59529. shape: Vector3[];
  59530. path: Vector3[];
  59531. scale?: number;
  59532. rotation?: number;
  59533. cap?: number;
  59534. updatable?: boolean;
  59535. sideOrientation?: number;
  59536. frontUVs?: Vector4;
  59537. backUVs?: Vector4;
  59538. instance?: Mesh;
  59539. invertUV?: boolean;
  59540. }, scene?: Nullable<Scene>): Mesh;
  59541. /**
  59542. * Creates an custom extruded shape mesh.
  59543. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59544. * * 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.
  59545. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59546. * * 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
  59547. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59548. * * 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
  59549. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59550. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59551. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59552. * * 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
  59553. * * 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
  59554. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59557. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59559. * @param name defines the name of the mesh
  59560. * @param options defines the options used to create the mesh
  59561. * @param scene defines the hosting scene
  59562. * @returns the custom extruded shape mesh
  59563. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59564. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59565. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59566. */
  59567. static ExtrudeShapeCustom(name: string, options: {
  59568. shape: Vector3[];
  59569. path: Vector3[];
  59570. scaleFunction?: any;
  59571. rotationFunction?: any;
  59572. ribbonCloseArray?: boolean;
  59573. ribbonClosePath?: boolean;
  59574. cap?: number;
  59575. updatable?: boolean;
  59576. sideOrientation?: number;
  59577. frontUVs?: Vector4;
  59578. backUVs?: Vector4;
  59579. instance?: Mesh;
  59580. invertUV?: boolean;
  59581. }, scene?: Nullable<Scene>): Mesh;
  59582. /**
  59583. * Creates lathe mesh.
  59584. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59585. * * 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
  59586. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59587. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59588. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59589. * * 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
  59590. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59591. * * 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
  59592. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59594. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59596. * @param name defines the name of the mesh
  59597. * @param options defines the options used to create the mesh
  59598. * @param scene defines the hosting scene
  59599. * @returns the lathe mesh
  59600. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59601. */
  59602. static CreateLathe(name: string, options: {
  59603. shape: Vector3[];
  59604. radius?: number;
  59605. tessellation?: number;
  59606. clip?: number;
  59607. arc?: number;
  59608. closed?: boolean;
  59609. updatable?: boolean;
  59610. sideOrientation?: number;
  59611. frontUVs?: Vector4;
  59612. backUVs?: Vector4;
  59613. cap?: number;
  59614. invertUV?: boolean;
  59615. }, scene?: Nullable<Scene>): Mesh;
  59616. /**
  59617. * Creates a tiled plane mesh
  59618. * * You can set a limited pattern arrangement with the tiles
  59619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59622. * @param name defines the name of the mesh
  59623. * @param options defines the options used to create the mesh
  59624. * @param scene defines the hosting scene
  59625. * @returns the plane mesh
  59626. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59627. */
  59628. static CreateTiledPlane(name: string, options: {
  59629. pattern?: number;
  59630. tileSize?: number;
  59631. tileWidth?: number;
  59632. tileHeight?: number;
  59633. size?: number;
  59634. width?: number;
  59635. height?: number;
  59636. alignHorizontal?: number;
  59637. alignVertical?: number;
  59638. sideOrientation?: number;
  59639. frontUVs?: Vector4;
  59640. backUVs?: Vector4;
  59641. updatable?: boolean;
  59642. }, scene?: Nullable<Scene>): Mesh;
  59643. /**
  59644. * Creates a plane mesh
  59645. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59646. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59647. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59649. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59651. * @param name defines the name of the mesh
  59652. * @param options defines the options used to create the mesh
  59653. * @param scene defines the hosting scene
  59654. * @returns the plane mesh
  59655. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59656. */
  59657. static CreatePlane(name: string, options: {
  59658. size?: number;
  59659. width?: number;
  59660. height?: number;
  59661. sideOrientation?: number;
  59662. frontUVs?: Vector4;
  59663. backUVs?: Vector4;
  59664. updatable?: boolean;
  59665. sourcePlane?: Plane;
  59666. }, scene?: Nullable<Scene>): Mesh;
  59667. /**
  59668. * Creates a ground mesh
  59669. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59670. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59672. * @param name defines the name of the mesh
  59673. * @param options defines the options used to create the mesh
  59674. * @param scene defines the hosting scene
  59675. * @returns the ground mesh
  59676. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59677. */
  59678. static CreateGround(name: string, options: {
  59679. width?: number;
  59680. height?: number;
  59681. subdivisions?: number;
  59682. subdivisionsX?: number;
  59683. subdivisionsY?: number;
  59684. updatable?: boolean;
  59685. }, scene?: Nullable<Scene>): Mesh;
  59686. /**
  59687. * Creates a tiled ground mesh
  59688. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59689. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59690. * * 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
  59691. * * 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
  59692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59693. * @param name defines the name of the mesh
  59694. * @param options defines the options used to create the mesh
  59695. * @param scene defines the hosting scene
  59696. * @returns the tiled ground mesh
  59697. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59698. */
  59699. static CreateTiledGround(name: string, options: {
  59700. xmin: number;
  59701. zmin: number;
  59702. xmax: number;
  59703. zmax: number;
  59704. subdivisions?: {
  59705. w: number;
  59706. h: number;
  59707. };
  59708. precision?: {
  59709. w: number;
  59710. h: number;
  59711. };
  59712. updatable?: boolean;
  59713. }, scene?: Nullable<Scene>): Mesh;
  59714. /**
  59715. * Creates a ground mesh from a height map
  59716. * * The parameter `url` sets the URL of the height map image resource.
  59717. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59718. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59719. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59720. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59721. * * 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.
  59722. * * 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).
  59723. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59725. * @param name defines the name of the mesh
  59726. * @param url defines the url to the height map
  59727. * @param options defines the options used to create the mesh
  59728. * @param scene defines the hosting scene
  59729. * @returns the ground mesh
  59730. * @see https://doc.babylonjs.com/babylon101/height_map
  59731. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59732. */
  59733. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59734. width?: number;
  59735. height?: number;
  59736. subdivisions?: number;
  59737. minHeight?: number;
  59738. maxHeight?: number;
  59739. colorFilter?: Color3;
  59740. alphaFilter?: number;
  59741. updatable?: boolean;
  59742. onReady?: (mesh: GroundMesh) => void;
  59743. }, scene?: Nullable<Scene>): GroundMesh;
  59744. /**
  59745. * Creates a polygon mesh
  59746. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59747. * * 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
  59748. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59751. * * Remember you can only change the shape positions, not their number when updating a polygon
  59752. * @param name defines the name of the mesh
  59753. * @param options defines the options used to create the mesh
  59754. * @param scene defines the hosting scene
  59755. * @param earcutInjection can be used to inject your own earcut reference
  59756. * @returns the polygon mesh
  59757. */
  59758. static CreatePolygon(name: string, options: {
  59759. shape: Vector3[];
  59760. holes?: Vector3[][];
  59761. depth?: number;
  59762. faceUV?: Vector4[];
  59763. faceColors?: Color4[];
  59764. updatable?: boolean;
  59765. sideOrientation?: number;
  59766. frontUVs?: Vector4;
  59767. backUVs?: Vector4;
  59768. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59769. /**
  59770. * Creates an extruded polygon mesh, with depth in the Y direction.
  59771. * * 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)
  59772. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59773. * @param name defines the name of the mesh
  59774. * @param options defines the options used to create the mesh
  59775. * @param scene defines the hosting scene
  59776. * @param earcutInjection can be used to inject your own earcut reference
  59777. * @returns the polygon mesh
  59778. */
  59779. static ExtrudePolygon(name: string, options: {
  59780. shape: Vector3[];
  59781. holes?: Vector3[][];
  59782. depth?: number;
  59783. faceUV?: Vector4[];
  59784. faceColors?: Color4[];
  59785. updatable?: boolean;
  59786. sideOrientation?: number;
  59787. frontUVs?: Vector4;
  59788. backUVs?: Vector4;
  59789. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59790. /**
  59791. * Creates a tube mesh.
  59792. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59793. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59794. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59795. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59796. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59797. * * 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)
  59798. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59799. * * 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
  59800. * * 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
  59801. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59802. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59803. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59805. * @param name defines the name of the mesh
  59806. * @param options defines the options used to create the mesh
  59807. * @param scene defines the hosting scene
  59808. * @returns the tube mesh
  59809. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59810. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59811. */
  59812. static CreateTube(name: string, options: {
  59813. path: Vector3[];
  59814. radius?: number;
  59815. tessellation?: number;
  59816. radiusFunction?: {
  59817. (i: number, distance: number): number;
  59818. };
  59819. cap?: number;
  59820. arc?: number;
  59821. updatable?: boolean;
  59822. sideOrientation?: number;
  59823. frontUVs?: Vector4;
  59824. backUVs?: Vector4;
  59825. instance?: Mesh;
  59826. invertUV?: boolean;
  59827. }, scene?: Nullable<Scene>): Mesh;
  59828. /**
  59829. * Creates a polyhedron mesh
  59830. * * 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
  59831. * * The parameter `size` (positive float, default 1) sets the polygon size
  59832. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59833. * * 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`
  59834. * * 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
  59835. * * 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)`)
  59836. * * 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
  59837. * * 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
  59838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59841. * @param name defines the name of the mesh
  59842. * @param options defines the options used to create the mesh
  59843. * @param scene defines the hosting scene
  59844. * @returns the polyhedron mesh
  59845. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59846. */
  59847. static CreatePolyhedron(name: string, options: {
  59848. type?: number;
  59849. size?: number;
  59850. sizeX?: number;
  59851. sizeY?: number;
  59852. sizeZ?: number;
  59853. custom?: any;
  59854. faceUV?: Vector4[];
  59855. faceColors?: Color4[];
  59856. flat?: boolean;
  59857. updatable?: boolean;
  59858. sideOrientation?: number;
  59859. frontUVs?: Vector4;
  59860. backUVs?: Vector4;
  59861. }, scene?: Nullable<Scene>): Mesh;
  59862. /**
  59863. * Creates a decal mesh.
  59864. * 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
  59865. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59866. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59867. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59868. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59869. * @param name defines the name of the mesh
  59870. * @param sourceMesh defines the mesh where the decal must be applied
  59871. * @param options defines the options used to create the mesh
  59872. * @param scene defines the hosting scene
  59873. * @returns the decal mesh
  59874. * @see https://doc.babylonjs.com/how_to/decals
  59875. */
  59876. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59877. position?: Vector3;
  59878. normal?: Vector3;
  59879. size?: Vector3;
  59880. angle?: number;
  59881. }): Mesh;
  59882. }
  59883. }
  59884. declare module "babylonjs/Meshes/meshSimplification" {
  59885. import { Mesh } from "babylonjs/Meshes/mesh";
  59886. /**
  59887. * A simplifier interface for future simplification implementations
  59888. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59889. */
  59890. export interface ISimplifier {
  59891. /**
  59892. * Simplification of a given mesh according to the given settings.
  59893. * Since this requires computation, it is assumed that the function runs async.
  59894. * @param settings The settings of the simplification, including quality and distance
  59895. * @param successCallback A callback that will be called after the mesh was simplified.
  59896. * @param errorCallback in case of an error, this callback will be called. optional.
  59897. */
  59898. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59899. }
  59900. /**
  59901. * Expected simplification settings.
  59902. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59903. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59904. */
  59905. export interface ISimplificationSettings {
  59906. /**
  59907. * Gets or sets the expected quality
  59908. */
  59909. quality: number;
  59910. /**
  59911. * Gets or sets the distance when this optimized version should be used
  59912. */
  59913. distance: number;
  59914. /**
  59915. * Gets an already optimized mesh
  59916. */
  59917. optimizeMesh?: boolean;
  59918. }
  59919. /**
  59920. * Class used to specify simplification options
  59921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59922. */
  59923. export class SimplificationSettings implements ISimplificationSettings {
  59924. /** expected quality */
  59925. quality: number;
  59926. /** distance when this optimized version should be used */
  59927. distance: number;
  59928. /** already optimized mesh */
  59929. optimizeMesh?: boolean | undefined;
  59930. /**
  59931. * Creates a SimplificationSettings
  59932. * @param quality expected quality
  59933. * @param distance distance when this optimized version should be used
  59934. * @param optimizeMesh already optimized mesh
  59935. */
  59936. constructor(
  59937. /** expected quality */
  59938. quality: number,
  59939. /** distance when this optimized version should be used */
  59940. distance: number,
  59941. /** already optimized mesh */
  59942. optimizeMesh?: boolean | undefined);
  59943. }
  59944. /**
  59945. * Interface used to define a simplification task
  59946. */
  59947. export interface ISimplificationTask {
  59948. /**
  59949. * Array of settings
  59950. */
  59951. settings: Array<ISimplificationSettings>;
  59952. /**
  59953. * Simplification type
  59954. */
  59955. simplificationType: SimplificationType;
  59956. /**
  59957. * Mesh to simplify
  59958. */
  59959. mesh: Mesh;
  59960. /**
  59961. * Callback called on success
  59962. */
  59963. successCallback?: () => void;
  59964. /**
  59965. * Defines if parallel processing can be used
  59966. */
  59967. parallelProcessing: boolean;
  59968. }
  59969. /**
  59970. * Queue used to order the simplification tasks
  59971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59972. */
  59973. export class SimplificationQueue {
  59974. private _simplificationArray;
  59975. /**
  59976. * Gets a boolean indicating that the process is still running
  59977. */
  59978. running: boolean;
  59979. /**
  59980. * Creates a new queue
  59981. */
  59982. constructor();
  59983. /**
  59984. * Adds a new simplification task
  59985. * @param task defines a task to add
  59986. */
  59987. addTask(task: ISimplificationTask): void;
  59988. /**
  59989. * Execute next task
  59990. */
  59991. executeNext(): void;
  59992. /**
  59993. * Execute a simplification task
  59994. * @param task defines the task to run
  59995. */
  59996. runSimplification(task: ISimplificationTask): void;
  59997. private getSimplifier;
  59998. }
  59999. /**
  60000. * The implemented types of simplification
  60001. * At the moment only Quadratic Error Decimation is implemented
  60002. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60003. */
  60004. export enum SimplificationType {
  60005. /** Quadratic error decimation */
  60006. QUADRATIC = 0
  60007. }
  60008. }
  60009. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60010. import { Scene } from "babylonjs/scene";
  60011. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60012. import { ISceneComponent } from "babylonjs/sceneComponent";
  60013. module "babylonjs/scene" {
  60014. interface Scene {
  60015. /** @hidden (Backing field) */
  60016. _simplificationQueue: SimplificationQueue;
  60017. /**
  60018. * Gets or sets the simplification queue attached to the scene
  60019. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60020. */
  60021. simplificationQueue: SimplificationQueue;
  60022. }
  60023. }
  60024. module "babylonjs/Meshes/mesh" {
  60025. interface Mesh {
  60026. /**
  60027. * Simplify the mesh according to the given array of settings.
  60028. * Function will return immediately and will simplify async
  60029. * @param settings a collection of simplification settings
  60030. * @param parallelProcessing should all levels calculate parallel or one after the other
  60031. * @param simplificationType the type of simplification to run
  60032. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60033. * @returns the current mesh
  60034. */
  60035. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60036. }
  60037. }
  60038. /**
  60039. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60040. * created in a scene
  60041. */
  60042. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60043. /**
  60044. * The component name helpfull to identify the component in the list of scene components.
  60045. */
  60046. readonly name: string;
  60047. /**
  60048. * The scene the component belongs to.
  60049. */
  60050. scene: Scene;
  60051. /**
  60052. * Creates a new instance of the component for the given scene
  60053. * @param scene Defines the scene to register the component in
  60054. */
  60055. constructor(scene: Scene);
  60056. /**
  60057. * Registers the component in a given scene
  60058. */
  60059. register(): void;
  60060. /**
  60061. * Rebuilds the elements related to this component in case of
  60062. * context lost for instance.
  60063. */
  60064. rebuild(): void;
  60065. /**
  60066. * Disposes the component and the associated ressources
  60067. */
  60068. dispose(): void;
  60069. private _beforeCameraUpdate;
  60070. }
  60071. }
  60072. declare module "babylonjs/Meshes/Builders/index" {
  60073. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60074. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60075. export * from "babylonjs/Meshes/Builders/discBuilder";
  60076. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60077. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60078. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60079. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60080. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60081. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60082. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60083. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60084. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60085. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60086. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60087. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60088. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60089. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60090. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60091. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60092. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60093. }
  60094. declare module "babylonjs/Meshes/index" {
  60095. export * from "babylonjs/Meshes/abstractMesh";
  60096. export * from "babylonjs/Meshes/buffer";
  60097. export * from "babylonjs/Meshes/Compression/index";
  60098. export * from "babylonjs/Meshes/csg";
  60099. export * from "babylonjs/Meshes/geometry";
  60100. export * from "babylonjs/Meshes/groundMesh";
  60101. export * from "babylonjs/Meshes/trailMesh";
  60102. export * from "babylonjs/Meshes/instancedMesh";
  60103. export * from "babylonjs/Meshes/linesMesh";
  60104. export * from "babylonjs/Meshes/mesh";
  60105. export * from "babylonjs/Meshes/mesh.vertexData";
  60106. export * from "babylonjs/Meshes/meshBuilder";
  60107. export * from "babylonjs/Meshes/meshSimplification";
  60108. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60109. export * from "babylonjs/Meshes/polygonMesh";
  60110. export * from "babylonjs/Meshes/subMesh";
  60111. export * from "babylonjs/Meshes/meshLODLevel";
  60112. export * from "babylonjs/Meshes/transformNode";
  60113. export * from "babylonjs/Meshes/Builders/index";
  60114. export * from "babylonjs/Meshes/dataBuffer";
  60115. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60116. }
  60117. declare module "babylonjs/Morph/index" {
  60118. export * from "babylonjs/Morph/morphTarget";
  60119. export * from "babylonjs/Morph/morphTargetManager";
  60120. }
  60121. declare module "babylonjs/Navigation/INavigationEngine" {
  60122. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60123. import { Vector3 } from "babylonjs/Maths/math";
  60124. import { Mesh } from "babylonjs/Meshes/mesh";
  60125. import { Scene } from "babylonjs/scene";
  60126. /**
  60127. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60128. */
  60129. export interface INavigationEnginePlugin {
  60130. /**
  60131. * plugin name
  60132. */
  60133. name: string;
  60134. /**
  60135. * Creates a navigation mesh
  60136. * @param meshes array of all the geometry used to compute the navigatio mesh
  60137. * @param parameters bunch of parameters used to filter geometry
  60138. */
  60139. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60140. /**
  60141. * Create a navigation mesh debug mesh
  60142. * @param scene is where the mesh will be added
  60143. * @returns debug display mesh
  60144. */
  60145. createDebugNavMesh(scene: Scene): Mesh;
  60146. /**
  60147. * Get a navigation mesh constrained position, closest to the parameter position
  60148. * @param position world position
  60149. * @returns the closest point to position constrained by the navigation mesh
  60150. */
  60151. getClosestPoint(position: Vector3): Vector3;
  60152. /**
  60153. * Get a navigation mesh constrained position, within a particular radius
  60154. * @param position world position
  60155. * @param maxRadius the maximum distance to the constrained world position
  60156. * @returns the closest point to position constrained by the navigation mesh
  60157. */
  60158. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60159. /**
  60160. * Compute the final position from a segment made of destination-position
  60161. * @param position world position
  60162. * @param destination world position
  60163. * @returns the resulting point along the navmesh
  60164. */
  60165. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60166. /**
  60167. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60168. * @param start world position
  60169. * @param end world position
  60170. * @returns array containing world position composing the path
  60171. */
  60172. computePath(start: Vector3, end: Vector3): Vector3[];
  60173. /**
  60174. * If this plugin is supported
  60175. * @returns true if plugin is supported
  60176. */
  60177. isSupported(): boolean;
  60178. /**
  60179. * Create a new Crowd so you can add agents
  60180. * @param maxAgents the maximum agent count in the crowd
  60181. * @param maxAgentRadius the maximum radius an agent can have
  60182. * @param scene to attach the crowd to
  60183. * @returns the crowd you can add agents to
  60184. */
  60185. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60186. /**
  60187. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60188. * The queries will try to find a solution within those bounds
  60189. * default is (1,1,1)
  60190. * @param extent x,y,z value that define the extent around the queries point of reference
  60191. */
  60192. setDefaultQueryExtent(extent: Vector3): void;
  60193. /**
  60194. * Get the Bounding box extent specified by setDefaultQueryExtent
  60195. * @returns the box extent values
  60196. */
  60197. getDefaultQueryExtent(): Vector3;
  60198. /**
  60199. * Release all resources
  60200. */
  60201. dispose(): void;
  60202. }
  60203. /**
  60204. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60205. */
  60206. export interface ICrowd {
  60207. /**
  60208. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60209. * You can attach anything to that node. The node position is updated in the scene update tick.
  60210. * @param pos world position that will be constrained by the navigation mesh
  60211. * @param parameters agent parameters
  60212. * @param transform hooked to the agent that will be update by the scene
  60213. * @returns agent index
  60214. */
  60215. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60216. /**
  60217. * Returns the agent position in world space
  60218. * @param index agent index returned by addAgent
  60219. * @returns world space position
  60220. */
  60221. getAgentPosition(index: number): Vector3;
  60222. /**
  60223. * Gets the agent velocity in world space
  60224. * @param index agent index returned by addAgent
  60225. * @returns world space velocity
  60226. */
  60227. getAgentVelocity(index: number): Vector3;
  60228. /**
  60229. * remove a particular agent previously created
  60230. * @param index agent index returned by addAgent
  60231. */
  60232. removeAgent(index: number): void;
  60233. /**
  60234. * get the list of all agents attached to this crowd
  60235. * @returns list of agent indices
  60236. */
  60237. getAgents(): number[];
  60238. /**
  60239. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60240. * @param deltaTime in seconds
  60241. */
  60242. update(deltaTime: number): void;
  60243. /**
  60244. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60245. * @param index agent index returned by addAgent
  60246. * @param destination targeted world position
  60247. */
  60248. agentGoto(index: number, destination: Vector3): void;
  60249. /**
  60250. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60251. * The queries will try to find a solution within those bounds
  60252. * default is (1,1,1)
  60253. * @param extent x,y,z value that define the extent around the queries point of reference
  60254. */
  60255. setDefaultQueryExtent(extent: Vector3): void;
  60256. /**
  60257. * Get the Bounding box extent specified by setDefaultQueryExtent
  60258. * @returns the box extent values
  60259. */
  60260. getDefaultQueryExtent(): Vector3;
  60261. /**
  60262. * Release all resources
  60263. */
  60264. dispose(): void;
  60265. }
  60266. /**
  60267. * Configures an agent
  60268. */
  60269. export interface IAgentParameters {
  60270. /**
  60271. * Agent radius. [Limit: >= 0]
  60272. */
  60273. radius: number;
  60274. /**
  60275. * Agent height. [Limit: > 0]
  60276. */
  60277. height: number;
  60278. /**
  60279. * Maximum allowed acceleration. [Limit: >= 0]
  60280. */
  60281. maxAcceleration: number;
  60282. /**
  60283. * Maximum allowed speed. [Limit: >= 0]
  60284. */
  60285. maxSpeed: number;
  60286. /**
  60287. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60288. */
  60289. collisionQueryRange: number;
  60290. /**
  60291. * The path visibility optimization range. [Limit: > 0]
  60292. */
  60293. pathOptimizationRange: number;
  60294. /**
  60295. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60296. */
  60297. separationWeight: number;
  60298. }
  60299. /**
  60300. * Configures the navigation mesh creation
  60301. */
  60302. export interface INavMeshParameters {
  60303. /**
  60304. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60305. */
  60306. cs: number;
  60307. /**
  60308. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60309. */
  60310. ch: number;
  60311. /**
  60312. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60313. */
  60314. walkableSlopeAngle: number;
  60315. /**
  60316. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60317. * be considered walkable. [Limit: >= 3] [Units: vx]
  60318. */
  60319. walkableHeight: number;
  60320. /**
  60321. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60322. */
  60323. walkableClimb: number;
  60324. /**
  60325. * The distance to erode/shrink the walkable area of the heightfield away from
  60326. * obstructions. [Limit: >=0] [Units: vx]
  60327. */
  60328. walkableRadius: number;
  60329. /**
  60330. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60331. */
  60332. maxEdgeLen: number;
  60333. /**
  60334. * The maximum distance a simplfied contour's border edges should deviate
  60335. * the original raw contour. [Limit: >=0] [Units: vx]
  60336. */
  60337. maxSimplificationError: number;
  60338. /**
  60339. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60340. */
  60341. minRegionArea: number;
  60342. /**
  60343. * Any regions with a span count smaller than this value will, if possible,
  60344. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60345. */
  60346. mergeRegionArea: number;
  60347. /**
  60348. * The maximum number of vertices allowed for polygons generated during the
  60349. * contour to polygon conversion process. [Limit: >= 3]
  60350. */
  60351. maxVertsPerPoly: number;
  60352. /**
  60353. * Sets the sampling distance to use when generating the detail mesh.
  60354. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60355. */
  60356. detailSampleDist: number;
  60357. /**
  60358. * The maximum distance the detail mesh surface should deviate from heightfield
  60359. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60360. */
  60361. detailSampleMaxError: number;
  60362. }
  60363. }
  60364. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60365. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60366. import { Mesh } from "babylonjs/Meshes/mesh";
  60367. import { Scene } from "babylonjs/scene";
  60368. import { Vector3 } from "babylonjs/Maths/math";
  60369. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60370. /**
  60371. * RecastJS navigation plugin
  60372. */
  60373. export class RecastJSPlugin implements INavigationEnginePlugin {
  60374. /**
  60375. * Reference to the Recast library
  60376. */
  60377. bjsRECAST: any;
  60378. /**
  60379. * plugin name
  60380. */
  60381. name: string;
  60382. /**
  60383. * the first navmesh created. We might extend this to support multiple navmeshes
  60384. */
  60385. navMesh: any;
  60386. /**
  60387. * Initializes the recastJS plugin
  60388. * @param recastInjection can be used to inject your own recast reference
  60389. */
  60390. constructor(recastInjection?: any);
  60391. /**
  60392. * Creates a navigation mesh
  60393. * @param meshes array of all the geometry used to compute the navigatio mesh
  60394. * @param parameters bunch of parameters used to filter geometry
  60395. */
  60396. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60397. /**
  60398. * Create a navigation mesh debug mesh
  60399. * @param scene is where the mesh will be added
  60400. * @returns debug display mesh
  60401. */
  60402. createDebugNavMesh(scene: Scene): Mesh;
  60403. /**
  60404. * Get a navigation mesh constrained position, closest to the parameter position
  60405. * @param position world position
  60406. * @returns the closest point to position constrained by the navigation mesh
  60407. */
  60408. getClosestPoint(position: Vector3): Vector3;
  60409. /**
  60410. * Get a navigation mesh constrained position, within a particular radius
  60411. * @param position world position
  60412. * @param maxRadius the maximum distance to the constrained world position
  60413. * @returns the closest point to position constrained by the navigation mesh
  60414. */
  60415. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60416. /**
  60417. * Compute the final position from a segment made of destination-position
  60418. * @param position world position
  60419. * @param destination world position
  60420. * @returns the resulting point along the navmesh
  60421. */
  60422. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60423. /**
  60424. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60425. * @param start world position
  60426. * @param end world position
  60427. * @returns array containing world position composing the path
  60428. */
  60429. computePath(start: Vector3, end: Vector3): Vector3[];
  60430. /**
  60431. * Create a new Crowd so you can add agents
  60432. * @param maxAgents the maximum agent count in the crowd
  60433. * @param maxAgentRadius the maximum radius an agent can have
  60434. * @param scene to attach the crowd to
  60435. * @returns the crowd you can add agents to
  60436. */
  60437. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60438. /**
  60439. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60440. * The queries will try to find a solution within those bounds
  60441. * default is (1,1,1)
  60442. * @param extent x,y,z value that define the extent around the queries point of reference
  60443. */
  60444. setDefaultQueryExtent(extent: Vector3): void;
  60445. /**
  60446. * Get the Bounding box extent specified by setDefaultQueryExtent
  60447. * @returns the box extent values
  60448. */
  60449. getDefaultQueryExtent(): Vector3;
  60450. /**
  60451. * Disposes
  60452. */
  60453. dispose(): void;
  60454. /**
  60455. * If this plugin is supported
  60456. * @returns true if plugin is supported
  60457. */
  60458. isSupported(): boolean;
  60459. }
  60460. /**
  60461. * Recast detour crowd implementation
  60462. */
  60463. export class RecastJSCrowd implements ICrowd {
  60464. /**
  60465. * Recast/detour plugin
  60466. */
  60467. bjsRECASTPlugin: RecastJSPlugin;
  60468. /**
  60469. * Link to the detour crowd
  60470. */
  60471. recastCrowd: any;
  60472. /**
  60473. * One transform per agent
  60474. */
  60475. transforms: TransformNode[];
  60476. /**
  60477. * All agents created
  60478. */
  60479. agents: number[];
  60480. /**
  60481. * Link to the scene is kept to unregister the crowd from the scene
  60482. */
  60483. private _scene;
  60484. /**
  60485. * Observer for crowd updates
  60486. */
  60487. private _onBeforeAnimationsObserver;
  60488. /**
  60489. * Constructor
  60490. * @param plugin recastJS plugin
  60491. * @param maxAgents the maximum agent count in the crowd
  60492. * @param maxAgentRadius the maximum radius an agent can have
  60493. * @param scene to attach the crowd to
  60494. * @returns the crowd you can add agents to
  60495. */
  60496. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60497. /**
  60498. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60499. * You can attach anything to that node. The node position is updated in the scene update tick.
  60500. * @param pos world position that will be constrained by the navigation mesh
  60501. * @param parameters agent parameters
  60502. * @param transform hooked to the agent that will be update by the scene
  60503. * @returns agent index
  60504. */
  60505. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60506. /**
  60507. * Returns the agent position in world space
  60508. * @param index agent index returned by addAgent
  60509. * @returns world space position
  60510. */
  60511. getAgentPosition(index: number): Vector3;
  60512. /**
  60513. * Returns the agent velocity in world space
  60514. * @param index agent index returned by addAgent
  60515. * @returns world space velocity
  60516. */
  60517. getAgentVelocity(index: number): Vector3;
  60518. /**
  60519. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60520. * @param index agent index returned by addAgent
  60521. * @param destination targeted world position
  60522. */
  60523. agentGoto(index: number, destination: Vector3): void;
  60524. /**
  60525. * remove a particular agent previously created
  60526. * @param index agent index returned by addAgent
  60527. */
  60528. removeAgent(index: number): void;
  60529. /**
  60530. * get the list of all agents attached to this crowd
  60531. * @returns list of agent indices
  60532. */
  60533. getAgents(): number[];
  60534. /**
  60535. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60536. * @param deltaTime in seconds
  60537. */
  60538. update(deltaTime: number): void;
  60539. /**
  60540. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60541. * The queries will try to find a solution within those bounds
  60542. * default is (1,1,1)
  60543. * @param extent x,y,z value that define the extent around the queries point of reference
  60544. */
  60545. setDefaultQueryExtent(extent: Vector3): void;
  60546. /**
  60547. * Get the Bounding box extent specified by setDefaultQueryExtent
  60548. * @returns the box extent values
  60549. */
  60550. getDefaultQueryExtent(): Vector3;
  60551. /**
  60552. * Release all resources
  60553. */
  60554. dispose(): void;
  60555. }
  60556. }
  60557. declare module "babylonjs/Navigation/Plugins/index" {
  60558. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60559. }
  60560. declare module "babylonjs/Navigation/index" {
  60561. export * from "babylonjs/Navigation/INavigationEngine";
  60562. export * from "babylonjs/Navigation/Plugins/index";
  60563. }
  60564. declare module "babylonjs/Offline/database" {
  60565. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60566. /**
  60567. * Class used to enable access to IndexedDB
  60568. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60569. */
  60570. export class Database implements IOfflineProvider {
  60571. private _callbackManifestChecked;
  60572. private _currentSceneUrl;
  60573. private _db;
  60574. private _enableSceneOffline;
  60575. private _enableTexturesOffline;
  60576. private _manifestVersionFound;
  60577. private _mustUpdateRessources;
  60578. private _hasReachedQuota;
  60579. private _isSupported;
  60580. private _idbFactory;
  60581. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60582. private static IsUASupportingBlobStorage;
  60583. /**
  60584. * Gets a boolean indicating if Database storate is enabled (off by default)
  60585. */
  60586. static IDBStorageEnabled: boolean;
  60587. /**
  60588. * Gets a boolean indicating if scene must be saved in the database
  60589. */
  60590. readonly enableSceneOffline: boolean;
  60591. /**
  60592. * Gets a boolean indicating if textures must be saved in the database
  60593. */
  60594. readonly enableTexturesOffline: boolean;
  60595. /**
  60596. * Creates a new Database
  60597. * @param urlToScene defines the url to load the scene
  60598. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60599. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60600. */
  60601. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60602. private static _ParseURL;
  60603. private static _ReturnFullUrlLocation;
  60604. private _checkManifestFile;
  60605. /**
  60606. * Open the database and make it available
  60607. * @param successCallback defines the callback to call on success
  60608. * @param errorCallback defines the callback to call on error
  60609. */
  60610. open(successCallback: () => void, errorCallback: () => void): void;
  60611. /**
  60612. * Loads an image from the database
  60613. * @param url defines the url to load from
  60614. * @param image defines the target DOM image
  60615. */
  60616. loadImage(url: string, image: HTMLImageElement): void;
  60617. private _loadImageFromDBAsync;
  60618. private _saveImageIntoDBAsync;
  60619. private _checkVersionFromDB;
  60620. private _loadVersionFromDBAsync;
  60621. private _saveVersionIntoDBAsync;
  60622. /**
  60623. * Loads a file from database
  60624. * @param url defines the URL to load from
  60625. * @param sceneLoaded defines a callback to call on success
  60626. * @param progressCallBack defines a callback to call when progress changed
  60627. * @param errorCallback defines a callback to call on error
  60628. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60629. */
  60630. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60631. private _loadFileAsync;
  60632. private _saveFileAsync;
  60633. /**
  60634. * Validates if xhr data is correct
  60635. * @param xhr defines the request to validate
  60636. * @param dataType defines the expected data type
  60637. * @returns true if data is correct
  60638. */
  60639. private static _ValidateXHRData;
  60640. }
  60641. }
  60642. declare module "babylonjs/Offline/index" {
  60643. export * from "babylonjs/Offline/database";
  60644. export * from "babylonjs/Offline/IOfflineProvider";
  60645. }
  60646. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60647. /** @hidden */
  60648. export var gpuUpdateParticlesPixelShader: {
  60649. name: string;
  60650. shader: string;
  60651. };
  60652. }
  60653. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60654. /** @hidden */
  60655. export var gpuUpdateParticlesVertexShader: {
  60656. name: string;
  60657. shader: string;
  60658. };
  60659. }
  60660. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60661. /** @hidden */
  60662. export var clipPlaneFragmentDeclaration2: {
  60663. name: string;
  60664. shader: string;
  60665. };
  60666. }
  60667. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60668. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60669. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60670. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60671. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60672. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60673. /** @hidden */
  60674. export var gpuRenderParticlesPixelShader: {
  60675. name: string;
  60676. shader: string;
  60677. };
  60678. }
  60679. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60680. /** @hidden */
  60681. export var clipPlaneVertexDeclaration2: {
  60682. name: string;
  60683. shader: string;
  60684. };
  60685. }
  60686. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60687. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60688. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60689. /** @hidden */
  60690. export var gpuRenderParticlesVertexShader: {
  60691. name: string;
  60692. shader: string;
  60693. };
  60694. }
  60695. declare module "babylonjs/Particles/gpuParticleSystem" {
  60696. import { Nullable } from "babylonjs/types";
  60697. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60698. import { Observable } from "babylonjs/Misc/observable";
  60699. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60700. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60701. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60702. import { Scene, IDisposable } from "babylonjs/scene";
  60703. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60704. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60705. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60706. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60707. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60708. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60709. /**
  60710. * This represents a GPU particle system in Babylon
  60711. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60712. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60713. */
  60714. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60715. /**
  60716. * The layer mask we are rendering the particles through.
  60717. */
  60718. layerMask: number;
  60719. private _capacity;
  60720. private _activeCount;
  60721. private _currentActiveCount;
  60722. private _accumulatedCount;
  60723. private _renderEffect;
  60724. private _updateEffect;
  60725. private _buffer0;
  60726. private _buffer1;
  60727. private _spriteBuffer;
  60728. private _updateVAO;
  60729. private _renderVAO;
  60730. private _targetIndex;
  60731. private _sourceBuffer;
  60732. private _targetBuffer;
  60733. private _engine;
  60734. private _currentRenderId;
  60735. private _started;
  60736. private _stopped;
  60737. private _timeDelta;
  60738. private _randomTexture;
  60739. private _randomTexture2;
  60740. private _attributesStrideSize;
  60741. private _updateEffectOptions;
  60742. private _randomTextureSize;
  60743. private _actualFrame;
  60744. private readonly _rawTextureWidth;
  60745. /**
  60746. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60747. */
  60748. static readonly IsSupported: boolean;
  60749. /**
  60750. * An event triggered when the system is disposed.
  60751. */
  60752. onDisposeObservable: Observable<GPUParticleSystem>;
  60753. /**
  60754. * Gets the maximum number of particles active at the same time.
  60755. * @returns The max number of active particles.
  60756. */
  60757. getCapacity(): number;
  60758. /**
  60759. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60760. * to override the particles.
  60761. */
  60762. forceDepthWrite: boolean;
  60763. /**
  60764. * Gets or set the number of active particles
  60765. */
  60766. activeParticleCount: number;
  60767. private _preWarmDone;
  60768. /**
  60769. * Is this system ready to be used/rendered
  60770. * @return true if the system is ready
  60771. */
  60772. isReady(): boolean;
  60773. /**
  60774. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60775. * @returns True if it has been started, otherwise false.
  60776. */
  60777. isStarted(): boolean;
  60778. /**
  60779. * Starts the particle system and begins to emit
  60780. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60781. */
  60782. start(delay?: number): void;
  60783. /**
  60784. * Stops the particle system.
  60785. */
  60786. stop(): void;
  60787. /**
  60788. * Remove all active particles
  60789. */
  60790. reset(): void;
  60791. /**
  60792. * Returns the string "GPUParticleSystem"
  60793. * @returns a string containing the class name
  60794. */
  60795. getClassName(): string;
  60796. private _colorGradientsTexture;
  60797. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60798. /**
  60799. * Adds a new color gradient
  60800. * @param gradient defines the gradient to use (between 0 and 1)
  60801. * @param color1 defines the color to affect to the specified gradient
  60802. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60803. * @returns the current particle system
  60804. */
  60805. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60806. /**
  60807. * Remove a specific color gradient
  60808. * @param gradient defines the gradient to remove
  60809. * @returns the current particle system
  60810. */
  60811. removeColorGradient(gradient: number): GPUParticleSystem;
  60812. private _angularSpeedGradientsTexture;
  60813. private _sizeGradientsTexture;
  60814. private _velocityGradientsTexture;
  60815. private _limitVelocityGradientsTexture;
  60816. private _dragGradientsTexture;
  60817. private _addFactorGradient;
  60818. /**
  60819. * Adds a new size gradient
  60820. * @param gradient defines the gradient to use (between 0 and 1)
  60821. * @param factor defines the size factor to affect to the specified gradient
  60822. * @returns the current particle system
  60823. */
  60824. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60825. /**
  60826. * Remove a specific size gradient
  60827. * @param gradient defines the gradient to remove
  60828. * @returns the current particle system
  60829. */
  60830. removeSizeGradient(gradient: number): GPUParticleSystem;
  60831. /**
  60832. * Adds a new angular speed gradient
  60833. * @param gradient defines the gradient to use (between 0 and 1)
  60834. * @param factor defines the angular speed to affect to the specified gradient
  60835. * @returns the current particle system
  60836. */
  60837. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60838. /**
  60839. * Remove a specific angular speed gradient
  60840. * @param gradient defines the gradient to remove
  60841. * @returns the current particle system
  60842. */
  60843. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60844. /**
  60845. * Adds a new velocity gradient
  60846. * @param gradient defines the gradient to use (between 0 and 1)
  60847. * @param factor defines the velocity to affect to the specified gradient
  60848. * @returns the current particle system
  60849. */
  60850. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60851. /**
  60852. * Remove a specific velocity gradient
  60853. * @param gradient defines the gradient to remove
  60854. * @returns the current particle system
  60855. */
  60856. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60857. /**
  60858. * Adds a new limit velocity gradient
  60859. * @param gradient defines the gradient to use (between 0 and 1)
  60860. * @param factor defines the limit velocity value to affect to the specified gradient
  60861. * @returns the current particle system
  60862. */
  60863. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60864. /**
  60865. * Remove a specific limit velocity gradient
  60866. * @param gradient defines the gradient to remove
  60867. * @returns the current particle system
  60868. */
  60869. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60870. /**
  60871. * Adds a new drag gradient
  60872. * @param gradient defines the gradient to use (between 0 and 1)
  60873. * @param factor defines the drag value to affect to the specified gradient
  60874. * @returns the current particle system
  60875. */
  60876. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60877. /**
  60878. * Remove a specific drag gradient
  60879. * @param gradient defines the gradient to remove
  60880. * @returns the current particle system
  60881. */
  60882. removeDragGradient(gradient: number): GPUParticleSystem;
  60883. /**
  60884. * Not supported by GPUParticleSystem
  60885. * @param gradient defines the gradient to use (between 0 and 1)
  60886. * @param factor defines the emit rate value to affect to the specified gradient
  60887. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60888. * @returns the current particle system
  60889. */
  60890. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60891. /**
  60892. * Not supported by GPUParticleSystem
  60893. * @param gradient defines the gradient to remove
  60894. * @returns the current particle system
  60895. */
  60896. removeEmitRateGradient(gradient: number): IParticleSystem;
  60897. /**
  60898. * Not supported by GPUParticleSystem
  60899. * @param gradient defines the gradient to use (between 0 and 1)
  60900. * @param factor defines the start size value to affect to the specified gradient
  60901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60902. * @returns the current particle system
  60903. */
  60904. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60905. /**
  60906. * Not supported by GPUParticleSystem
  60907. * @param gradient defines the gradient to remove
  60908. * @returns the current particle system
  60909. */
  60910. removeStartSizeGradient(gradient: number): IParticleSystem;
  60911. /**
  60912. * Not supported by GPUParticleSystem
  60913. * @param gradient defines the gradient to use (between 0 and 1)
  60914. * @param min defines the color remap minimal range
  60915. * @param max defines the color remap maximal range
  60916. * @returns the current particle system
  60917. */
  60918. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60919. /**
  60920. * Not supported by GPUParticleSystem
  60921. * @param gradient defines the gradient to remove
  60922. * @returns the current particle system
  60923. */
  60924. removeColorRemapGradient(): IParticleSystem;
  60925. /**
  60926. * Not supported by GPUParticleSystem
  60927. * @param gradient defines the gradient to use (between 0 and 1)
  60928. * @param min defines the alpha remap minimal range
  60929. * @param max defines the alpha remap maximal range
  60930. * @returns the current particle system
  60931. */
  60932. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60933. /**
  60934. * Not supported by GPUParticleSystem
  60935. * @param gradient defines the gradient to remove
  60936. * @returns the current particle system
  60937. */
  60938. removeAlphaRemapGradient(): IParticleSystem;
  60939. /**
  60940. * Not supported by GPUParticleSystem
  60941. * @param gradient defines the gradient to use (between 0 and 1)
  60942. * @param color defines the color to affect to the specified gradient
  60943. * @returns the current particle system
  60944. */
  60945. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60946. /**
  60947. * Not supported by GPUParticleSystem
  60948. * @param gradient defines the gradient to remove
  60949. * @returns the current particle system
  60950. */
  60951. removeRampGradient(): IParticleSystem;
  60952. /**
  60953. * Not supported by GPUParticleSystem
  60954. * @returns the list of ramp gradients
  60955. */
  60956. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60957. /**
  60958. * Not supported by GPUParticleSystem
  60959. * Gets or sets a boolean indicating that ramp gradients must be used
  60960. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60961. */
  60962. useRampGradients: boolean;
  60963. /**
  60964. * Not supported by GPUParticleSystem
  60965. * @param gradient defines the gradient to use (between 0 and 1)
  60966. * @param factor defines the life time factor to affect to the specified gradient
  60967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60968. * @returns the current particle system
  60969. */
  60970. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60971. /**
  60972. * Not supported by GPUParticleSystem
  60973. * @param gradient defines the gradient to remove
  60974. * @returns the current particle system
  60975. */
  60976. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60977. /**
  60978. * Instantiates a GPU particle system.
  60979. * 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.
  60980. * @param name The name of the particle system
  60981. * @param options The options used to create the system
  60982. * @param scene The scene the particle system belongs to
  60983. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60984. */
  60985. constructor(name: string, options: Partial<{
  60986. capacity: number;
  60987. randomTextureSize: number;
  60988. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60989. protected _reset(): void;
  60990. private _createUpdateVAO;
  60991. private _createRenderVAO;
  60992. private _initialize;
  60993. /** @hidden */
  60994. _recreateUpdateEffect(): void;
  60995. /** @hidden */
  60996. _recreateRenderEffect(): void;
  60997. /**
  60998. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60999. * @param preWarm defines if we are in the pre-warmimg phase
  61000. */
  61001. animate(preWarm?: boolean): void;
  61002. private _createFactorGradientTexture;
  61003. private _createSizeGradientTexture;
  61004. private _createAngularSpeedGradientTexture;
  61005. private _createVelocityGradientTexture;
  61006. private _createLimitVelocityGradientTexture;
  61007. private _createDragGradientTexture;
  61008. private _createColorGradientTexture;
  61009. /**
  61010. * Renders the particle system in its current state
  61011. * @param preWarm defines if the system should only update the particles but not render them
  61012. * @returns the current number of particles
  61013. */
  61014. render(preWarm?: boolean): number;
  61015. /**
  61016. * Rebuilds the particle system
  61017. */
  61018. rebuild(): void;
  61019. private _releaseBuffers;
  61020. private _releaseVAOs;
  61021. /**
  61022. * Disposes the particle system and free the associated resources
  61023. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61024. */
  61025. dispose(disposeTexture?: boolean): void;
  61026. /**
  61027. * Clones the particle system.
  61028. * @param name The name of the cloned object
  61029. * @param newEmitter The new emitter to use
  61030. * @returns the cloned particle system
  61031. */
  61032. clone(name: string, newEmitter: any): GPUParticleSystem;
  61033. /**
  61034. * Serializes the particle system to a JSON object.
  61035. * @returns the JSON object
  61036. */
  61037. serialize(): any;
  61038. /**
  61039. * Parses a JSON object to create a GPU particle system.
  61040. * @param parsedParticleSystem The JSON object to parse
  61041. * @param scene The scene to create the particle system in
  61042. * @param rootUrl The root url to use to load external dependencies like texture
  61043. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61044. * @returns the parsed GPU particle system
  61045. */
  61046. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61047. }
  61048. }
  61049. declare module "babylonjs/Particles/particleSystemSet" {
  61050. import { Nullable } from "babylonjs/types";
  61051. import { Color3 } from "babylonjs/Maths/math.color";
  61052. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61054. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61055. import { Scene, IDisposable } from "babylonjs/scene";
  61056. /**
  61057. * Represents a set of particle systems working together to create a specific effect
  61058. */
  61059. export class ParticleSystemSet implements IDisposable {
  61060. private _emitterCreationOptions;
  61061. private _emitterNode;
  61062. /**
  61063. * Gets the particle system list
  61064. */
  61065. systems: IParticleSystem[];
  61066. /**
  61067. * Gets the emitter node used with this set
  61068. */
  61069. readonly emitterNode: Nullable<TransformNode>;
  61070. /**
  61071. * Creates a new emitter mesh as a sphere
  61072. * @param options defines the options used to create the sphere
  61073. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61074. * @param scene defines the hosting scene
  61075. */
  61076. setEmitterAsSphere(options: {
  61077. diameter: number;
  61078. segments: number;
  61079. color: Color3;
  61080. }, renderingGroupId: number, scene: Scene): void;
  61081. /**
  61082. * Starts all particle systems of the set
  61083. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61084. */
  61085. start(emitter?: AbstractMesh): void;
  61086. /**
  61087. * Release all associated resources
  61088. */
  61089. dispose(): void;
  61090. /**
  61091. * Serialize the set into a JSON compatible object
  61092. * @returns a JSON compatible representation of the set
  61093. */
  61094. serialize(): any;
  61095. /**
  61096. * Parse a new ParticleSystemSet from a serialized source
  61097. * @param data defines a JSON compatible representation of the set
  61098. * @param scene defines the hosting scene
  61099. * @param gpu defines if we want GPU particles or CPU particles
  61100. * @returns a new ParticleSystemSet
  61101. */
  61102. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61103. }
  61104. }
  61105. declare module "babylonjs/Particles/particleHelper" {
  61106. import { Nullable } from "babylonjs/types";
  61107. import { Scene } from "babylonjs/scene";
  61108. import { Vector3 } from "babylonjs/Maths/math.vector";
  61109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61110. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61111. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61112. /**
  61113. * This class is made for on one-liner static method to help creating particle system set.
  61114. */
  61115. export class ParticleHelper {
  61116. /**
  61117. * Gets or sets base Assets URL
  61118. */
  61119. static BaseAssetsUrl: string;
  61120. /**
  61121. * Create a default particle system that you can tweak
  61122. * @param emitter defines the emitter to use
  61123. * @param capacity defines the system capacity (default is 500 particles)
  61124. * @param scene defines the hosting scene
  61125. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61126. * @returns the new Particle system
  61127. */
  61128. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61129. /**
  61130. * This is the main static method (one-liner) of this helper to create different particle systems
  61131. * @param type This string represents the type to the particle system to create
  61132. * @param scene The scene where the particle system should live
  61133. * @param gpu If the system will use gpu
  61134. * @returns the ParticleSystemSet created
  61135. */
  61136. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61137. /**
  61138. * Static function used to export a particle system to a ParticleSystemSet variable.
  61139. * Please note that the emitter shape is not exported
  61140. * @param systems defines the particle systems to export
  61141. * @returns the created particle system set
  61142. */
  61143. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61144. }
  61145. }
  61146. declare module "babylonjs/Particles/particleSystemComponent" {
  61147. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61148. import { Effect } from "babylonjs/Materials/effect";
  61149. import "babylonjs/Shaders/particles.vertex";
  61150. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61151. module "babylonjs/Engines/engine" {
  61152. interface Engine {
  61153. /**
  61154. * Create an effect to use with particle systems.
  61155. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61156. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61157. * @param uniformsNames defines a list of attribute names
  61158. * @param samplers defines an array of string used to represent textures
  61159. * @param defines defines the string containing the defines to use to compile the shaders
  61160. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61161. * @param onCompiled defines a function to call when the effect creation is successful
  61162. * @param onError defines a function to call when the effect creation has failed
  61163. * @returns the new Effect
  61164. */
  61165. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61166. }
  61167. }
  61168. module "babylonjs/Meshes/mesh" {
  61169. interface Mesh {
  61170. /**
  61171. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61172. * @returns an array of IParticleSystem
  61173. */
  61174. getEmittedParticleSystems(): IParticleSystem[];
  61175. /**
  61176. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61177. * @returns an array of IParticleSystem
  61178. */
  61179. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61180. }
  61181. }
  61182. /**
  61183. * @hidden
  61184. */
  61185. export var _IDoNeedToBeInTheBuild: number;
  61186. }
  61187. declare module "babylonjs/Particles/index" {
  61188. export * from "babylonjs/Particles/baseParticleSystem";
  61189. export * from "babylonjs/Particles/EmitterTypes/index";
  61190. export * from "babylonjs/Particles/gpuParticleSystem";
  61191. export * from "babylonjs/Particles/IParticleSystem";
  61192. export * from "babylonjs/Particles/particle";
  61193. export * from "babylonjs/Particles/particleHelper";
  61194. export * from "babylonjs/Particles/particleSystem";
  61195. export * from "babylonjs/Particles/particleSystemComponent";
  61196. export * from "babylonjs/Particles/particleSystemSet";
  61197. export * from "babylonjs/Particles/solidParticle";
  61198. export * from "babylonjs/Particles/solidParticleSystem";
  61199. export * from "babylonjs/Particles/subEmitter";
  61200. }
  61201. declare module "babylonjs/Physics/physicsEngineComponent" {
  61202. import { Nullable } from "babylonjs/types";
  61203. import { Observable, Observer } from "babylonjs/Misc/observable";
  61204. import { Vector3 } from "babylonjs/Maths/math.vector";
  61205. import { Mesh } from "babylonjs/Meshes/mesh";
  61206. import { ISceneComponent } from "babylonjs/sceneComponent";
  61207. import { Scene } from "babylonjs/scene";
  61208. import { Node } from "babylonjs/node";
  61209. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61210. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61211. module "babylonjs/scene" {
  61212. interface Scene {
  61213. /** @hidden (Backing field) */
  61214. _physicsEngine: Nullable<IPhysicsEngine>;
  61215. /**
  61216. * Gets the current physics engine
  61217. * @returns a IPhysicsEngine or null if none attached
  61218. */
  61219. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61220. /**
  61221. * Enables physics to the current scene
  61222. * @param gravity defines the scene's gravity for the physics engine
  61223. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61224. * @return a boolean indicating if the physics engine was initialized
  61225. */
  61226. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61227. /**
  61228. * Disables and disposes the physics engine associated with the scene
  61229. */
  61230. disablePhysicsEngine(): void;
  61231. /**
  61232. * Gets a boolean indicating if there is an active physics engine
  61233. * @returns a boolean indicating if there is an active physics engine
  61234. */
  61235. isPhysicsEnabled(): boolean;
  61236. /**
  61237. * Deletes a physics compound impostor
  61238. * @param compound defines the compound to delete
  61239. */
  61240. deleteCompoundImpostor(compound: any): void;
  61241. /**
  61242. * An event triggered when physic simulation is about to be run
  61243. */
  61244. onBeforePhysicsObservable: Observable<Scene>;
  61245. /**
  61246. * An event triggered when physic simulation has been done
  61247. */
  61248. onAfterPhysicsObservable: Observable<Scene>;
  61249. }
  61250. }
  61251. module "babylonjs/Meshes/abstractMesh" {
  61252. interface AbstractMesh {
  61253. /** @hidden */
  61254. _physicsImpostor: Nullable<PhysicsImpostor>;
  61255. /**
  61256. * Gets or sets impostor used for physic simulation
  61257. * @see http://doc.babylonjs.com/features/physics_engine
  61258. */
  61259. physicsImpostor: Nullable<PhysicsImpostor>;
  61260. /**
  61261. * Gets the current physics impostor
  61262. * @see http://doc.babylonjs.com/features/physics_engine
  61263. * @returns a physics impostor or null
  61264. */
  61265. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61266. /** Apply a physic impulse to the mesh
  61267. * @param force defines the force to apply
  61268. * @param contactPoint defines where to apply the force
  61269. * @returns the current mesh
  61270. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61271. */
  61272. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61273. /**
  61274. * Creates a physic joint between two meshes
  61275. * @param otherMesh defines the other mesh to use
  61276. * @param pivot1 defines the pivot to use on this mesh
  61277. * @param pivot2 defines the pivot to use on the other mesh
  61278. * @param options defines additional options (can be plugin dependent)
  61279. * @returns the current mesh
  61280. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61281. */
  61282. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61283. /** @hidden */
  61284. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61285. }
  61286. }
  61287. /**
  61288. * Defines the physics engine scene component responsible to manage a physics engine
  61289. */
  61290. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61291. /**
  61292. * The component name helpful to identify the component in the list of scene components.
  61293. */
  61294. readonly name: string;
  61295. /**
  61296. * The scene the component belongs to.
  61297. */
  61298. scene: Scene;
  61299. /**
  61300. * Creates a new instance of the component for the given scene
  61301. * @param scene Defines the scene to register the component in
  61302. */
  61303. constructor(scene: Scene);
  61304. /**
  61305. * Registers the component in a given scene
  61306. */
  61307. register(): void;
  61308. /**
  61309. * Rebuilds the elements related to this component in case of
  61310. * context lost for instance.
  61311. */
  61312. rebuild(): void;
  61313. /**
  61314. * Disposes the component and the associated ressources
  61315. */
  61316. dispose(): void;
  61317. }
  61318. }
  61319. declare module "babylonjs/Physics/physicsHelper" {
  61320. import { Nullable } from "babylonjs/types";
  61321. import { Vector3 } from "babylonjs/Maths/math.vector";
  61322. import { Mesh } from "babylonjs/Meshes/mesh";
  61323. import { Scene } from "babylonjs/scene";
  61324. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61325. /**
  61326. * A helper for physics simulations
  61327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61328. */
  61329. export class PhysicsHelper {
  61330. private _scene;
  61331. private _physicsEngine;
  61332. /**
  61333. * Initializes the Physics helper
  61334. * @param scene Babylon.js scene
  61335. */
  61336. constructor(scene: Scene);
  61337. /**
  61338. * Applies a radial explosion impulse
  61339. * @param origin the origin of the explosion
  61340. * @param radiusOrEventOptions the radius or the options of radial explosion
  61341. * @param strength the explosion strength
  61342. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61343. * @returns A physics radial explosion event, or null
  61344. */
  61345. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61346. /**
  61347. * Applies a radial explosion force
  61348. * @param origin the origin of the explosion
  61349. * @param radiusOrEventOptions the radius or the options of radial explosion
  61350. * @param strength the explosion strength
  61351. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61352. * @returns A physics radial explosion event, or null
  61353. */
  61354. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61355. /**
  61356. * Creates a gravitational field
  61357. * @param origin the origin of the explosion
  61358. * @param radiusOrEventOptions the radius or the options of radial explosion
  61359. * @param strength the explosion strength
  61360. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61361. * @returns A physics gravitational field event, or null
  61362. */
  61363. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61364. /**
  61365. * Creates a physics updraft event
  61366. * @param origin the origin of the updraft
  61367. * @param radiusOrEventOptions the radius or the options of the updraft
  61368. * @param strength the strength of the updraft
  61369. * @param height the height of the updraft
  61370. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61371. * @returns A physics updraft event, or null
  61372. */
  61373. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61374. /**
  61375. * Creates a physics vortex event
  61376. * @param origin the of the vortex
  61377. * @param radiusOrEventOptions the radius or the options of the vortex
  61378. * @param strength the strength of the vortex
  61379. * @param height the height of the vortex
  61380. * @returns a Physics vortex event, or null
  61381. * A physics vortex event or null
  61382. */
  61383. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61384. }
  61385. /**
  61386. * Represents a physics radial explosion event
  61387. */
  61388. class PhysicsRadialExplosionEvent {
  61389. private _scene;
  61390. private _options;
  61391. private _sphere;
  61392. private _dataFetched;
  61393. /**
  61394. * Initializes a radial explosioin event
  61395. * @param _scene BabylonJS scene
  61396. * @param _options The options for the vortex event
  61397. */
  61398. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61399. /**
  61400. * Returns the data related to the radial explosion event (sphere).
  61401. * @returns The radial explosion event data
  61402. */
  61403. getData(): PhysicsRadialExplosionEventData;
  61404. /**
  61405. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61406. * @param impostor A physics imposter
  61407. * @param origin the origin of the explosion
  61408. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61409. */
  61410. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61411. /**
  61412. * Triggers affecterd impostors callbacks
  61413. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61414. */
  61415. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61416. /**
  61417. * Disposes the sphere.
  61418. * @param force Specifies if the sphere should be disposed by force
  61419. */
  61420. dispose(force?: boolean): void;
  61421. /*** Helpers ***/
  61422. private _prepareSphere;
  61423. private _intersectsWithSphere;
  61424. }
  61425. /**
  61426. * Represents a gravitational field event
  61427. */
  61428. class PhysicsGravitationalFieldEvent {
  61429. private _physicsHelper;
  61430. private _scene;
  61431. private _origin;
  61432. private _options;
  61433. private _tickCallback;
  61434. private _sphere;
  61435. private _dataFetched;
  61436. /**
  61437. * Initializes the physics gravitational field event
  61438. * @param _physicsHelper A physics helper
  61439. * @param _scene BabylonJS scene
  61440. * @param _origin The origin position of the gravitational field event
  61441. * @param _options The options for the vortex event
  61442. */
  61443. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61444. /**
  61445. * Returns the data related to the gravitational field event (sphere).
  61446. * @returns A gravitational field event
  61447. */
  61448. getData(): PhysicsGravitationalFieldEventData;
  61449. /**
  61450. * Enables the gravitational field.
  61451. */
  61452. enable(): void;
  61453. /**
  61454. * Disables the gravitational field.
  61455. */
  61456. disable(): void;
  61457. /**
  61458. * Disposes the sphere.
  61459. * @param force The force to dispose from the gravitational field event
  61460. */
  61461. dispose(force?: boolean): void;
  61462. private _tick;
  61463. }
  61464. /**
  61465. * Represents a physics updraft event
  61466. */
  61467. class PhysicsUpdraftEvent {
  61468. private _scene;
  61469. private _origin;
  61470. private _options;
  61471. private _physicsEngine;
  61472. private _originTop;
  61473. private _originDirection;
  61474. private _tickCallback;
  61475. private _cylinder;
  61476. private _cylinderPosition;
  61477. private _dataFetched;
  61478. /**
  61479. * Initializes the physics updraft event
  61480. * @param _scene BabylonJS scene
  61481. * @param _origin The origin position of the updraft
  61482. * @param _options The options for the updraft event
  61483. */
  61484. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61485. /**
  61486. * Returns the data related to the updraft event (cylinder).
  61487. * @returns A physics updraft event
  61488. */
  61489. getData(): PhysicsUpdraftEventData;
  61490. /**
  61491. * Enables the updraft.
  61492. */
  61493. enable(): void;
  61494. /**
  61495. * Disables the updraft.
  61496. */
  61497. disable(): void;
  61498. /**
  61499. * Disposes the cylinder.
  61500. * @param force Specifies if the updraft should be disposed by force
  61501. */
  61502. dispose(force?: boolean): void;
  61503. private getImpostorHitData;
  61504. private _tick;
  61505. /*** Helpers ***/
  61506. private _prepareCylinder;
  61507. private _intersectsWithCylinder;
  61508. }
  61509. /**
  61510. * Represents a physics vortex event
  61511. */
  61512. class PhysicsVortexEvent {
  61513. private _scene;
  61514. private _origin;
  61515. private _options;
  61516. private _physicsEngine;
  61517. private _originTop;
  61518. private _tickCallback;
  61519. private _cylinder;
  61520. private _cylinderPosition;
  61521. private _dataFetched;
  61522. /**
  61523. * Initializes the physics vortex event
  61524. * @param _scene The BabylonJS scene
  61525. * @param _origin The origin position of the vortex
  61526. * @param _options The options for the vortex event
  61527. */
  61528. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61529. /**
  61530. * Returns the data related to the vortex event (cylinder).
  61531. * @returns The physics vortex event data
  61532. */
  61533. getData(): PhysicsVortexEventData;
  61534. /**
  61535. * Enables the vortex.
  61536. */
  61537. enable(): void;
  61538. /**
  61539. * Disables the cortex.
  61540. */
  61541. disable(): void;
  61542. /**
  61543. * Disposes the sphere.
  61544. * @param force
  61545. */
  61546. dispose(force?: boolean): void;
  61547. private getImpostorHitData;
  61548. private _tick;
  61549. /*** Helpers ***/
  61550. private _prepareCylinder;
  61551. private _intersectsWithCylinder;
  61552. }
  61553. /**
  61554. * Options fot the radial explosion event
  61555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61556. */
  61557. export class PhysicsRadialExplosionEventOptions {
  61558. /**
  61559. * The radius of the sphere for the radial explosion.
  61560. */
  61561. radius: number;
  61562. /**
  61563. * The strenth of the explosion.
  61564. */
  61565. strength: number;
  61566. /**
  61567. * The strenght of the force in correspondence to the distance of the affected object
  61568. */
  61569. falloff: PhysicsRadialImpulseFalloff;
  61570. /**
  61571. * Sphere options for the radial explosion.
  61572. */
  61573. sphere: {
  61574. segments: number;
  61575. diameter: number;
  61576. };
  61577. /**
  61578. * Sphere options for the radial explosion.
  61579. */
  61580. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61581. }
  61582. /**
  61583. * Options fot the updraft event
  61584. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61585. */
  61586. export class PhysicsUpdraftEventOptions {
  61587. /**
  61588. * The radius of the cylinder for the vortex
  61589. */
  61590. radius: number;
  61591. /**
  61592. * The strenth of the updraft.
  61593. */
  61594. strength: number;
  61595. /**
  61596. * The height of the cylinder for the updraft.
  61597. */
  61598. height: number;
  61599. /**
  61600. * The mode for the the updraft.
  61601. */
  61602. updraftMode: PhysicsUpdraftMode;
  61603. }
  61604. /**
  61605. * Options fot the vortex event
  61606. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61607. */
  61608. export class PhysicsVortexEventOptions {
  61609. /**
  61610. * The radius of the cylinder for the vortex
  61611. */
  61612. radius: number;
  61613. /**
  61614. * The strenth of the vortex.
  61615. */
  61616. strength: number;
  61617. /**
  61618. * The height of the cylinder for the vortex.
  61619. */
  61620. height: number;
  61621. /**
  61622. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61623. */
  61624. centripetalForceThreshold: number;
  61625. /**
  61626. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61627. */
  61628. centripetalForceMultiplier: number;
  61629. /**
  61630. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61631. */
  61632. centrifugalForceMultiplier: number;
  61633. /**
  61634. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61635. */
  61636. updraftForceMultiplier: number;
  61637. }
  61638. /**
  61639. * The strenght of the force in correspondence to the distance of the affected object
  61640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61641. */
  61642. export enum PhysicsRadialImpulseFalloff {
  61643. /** Defines that impulse is constant in strength across it's whole radius */
  61644. Constant = 0,
  61645. /** Defines that impulse gets weaker if it's further from the origin */
  61646. Linear = 1
  61647. }
  61648. /**
  61649. * The strength of the force in correspondence to the distance of the affected object
  61650. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61651. */
  61652. export enum PhysicsUpdraftMode {
  61653. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61654. Center = 0,
  61655. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61656. Perpendicular = 1
  61657. }
  61658. /**
  61659. * Interface for a physics hit data
  61660. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61661. */
  61662. export interface PhysicsHitData {
  61663. /**
  61664. * The force applied at the contact point
  61665. */
  61666. force: Vector3;
  61667. /**
  61668. * The contact point
  61669. */
  61670. contactPoint: Vector3;
  61671. /**
  61672. * The distance from the origin to the contact point
  61673. */
  61674. distanceFromOrigin: number;
  61675. }
  61676. /**
  61677. * Interface for radial explosion event data
  61678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61679. */
  61680. export interface PhysicsRadialExplosionEventData {
  61681. /**
  61682. * A sphere used for the radial explosion event
  61683. */
  61684. sphere: Mesh;
  61685. }
  61686. /**
  61687. * Interface for gravitational field event data
  61688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61689. */
  61690. export interface PhysicsGravitationalFieldEventData {
  61691. /**
  61692. * A sphere mesh used for the gravitational field event
  61693. */
  61694. sphere: Mesh;
  61695. }
  61696. /**
  61697. * Interface for updraft event data
  61698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61699. */
  61700. export interface PhysicsUpdraftEventData {
  61701. /**
  61702. * A cylinder used for the updraft event
  61703. */
  61704. cylinder: Mesh;
  61705. }
  61706. /**
  61707. * Interface for vortex event data
  61708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61709. */
  61710. export interface PhysicsVortexEventData {
  61711. /**
  61712. * A cylinder used for the vortex event
  61713. */
  61714. cylinder: Mesh;
  61715. }
  61716. /**
  61717. * Interface for an affected physics impostor
  61718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61719. */
  61720. export interface PhysicsAffectedImpostorWithData {
  61721. /**
  61722. * The impostor affected by the effect
  61723. */
  61724. impostor: PhysicsImpostor;
  61725. /**
  61726. * The data about the hit/horce from the explosion
  61727. */
  61728. hitData: PhysicsHitData;
  61729. }
  61730. }
  61731. declare module "babylonjs/Physics/Plugins/index" {
  61732. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61733. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61734. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61735. }
  61736. declare module "babylonjs/Physics/index" {
  61737. export * from "babylonjs/Physics/IPhysicsEngine";
  61738. export * from "babylonjs/Physics/physicsEngine";
  61739. export * from "babylonjs/Physics/physicsEngineComponent";
  61740. export * from "babylonjs/Physics/physicsHelper";
  61741. export * from "babylonjs/Physics/physicsImpostor";
  61742. export * from "babylonjs/Physics/physicsJoint";
  61743. export * from "babylonjs/Physics/Plugins/index";
  61744. }
  61745. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61746. /** @hidden */
  61747. export var blackAndWhitePixelShader: {
  61748. name: string;
  61749. shader: string;
  61750. };
  61751. }
  61752. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61753. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61754. import { Camera } from "babylonjs/Cameras/camera";
  61755. import { Engine } from "babylonjs/Engines/engine";
  61756. import "babylonjs/Shaders/blackAndWhite.fragment";
  61757. /**
  61758. * Post process used to render in black and white
  61759. */
  61760. export class BlackAndWhitePostProcess extends PostProcess {
  61761. /**
  61762. * Linear about to convert he result to black and white (default: 1)
  61763. */
  61764. degree: number;
  61765. /**
  61766. * Creates a black and white post process
  61767. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61768. * @param name The name of the effect.
  61769. * @param options The required width/height ratio to downsize to before computing the render pass.
  61770. * @param camera The camera to apply the render pass to.
  61771. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61772. * @param engine The engine which the post process will be applied. (default: current engine)
  61773. * @param reusable If the post process can be reused on the same frame. (default: false)
  61774. */
  61775. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61776. }
  61777. }
  61778. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61779. import { Nullable } from "babylonjs/types";
  61780. import { Camera } from "babylonjs/Cameras/camera";
  61781. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61782. import { Engine } from "babylonjs/Engines/engine";
  61783. /**
  61784. * This represents a set of one or more post processes in Babylon.
  61785. * A post process can be used to apply a shader to a texture after it is rendered.
  61786. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61787. */
  61788. export class PostProcessRenderEffect {
  61789. private _postProcesses;
  61790. private _getPostProcesses;
  61791. private _singleInstance;
  61792. private _cameras;
  61793. private _indicesForCamera;
  61794. /**
  61795. * Name of the effect
  61796. * @hidden
  61797. */
  61798. _name: string;
  61799. /**
  61800. * Instantiates a post process render effect.
  61801. * A post process can be used to apply a shader to a texture after it is rendered.
  61802. * @param engine The engine the effect is tied to
  61803. * @param name The name of the effect
  61804. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61805. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61806. */
  61807. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61808. /**
  61809. * Checks if all the post processes in the effect are supported.
  61810. */
  61811. readonly isSupported: boolean;
  61812. /**
  61813. * Updates the current state of the effect
  61814. * @hidden
  61815. */
  61816. _update(): void;
  61817. /**
  61818. * Attaches the effect on cameras
  61819. * @param cameras The camera to attach to.
  61820. * @hidden
  61821. */
  61822. _attachCameras(cameras: Camera): void;
  61823. /**
  61824. * Attaches the effect on cameras
  61825. * @param cameras The camera to attach to.
  61826. * @hidden
  61827. */
  61828. _attachCameras(cameras: Camera[]): void;
  61829. /**
  61830. * Detaches the effect on cameras
  61831. * @param cameras The camera to detatch from.
  61832. * @hidden
  61833. */
  61834. _detachCameras(cameras: Camera): void;
  61835. /**
  61836. * Detatches the effect on cameras
  61837. * @param cameras The camera to detatch from.
  61838. * @hidden
  61839. */
  61840. _detachCameras(cameras: Camera[]): void;
  61841. /**
  61842. * Enables the effect on given cameras
  61843. * @param cameras The camera to enable.
  61844. * @hidden
  61845. */
  61846. _enable(cameras: Camera): void;
  61847. /**
  61848. * Enables the effect on given cameras
  61849. * @param cameras The camera to enable.
  61850. * @hidden
  61851. */
  61852. _enable(cameras: Nullable<Camera[]>): void;
  61853. /**
  61854. * Disables the effect on the given cameras
  61855. * @param cameras The camera to disable.
  61856. * @hidden
  61857. */
  61858. _disable(cameras: Camera): void;
  61859. /**
  61860. * Disables the effect on the given cameras
  61861. * @param cameras The camera to disable.
  61862. * @hidden
  61863. */
  61864. _disable(cameras: Nullable<Camera[]>): void;
  61865. /**
  61866. * Gets a list of the post processes contained in the effect.
  61867. * @param camera The camera to get the post processes on.
  61868. * @returns The list of the post processes in the effect.
  61869. */
  61870. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61871. }
  61872. }
  61873. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61874. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61875. /** @hidden */
  61876. export var extractHighlightsPixelShader: {
  61877. name: string;
  61878. shader: string;
  61879. };
  61880. }
  61881. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61882. import { Nullable } from "babylonjs/types";
  61883. import { Camera } from "babylonjs/Cameras/camera";
  61884. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61885. import { Engine } from "babylonjs/Engines/engine";
  61886. import "babylonjs/Shaders/extractHighlights.fragment";
  61887. /**
  61888. * 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.
  61889. */
  61890. export class ExtractHighlightsPostProcess extends PostProcess {
  61891. /**
  61892. * The luminance threshold, pixels below this value will be set to black.
  61893. */
  61894. threshold: number;
  61895. /** @hidden */
  61896. _exposure: number;
  61897. /**
  61898. * Post process which has the input texture to be used when performing highlight extraction
  61899. * @hidden
  61900. */
  61901. _inputPostProcess: Nullable<PostProcess>;
  61902. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61903. }
  61904. }
  61905. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61906. /** @hidden */
  61907. export var bloomMergePixelShader: {
  61908. name: string;
  61909. shader: string;
  61910. };
  61911. }
  61912. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61913. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61914. import { Nullable } from "babylonjs/types";
  61915. import { Engine } from "babylonjs/Engines/engine";
  61916. import { Camera } from "babylonjs/Cameras/camera";
  61917. import "babylonjs/Shaders/bloomMerge.fragment";
  61918. /**
  61919. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61920. */
  61921. export class BloomMergePostProcess extends PostProcess {
  61922. /** Weight of the bloom to be added to the original input. */
  61923. weight: number;
  61924. /**
  61925. * Creates a new instance of @see BloomMergePostProcess
  61926. * @param name The name of the effect.
  61927. * @param originalFromInput Post process which's input will be used for the merge.
  61928. * @param blurred Blurred highlights post process which's output will be used.
  61929. * @param weight Weight of the bloom to be added to the original input.
  61930. * @param options The required width/height ratio to downsize to before computing the render pass.
  61931. * @param camera The camera to apply the render pass to.
  61932. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61933. * @param engine The engine which the post process will be applied. (default: current engine)
  61934. * @param reusable If the post process can be reused on the same frame. (default: false)
  61935. * @param textureType Type of textures used when performing the post process. (default: 0)
  61936. * @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)
  61937. */
  61938. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61939. /** Weight of the bloom to be added to the original input. */
  61940. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61941. }
  61942. }
  61943. declare module "babylonjs/PostProcesses/bloomEffect" {
  61944. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61945. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61946. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61947. import { Camera } from "babylonjs/Cameras/camera";
  61948. import { Scene } from "babylonjs/scene";
  61949. /**
  61950. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61951. */
  61952. export class BloomEffect extends PostProcessRenderEffect {
  61953. private bloomScale;
  61954. /**
  61955. * @hidden Internal
  61956. */
  61957. _effects: Array<PostProcess>;
  61958. /**
  61959. * @hidden Internal
  61960. */
  61961. _downscale: ExtractHighlightsPostProcess;
  61962. private _blurX;
  61963. private _blurY;
  61964. private _merge;
  61965. /**
  61966. * The luminance threshold to find bright areas of the image to bloom.
  61967. */
  61968. threshold: number;
  61969. /**
  61970. * The strength of the bloom.
  61971. */
  61972. weight: number;
  61973. /**
  61974. * Specifies the size of the bloom blur kernel, relative to the final output size
  61975. */
  61976. kernel: number;
  61977. /**
  61978. * Creates a new instance of @see BloomEffect
  61979. * @param scene The scene the effect belongs to.
  61980. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61981. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61982. * @param bloomWeight The the strength of bloom.
  61983. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61984. * @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)
  61985. */
  61986. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61987. /**
  61988. * Disposes each of the internal effects for a given camera.
  61989. * @param camera The camera to dispose the effect on.
  61990. */
  61991. disposeEffects(camera: Camera): void;
  61992. /**
  61993. * @hidden Internal
  61994. */
  61995. _updateEffects(): void;
  61996. /**
  61997. * Internal
  61998. * @returns if all the contained post processes are ready.
  61999. * @hidden
  62000. */
  62001. _isReady(): boolean;
  62002. }
  62003. }
  62004. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62005. /** @hidden */
  62006. export var chromaticAberrationPixelShader: {
  62007. name: string;
  62008. shader: string;
  62009. };
  62010. }
  62011. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62012. import { Vector2 } from "babylonjs/Maths/math.vector";
  62013. import { Nullable } from "babylonjs/types";
  62014. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62015. import { Camera } from "babylonjs/Cameras/camera";
  62016. import { Engine } from "babylonjs/Engines/engine";
  62017. import "babylonjs/Shaders/chromaticAberration.fragment";
  62018. /**
  62019. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62020. */
  62021. export class ChromaticAberrationPostProcess extends PostProcess {
  62022. /**
  62023. * The amount of seperation of rgb channels (default: 30)
  62024. */
  62025. aberrationAmount: number;
  62026. /**
  62027. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62028. */
  62029. radialIntensity: number;
  62030. /**
  62031. * 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))
  62032. */
  62033. direction: Vector2;
  62034. /**
  62035. * 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))
  62036. */
  62037. centerPosition: Vector2;
  62038. /**
  62039. * Creates a new instance ChromaticAberrationPostProcess
  62040. * @param name The name of the effect.
  62041. * @param screenWidth The width of the screen to apply the effect on.
  62042. * @param screenHeight The height of the screen to apply the effect on.
  62043. * @param options The required width/height ratio to downsize to before computing the render pass.
  62044. * @param camera The camera to apply the render pass to.
  62045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62046. * @param engine The engine which the post process will be applied. (default: current engine)
  62047. * @param reusable If the post process can be reused on the same frame. (default: false)
  62048. * @param textureType Type of textures used when performing the post process. (default: 0)
  62049. * @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)
  62050. */
  62051. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62052. }
  62053. }
  62054. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62055. /** @hidden */
  62056. export var circleOfConfusionPixelShader: {
  62057. name: string;
  62058. shader: string;
  62059. };
  62060. }
  62061. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62062. import { Nullable } from "babylonjs/types";
  62063. import { Engine } from "babylonjs/Engines/engine";
  62064. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62065. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62066. import { Camera } from "babylonjs/Cameras/camera";
  62067. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62068. /**
  62069. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62070. */
  62071. export class CircleOfConfusionPostProcess extends PostProcess {
  62072. /**
  62073. * 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.
  62074. */
  62075. lensSize: number;
  62076. /**
  62077. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62078. */
  62079. fStop: number;
  62080. /**
  62081. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62082. */
  62083. focusDistance: number;
  62084. /**
  62085. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62086. */
  62087. focalLength: number;
  62088. private _depthTexture;
  62089. /**
  62090. * Creates a new instance CircleOfConfusionPostProcess
  62091. * @param name The name of the effect.
  62092. * @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.
  62093. * @param options The required width/height ratio to downsize to before computing the render pass.
  62094. * @param camera The camera to apply the render pass to.
  62095. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62096. * @param engine The engine which the post process will be applied. (default: current engine)
  62097. * @param reusable If the post process can be reused on the same frame. (default: false)
  62098. * @param textureType Type of textures used when performing the post process. (default: 0)
  62099. * @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)
  62100. */
  62101. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62102. /**
  62103. * 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.
  62104. */
  62105. depthTexture: RenderTargetTexture;
  62106. }
  62107. }
  62108. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62109. /** @hidden */
  62110. export var colorCorrectionPixelShader: {
  62111. name: string;
  62112. shader: string;
  62113. };
  62114. }
  62115. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62116. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62117. import { Engine } from "babylonjs/Engines/engine";
  62118. import { Camera } from "babylonjs/Cameras/camera";
  62119. import "babylonjs/Shaders/colorCorrection.fragment";
  62120. /**
  62121. *
  62122. * This post-process allows the modification of rendered colors by using
  62123. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62124. *
  62125. * The object needs to be provided an url to a texture containing the color
  62126. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62127. * Use an image editing software to tweak the LUT to match your needs.
  62128. *
  62129. * For an example of a color LUT, see here:
  62130. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62131. * For explanations on color grading, see here:
  62132. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62133. *
  62134. */
  62135. export class ColorCorrectionPostProcess extends PostProcess {
  62136. private _colorTableTexture;
  62137. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62138. }
  62139. }
  62140. declare module "babylonjs/Shaders/convolution.fragment" {
  62141. /** @hidden */
  62142. export var convolutionPixelShader: {
  62143. name: string;
  62144. shader: string;
  62145. };
  62146. }
  62147. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62148. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62149. import { Nullable } from "babylonjs/types";
  62150. import { Camera } from "babylonjs/Cameras/camera";
  62151. import { Engine } from "babylonjs/Engines/engine";
  62152. import "babylonjs/Shaders/convolution.fragment";
  62153. /**
  62154. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62155. * input texture to perform effects such as edge detection or sharpening
  62156. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62157. */
  62158. export class ConvolutionPostProcess extends PostProcess {
  62159. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62160. kernel: number[];
  62161. /**
  62162. * Creates a new instance ConvolutionPostProcess
  62163. * @param name The name of the effect.
  62164. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62165. * @param options The required width/height ratio to downsize to before computing the render pass.
  62166. * @param camera The camera to apply the render pass to.
  62167. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62168. * @param engine The engine which the post process will be applied. (default: current engine)
  62169. * @param reusable If the post process can be reused on the same frame. (default: false)
  62170. * @param textureType Type of textures used when performing the post process. (default: 0)
  62171. */
  62172. constructor(name: string,
  62173. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62174. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62175. /**
  62176. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62177. */
  62178. static EdgeDetect0Kernel: number[];
  62179. /**
  62180. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62181. */
  62182. static EdgeDetect1Kernel: number[];
  62183. /**
  62184. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62185. */
  62186. static EdgeDetect2Kernel: number[];
  62187. /**
  62188. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62189. */
  62190. static SharpenKernel: number[];
  62191. /**
  62192. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62193. */
  62194. static EmbossKernel: number[];
  62195. /**
  62196. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62197. */
  62198. static GaussianKernel: number[];
  62199. }
  62200. }
  62201. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62202. import { Nullable } from "babylonjs/types";
  62203. import { Vector2 } from "babylonjs/Maths/math.vector";
  62204. import { Camera } from "babylonjs/Cameras/camera";
  62205. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62206. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62207. import { Engine } from "babylonjs/Engines/engine";
  62208. import { Scene } from "babylonjs/scene";
  62209. /**
  62210. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62211. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62212. * based on samples that have a large difference in distance than the center pixel.
  62213. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62214. */
  62215. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62216. direction: Vector2;
  62217. /**
  62218. * Creates a new instance CircleOfConfusionPostProcess
  62219. * @param name The name of the effect.
  62220. * @param scene The scene the effect belongs to.
  62221. * @param direction The direction the blur should be applied.
  62222. * @param kernel The size of the kernel used to blur.
  62223. * @param options The required width/height ratio to downsize to before computing the render pass.
  62224. * @param camera The camera to apply the render pass to.
  62225. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62226. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62227. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62228. * @param engine The engine which the post process will be applied. (default: current engine)
  62229. * @param reusable If the post process can be reused on the same frame. (default: false)
  62230. * @param textureType Type of textures used when performing the post process. (default: 0)
  62231. * @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)
  62232. */
  62233. 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);
  62234. }
  62235. }
  62236. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62237. /** @hidden */
  62238. export var depthOfFieldMergePixelShader: {
  62239. name: string;
  62240. shader: string;
  62241. };
  62242. }
  62243. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62244. import { Nullable } from "babylonjs/types";
  62245. import { Camera } from "babylonjs/Cameras/camera";
  62246. import { Effect } from "babylonjs/Materials/effect";
  62247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62248. import { Engine } from "babylonjs/Engines/engine";
  62249. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62250. /**
  62251. * Options to be set when merging outputs from the default pipeline.
  62252. */
  62253. export class DepthOfFieldMergePostProcessOptions {
  62254. /**
  62255. * The original image to merge on top of
  62256. */
  62257. originalFromInput: PostProcess;
  62258. /**
  62259. * Parameters to perform the merge of the depth of field effect
  62260. */
  62261. depthOfField?: {
  62262. circleOfConfusion: PostProcess;
  62263. blurSteps: Array<PostProcess>;
  62264. };
  62265. /**
  62266. * Parameters to perform the merge of bloom effect
  62267. */
  62268. bloom?: {
  62269. blurred: PostProcess;
  62270. weight: number;
  62271. };
  62272. }
  62273. /**
  62274. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62275. */
  62276. export class DepthOfFieldMergePostProcess extends PostProcess {
  62277. private blurSteps;
  62278. /**
  62279. * Creates a new instance of DepthOfFieldMergePostProcess
  62280. * @param name The name of the effect.
  62281. * @param originalFromInput Post process which's input will be used for the merge.
  62282. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62283. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62284. * @param options The required width/height ratio to downsize to before computing the render pass.
  62285. * @param camera The camera to apply the render pass to.
  62286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62287. * @param engine The engine which the post process will be applied. (default: current engine)
  62288. * @param reusable If the post process can be reused on the same frame. (default: false)
  62289. * @param textureType Type of textures used when performing the post process. (default: 0)
  62290. * @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)
  62291. */
  62292. 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);
  62293. /**
  62294. * Updates the effect with the current post process compile time values and recompiles the shader.
  62295. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62296. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62297. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62298. * @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
  62299. * @param onCompiled Called when the shader has been compiled.
  62300. * @param onError Called if there is an error when compiling a shader.
  62301. */
  62302. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62303. }
  62304. }
  62305. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62306. import { Nullable } from "babylonjs/types";
  62307. import { Camera } from "babylonjs/Cameras/camera";
  62308. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62309. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62310. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62311. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62312. import { Scene } from "babylonjs/scene";
  62313. /**
  62314. * Specifies the level of max blur that should be applied when using the depth of field effect
  62315. */
  62316. export enum DepthOfFieldEffectBlurLevel {
  62317. /**
  62318. * Subtle blur
  62319. */
  62320. Low = 0,
  62321. /**
  62322. * Medium blur
  62323. */
  62324. Medium = 1,
  62325. /**
  62326. * Large blur
  62327. */
  62328. High = 2
  62329. }
  62330. /**
  62331. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62332. */
  62333. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62334. private _circleOfConfusion;
  62335. /**
  62336. * @hidden Internal, blurs from high to low
  62337. */
  62338. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62339. private _depthOfFieldBlurY;
  62340. private _dofMerge;
  62341. /**
  62342. * @hidden Internal post processes in depth of field effect
  62343. */
  62344. _effects: Array<PostProcess>;
  62345. /**
  62346. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62347. */
  62348. focalLength: number;
  62349. /**
  62350. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62351. */
  62352. fStop: number;
  62353. /**
  62354. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62355. */
  62356. focusDistance: number;
  62357. /**
  62358. * 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.
  62359. */
  62360. lensSize: number;
  62361. /**
  62362. * Creates a new instance DepthOfFieldEffect
  62363. * @param scene The scene the effect belongs to.
  62364. * @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.
  62365. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62366. * @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)
  62367. */
  62368. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62369. /**
  62370. * Get the current class name of the current effet
  62371. * @returns "DepthOfFieldEffect"
  62372. */
  62373. getClassName(): string;
  62374. /**
  62375. * 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.
  62376. */
  62377. depthTexture: RenderTargetTexture;
  62378. /**
  62379. * Disposes each of the internal effects for a given camera.
  62380. * @param camera The camera to dispose the effect on.
  62381. */
  62382. disposeEffects(camera: Camera): void;
  62383. /**
  62384. * @hidden Internal
  62385. */
  62386. _updateEffects(): void;
  62387. /**
  62388. * Internal
  62389. * @returns if all the contained post processes are ready.
  62390. * @hidden
  62391. */
  62392. _isReady(): boolean;
  62393. }
  62394. }
  62395. declare module "babylonjs/Shaders/displayPass.fragment" {
  62396. /** @hidden */
  62397. export var displayPassPixelShader: {
  62398. name: string;
  62399. shader: string;
  62400. };
  62401. }
  62402. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62403. import { Nullable } from "babylonjs/types";
  62404. import { Camera } from "babylonjs/Cameras/camera";
  62405. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62406. import { Engine } from "babylonjs/Engines/engine";
  62407. import "babylonjs/Shaders/displayPass.fragment";
  62408. /**
  62409. * DisplayPassPostProcess which produces an output the same as it's input
  62410. */
  62411. export class DisplayPassPostProcess extends PostProcess {
  62412. /**
  62413. * Creates the DisplayPassPostProcess
  62414. * @param name The name of the effect.
  62415. * @param options The required width/height ratio to downsize to before computing the render pass.
  62416. * @param camera The camera to apply the render pass to.
  62417. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62418. * @param engine The engine which the post process will be applied. (default: current engine)
  62419. * @param reusable If the post process can be reused on the same frame. (default: false)
  62420. */
  62421. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62422. }
  62423. }
  62424. declare module "babylonjs/Shaders/filter.fragment" {
  62425. /** @hidden */
  62426. export var filterPixelShader: {
  62427. name: string;
  62428. shader: string;
  62429. };
  62430. }
  62431. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62432. import { Nullable } from "babylonjs/types";
  62433. import { Matrix } from "babylonjs/Maths/math.vector";
  62434. import { Camera } from "babylonjs/Cameras/camera";
  62435. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62436. import { Engine } from "babylonjs/Engines/engine";
  62437. import "babylonjs/Shaders/filter.fragment";
  62438. /**
  62439. * Applies a kernel filter to the image
  62440. */
  62441. export class FilterPostProcess extends PostProcess {
  62442. /** The matrix to be applied to the image */
  62443. kernelMatrix: Matrix;
  62444. /**
  62445. *
  62446. * @param name The name of the effect.
  62447. * @param kernelMatrix The matrix to be applied to the image
  62448. * @param options The required width/height ratio to downsize to before computing the render pass.
  62449. * @param camera The camera to apply the render pass to.
  62450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62451. * @param engine The engine which the post process will be applied. (default: current engine)
  62452. * @param reusable If the post process can be reused on the same frame. (default: false)
  62453. */
  62454. constructor(name: string,
  62455. /** The matrix to be applied to the image */
  62456. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62457. }
  62458. }
  62459. declare module "babylonjs/Shaders/fxaa.fragment" {
  62460. /** @hidden */
  62461. export var fxaaPixelShader: {
  62462. name: string;
  62463. shader: string;
  62464. };
  62465. }
  62466. declare module "babylonjs/Shaders/fxaa.vertex" {
  62467. /** @hidden */
  62468. export var fxaaVertexShader: {
  62469. name: string;
  62470. shader: string;
  62471. };
  62472. }
  62473. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62474. import { Nullable } from "babylonjs/types";
  62475. import { Camera } from "babylonjs/Cameras/camera";
  62476. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62477. import { Engine } from "babylonjs/Engines/engine";
  62478. import "babylonjs/Shaders/fxaa.fragment";
  62479. import "babylonjs/Shaders/fxaa.vertex";
  62480. /**
  62481. * Fxaa post process
  62482. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62483. */
  62484. export class FxaaPostProcess extends PostProcess {
  62485. /** @hidden */
  62486. texelWidth: number;
  62487. /** @hidden */
  62488. texelHeight: number;
  62489. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62490. private _getDefines;
  62491. }
  62492. }
  62493. declare module "babylonjs/Shaders/grain.fragment" {
  62494. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62495. /** @hidden */
  62496. export var grainPixelShader: {
  62497. name: string;
  62498. shader: string;
  62499. };
  62500. }
  62501. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62502. import { Nullable } from "babylonjs/types";
  62503. import { Camera } from "babylonjs/Cameras/camera";
  62504. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62505. import { Engine } from "babylonjs/Engines/engine";
  62506. import "babylonjs/Shaders/grain.fragment";
  62507. /**
  62508. * The GrainPostProcess adds noise to the image at mid luminance levels
  62509. */
  62510. export class GrainPostProcess extends PostProcess {
  62511. /**
  62512. * The intensity of the grain added (default: 30)
  62513. */
  62514. intensity: number;
  62515. /**
  62516. * If the grain should be randomized on every frame
  62517. */
  62518. animated: boolean;
  62519. /**
  62520. * Creates a new instance of @see GrainPostProcess
  62521. * @param name The name of the effect.
  62522. * @param options The required width/height ratio to downsize to before computing the render pass.
  62523. * @param camera The camera to apply the render pass to.
  62524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62525. * @param engine The engine which the post process will be applied. (default: current engine)
  62526. * @param reusable If the post process can be reused on the same frame. (default: false)
  62527. * @param textureType Type of textures used when performing the post process. (default: 0)
  62528. * @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)
  62529. */
  62530. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62531. }
  62532. }
  62533. declare module "babylonjs/Shaders/highlights.fragment" {
  62534. /** @hidden */
  62535. export var highlightsPixelShader: {
  62536. name: string;
  62537. shader: string;
  62538. };
  62539. }
  62540. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62541. import { Nullable } from "babylonjs/types";
  62542. import { Camera } from "babylonjs/Cameras/camera";
  62543. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62544. import { Engine } from "babylonjs/Engines/engine";
  62545. import "babylonjs/Shaders/highlights.fragment";
  62546. /**
  62547. * Extracts highlights from the image
  62548. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62549. */
  62550. export class HighlightsPostProcess extends PostProcess {
  62551. /**
  62552. * Extracts highlights from the image
  62553. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62554. * @param name The name of the effect.
  62555. * @param options The required width/height ratio to downsize to before computing the render pass.
  62556. * @param camera The camera to apply the render pass to.
  62557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62558. * @param engine The engine which the post process will be applied. (default: current engine)
  62559. * @param reusable If the post process can be reused on the same frame. (default: false)
  62560. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62561. */
  62562. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62563. }
  62564. }
  62565. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62566. /** @hidden */
  62567. export var mrtFragmentDeclaration: {
  62568. name: string;
  62569. shader: string;
  62570. };
  62571. }
  62572. declare module "babylonjs/Shaders/geometry.fragment" {
  62573. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62574. /** @hidden */
  62575. export var geometryPixelShader: {
  62576. name: string;
  62577. shader: string;
  62578. };
  62579. }
  62580. declare module "babylonjs/Shaders/geometry.vertex" {
  62581. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62582. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62583. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62584. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62585. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62586. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62587. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62588. /** @hidden */
  62589. export var geometryVertexShader: {
  62590. name: string;
  62591. shader: string;
  62592. };
  62593. }
  62594. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62595. import { Matrix } from "babylonjs/Maths/math.vector";
  62596. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62597. import { Mesh } from "babylonjs/Meshes/mesh";
  62598. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62599. import { Effect } from "babylonjs/Materials/effect";
  62600. import { Scene } from "babylonjs/scene";
  62601. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62602. import "babylonjs/Shaders/geometry.fragment";
  62603. import "babylonjs/Shaders/geometry.vertex";
  62604. /** @hidden */
  62605. interface ISavedTransformationMatrix {
  62606. world: Matrix;
  62607. viewProjection: Matrix;
  62608. }
  62609. /**
  62610. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62611. */
  62612. export class GeometryBufferRenderer {
  62613. /**
  62614. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62615. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62616. */
  62617. static readonly POSITION_TEXTURE_TYPE: number;
  62618. /**
  62619. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62620. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62621. */
  62622. static readonly VELOCITY_TEXTURE_TYPE: number;
  62623. /**
  62624. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62625. * in order to compute objects velocities when enableVelocity is set to "true"
  62626. * @hidden
  62627. */
  62628. _previousTransformationMatrices: {
  62629. [index: number]: ISavedTransformationMatrix;
  62630. };
  62631. /**
  62632. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62633. * in order to compute objects velocities when enableVelocity is set to "true"
  62634. * @hidden
  62635. */
  62636. _previousBonesTransformationMatrices: {
  62637. [index: number]: Float32Array;
  62638. };
  62639. /**
  62640. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62641. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62642. */
  62643. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62644. private _scene;
  62645. private _multiRenderTarget;
  62646. private _ratio;
  62647. private _enablePosition;
  62648. private _enableVelocity;
  62649. private _positionIndex;
  62650. private _velocityIndex;
  62651. protected _effect: Effect;
  62652. protected _cachedDefines: string;
  62653. /**
  62654. * Set the render list (meshes to be rendered) used in the G buffer.
  62655. */
  62656. renderList: Mesh[];
  62657. /**
  62658. * Gets wether or not G buffer are supported by the running hardware.
  62659. * This requires draw buffer supports
  62660. */
  62661. readonly isSupported: boolean;
  62662. /**
  62663. * Returns the index of the given texture type in the G-Buffer textures array
  62664. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62665. * @returns the index of the given texture type in the G-Buffer textures array
  62666. */
  62667. getTextureIndex(textureType: number): number;
  62668. /**
  62669. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62670. */
  62671. /**
  62672. * Sets whether or not objects positions are enabled for the G buffer.
  62673. */
  62674. enablePosition: boolean;
  62675. /**
  62676. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62677. */
  62678. /**
  62679. * Sets wether or not objects velocities are enabled for the G buffer.
  62680. */
  62681. enableVelocity: boolean;
  62682. /**
  62683. * Gets the scene associated with the buffer.
  62684. */
  62685. readonly scene: Scene;
  62686. /**
  62687. * Gets the ratio used by the buffer during its creation.
  62688. * How big is the buffer related to the main canvas.
  62689. */
  62690. readonly ratio: number;
  62691. /** @hidden */
  62692. static _SceneComponentInitialization: (scene: Scene) => void;
  62693. /**
  62694. * Creates a new G Buffer for the scene
  62695. * @param scene The scene the buffer belongs to
  62696. * @param ratio How big is the buffer related to the main canvas.
  62697. */
  62698. constructor(scene: Scene, ratio?: number);
  62699. /**
  62700. * Checks wether everything is ready to render a submesh to the G buffer.
  62701. * @param subMesh the submesh to check readiness for
  62702. * @param useInstances is the mesh drawn using instance or not
  62703. * @returns true if ready otherwise false
  62704. */
  62705. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62706. /**
  62707. * Gets the current underlying G Buffer.
  62708. * @returns the buffer
  62709. */
  62710. getGBuffer(): MultiRenderTarget;
  62711. /**
  62712. * Gets the number of samples used to render the buffer (anti aliasing).
  62713. */
  62714. /**
  62715. * Sets the number of samples used to render the buffer (anti aliasing).
  62716. */
  62717. samples: number;
  62718. /**
  62719. * Disposes the renderer and frees up associated resources.
  62720. */
  62721. dispose(): void;
  62722. protected _createRenderTargets(): void;
  62723. private _copyBonesTransformationMatrices;
  62724. }
  62725. }
  62726. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62727. import { Nullable } from "babylonjs/types";
  62728. import { Scene } from "babylonjs/scene";
  62729. import { ISceneComponent } from "babylonjs/sceneComponent";
  62730. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62731. module "babylonjs/scene" {
  62732. interface Scene {
  62733. /** @hidden (Backing field) */
  62734. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62735. /**
  62736. * Gets or Sets the current geometry buffer associated to the scene.
  62737. */
  62738. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62739. /**
  62740. * Enables a GeometryBufferRender and associates it with the scene
  62741. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62742. * @returns the GeometryBufferRenderer
  62743. */
  62744. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62745. /**
  62746. * Disables the GeometryBufferRender associated with the scene
  62747. */
  62748. disableGeometryBufferRenderer(): void;
  62749. }
  62750. }
  62751. /**
  62752. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62753. * in several rendering techniques.
  62754. */
  62755. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62756. /**
  62757. * The component name helpful to identify the component in the list of scene components.
  62758. */
  62759. readonly name: string;
  62760. /**
  62761. * The scene the component belongs to.
  62762. */
  62763. scene: Scene;
  62764. /**
  62765. * Creates a new instance of the component for the given scene
  62766. * @param scene Defines the scene to register the component in
  62767. */
  62768. constructor(scene: Scene);
  62769. /**
  62770. * Registers the component in a given scene
  62771. */
  62772. register(): void;
  62773. /**
  62774. * Rebuilds the elements related to this component in case of
  62775. * context lost for instance.
  62776. */
  62777. rebuild(): void;
  62778. /**
  62779. * Disposes the component and the associated ressources
  62780. */
  62781. dispose(): void;
  62782. private _gatherRenderTargets;
  62783. }
  62784. }
  62785. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62786. /** @hidden */
  62787. export var motionBlurPixelShader: {
  62788. name: string;
  62789. shader: string;
  62790. };
  62791. }
  62792. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62793. import { Nullable } from "babylonjs/types";
  62794. import { Camera } from "babylonjs/Cameras/camera";
  62795. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62796. import { Scene } from "babylonjs/scene";
  62797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62798. import "babylonjs/Animations/animatable";
  62799. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62800. import "babylonjs/Shaders/motionBlur.fragment";
  62801. import { Engine } from "babylonjs/Engines/engine";
  62802. /**
  62803. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62804. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62805. * As an example, all you have to do is to create the post-process:
  62806. * var mb = new BABYLON.MotionBlurPostProcess(
  62807. * 'mb', // The name of the effect.
  62808. * scene, // The scene containing the objects to blur according to their velocity.
  62809. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62810. * camera // The camera to apply the render pass to.
  62811. * );
  62812. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62813. */
  62814. export class MotionBlurPostProcess extends PostProcess {
  62815. /**
  62816. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62817. */
  62818. motionStrength: number;
  62819. /**
  62820. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62821. */
  62822. /**
  62823. * Sets the number of iterations to be used for motion blur quality
  62824. */
  62825. motionBlurSamples: number;
  62826. private _motionBlurSamples;
  62827. private _geometryBufferRenderer;
  62828. /**
  62829. * Creates a new instance MotionBlurPostProcess
  62830. * @param name The name of the effect.
  62831. * @param scene The scene containing the objects to blur according to their velocity.
  62832. * @param options The required width/height ratio to downsize to before computing the render pass.
  62833. * @param camera The camera to apply the render pass to.
  62834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62835. * @param engine The engine which the post process will be applied. (default: current engine)
  62836. * @param reusable If the post process can be reused on the same frame. (default: false)
  62837. * @param textureType Type of textures used when performing the post process. (default: 0)
  62838. * @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)
  62839. */
  62840. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62841. /**
  62842. * Excludes the given skinned mesh from computing bones velocities.
  62843. * 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.
  62844. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62845. */
  62846. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62847. /**
  62848. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62849. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62850. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62851. */
  62852. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62853. /**
  62854. * Disposes the post process.
  62855. * @param camera The camera to dispose the post process on.
  62856. */
  62857. dispose(camera?: Camera): void;
  62858. }
  62859. }
  62860. declare module "babylonjs/Shaders/refraction.fragment" {
  62861. /** @hidden */
  62862. export var refractionPixelShader: {
  62863. name: string;
  62864. shader: string;
  62865. };
  62866. }
  62867. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62868. import { Color3 } from "babylonjs/Maths/math.color";
  62869. import { Camera } from "babylonjs/Cameras/camera";
  62870. import { Texture } from "babylonjs/Materials/Textures/texture";
  62871. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62872. import { Engine } from "babylonjs/Engines/engine";
  62873. import "babylonjs/Shaders/refraction.fragment";
  62874. /**
  62875. * Post process which applies a refractin texture
  62876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62877. */
  62878. export class RefractionPostProcess extends PostProcess {
  62879. /** the base color of the refraction (used to taint the rendering) */
  62880. color: Color3;
  62881. /** simulated refraction depth */
  62882. depth: number;
  62883. /** the coefficient of the base color (0 to remove base color tainting) */
  62884. colorLevel: number;
  62885. private _refTexture;
  62886. private _ownRefractionTexture;
  62887. /**
  62888. * Gets or sets the refraction texture
  62889. * Please note that you are responsible for disposing the texture if you set it manually
  62890. */
  62891. refractionTexture: Texture;
  62892. /**
  62893. * Initializes the RefractionPostProcess
  62894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62895. * @param name The name of the effect.
  62896. * @param refractionTextureUrl Url of the refraction texture to use
  62897. * @param color the base color of the refraction (used to taint the rendering)
  62898. * @param depth simulated refraction depth
  62899. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62900. * @param camera The camera to apply the render pass to.
  62901. * @param options The required width/height ratio to downsize to before computing the render pass.
  62902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62903. * @param engine The engine which the post process will be applied. (default: current engine)
  62904. * @param reusable If the post process can be reused on the same frame. (default: false)
  62905. */
  62906. constructor(name: string, refractionTextureUrl: string,
  62907. /** the base color of the refraction (used to taint the rendering) */
  62908. color: Color3,
  62909. /** simulated refraction depth */
  62910. depth: number,
  62911. /** the coefficient of the base color (0 to remove base color tainting) */
  62912. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62913. /**
  62914. * Disposes of the post process
  62915. * @param camera Camera to dispose post process on
  62916. */
  62917. dispose(camera: Camera): void;
  62918. }
  62919. }
  62920. declare module "babylonjs/Shaders/sharpen.fragment" {
  62921. /** @hidden */
  62922. export var sharpenPixelShader: {
  62923. name: string;
  62924. shader: string;
  62925. };
  62926. }
  62927. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62928. import { Nullable } from "babylonjs/types";
  62929. import { Camera } from "babylonjs/Cameras/camera";
  62930. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62931. import "babylonjs/Shaders/sharpen.fragment";
  62932. import { Engine } from "babylonjs/Engines/engine";
  62933. /**
  62934. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62935. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62936. */
  62937. export class SharpenPostProcess extends PostProcess {
  62938. /**
  62939. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62940. */
  62941. colorAmount: number;
  62942. /**
  62943. * How much sharpness should be applied (default: 0.3)
  62944. */
  62945. edgeAmount: number;
  62946. /**
  62947. * Creates a new instance ConvolutionPostProcess
  62948. * @param name The name of the effect.
  62949. * @param options The required width/height ratio to downsize to before computing the render pass.
  62950. * @param camera The camera to apply the render pass to.
  62951. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62952. * @param engine The engine which the post process will be applied. (default: current engine)
  62953. * @param reusable If the post process can be reused on the same frame. (default: false)
  62954. * @param textureType Type of textures used when performing the post process. (default: 0)
  62955. * @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)
  62956. */
  62957. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62958. }
  62959. }
  62960. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62961. import { Nullable } from "babylonjs/types";
  62962. import { Camera } from "babylonjs/Cameras/camera";
  62963. import { Engine } from "babylonjs/Engines/engine";
  62964. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62965. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62966. /**
  62967. * PostProcessRenderPipeline
  62968. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62969. */
  62970. export class PostProcessRenderPipeline {
  62971. private engine;
  62972. private _renderEffects;
  62973. private _renderEffectsForIsolatedPass;
  62974. /**
  62975. * List of inspectable custom properties (used by the Inspector)
  62976. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62977. */
  62978. inspectableCustomProperties: IInspectable[];
  62979. /**
  62980. * @hidden
  62981. */
  62982. protected _cameras: Camera[];
  62983. /** @hidden */
  62984. _name: string;
  62985. /**
  62986. * Gets pipeline name
  62987. */
  62988. readonly name: string;
  62989. /**
  62990. * Initializes a PostProcessRenderPipeline
  62991. * @param engine engine to add the pipeline to
  62992. * @param name name of the pipeline
  62993. */
  62994. constructor(engine: Engine, name: string);
  62995. /**
  62996. * Gets the class name
  62997. * @returns "PostProcessRenderPipeline"
  62998. */
  62999. getClassName(): string;
  63000. /**
  63001. * If all the render effects in the pipeline are supported
  63002. */
  63003. readonly isSupported: boolean;
  63004. /**
  63005. * Adds an effect to the pipeline
  63006. * @param renderEffect the effect to add
  63007. */
  63008. addEffect(renderEffect: PostProcessRenderEffect): void;
  63009. /** @hidden */
  63010. _rebuild(): void;
  63011. /** @hidden */
  63012. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63013. /** @hidden */
  63014. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63015. /** @hidden */
  63016. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63017. /** @hidden */
  63018. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63019. /** @hidden */
  63020. _attachCameras(cameras: Camera, unique: boolean): void;
  63021. /** @hidden */
  63022. _attachCameras(cameras: Camera[], unique: boolean): void;
  63023. /** @hidden */
  63024. _detachCameras(cameras: Camera): void;
  63025. /** @hidden */
  63026. _detachCameras(cameras: Nullable<Camera[]>): void;
  63027. /** @hidden */
  63028. _update(): void;
  63029. /** @hidden */
  63030. _reset(): void;
  63031. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63032. /**
  63033. * Disposes of the pipeline
  63034. */
  63035. dispose(): void;
  63036. }
  63037. }
  63038. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63039. import { Camera } from "babylonjs/Cameras/camera";
  63040. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63041. /**
  63042. * PostProcessRenderPipelineManager class
  63043. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63044. */
  63045. export class PostProcessRenderPipelineManager {
  63046. private _renderPipelines;
  63047. /**
  63048. * Initializes a PostProcessRenderPipelineManager
  63049. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63050. */
  63051. constructor();
  63052. /**
  63053. * Gets the list of supported render pipelines
  63054. */
  63055. readonly supportedPipelines: PostProcessRenderPipeline[];
  63056. /**
  63057. * Adds a pipeline to the manager
  63058. * @param renderPipeline The pipeline to add
  63059. */
  63060. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63061. /**
  63062. * Attaches a camera to the pipeline
  63063. * @param renderPipelineName The name of the pipeline to attach to
  63064. * @param cameras the camera to attach
  63065. * @param unique if the camera can be attached multiple times to the pipeline
  63066. */
  63067. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63068. /**
  63069. * Detaches a camera from the pipeline
  63070. * @param renderPipelineName The name of the pipeline to detach from
  63071. * @param cameras the camera to detach
  63072. */
  63073. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63074. /**
  63075. * Enables an effect by name on a pipeline
  63076. * @param renderPipelineName the name of the pipeline to enable the effect in
  63077. * @param renderEffectName the name of the effect to enable
  63078. * @param cameras the cameras that the effect should be enabled on
  63079. */
  63080. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63081. /**
  63082. * Disables an effect by name on a pipeline
  63083. * @param renderPipelineName the name of the pipeline to disable the effect in
  63084. * @param renderEffectName the name of the effect to disable
  63085. * @param cameras the cameras that the effect should be disabled on
  63086. */
  63087. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63088. /**
  63089. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63090. */
  63091. update(): void;
  63092. /** @hidden */
  63093. _rebuild(): void;
  63094. /**
  63095. * Disposes of the manager and pipelines
  63096. */
  63097. dispose(): void;
  63098. }
  63099. }
  63100. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63101. import { ISceneComponent } from "babylonjs/sceneComponent";
  63102. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63103. import { Scene } from "babylonjs/scene";
  63104. module "babylonjs/scene" {
  63105. interface Scene {
  63106. /** @hidden (Backing field) */
  63107. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63108. /**
  63109. * Gets the postprocess render pipeline manager
  63110. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63111. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63112. */
  63113. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63114. }
  63115. }
  63116. /**
  63117. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63118. */
  63119. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63120. /**
  63121. * The component name helpfull to identify the component in the list of scene components.
  63122. */
  63123. readonly name: string;
  63124. /**
  63125. * The scene the component belongs to.
  63126. */
  63127. scene: Scene;
  63128. /**
  63129. * Creates a new instance of the component for the given scene
  63130. * @param scene Defines the scene to register the component in
  63131. */
  63132. constructor(scene: Scene);
  63133. /**
  63134. * Registers the component in a given scene
  63135. */
  63136. register(): void;
  63137. /**
  63138. * Rebuilds the elements related to this component in case of
  63139. * context lost for instance.
  63140. */
  63141. rebuild(): void;
  63142. /**
  63143. * Disposes the component and the associated ressources
  63144. */
  63145. dispose(): void;
  63146. private _gatherRenderTargets;
  63147. }
  63148. }
  63149. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63150. import { Nullable } from "babylonjs/types";
  63151. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63152. import { Camera } from "babylonjs/Cameras/camera";
  63153. import { IDisposable } from "babylonjs/scene";
  63154. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63155. import { Scene } from "babylonjs/scene";
  63156. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63157. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63158. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63159. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63160. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63161. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63162. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63163. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63164. import { Animation } from "babylonjs/Animations/animation";
  63165. /**
  63166. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63167. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63168. */
  63169. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63170. private _scene;
  63171. private _camerasToBeAttached;
  63172. /**
  63173. * ID of the sharpen post process,
  63174. */
  63175. private readonly SharpenPostProcessId;
  63176. /**
  63177. * @ignore
  63178. * ID of the image processing post process;
  63179. */
  63180. readonly ImageProcessingPostProcessId: string;
  63181. /**
  63182. * @ignore
  63183. * ID of the Fast Approximate Anti-Aliasing post process;
  63184. */
  63185. readonly FxaaPostProcessId: string;
  63186. /**
  63187. * ID of the chromatic aberration post process,
  63188. */
  63189. private readonly ChromaticAberrationPostProcessId;
  63190. /**
  63191. * ID of the grain post process
  63192. */
  63193. private readonly GrainPostProcessId;
  63194. /**
  63195. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63196. */
  63197. sharpen: SharpenPostProcess;
  63198. private _sharpenEffect;
  63199. private bloom;
  63200. /**
  63201. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63202. */
  63203. depthOfField: DepthOfFieldEffect;
  63204. /**
  63205. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63206. */
  63207. fxaa: FxaaPostProcess;
  63208. /**
  63209. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63210. */
  63211. imageProcessing: ImageProcessingPostProcess;
  63212. /**
  63213. * Chromatic aberration post process which will shift rgb colors in the image
  63214. */
  63215. chromaticAberration: ChromaticAberrationPostProcess;
  63216. private _chromaticAberrationEffect;
  63217. /**
  63218. * Grain post process which add noise to the image
  63219. */
  63220. grain: GrainPostProcess;
  63221. private _grainEffect;
  63222. /**
  63223. * Glow post process which adds a glow to emissive areas of the image
  63224. */
  63225. private _glowLayer;
  63226. /**
  63227. * Animations which can be used to tweak settings over a period of time
  63228. */
  63229. animations: Animation[];
  63230. private _imageProcessingConfigurationObserver;
  63231. private _sharpenEnabled;
  63232. private _bloomEnabled;
  63233. private _depthOfFieldEnabled;
  63234. private _depthOfFieldBlurLevel;
  63235. private _fxaaEnabled;
  63236. private _imageProcessingEnabled;
  63237. private _defaultPipelineTextureType;
  63238. private _bloomScale;
  63239. private _chromaticAberrationEnabled;
  63240. private _grainEnabled;
  63241. private _buildAllowed;
  63242. /**
  63243. * Gets active scene
  63244. */
  63245. readonly scene: Scene;
  63246. /**
  63247. * Enable or disable the sharpen process from the pipeline
  63248. */
  63249. sharpenEnabled: boolean;
  63250. private _resizeObserver;
  63251. private _hardwareScaleLevel;
  63252. private _bloomKernel;
  63253. /**
  63254. * Specifies the size of the bloom blur kernel, relative to the final output size
  63255. */
  63256. bloomKernel: number;
  63257. /**
  63258. * Specifies the weight of the bloom in the final rendering
  63259. */
  63260. private _bloomWeight;
  63261. /**
  63262. * Specifies the luma threshold for the area that will be blurred by the bloom
  63263. */
  63264. private _bloomThreshold;
  63265. private _hdr;
  63266. /**
  63267. * The strength of the bloom.
  63268. */
  63269. bloomWeight: number;
  63270. /**
  63271. * The strength of the bloom.
  63272. */
  63273. bloomThreshold: number;
  63274. /**
  63275. * The scale of the bloom, lower value will provide better performance.
  63276. */
  63277. bloomScale: number;
  63278. /**
  63279. * Enable or disable the bloom from the pipeline
  63280. */
  63281. bloomEnabled: boolean;
  63282. private _rebuildBloom;
  63283. /**
  63284. * If the depth of field is enabled.
  63285. */
  63286. depthOfFieldEnabled: boolean;
  63287. /**
  63288. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63289. */
  63290. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63291. /**
  63292. * If the anti aliasing is enabled.
  63293. */
  63294. fxaaEnabled: boolean;
  63295. private _samples;
  63296. /**
  63297. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63298. */
  63299. samples: number;
  63300. /**
  63301. * If image processing is enabled.
  63302. */
  63303. imageProcessingEnabled: boolean;
  63304. /**
  63305. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63306. */
  63307. glowLayerEnabled: boolean;
  63308. /**
  63309. * Gets the glow layer (or null if not defined)
  63310. */
  63311. readonly glowLayer: Nullable<GlowLayer>;
  63312. /**
  63313. * Enable or disable the chromaticAberration process from the pipeline
  63314. */
  63315. chromaticAberrationEnabled: boolean;
  63316. /**
  63317. * Enable or disable the grain process from the pipeline
  63318. */
  63319. grainEnabled: boolean;
  63320. /**
  63321. * @constructor
  63322. * @param name - The rendering pipeline name (default: "")
  63323. * @param hdr - If high dynamic range textures should be used (default: true)
  63324. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63325. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63326. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63327. */
  63328. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63329. /**
  63330. * Get the class name
  63331. * @returns "DefaultRenderingPipeline"
  63332. */
  63333. getClassName(): string;
  63334. /**
  63335. * Force the compilation of the entire pipeline.
  63336. */
  63337. prepare(): void;
  63338. private _hasCleared;
  63339. private _prevPostProcess;
  63340. private _prevPrevPostProcess;
  63341. private _setAutoClearAndTextureSharing;
  63342. private _depthOfFieldSceneObserver;
  63343. private _buildPipeline;
  63344. private _disposePostProcesses;
  63345. /**
  63346. * Adds a camera to the pipeline
  63347. * @param camera the camera to be added
  63348. */
  63349. addCamera(camera: Camera): void;
  63350. /**
  63351. * Removes a camera from the pipeline
  63352. * @param camera the camera to remove
  63353. */
  63354. removeCamera(camera: Camera): void;
  63355. /**
  63356. * Dispose of the pipeline and stop all post processes
  63357. */
  63358. dispose(): void;
  63359. /**
  63360. * Serialize the rendering pipeline (Used when exporting)
  63361. * @returns the serialized object
  63362. */
  63363. serialize(): any;
  63364. /**
  63365. * Parse the serialized pipeline
  63366. * @param source Source pipeline.
  63367. * @param scene The scene to load the pipeline to.
  63368. * @param rootUrl The URL of the serialized pipeline.
  63369. * @returns An instantiated pipeline from the serialized object.
  63370. */
  63371. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63372. }
  63373. }
  63374. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63375. /** @hidden */
  63376. export var lensHighlightsPixelShader: {
  63377. name: string;
  63378. shader: string;
  63379. };
  63380. }
  63381. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63382. /** @hidden */
  63383. export var depthOfFieldPixelShader: {
  63384. name: string;
  63385. shader: string;
  63386. };
  63387. }
  63388. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63389. import { Camera } from "babylonjs/Cameras/camera";
  63390. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63391. import { Scene } from "babylonjs/scene";
  63392. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63393. import "babylonjs/Shaders/chromaticAberration.fragment";
  63394. import "babylonjs/Shaders/lensHighlights.fragment";
  63395. import "babylonjs/Shaders/depthOfField.fragment";
  63396. /**
  63397. * BABYLON.JS Chromatic Aberration GLSL Shader
  63398. * Author: Olivier Guyot
  63399. * Separates very slightly R, G and B colors on the edges of the screen
  63400. * Inspired by Francois Tarlier & Martins Upitis
  63401. */
  63402. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63403. /**
  63404. * @ignore
  63405. * The chromatic aberration PostProcess id in the pipeline
  63406. */
  63407. LensChromaticAberrationEffect: string;
  63408. /**
  63409. * @ignore
  63410. * The highlights enhancing PostProcess id in the pipeline
  63411. */
  63412. HighlightsEnhancingEffect: string;
  63413. /**
  63414. * @ignore
  63415. * The depth-of-field PostProcess id in the pipeline
  63416. */
  63417. LensDepthOfFieldEffect: string;
  63418. private _scene;
  63419. private _depthTexture;
  63420. private _grainTexture;
  63421. private _chromaticAberrationPostProcess;
  63422. private _highlightsPostProcess;
  63423. private _depthOfFieldPostProcess;
  63424. private _edgeBlur;
  63425. private _grainAmount;
  63426. private _chromaticAberration;
  63427. private _distortion;
  63428. private _highlightsGain;
  63429. private _highlightsThreshold;
  63430. private _dofDistance;
  63431. private _dofAperture;
  63432. private _dofDarken;
  63433. private _dofPentagon;
  63434. private _blurNoise;
  63435. /**
  63436. * @constructor
  63437. *
  63438. * Effect parameters are as follow:
  63439. * {
  63440. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63441. * edge_blur: number; // from 0 to x (1 for realism)
  63442. * distortion: number; // from 0 to x (1 for realism)
  63443. * grain_amount: number; // from 0 to 1
  63444. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63445. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63446. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63447. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63448. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63449. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63450. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63451. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63452. * }
  63453. * Note: if an effect parameter is unset, effect is disabled
  63454. *
  63455. * @param name The rendering pipeline name
  63456. * @param parameters - An object containing all parameters (see above)
  63457. * @param scene The scene linked to this pipeline
  63458. * @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)
  63459. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63460. */
  63461. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63462. /**
  63463. * Get the class name
  63464. * @returns "LensRenderingPipeline"
  63465. */
  63466. getClassName(): string;
  63467. /**
  63468. * Gets associated scene
  63469. */
  63470. readonly scene: Scene;
  63471. /**
  63472. * Gets or sets the edge blur
  63473. */
  63474. edgeBlur: number;
  63475. /**
  63476. * Gets or sets the grain amount
  63477. */
  63478. grainAmount: number;
  63479. /**
  63480. * Gets or sets the chromatic aberration amount
  63481. */
  63482. chromaticAberration: number;
  63483. /**
  63484. * Gets or sets the depth of field aperture
  63485. */
  63486. dofAperture: number;
  63487. /**
  63488. * Gets or sets the edge distortion
  63489. */
  63490. edgeDistortion: number;
  63491. /**
  63492. * Gets or sets the depth of field distortion
  63493. */
  63494. dofDistortion: number;
  63495. /**
  63496. * Gets or sets the darken out of focus amount
  63497. */
  63498. darkenOutOfFocus: number;
  63499. /**
  63500. * Gets or sets a boolean indicating if blur noise is enabled
  63501. */
  63502. blurNoise: boolean;
  63503. /**
  63504. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63505. */
  63506. pentagonBokeh: boolean;
  63507. /**
  63508. * Gets or sets the highlight grain amount
  63509. */
  63510. highlightsGain: number;
  63511. /**
  63512. * Gets or sets the highlight threshold
  63513. */
  63514. highlightsThreshold: number;
  63515. /**
  63516. * Sets the amount of blur at the edges
  63517. * @param amount blur amount
  63518. */
  63519. setEdgeBlur(amount: number): void;
  63520. /**
  63521. * Sets edge blur to 0
  63522. */
  63523. disableEdgeBlur(): void;
  63524. /**
  63525. * Sets the amout of grain
  63526. * @param amount Amount of grain
  63527. */
  63528. setGrainAmount(amount: number): void;
  63529. /**
  63530. * Set grain amount to 0
  63531. */
  63532. disableGrain(): void;
  63533. /**
  63534. * Sets the chromatic aberration amount
  63535. * @param amount amount of chromatic aberration
  63536. */
  63537. setChromaticAberration(amount: number): void;
  63538. /**
  63539. * Sets chromatic aberration amount to 0
  63540. */
  63541. disableChromaticAberration(): void;
  63542. /**
  63543. * Sets the EdgeDistortion amount
  63544. * @param amount amount of EdgeDistortion
  63545. */
  63546. setEdgeDistortion(amount: number): void;
  63547. /**
  63548. * Sets edge distortion to 0
  63549. */
  63550. disableEdgeDistortion(): void;
  63551. /**
  63552. * Sets the FocusDistance amount
  63553. * @param amount amount of FocusDistance
  63554. */
  63555. setFocusDistance(amount: number): void;
  63556. /**
  63557. * Disables depth of field
  63558. */
  63559. disableDepthOfField(): void;
  63560. /**
  63561. * Sets the Aperture amount
  63562. * @param amount amount of Aperture
  63563. */
  63564. setAperture(amount: number): void;
  63565. /**
  63566. * Sets the DarkenOutOfFocus amount
  63567. * @param amount amount of DarkenOutOfFocus
  63568. */
  63569. setDarkenOutOfFocus(amount: number): void;
  63570. private _pentagonBokehIsEnabled;
  63571. /**
  63572. * Creates a pentagon bokeh effect
  63573. */
  63574. enablePentagonBokeh(): void;
  63575. /**
  63576. * Disables the pentagon bokeh effect
  63577. */
  63578. disablePentagonBokeh(): void;
  63579. /**
  63580. * Enables noise blur
  63581. */
  63582. enableNoiseBlur(): void;
  63583. /**
  63584. * Disables noise blur
  63585. */
  63586. disableNoiseBlur(): void;
  63587. /**
  63588. * Sets the HighlightsGain amount
  63589. * @param amount amount of HighlightsGain
  63590. */
  63591. setHighlightsGain(amount: number): void;
  63592. /**
  63593. * Sets the HighlightsThreshold amount
  63594. * @param amount amount of HighlightsThreshold
  63595. */
  63596. setHighlightsThreshold(amount: number): void;
  63597. /**
  63598. * Disables highlights
  63599. */
  63600. disableHighlights(): void;
  63601. /**
  63602. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63603. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63604. */
  63605. dispose(disableDepthRender?: boolean): void;
  63606. private _createChromaticAberrationPostProcess;
  63607. private _createHighlightsPostProcess;
  63608. private _createDepthOfFieldPostProcess;
  63609. private _createGrainTexture;
  63610. }
  63611. }
  63612. declare module "babylonjs/Shaders/ssao2.fragment" {
  63613. /** @hidden */
  63614. export var ssao2PixelShader: {
  63615. name: string;
  63616. shader: string;
  63617. };
  63618. }
  63619. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63620. /** @hidden */
  63621. export var ssaoCombinePixelShader: {
  63622. name: string;
  63623. shader: string;
  63624. };
  63625. }
  63626. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63627. import { Camera } from "babylonjs/Cameras/camera";
  63628. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63629. import { Scene } from "babylonjs/scene";
  63630. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63631. import "babylonjs/Shaders/ssao2.fragment";
  63632. import "babylonjs/Shaders/ssaoCombine.fragment";
  63633. /**
  63634. * Render pipeline to produce ssao effect
  63635. */
  63636. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63637. /**
  63638. * @ignore
  63639. * The PassPostProcess id in the pipeline that contains the original scene color
  63640. */
  63641. SSAOOriginalSceneColorEffect: string;
  63642. /**
  63643. * @ignore
  63644. * The SSAO PostProcess id in the pipeline
  63645. */
  63646. SSAORenderEffect: string;
  63647. /**
  63648. * @ignore
  63649. * The horizontal blur PostProcess id in the pipeline
  63650. */
  63651. SSAOBlurHRenderEffect: string;
  63652. /**
  63653. * @ignore
  63654. * The vertical blur PostProcess id in the pipeline
  63655. */
  63656. SSAOBlurVRenderEffect: string;
  63657. /**
  63658. * @ignore
  63659. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63660. */
  63661. SSAOCombineRenderEffect: string;
  63662. /**
  63663. * The output strength of the SSAO post-process. Default value is 1.0.
  63664. */
  63665. totalStrength: number;
  63666. /**
  63667. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63668. */
  63669. maxZ: number;
  63670. /**
  63671. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63672. */
  63673. minZAspect: number;
  63674. private _samples;
  63675. /**
  63676. * Number of samples used for the SSAO calculations. Default value is 8
  63677. */
  63678. samples: number;
  63679. private _textureSamples;
  63680. /**
  63681. * Number of samples to use for antialiasing
  63682. */
  63683. textureSamples: number;
  63684. /**
  63685. * Ratio object used for SSAO ratio and blur ratio
  63686. */
  63687. private _ratio;
  63688. /**
  63689. * Dynamically generated sphere sampler.
  63690. */
  63691. private _sampleSphere;
  63692. /**
  63693. * Blur filter offsets
  63694. */
  63695. private _samplerOffsets;
  63696. private _expensiveBlur;
  63697. /**
  63698. * If bilateral blur should be used
  63699. */
  63700. expensiveBlur: boolean;
  63701. /**
  63702. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63703. */
  63704. radius: number;
  63705. /**
  63706. * The base color of the SSAO post-process
  63707. * The final result is "base + ssao" between [0, 1]
  63708. */
  63709. base: number;
  63710. /**
  63711. * Support test.
  63712. */
  63713. static readonly IsSupported: boolean;
  63714. private _scene;
  63715. private _depthTexture;
  63716. private _normalTexture;
  63717. private _randomTexture;
  63718. private _originalColorPostProcess;
  63719. private _ssaoPostProcess;
  63720. private _blurHPostProcess;
  63721. private _blurVPostProcess;
  63722. private _ssaoCombinePostProcess;
  63723. private _firstUpdate;
  63724. /**
  63725. * Gets active scene
  63726. */
  63727. readonly scene: Scene;
  63728. /**
  63729. * @constructor
  63730. * @param name The rendering pipeline name
  63731. * @param scene The scene linked to this pipeline
  63732. * @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 }
  63733. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63734. */
  63735. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63736. /**
  63737. * Get the class name
  63738. * @returns "SSAO2RenderingPipeline"
  63739. */
  63740. getClassName(): string;
  63741. /**
  63742. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63743. */
  63744. dispose(disableGeometryBufferRenderer?: boolean): void;
  63745. private _createBlurPostProcess;
  63746. /** @hidden */
  63747. _rebuild(): void;
  63748. private _bits;
  63749. private _radicalInverse_VdC;
  63750. private _hammersley;
  63751. private _hemisphereSample_uniform;
  63752. private _generateHemisphere;
  63753. private _createSSAOPostProcess;
  63754. private _createSSAOCombinePostProcess;
  63755. private _createRandomTexture;
  63756. /**
  63757. * Serialize the rendering pipeline (Used when exporting)
  63758. * @returns the serialized object
  63759. */
  63760. serialize(): any;
  63761. /**
  63762. * Parse the serialized pipeline
  63763. * @param source Source pipeline.
  63764. * @param scene The scene to load the pipeline to.
  63765. * @param rootUrl The URL of the serialized pipeline.
  63766. * @returns An instantiated pipeline from the serialized object.
  63767. */
  63768. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63769. }
  63770. }
  63771. declare module "babylonjs/Shaders/ssao.fragment" {
  63772. /** @hidden */
  63773. export var ssaoPixelShader: {
  63774. name: string;
  63775. shader: string;
  63776. };
  63777. }
  63778. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63779. import { Camera } from "babylonjs/Cameras/camera";
  63780. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63781. import { Scene } from "babylonjs/scene";
  63782. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63783. import "babylonjs/Shaders/ssao.fragment";
  63784. import "babylonjs/Shaders/ssaoCombine.fragment";
  63785. /**
  63786. * Render pipeline to produce ssao effect
  63787. */
  63788. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63789. /**
  63790. * @ignore
  63791. * The PassPostProcess id in the pipeline that contains the original scene color
  63792. */
  63793. SSAOOriginalSceneColorEffect: string;
  63794. /**
  63795. * @ignore
  63796. * The SSAO PostProcess id in the pipeline
  63797. */
  63798. SSAORenderEffect: string;
  63799. /**
  63800. * @ignore
  63801. * The horizontal blur PostProcess id in the pipeline
  63802. */
  63803. SSAOBlurHRenderEffect: string;
  63804. /**
  63805. * @ignore
  63806. * The vertical blur PostProcess id in the pipeline
  63807. */
  63808. SSAOBlurVRenderEffect: string;
  63809. /**
  63810. * @ignore
  63811. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63812. */
  63813. SSAOCombineRenderEffect: string;
  63814. /**
  63815. * The output strength of the SSAO post-process. Default value is 1.0.
  63816. */
  63817. totalStrength: number;
  63818. /**
  63819. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63820. */
  63821. radius: number;
  63822. /**
  63823. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63824. * Must not be equal to fallOff and superior to fallOff.
  63825. * Default value is 0.0075
  63826. */
  63827. area: number;
  63828. /**
  63829. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63830. * Must not be equal to area and inferior to area.
  63831. * Default value is 0.000001
  63832. */
  63833. fallOff: number;
  63834. /**
  63835. * The base color of the SSAO post-process
  63836. * The final result is "base + ssao" between [0, 1]
  63837. */
  63838. base: number;
  63839. private _scene;
  63840. private _depthTexture;
  63841. private _randomTexture;
  63842. private _originalColorPostProcess;
  63843. private _ssaoPostProcess;
  63844. private _blurHPostProcess;
  63845. private _blurVPostProcess;
  63846. private _ssaoCombinePostProcess;
  63847. private _firstUpdate;
  63848. /**
  63849. * Gets active scene
  63850. */
  63851. readonly scene: Scene;
  63852. /**
  63853. * @constructor
  63854. * @param name - The rendering pipeline name
  63855. * @param scene - The scene linked to this pipeline
  63856. * @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 }
  63857. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63858. */
  63859. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63860. /**
  63861. * Get the class name
  63862. * @returns "SSAORenderingPipeline"
  63863. */
  63864. getClassName(): string;
  63865. /**
  63866. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63867. */
  63868. dispose(disableDepthRender?: boolean): void;
  63869. private _createBlurPostProcess;
  63870. /** @hidden */
  63871. _rebuild(): void;
  63872. private _createSSAOPostProcess;
  63873. private _createSSAOCombinePostProcess;
  63874. private _createRandomTexture;
  63875. }
  63876. }
  63877. declare module "babylonjs/Shaders/standard.fragment" {
  63878. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63879. /** @hidden */
  63880. export var standardPixelShader: {
  63881. name: string;
  63882. shader: string;
  63883. };
  63884. }
  63885. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63886. import { Nullable } from "babylonjs/types";
  63887. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63888. import { Camera } from "babylonjs/Cameras/camera";
  63889. import { Texture } from "babylonjs/Materials/Textures/texture";
  63890. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63891. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63892. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63893. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63894. import { IDisposable } from "babylonjs/scene";
  63895. import { SpotLight } from "babylonjs/Lights/spotLight";
  63896. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63897. import { Scene } from "babylonjs/scene";
  63898. import { Animation } from "babylonjs/Animations/animation";
  63899. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63900. import "babylonjs/Shaders/standard.fragment";
  63901. /**
  63902. * Standard rendering pipeline
  63903. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63904. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63905. */
  63906. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63907. /**
  63908. * Public members
  63909. */
  63910. /**
  63911. * Post-process which contains the original scene color before the pipeline applies all the effects
  63912. */
  63913. originalPostProcess: Nullable<PostProcess>;
  63914. /**
  63915. * Post-process used to down scale an image x4
  63916. */
  63917. downSampleX4PostProcess: Nullable<PostProcess>;
  63918. /**
  63919. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63920. */
  63921. brightPassPostProcess: Nullable<PostProcess>;
  63922. /**
  63923. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63924. */
  63925. blurHPostProcesses: PostProcess[];
  63926. /**
  63927. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63928. */
  63929. blurVPostProcesses: PostProcess[];
  63930. /**
  63931. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63932. */
  63933. textureAdderPostProcess: Nullable<PostProcess>;
  63934. /**
  63935. * Post-process used to create volumetric lighting effect
  63936. */
  63937. volumetricLightPostProcess: Nullable<PostProcess>;
  63938. /**
  63939. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63940. */
  63941. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63942. /**
  63943. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63944. */
  63945. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63946. /**
  63947. * Post-process used to merge the volumetric light effect and the real scene color
  63948. */
  63949. volumetricLightMergePostProces: Nullable<PostProcess>;
  63950. /**
  63951. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63952. */
  63953. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63954. /**
  63955. * Base post-process used to calculate the average luminance of the final image for HDR
  63956. */
  63957. luminancePostProcess: Nullable<PostProcess>;
  63958. /**
  63959. * Post-processes used to create down sample post-processes in order to get
  63960. * the average luminance of the final image for HDR
  63961. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63962. */
  63963. luminanceDownSamplePostProcesses: PostProcess[];
  63964. /**
  63965. * Post-process used to create a HDR effect (light adaptation)
  63966. */
  63967. hdrPostProcess: Nullable<PostProcess>;
  63968. /**
  63969. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63970. */
  63971. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63972. /**
  63973. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63974. */
  63975. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63976. /**
  63977. * Post-process used to merge the final HDR post-process and the real scene color
  63978. */
  63979. hdrFinalPostProcess: Nullable<PostProcess>;
  63980. /**
  63981. * Post-process used to create a lens flare effect
  63982. */
  63983. lensFlarePostProcess: Nullable<PostProcess>;
  63984. /**
  63985. * Post-process that merges the result of the lens flare post-process and the real scene color
  63986. */
  63987. lensFlareComposePostProcess: Nullable<PostProcess>;
  63988. /**
  63989. * Post-process used to create a motion blur effect
  63990. */
  63991. motionBlurPostProcess: Nullable<PostProcess>;
  63992. /**
  63993. * Post-process used to create a depth of field effect
  63994. */
  63995. depthOfFieldPostProcess: Nullable<PostProcess>;
  63996. /**
  63997. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63998. */
  63999. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64000. /**
  64001. * Represents the brightness threshold in order to configure the illuminated surfaces
  64002. */
  64003. brightThreshold: number;
  64004. /**
  64005. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64006. */
  64007. blurWidth: number;
  64008. /**
  64009. * Sets if the blur for highlighted surfaces must be only horizontal
  64010. */
  64011. horizontalBlur: boolean;
  64012. /**
  64013. * Gets the overall exposure used by the pipeline
  64014. */
  64015. /**
  64016. * Sets the overall exposure used by the pipeline
  64017. */
  64018. exposure: number;
  64019. /**
  64020. * Texture used typically to simulate "dirty" on camera lens
  64021. */
  64022. lensTexture: Nullable<Texture>;
  64023. /**
  64024. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64025. */
  64026. volumetricLightCoefficient: number;
  64027. /**
  64028. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64029. */
  64030. volumetricLightPower: number;
  64031. /**
  64032. * Used the set the blur intensity to smooth the volumetric lights
  64033. */
  64034. volumetricLightBlurScale: number;
  64035. /**
  64036. * Light (spot or directional) used to generate the volumetric lights rays
  64037. * The source light must have a shadow generate so the pipeline can get its
  64038. * depth map
  64039. */
  64040. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64041. /**
  64042. * For eye adaptation, represents the minimum luminance the eye can see
  64043. */
  64044. hdrMinimumLuminance: number;
  64045. /**
  64046. * For eye adaptation, represents the decrease luminance speed
  64047. */
  64048. hdrDecreaseRate: number;
  64049. /**
  64050. * For eye adaptation, represents the increase luminance speed
  64051. */
  64052. hdrIncreaseRate: number;
  64053. /**
  64054. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64055. */
  64056. /**
  64057. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64058. */
  64059. hdrAutoExposure: boolean;
  64060. /**
  64061. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64062. */
  64063. lensColorTexture: Nullable<Texture>;
  64064. /**
  64065. * The overall strengh for the lens flare effect
  64066. */
  64067. lensFlareStrength: number;
  64068. /**
  64069. * Dispersion coefficient for lens flare ghosts
  64070. */
  64071. lensFlareGhostDispersal: number;
  64072. /**
  64073. * Main lens flare halo width
  64074. */
  64075. lensFlareHaloWidth: number;
  64076. /**
  64077. * Based on the lens distortion effect, defines how much the lens flare result
  64078. * is distorted
  64079. */
  64080. lensFlareDistortionStrength: number;
  64081. /**
  64082. * Configures the blur intensity used for for lens flare (halo)
  64083. */
  64084. lensFlareBlurWidth: number;
  64085. /**
  64086. * Lens star texture must be used to simulate rays on the flares and is available
  64087. * in the documentation
  64088. */
  64089. lensStarTexture: Nullable<Texture>;
  64090. /**
  64091. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64092. * flare effect by taking account of the dirt texture
  64093. */
  64094. lensFlareDirtTexture: Nullable<Texture>;
  64095. /**
  64096. * Represents the focal length for the depth of field effect
  64097. */
  64098. depthOfFieldDistance: number;
  64099. /**
  64100. * Represents the blur intensity for the blurred part of the depth of field effect
  64101. */
  64102. depthOfFieldBlurWidth: number;
  64103. /**
  64104. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64105. */
  64106. /**
  64107. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64108. */
  64109. motionStrength: number;
  64110. /**
  64111. * Gets wether or not the motion blur post-process is object based or screen based.
  64112. */
  64113. /**
  64114. * Sets wether or not the motion blur post-process should be object based or screen based
  64115. */
  64116. objectBasedMotionBlur: boolean;
  64117. /**
  64118. * List of animations for the pipeline (IAnimatable implementation)
  64119. */
  64120. animations: Animation[];
  64121. /**
  64122. * Private members
  64123. */
  64124. private _scene;
  64125. private _currentDepthOfFieldSource;
  64126. private _basePostProcess;
  64127. private _fixedExposure;
  64128. private _currentExposure;
  64129. private _hdrAutoExposure;
  64130. private _hdrCurrentLuminance;
  64131. private _motionStrength;
  64132. private _isObjectBasedMotionBlur;
  64133. private _floatTextureType;
  64134. private _camerasToBeAttached;
  64135. private _ratio;
  64136. private _bloomEnabled;
  64137. private _depthOfFieldEnabled;
  64138. private _vlsEnabled;
  64139. private _lensFlareEnabled;
  64140. private _hdrEnabled;
  64141. private _motionBlurEnabled;
  64142. private _fxaaEnabled;
  64143. private _motionBlurSamples;
  64144. private _volumetricLightStepsCount;
  64145. private _samples;
  64146. /**
  64147. * @ignore
  64148. * Specifies if the bloom pipeline is enabled
  64149. */
  64150. BloomEnabled: boolean;
  64151. /**
  64152. * @ignore
  64153. * Specifies if the depth of field pipeline is enabed
  64154. */
  64155. DepthOfFieldEnabled: boolean;
  64156. /**
  64157. * @ignore
  64158. * Specifies if the lens flare pipeline is enabed
  64159. */
  64160. LensFlareEnabled: boolean;
  64161. /**
  64162. * @ignore
  64163. * Specifies if the HDR pipeline is enabled
  64164. */
  64165. HDREnabled: boolean;
  64166. /**
  64167. * @ignore
  64168. * Specifies if the volumetric lights scattering effect is enabled
  64169. */
  64170. VLSEnabled: boolean;
  64171. /**
  64172. * @ignore
  64173. * Specifies if the motion blur effect is enabled
  64174. */
  64175. MotionBlurEnabled: boolean;
  64176. /**
  64177. * Specifies if anti-aliasing is enabled
  64178. */
  64179. fxaaEnabled: boolean;
  64180. /**
  64181. * Specifies the number of steps used to calculate the volumetric lights
  64182. * Typically in interval [50, 200]
  64183. */
  64184. volumetricLightStepsCount: number;
  64185. /**
  64186. * Specifies the number of samples used for the motion blur effect
  64187. * Typically in interval [16, 64]
  64188. */
  64189. motionBlurSamples: number;
  64190. /**
  64191. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64192. */
  64193. samples: number;
  64194. /**
  64195. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64196. * @constructor
  64197. * @param name The rendering pipeline name
  64198. * @param scene The scene linked to this pipeline
  64199. * @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)
  64200. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64201. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64202. */
  64203. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64204. private _buildPipeline;
  64205. private _createDownSampleX4PostProcess;
  64206. private _createBrightPassPostProcess;
  64207. private _createBlurPostProcesses;
  64208. private _createTextureAdderPostProcess;
  64209. private _createVolumetricLightPostProcess;
  64210. private _createLuminancePostProcesses;
  64211. private _createHdrPostProcess;
  64212. private _createLensFlarePostProcess;
  64213. private _createDepthOfFieldPostProcess;
  64214. private _createMotionBlurPostProcess;
  64215. private _getDepthTexture;
  64216. private _disposePostProcesses;
  64217. /**
  64218. * Dispose of the pipeline and stop all post processes
  64219. */
  64220. dispose(): void;
  64221. /**
  64222. * Serialize the rendering pipeline (Used when exporting)
  64223. * @returns the serialized object
  64224. */
  64225. serialize(): any;
  64226. /**
  64227. * Parse the serialized pipeline
  64228. * @param source Source pipeline.
  64229. * @param scene The scene to load the pipeline to.
  64230. * @param rootUrl The URL of the serialized pipeline.
  64231. * @returns An instantiated pipeline from the serialized object.
  64232. */
  64233. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64234. /**
  64235. * Luminance steps
  64236. */
  64237. static LuminanceSteps: number;
  64238. }
  64239. }
  64240. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64241. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64242. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64243. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64244. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64245. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64246. }
  64247. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64248. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64249. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64250. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64251. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64252. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64253. }
  64254. declare module "babylonjs/Shaders/tonemap.fragment" {
  64255. /** @hidden */
  64256. export var tonemapPixelShader: {
  64257. name: string;
  64258. shader: string;
  64259. };
  64260. }
  64261. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64262. import { Camera } from "babylonjs/Cameras/camera";
  64263. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64264. import "babylonjs/Shaders/tonemap.fragment";
  64265. import { Engine } from "babylonjs/Engines/engine";
  64266. /** Defines operator used for tonemapping */
  64267. export enum TonemappingOperator {
  64268. /** Hable */
  64269. Hable = 0,
  64270. /** Reinhard */
  64271. Reinhard = 1,
  64272. /** HejiDawson */
  64273. HejiDawson = 2,
  64274. /** Photographic */
  64275. Photographic = 3
  64276. }
  64277. /**
  64278. * Defines a post process to apply tone mapping
  64279. */
  64280. export class TonemapPostProcess extends PostProcess {
  64281. private _operator;
  64282. /** Defines the required exposure adjustement */
  64283. exposureAdjustment: number;
  64284. /**
  64285. * Creates a new TonemapPostProcess
  64286. * @param name defines the name of the postprocess
  64287. * @param _operator defines the operator to use
  64288. * @param exposureAdjustment defines the required exposure adjustement
  64289. * @param camera defines the camera to use (can be null)
  64290. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64291. * @param engine defines the hosting engine (can be ignore if camera is set)
  64292. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64293. */
  64294. constructor(name: string, _operator: TonemappingOperator,
  64295. /** Defines the required exposure adjustement */
  64296. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64297. }
  64298. }
  64299. declare module "babylonjs/Shaders/depth.vertex" {
  64300. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64301. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64302. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64303. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64304. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64305. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64306. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64307. /** @hidden */
  64308. export var depthVertexShader: {
  64309. name: string;
  64310. shader: string;
  64311. };
  64312. }
  64313. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64314. /** @hidden */
  64315. export var volumetricLightScatteringPixelShader: {
  64316. name: string;
  64317. shader: string;
  64318. };
  64319. }
  64320. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64321. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64322. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64323. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64324. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64325. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64326. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64327. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64328. /** @hidden */
  64329. export var volumetricLightScatteringPassVertexShader: {
  64330. name: string;
  64331. shader: string;
  64332. };
  64333. }
  64334. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64335. /** @hidden */
  64336. export var volumetricLightScatteringPassPixelShader: {
  64337. name: string;
  64338. shader: string;
  64339. };
  64340. }
  64341. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64342. import { Vector3 } from "babylonjs/Maths/math.vector";
  64343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64344. import { Mesh } from "babylonjs/Meshes/mesh";
  64345. import { Camera } from "babylonjs/Cameras/camera";
  64346. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64347. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64348. import { Scene } from "babylonjs/scene";
  64349. import "babylonjs/Meshes/Builders/planeBuilder";
  64350. import "babylonjs/Shaders/depth.vertex";
  64351. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64352. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64353. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64354. import { Engine } from "babylonjs/Engines/engine";
  64355. /**
  64356. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64357. */
  64358. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64359. private _volumetricLightScatteringPass;
  64360. private _volumetricLightScatteringRTT;
  64361. private _viewPort;
  64362. private _screenCoordinates;
  64363. private _cachedDefines;
  64364. /**
  64365. * If not undefined, the mesh position is computed from the attached node position
  64366. */
  64367. attachedNode: {
  64368. position: Vector3;
  64369. };
  64370. /**
  64371. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64372. */
  64373. customMeshPosition: Vector3;
  64374. /**
  64375. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64376. */
  64377. useCustomMeshPosition: boolean;
  64378. /**
  64379. * If the post-process should inverse the light scattering direction
  64380. */
  64381. invert: boolean;
  64382. /**
  64383. * The internal mesh used by the post-process
  64384. */
  64385. mesh: Mesh;
  64386. /**
  64387. * @hidden
  64388. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64389. */
  64390. useDiffuseColor: boolean;
  64391. /**
  64392. * Array containing the excluded meshes not rendered in the internal pass
  64393. */
  64394. excludedMeshes: AbstractMesh[];
  64395. /**
  64396. * Controls the overall intensity of the post-process
  64397. */
  64398. exposure: number;
  64399. /**
  64400. * Dissipates each sample's contribution in range [0, 1]
  64401. */
  64402. decay: number;
  64403. /**
  64404. * Controls the overall intensity of each sample
  64405. */
  64406. weight: number;
  64407. /**
  64408. * Controls the density of each sample
  64409. */
  64410. density: number;
  64411. /**
  64412. * @constructor
  64413. * @param name The post-process name
  64414. * @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)
  64415. * @param camera The camera that the post-process will be attached to
  64416. * @param mesh The mesh used to create the light scattering
  64417. * @param samples The post-process quality, default 100
  64418. * @param samplingModeThe post-process filtering mode
  64419. * @param engine The babylon engine
  64420. * @param reusable If the post-process is reusable
  64421. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64422. */
  64423. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64424. /**
  64425. * Returns the string "VolumetricLightScatteringPostProcess"
  64426. * @returns "VolumetricLightScatteringPostProcess"
  64427. */
  64428. getClassName(): string;
  64429. private _isReady;
  64430. /**
  64431. * Sets the new light position for light scattering effect
  64432. * @param position The new custom light position
  64433. */
  64434. setCustomMeshPosition(position: Vector3): void;
  64435. /**
  64436. * Returns the light position for light scattering effect
  64437. * @return Vector3 The custom light position
  64438. */
  64439. getCustomMeshPosition(): Vector3;
  64440. /**
  64441. * Disposes the internal assets and detaches the post-process from the camera
  64442. */
  64443. dispose(camera: Camera): void;
  64444. /**
  64445. * Returns the render target texture used by the post-process
  64446. * @return the render target texture used by the post-process
  64447. */
  64448. getPass(): RenderTargetTexture;
  64449. private _meshExcluded;
  64450. private _createPass;
  64451. private _updateMeshScreenCoordinates;
  64452. /**
  64453. * Creates a default mesh for the Volumeric Light Scattering post-process
  64454. * @param name The mesh name
  64455. * @param scene The scene where to create the mesh
  64456. * @return the default mesh
  64457. */
  64458. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64459. }
  64460. }
  64461. declare module "babylonjs/PostProcesses/index" {
  64462. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64463. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64464. export * from "babylonjs/PostProcesses/bloomEffect";
  64465. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64466. export * from "babylonjs/PostProcesses/blurPostProcess";
  64467. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64468. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64469. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64470. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64471. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64472. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64473. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64474. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64475. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64476. export * from "babylonjs/PostProcesses/filterPostProcess";
  64477. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64478. export * from "babylonjs/PostProcesses/grainPostProcess";
  64479. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64480. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64481. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64482. export * from "babylonjs/PostProcesses/passPostProcess";
  64483. export * from "babylonjs/PostProcesses/postProcess";
  64484. export * from "babylonjs/PostProcesses/postProcessManager";
  64485. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64486. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64487. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64488. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64489. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64490. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64491. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64492. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64493. }
  64494. declare module "babylonjs/Probes/index" {
  64495. export * from "babylonjs/Probes/reflectionProbe";
  64496. }
  64497. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64498. import { Scene } from "babylonjs/scene";
  64499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64500. import { SmartArray } from "babylonjs/Misc/smartArray";
  64501. import { ISceneComponent } from "babylonjs/sceneComponent";
  64502. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64503. import "babylonjs/Meshes/Builders/boxBuilder";
  64504. import "babylonjs/Shaders/color.fragment";
  64505. import "babylonjs/Shaders/color.vertex";
  64506. import { Color3 } from "babylonjs/Maths/math.color";
  64507. module "babylonjs/scene" {
  64508. interface Scene {
  64509. /** @hidden (Backing field) */
  64510. _boundingBoxRenderer: BoundingBoxRenderer;
  64511. /** @hidden (Backing field) */
  64512. _forceShowBoundingBoxes: boolean;
  64513. /**
  64514. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64515. */
  64516. forceShowBoundingBoxes: boolean;
  64517. /**
  64518. * Gets the bounding box renderer associated with the scene
  64519. * @returns a BoundingBoxRenderer
  64520. */
  64521. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64522. }
  64523. }
  64524. module "babylonjs/Meshes/abstractMesh" {
  64525. interface AbstractMesh {
  64526. /** @hidden (Backing field) */
  64527. _showBoundingBox: boolean;
  64528. /**
  64529. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64530. */
  64531. showBoundingBox: boolean;
  64532. }
  64533. }
  64534. /**
  64535. * Component responsible of rendering the bounding box of the meshes in a scene.
  64536. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64537. */
  64538. export class BoundingBoxRenderer implements ISceneComponent {
  64539. /**
  64540. * The component name helpfull to identify the component in the list of scene components.
  64541. */
  64542. readonly name: string;
  64543. /**
  64544. * The scene the component belongs to.
  64545. */
  64546. scene: Scene;
  64547. /**
  64548. * Color of the bounding box lines placed in front of an object
  64549. */
  64550. frontColor: Color3;
  64551. /**
  64552. * Color of the bounding box lines placed behind an object
  64553. */
  64554. backColor: Color3;
  64555. /**
  64556. * Defines if the renderer should show the back lines or not
  64557. */
  64558. showBackLines: boolean;
  64559. /**
  64560. * @hidden
  64561. */
  64562. renderList: SmartArray<BoundingBox>;
  64563. private _colorShader;
  64564. private _vertexBuffers;
  64565. private _indexBuffer;
  64566. private _fillIndexBuffer;
  64567. private _fillIndexData;
  64568. /**
  64569. * Instantiates a new bounding box renderer in a scene.
  64570. * @param scene the scene the renderer renders in
  64571. */
  64572. constructor(scene: Scene);
  64573. /**
  64574. * Registers the component in a given scene
  64575. */
  64576. register(): void;
  64577. private _evaluateSubMesh;
  64578. private _activeMesh;
  64579. private _prepareRessources;
  64580. private _createIndexBuffer;
  64581. /**
  64582. * Rebuilds the elements related to this component in case of
  64583. * context lost for instance.
  64584. */
  64585. rebuild(): void;
  64586. /**
  64587. * @hidden
  64588. */
  64589. reset(): void;
  64590. /**
  64591. * Render the bounding boxes of a specific rendering group
  64592. * @param renderingGroupId defines the rendering group to render
  64593. */
  64594. render(renderingGroupId: number): void;
  64595. /**
  64596. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64597. * @param mesh Define the mesh to render the occlusion bounding box for
  64598. */
  64599. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64600. /**
  64601. * Dispose and release the resources attached to this renderer.
  64602. */
  64603. dispose(): void;
  64604. }
  64605. }
  64606. declare module "babylonjs/Shaders/depth.fragment" {
  64607. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64608. /** @hidden */
  64609. export var depthPixelShader: {
  64610. name: string;
  64611. shader: string;
  64612. };
  64613. }
  64614. declare module "babylonjs/Rendering/depthRenderer" {
  64615. import { Nullable } from "babylonjs/types";
  64616. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64617. import { Scene } from "babylonjs/scene";
  64618. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64619. import { Camera } from "babylonjs/Cameras/camera";
  64620. import "babylonjs/Shaders/depth.fragment";
  64621. import "babylonjs/Shaders/depth.vertex";
  64622. /**
  64623. * This represents a depth renderer in Babylon.
  64624. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64625. */
  64626. export class DepthRenderer {
  64627. private _scene;
  64628. private _depthMap;
  64629. private _effect;
  64630. private readonly _storeNonLinearDepth;
  64631. private readonly _clearColor;
  64632. /** Get if the depth renderer is using packed depth or not */
  64633. readonly isPacked: boolean;
  64634. private _cachedDefines;
  64635. private _camera;
  64636. /**
  64637. * Specifiess that the depth renderer will only be used within
  64638. * the camera it is created for.
  64639. * This can help forcing its rendering during the camera processing.
  64640. */
  64641. useOnlyInActiveCamera: boolean;
  64642. /** @hidden */
  64643. static _SceneComponentInitialization: (scene: Scene) => void;
  64644. /**
  64645. * Instantiates a depth renderer
  64646. * @param scene The scene the renderer belongs to
  64647. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64648. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64649. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64650. */
  64651. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64652. /**
  64653. * Creates the depth rendering effect and checks if the effect is ready.
  64654. * @param subMesh The submesh to be used to render the depth map of
  64655. * @param useInstances If multiple world instances should be used
  64656. * @returns if the depth renderer is ready to render the depth map
  64657. */
  64658. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64659. /**
  64660. * Gets the texture which the depth map will be written to.
  64661. * @returns The depth map texture
  64662. */
  64663. getDepthMap(): RenderTargetTexture;
  64664. /**
  64665. * Disposes of the depth renderer.
  64666. */
  64667. dispose(): void;
  64668. }
  64669. }
  64670. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64671. import { Nullable } from "babylonjs/types";
  64672. import { Scene } from "babylonjs/scene";
  64673. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64674. import { Camera } from "babylonjs/Cameras/camera";
  64675. import { ISceneComponent } from "babylonjs/sceneComponent";
  64676. module "babylonjs/scene" {
  64677. interface Scene {
  64678. /** @hidden (Backing field) */
  64679. _depthRenderer: {
  64680. [id: string]: DepthRenderer;
  64681. };
  64682. /**
  64683. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64684. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64685. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64686. * @returns the created depth renderer
  64687. */
  64688. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64689. /**
  64690. * Disables a depth renderer for a given camera
  64691. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64692. */
  64693. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64694. }
  64695. }
  64696. /**
  64697. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64698. * in several rendering techniques.
  64699. */
  64700. export class DepthRendererSceneComponent implements ISceneComponent {
  64701. /**
  64702. * The component name helpfull to identify the component in the list of scene components.
  64703. */
  64704. readonly name: string;
  64705. /**
  64706. * The scene the component belongs to.
  64707. */
  64708. scene: Scene;
  64709. /**
  64710. * Creates a new instance of the component for the given scene
  64711. * @param scene Defines the scene to register the component in
  64712. */
  64713. constructor(scene: Scene);
  64714. /**
  64715. * Registers the component in a given scene
  64716. */
  64717. register(): void;
  64718. /**
  64719. * Rebuilds the elements related to this component in case of
  64720. * context lost for instance.
  64721. */
  64722. rebuild(): void;
  64723. /**
  64724. * Disposes the component and the associated ressources
  64725. */
  64726. dispose(): void;
  64727. private _gatherRenderTargets;
  64728. private _gatherActiveCameraRenderTargets;
  64729. }
  64730. }
  64731. declare module "babylonjs/Shaders/outline.fragment" {
  64732. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64733. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64734. /** @hidden */
  64735. export var outlinePixelShader: {
  64736. name: string;
  64737. shader: string;
  64738. };
  64739. }
  64740. declare module "babylonjs/Shaders/outline.vertex" {
  64741. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64742. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64743. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64744. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64745. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64746. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64747. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64748. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64749. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64750. /** @hidden */
  64751. export var outlineVertexShader: {
  64752. name: string;
  64753. shader: string;
  64754. };
  64755. }
  64756. declare module "babylonjs/Rendering/outlineRenderer" {
  64757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64758. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64759. import { Scene } from "babylonjs/scene";
  64760. import { ISceneComponent } from "babylonjs/sceneComponent";
  64761. import "babylonjs/Shaders/outline.fragment";
  64762. import "babylonjs/Shaders/outline.vertex";
  64763. module "babylonjs/scene" {
  64764. interface Scene {
  64765. /** @hidden */
  64766. _outlineRenderer: OutlineRenderer;
  64767. /**
  64768. * Gets the outline renderer associated with the scene
  64769. * @returns a OutlineRenderer
  64770. */
  64771. getOutlineRenderer(): OutlineRenderer;
  64772. }
  64773. }
  64774. module "babylonjs/Meshes/abstractMesh" {
  64775. interface AbstractMesh {
  64776. /** @hidden (Backing field) */
  64777. _renderOutline: boolean;
  64778. /**
  64779. * Gets or sets a boolean indicating if the outline must be rendered as well
  64780. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64781. */
  64782. renderOutline: boolean;
  64783. /** @hidden (Backing field) */
  64784. _renderOverlay: boolean;
  64785. /**
  64786. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64787. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64788. */
  64789. renderOverlay: boolean;
  64790. }
  64791. }
  64792. /**
  64793. * This class is responsible to draw bothe outline/overlay of meshes.
  64794. * It should not be used directly but through the available method on mesh.
  64795. */
  64796. export class OutlineRenderer implements ISceneComponent {
  64797. /**
  64798. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64799. */
  64800. private static _StencilReference;
  64801. /**
  64802. * The name of the component. Each component must have a unique name.
  64803. */
  64804. name: string;
  64805. /**
  64806. * The scene the component belongs to.
  64807. */
  64808. scene: Scene;
  64809. /**
  64810. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64811. */
  64812. zOffset: number;
  64813. private _engine;
  64814. private _effect;
  64815. private _cachedDefines;
  64816. private _savedDepthWrite;
  64817. /**
  64818. * Instantiates a new outline renderer. (There could be only one per scene).
  64819. * @param scene Defines the scene it belongs to
  64820. */
  64821. constructor(scene: Scene);
  64822. /**
  64823. * Register the component to one instance of a scene.
  64824. */
  64825. register(): void;
  64826. /**
  64827. * Rebuilds the elements related to this component in case of
  64828. * context lost for instance.
  64829. */
  64830. rebuild(): void;
  64831. /**
  64832. * Disposes the component and the associated ressources.
  64833. */
  64834. dispose(): void;
  64835. /**
  64836. * Renders the outline in the canvas.
  64837. * @param subMesh Defines the sumesh to render
  64838. * @param batch Defines the batch of meshes in case of instances
  64839. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64840. */
  64841. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64842. /**
  64843. * Returns whether or not the outline renderer is ready for a given submesh.
  64844. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64845. * @param subMesh Defines the submesh to check readyness for
  64846. * @param useInstances Defines wheter wee are trying to render instances or not
  64847. * @returns true if ready otherwise false
  64848. */
  64849. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64850. private _beforeRenderingMesh;
  64851. private _afterRenderingMesh;
  64852. }
  64853. }
  64854. declare module "babylonjs/Rendering/index" {
  64855. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64856. export * from "babylonjs/Rendering/depthRenderer";
  64857. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64858. export * from "babylonjs/Rendering/edgesRenderer";
  64859. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64860. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64861. export * from "babylonjs/Rendering/outlineRenderer";
  64862. export * from "babylonjs/Rendering/renderingGroup";
  64863. export * from "babylonjs/Rendering/renderingManager";
  64864. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64865. }
  64866. declare module "babylonjs/Sprites/spritePackedManager" {
  64867. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64868. import { Scene } from "babylonjs/scene";
  64869. /**
  64870. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64871. * @see http://doc.babylonjs.com/babylon101/sprites
  64872. */
  64873. export class SpritePackedManager extends SpriteManager {
  64874. /** defines the packed manager's name */
  64875. name: string;
  64876. /**
  64877. * Creates a new sprite manager from a packed sprite sheet
  64878. * @param name defines the manager's name
  64879. * @param imgUrl defines the sprite sheet url
  64880. * @param capacity defines the maximum allowed number of sprites
  64881. * @param scene defines the hosting scene
  64882. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64883. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64884. * @param samplingMode defines the smapling mode to use with spritesheet
  64885. * @param fromPacked set to true; do not alter
  64886. */
  64887. constructor(
  64888. /** defines the packed manager's name */
  64889. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64890. }
  64891. }
  64892. declare module "babylonjs/Sprites/index" {
  64893. export * from "babylonjs/Sprites/sprite";
  64894. export * from "babylonjs/Sprites/spriteManager";
  64895. export * from "babylonjs/Sprites/spritePackedManager";
  64896. export * from "babylonjs/Sprites/spriteSceneComponent";
  64897. }
  64898. declare module "babylonjs/States/index" {
  64899. export * from "babylonjs/States/alphaCullingState";
  64900. export * from "babylonjs/States/depthCullingState";
  64901. export * from "babylonjs/States/stencilState";
  64902. }
  64903. declare module "babylonjs/Misc/assetsManager" {
  64904. import { Scene } from "babylonjs/scene";
  64905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64906. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64907. import { Skeleton } from "babylonjs/Bones/skeleton";
  64908. import { Observable } from "babylonjs/Misc/observable";
  64909. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64910. import { Texture } from "babylonjs/Materials/Textures/texture";
  64911. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64912. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64913. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64914. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64915. /**
  64916. * Defines the list of states available for a task inside a AssetsManager
  64917. */
  64918. export enum AssetTaskState {
  64919. /**
  64920. * Initialization
  64921. */
  64922. INIT = 0,
  64923. /**
  64924. * Running
  64925. */
  64926. RUNNING = 1,
  64927. /**
  64928. * Done
  64929. */
  64930. DONE = 2,
  64931. /**
  64932. * Error
  64933. */
  64934. ERROR = 3
  64935. }
  64936. /**
  64937. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64938. */
  64939. export abstract class AbstractAssetTask {
  64940. /**
  64941. * Task name
  64942. */ name: string;
  64943. /**
  64944. * Callback called when the task is successful
  64945. */
  64946. onSuccess: (task: any) => void;
  64947. /**
  64948. * Callback called when the task is not successful
  64949. */
  64950. onError: (task: any, message?: string, exception?: any) => void;
  64951. /**
  64952. * Creates a new AssetsManager
  64953. * @param name defines the name of the task
  64954. */
  64955. constructor(
  64956. /**
  64957. * Task name
  64958. */ name: string);
  64959. private _isCompleted;
  64960. private _taskState;
  64961. private _errorObject;
  64962. /**
  64963. * Get if the task is completed
  64964. */
  64965. readonly isCompleted: boolean;
  64966. /**
  64967. * Gets the current state of the task
  64968. */
  64969. readonly taskState: AssetTaskState;
  64970. /**
  64971. * Gets the current error object (if task is in error)
  64972. */
  64973. readonly errorObject: {
  64974. message?: string;
  64975. exception?: any;
  64976. };
  64977. /**
  64978. * Internal only
  64979. * @hidden
  64980. */
  64981. _setErrorObject(message?: string, exception?: any): void;
  64982. /**
  64983. * Execute the current task
  64984. * @param scene defines the scene where you want your assets to be loaded
  64985. * @param onSuccess is a callback called when the task is successfully executed
  64986. * @param onError is a callback called if an error occurs
  64987. */
  64988. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64989. /**
  64990. * Execute the current task
  64991. * @param scene defines the scene where you want your assets to be loaded
  64992. * @param onSuccess is a callback called when the task is successfully executed
  64993. * @param onError is a callback called if an error occurs
  64994. */
  64995. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64996. /**
  64997. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64998. * This can be used with failed tasks that have the reason for failure fixed.
  64999. */
  65000. reset(): void;
  65001. private onErrorCallback;
  65002. private onDoneCallback;
  65003. }
  65004. /**
  65005. * Define the interface used by progress events raised during assets loading
  65006. */
  65007. export interface IAssetsProgressEvent {
  65008. /**
  65009. * Defines the number of remaining tasks to process
  65010. */
  65011. remainingCount: number;
  65012. /**
  65013. * Defines the total number of tasks
  65014. */
  65015. totalCount: number;
  65016. /**
  65017. * Defines the task that was just processed
  65018. */
  65019. task: AbstractAssetTask;
  65020. }
  65021. /**
  65022. * Class used to share progress information about assets loading
  65023. */
  65024. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65025. /**
  65026. * Defines the number of remaining tasks to process
  65027. */
  65028. remainingCount: number;
  65029. /**
  65030. * Defines the total number of tasks
  65031. */
  65032. totalCount: number;
  65033. /**
  65034. * Defines the task that was just processed
  65035. */
  65036. task: AbstractAssetTask;
  65037. /**
  65038. * Creates a AssetsProgressEvent
  65039. * @param remainingCount defines the number of remaining tasks to process
  65040. * @param totalCount defines the total number of tasks
  65041. * @param task defines the task that was just processed
  65042. */
  65043. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65044. }
  65045. /**
  65046. * Define a task used by AssetsManager to load meshes
  65047. */
  65048. export class MeshAssetTask extends AbstractAssetTask {
  65049. /**
  65050. * Defines the name of the task
  65051. */
  65052. name: string;
  65053. /**
  65054. * Defines the list of mesh's names you want to load
  65055. */
  65056. meshesNames: any;
  65057. /**
  65058. * Defines the root url to use as a base to load your meshes and associated resources
  65059. */
  65060. rootUrl: string;
  65061. /**
  65062. * Defines the filename of the scene to load from
  65063. */
  65064. sceneFilename: string;
  65065. /**
  65066. * Gets the list of loaded meshes
  65067. */
  65068. loadedMeshes: Array<AbstractMesh>;
  65069. /**
  65070. * Gets the list of loaded particle systems
  65071. */
  65072. loadedParticleSystems: Array<IParticleSystem>;
  65073. /**
  65074. * Gets the list of loaded skeletons
  65075. */
  65076. loadedSkeletons: Array<Skeleton>;
  65077. /**
  65078. * Gets the list of loaded animation groups
  65079. */
  65080. loadedAnimationGroups: Array<AnimationGroup>;
  65081. /**
  65082. * Callback called when the task is successful
  65083. */
  65084. onSuccess: (task: MeshAssetTask) => void;
  65085. /**
  65086. * Callback called when the task is successful
  65087. */
  65088. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65089. /**
  65090. * Creates a new MeshAssetTask
  65091. * @param name defines the name of the task
  65092. * @param meshesNames defines the list of mesh's names you want to load
  65093. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65094. * @param sceneFilename defines the filename of the scene to load from
  65095. */
  65096. constructor(
  65097. /**
  65098. * Defines the name of the task
  65099. */
  65100. name: string,
  65101. /**
  65102. * Defines the list of mesh's names you want to load
  65103. */
  65104. meshesNames: any,
  65105. /**
  65106. * Defines the root url to use as a base to load your meshes and associated resources
  65107. */
  65108. rootUrl: string,
  65109. /**
  65110. * Defines the filename of the scene to load from
  65111. */
  65112. sceneFilename: string);
  65113. /**
  65114. * Execute the current task
  65115. * @param scene defines the scene where you want your assets to be loaded
  65116. * @param onSuccess is a callback called when the task is successfully executed
  65117. * @param onError is a callback called if an error occurs
  65118. */
  65119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65120. }
  65121. /**
  65122. * Define a task used by AssetsManager to load text content
  65123. */
  65124. export class TextFileAssetTask extends AbstractAssetTask {
  65125. /**
  65126. * Defines the name of the task
  65127. */
  65128. name: string;
  65129. /**
  65130. * Defines the location of the file to load
  65131. */
  65132. url: string;
  65133. /**
  65134. * Gets the loaded text string
  65135. */
  65136. text: string;
  65137. /**
  65138. * Callback called when the task is successful
  65139. */
  65140. onSuccess: (task: TextFileAssetTask) => void;
  65141. /**
  65142. * Callback called when the task is successful
  65143. */
  65144. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65145. /**
  65146. * Creates a new TextFileAssetTask object
  65147. * @param name defines the name of the task
  65148. * @param url defines the location of the file to load
  65149. */
  65150. constructor(
  65151. /**
  65152. * Defines the name of the task
  65153. */
  65154. name: string,
  65155. /**
  65156. * Defines the location of the file to load
  65157. */
  65158. url: string);
  65159. /**
  65160. * Execute the current task
  65161. * @param scene defines the scene where you want your assets to be loaded
  65162. * @param onSuccess is a callback called when the task is successfully executed
  65163. * @param onError is a callback called if an error occurs
  65164. */
  65165. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65166. }
  65167. /**
  65168. * Define a task used by AssetsManager to load binary data
  65169. */
  65170. export class BinaryFileAssetTask extends AbstractAssetTask {
  65171. /**
  65172. * Defines the name of the task
  65173. */
  65174. name: string;
  65175. /**
  65176. * Defines the location of the file to load
  65177. */
  65178. url: string;
  65179. /**
  65180. * Gets the lodaded data (as an array buffer)
  65181. */
  65182. data: ArrayBuffer;
  65183. /**
  65184. * Callback called when the task is successful
  65185. */
  65186. onSuccess: (task: BinaryFileAssetTask) => void;
  65187. /**
  65188. * Callback called when the task is successful
  65189. */
  65190. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65191. /**
  65192. * Creates a new BinaryFileAssetTask object
  65193. * @param name defines the name of the new task
  65194. * @param url defines the location of the file to load
  65195. */
  65196. constructor(
  65197. /**
  65198. * Defines the name of the task
  65199. */
  65200. name: string,
  65201. /**
  65202. * Defines the location of the file to load
  65203. */
  65204. url: string);
  65205. /**
  65206. * Execute the current task
  65207. * @param scene defines the scene where you want your assets to be loaded
  65208. * @param onSuccess is a callback called when the task is successfully executed
  65209. * @param onError is a callback called if an error occurs
  65210. */
  65211. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65212. }
  65213. /**
  65214. * Define a task used by AssetsManager to load images
  65215. */
  65216. export class ImageAssetTask extends AbstractAssetTask {
  65217. /**
  65218. * Defines the name of the task
  65219. */
  65220. name: string;
  65221. /**
  65222. * Defines the location of the image to load
  65223. */
  65224. url: string;
  65225. /**
  65226. * Gets the loaded images
  65227. */
  65228. image: HTMLImageElement;
  65229. /**
  65230. * Callback called when the task is successful
  65231. */
  65232. onSuccess: (task: ImageAssetTask) => void;
  65233. /**
  65234. * Callback called when the task is successful
  65235. */
  65236. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65237. /**
  65238. * Creates a new ImageAssetTask
  65239. * @param name defines the name of the task
  65240. * @param url defines the location of the image to load
  65241. */
  65242. constructor(
  65243. /**
  65244. * Defines the name of the task
  65245. */
  65246. name: string,
  65247. /**
  65248. * Defines the location of the image to load
  65249. */
  65250. url: string);
  65251. /**
  65252. * Execute the current task
  65253. * @param scene defines the scene where you want your assets to be loaded
  65254. * @param onSuccess is a callback called when the task is successfully executed
  65255. * @param onError is a callback called if an error occurs
  65256. */
  65257. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65258. }
  65259. /**
  65260. * Defines the interface used by texture loading tasks
  65261. */
  65262. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65263. /**
  65264. * Gets the loaded texture
  65265. */
  65266. texture: TEX;
  65267. }
  65268. /**
  65269. * Define a task used by AssetsManager to load 2D textures
  65270. */
  65271. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65272. /**
  65273. * Defines the name of the task
  65274. */
  65275. name: string;
  65276. /**
  65277. * Defines the location of the file to load
  65278. */
  65279. url: string;
  65280. /**
  65281. * Defines if mipmap should not be generated (default is false)
  65282. */
  65283. noMipmap?: boolean | undefined;
  65284. /**
  65285. * Defines if texture must be inverted on Y axis (default is false)
  65286. */
  65287. invertY?: boolean | undefined;
  65288. /**
  65289. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65290. */
  65291. samplingMode: number;
  65292. /**
  65293. * Gets the loaded texture
  65294. */
  65295. texture: Texture;
  65296. /**
  65297. * Callback called when the task is successful
  65298. */
  65299. onSuccess: (task: TextureAssetTask) => void;
  65300. /**
  65301. * Callback called when the task is successful
  65302. */
  65303. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65304. /**
  65305. * Creates a new TextureAssetTask object
  65306. * @param name defines the name of the task
  65307. * @param url defines the location of the file to load
  65308. * @param noMipmap defines if mipmap should not be generated (default is false)
  65309. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65310. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65311. */
  65312. constructor(
  65313. /**
  65314. * Defines the name of the task
  65315. */
  65316. name: string,
  65317. /**
  65318. * Defines the location of the file to load
  65319. */
  65320. url: string,
  65321. /**
  65322. * Defines if mipmap should not be generated (default is false)
  65323. */
  65324. noMipmap?: boolean | undefined,
  65325. /**
  65326. * Defines if texture must be inverted on Y axis (default is false)
  65327. */
  65328. invertY?: boolean | undefined,
  65329. /**
  65330. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65331. */
  65332. samplingMode?: number);
  65333. /**
  65334. * Execute the current task
  65335. * @param scene defines the scene where you want your assets to be loaded
  65336. * @param onSuccess is a callback called when the task is successfully executed
  65337. * @param onError is a callback called if an error occurs
  65338. */
  65339. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65340. }
  65341. /**
  65342. * Define a task used by AssetsManager to load cube textures
  65343. */
  65344. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65345. /**
  65346. * Defines the name of the task
  65347. */
  65348. name: string;
  65349. /**
  65350. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65351. */
  65352. url: string;
  65353. /**
  65354. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65355. */
  65356. extensions?: string[] | undefined;
  65357. /**
  65358. * Defines if mipmaps should not be generated (default is false)
  65359. */
  65360. noMipmap?: boolean | undefined;
  65361. /**
  65362. * Defines the explicit list of files (undefined by default)
  65363. */
  65364. files?: string[] | undefined;
  65365. /**
  65366. * Gets the loaded texture
  65367. */
  65368. texture: CubeTexture;
  65369. /**
  65370. * Callback called when the task is successful
  65371. */
  65372. onSuccess: (task: CubeTextureAssetTask) => void;
  65373. /**
  65374. * Callback called when the task is successful
  65375. */
  65376. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65377. /**
  65378. * Creates a new CubeTextureAssetTask
  65379. * @param name defines the name of the task
  65380. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65381. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65382. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65383. * @param files defines the explicit list of files (undefined by default)
  65384. */
  65385. constructor(
  65386. /**
  65387. * Defines the name of the task
  65388. */
  65389. name: string,
  65390. /**
  65391. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65392. */
  65393. url: string,
  65394. /**
  65395. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65396. */
  65397. extensions?: string[] | undefined,
  65398. /**
  65399. * Defines if mipmaps should not be generated (default is false)
  65400. */
  65401. noMipmap?: boolean | undefined,
  65402. /**
  65403. * Defines the explicit list of files (undefined by default)
  65404. */
  65405. files?: string[] | undefined);
  65406. /**
  65407. * Execute the current task
  65408. * @param scene defines the scene where you want your assets to be loaded
  65409. * @param onSuccess is a callback called when the task is successfully executed
  65410. * @param onError is a callback called if an error occurs
  65411. */
  65412. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65413. }
  65414. /**
  65415. * Define a task used by AssetsManager to load HDR cube textures
  65416. */
  65417. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65418. /**
  65419. * Defines the name of the task
  65420. */
  65421. name: string;
  65422. /**
  65423. * Defines the location of the file to load
  65424. */
  65425. url: string;
  65426. /**
  65427. * Defines the desired size (the more it increases the longer the generation will be)
  65428. */
  65429. size: number;
  65430. /**
  65431. * Defines if mipmaps should not be generated (default is false)
  65432. */
  65433. noMipmap: boolean;
  65434. /**
  65435. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65436. */
  65437. generateHarmonics: boolean;
  65438. /**
  65439. * 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)
  65440. */
  65441. gammaSpace: boolean;
  65442. /**
  65443. * Internal Use Only
  65444. */
  65445. reserved: boolean;
  65446. /**
  65447. * Gets the loaded texture
  65448. */
  65449. texture: HDRCubeTexture;
  65450. /**
  65451. * Callback called when the task is successful
  65452. */
  65453. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65454. /**
  65455. * Callback called when the task is successful
  65456. */
  65457. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65458. /**
  65459. * Creates a new HDRCubeTextureAssetTask object
  65460. * @param name defines the name of the task
  65461. * @param url defines the location of the file to load
  65462. * @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.
  65463. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65464. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65465. * @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)
  65466. * @param reserved Internal use only
  65467. */
  65468. constructor(
  65469. /**
  65470. * Defines the name of the task
  65471. */
  65472. name: string,
  65473. /**
  65474. * Defines the location of the file to load
  65475. */
  65476. url: string,
  65477. /**
  65478. * Defines the desired size (the more it increases the longer the generation will be)
  65479. */
  65480. size: number,
  65481. /**
  65482. * Defines if mipmaps should not be generated (default is false)
  65483. */
  65484. noMipmap?: boolean,
  65485. /**
  65486. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65487. */
  65488. generateHarmonics?: boolean,
  65489. /**
  65490. * 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)
  65491. */
  65492. gammaSpace?: boolean,
  65493. /**
  65494. * Internal Use Only
  65495. */
  65496. reserved?: boolean);
  65497. /**
  65498. * Execute the current task
  65499. * @param scene defines the scene where you want your assets to be loaded
  65500. * @param onSuccess is a callback called when the task is successfully executed
  65501. * @param onError is a callback called if an error occurs
  65502. */
  65503. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65504. }
  65505. /**
  65506. * Define a task used by AssetsManager to load Equirectangular cube textures
  65507. */
  65508. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65509. /**
  65510. * Defines the name of the task
  65511. */
  65512. name: string;
  65513. /**
  65514. * Defines the location of the file to load
  65515. */
  65516. url: string;
  65517. /**
  65518. * Defines the desired size (the more it increases the longer the generation will be)
  65519. */
  65520. size: number;
  65521. /**
  65522. * Defines if mipmaps should not be generated (default is false)
  65523. */
  65524. noMipmap: boolean;
  65525. /**
  65526. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65527. * but the standard material would require them in Gamma space) (default is true)
  65528. */
  65529. gammaSpace: boolean;
  65530. /**
  65531. * Gets the loaded texture
  65532. */
  65533. texture: EquiRectangularCubeTexture;
  65534. /**
  65535. * Callback called when the task is successful
  65536. */
  65537. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65538. /**
  65539. * Callback called when the task is successful
  65540. */
  65541. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65542. /**
  65543. * Creates a new EquiRectangularCubeTextureAssetTask object
  65544. * @param name defines the name of the task
  65545. * @param url defines the location of the file to load
  65546. * @param size defines the desired size (the more it increases the longer the generation will be)
  65547. * If the size is omitted this implies you are using a preprocessed cubemap.
  65548. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65549. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65550. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65551. * (default is true)
  65552. */
  65553. constructor(
  65554. /**
  65555. * Defines the name of the task
  65556. */
  65557. name: string,
  65558. /**
  65559. * Defines the location of the file to load
  65560. */
  65561. url: string,
  65562. /**
  65563. * Defines the desired size (the more it increases the longer the generation will be)
  65564. */
  65565. size: number,
  65566. /**
  65567. * Defines if mipmaps should not be generated (default is false)
  65568. */
  65569. noMipmap?: boolean,
  65570. /**
  65571. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65572. * but the standard material would require them in Gamma space) (default is true)
  65573. */
  65574. gammaSpace?: boolean);
  65575. /**
  65576. * Execute the current task
  65577. * @param scene defines the scene where you want your assets to be loaded
  65578. * @param onSuccess is a callback called when the task is successfully executed
  65579. * @param onError is a callback called if an error occurs
  65580. */
  65581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65582. }
  65583. /**
  65584. * This class can be used to easily import assets into a scene
  65585. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65586. */
  65587. export class AssetsManager {
  65588. private _scene;
  65589. private _isLoading;
  65590. protected _tasks: AbstractAssetTask[];
  65591. protected _waitingTasksCount: number;
  65592. protected _totalTasksCount: number;
  65593. /**
  65594. * Callback called when all tasks are processed
  65595. */
  65596. onFinish: (tasks: AbstractAssetTask[]) => void;
  65597. /**
  65598. * Callback called when a task is successful
  65599. */
  65600. onTaskSuccess: (task: AbstractAssetTask) => void;
  65601. /**
  65602. * Callback called when a task had an error
  65603. */
  65604. onTaskError: (task: AbstractAssetTask) => void;
  65605. /**
  65606. * Callback called when a task is done (whatever the result is)
  65607. */
  65608. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65609. /**
  65610. * Observable called when all tasks are processed
  65611. */
  65612. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65613. /**
  65614. * Observable called when a task had an error
  65615. */
  65616. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65617. /**
  65618. * Observable called when all tasks were executed
  65619. */
  65620. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65621. /**
  65622. * Observable called when a task is done (whatever the result is)
  65623. */
  65624. onProgressObservable: Observable<IAssetsProgressEvent>;
  65625. /**
  65626. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65627. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65628. */
  65629. useDefaultLoadingScreen: boolean;
  65630. /**
  65631. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65632. * when all assets have been downloaded.
  65633. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65634. */
  65635. autoHideLoadingUI: boolean;
  65636. /**
  65637. * Creates a new AssetsManager
  65638. * @param scene defines the scene to work on
  65639. */
  65640. constructor(scene: Scene);
  65641. /**
  65642. * Add a MeshAssetTask to the list of active tasks
  65643. * @param taskName defines the name of the new task
  65644. * @param meshesNames defines the name of meshes to load
  65645. * @param rootUrl defines the root url to use to locate files
  65646. * @param sceneFilename defines the filename of the scene file
  65647. * @returns a new MeshAssetTask object
  65648. */
  65649. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65650. /**
  65651. * Add a TextFileAssetTask to the list of active tasks
  65652. * @param taskName defines the name of the new task
  65653. * @param url defines the url of the file to load
  65654. * @returns a new TextFileAssetTask object
  65655. */
  65656. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65657. /**
  65658. * Add a BinaryFileAssetTask to the list of active tasks
  65659. * @param taskName defines the name of the new task
  65660. * @param url defines the url of the file to load
  65661. * @returns a new BinaryFileAssetTask object
  65662. */
  65663. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65664. /**
  65665. * Add a ImageAssetTask to the list of active tasks
  65666. * @param taskName defines the name of the new task
  65667. * @param url defines the url of the file to load
  65668. * @returns a new ImageAssetTask object
  65669. */
  65670. addImageTask(taskName: string, url: string): ImageAssetTask;
  65671. /**
  65672. * Add a TextureAssetTask to the list of active tasks
  65673. * @param taskName defines the name of the new task
  65674. * @param url defines the url of the file to load
  65675. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65676. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65677. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65678. * @returns a new TextureAssetTask object
  65679. */
  65680. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65681. /**
  65682. * Add a CubeTextureAssetTask to the list of active tasks
  65683. * @param taskName defines the name of the new task
  65684. * @param url defines the url of the file to load
  65685. * @param extensions defines the extension to use to load the cube map (can be null)
  65686. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65687. * @param files defines the list of files to load (can be null)
  65688. * @returns a new CubeTextureAssetTask object
  65689. */
  65690. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65691. /**
  65692. *
  65693. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65694. * @param taskName defines the name of the new task
  65695. * @param url defines the url of the file to load
  65696. * @param size defines the size you want for the cubemap (can be null)
  65697. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65698. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65699. * @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)
  65700. * @param reserved Internal use only
  65701. * @returns a new HDRCubeTextureAssetTask object
  65702. */
  65703. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65704. /**
  65705. *
  65706. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65707. * @param taskName defines the name of the new task
  65708. * @param url defines the url of the file to load
  65709. * @param size defines the size you want for the cubemap (can be null)
  65710. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65711. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65712. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65713. * @returns a new EquiRectangularCubeTextureAssetTask object
  65714. */
  65715. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65716. /**
  65717. * Remove a task from the assets manager.
  65718. * @param task the task to remove
  65719. */
  65720. removeTask(task: AbstractAssetTask): void;
  65721. private _decreaseWaitingTasksCount;
  65722. private _runTask;
  65723. /**
  65724. * Reset the AssetsManager and remove all tasks
  65725. * @return the current instance of the AssetsManager
  65726. */
  65727. reset(): AssetsManager;
  65728. /**
  65729. * Start the loading process
  65730. * @return the current instance of the AssetsManager
  65731. */
  65732. load(): AssetsManager;
  65733. /**
  65734. * Start the loading process as an async operation
  65735. * @return a promise returning the list of failed tasks
  65736. */
  65737. loadAsync(): Promise<void>;
  65738. }
  65739. }
  65740. declare module "babylonjs/Misc/deferred" {
  65741. /**
  65742. * Wrapper class for promise with external resolve and reject.
  65743. */
  65744. export class Deferred<T> {
  65745. /**
  65746. * The promise associated with this deferred object.
  65747. */
  65748. readonly promise: Promise<T>;
  65749. private _resolve;
  65750. private _reject;
  65751. /**
  65752. * The resolve method of the promise associated with this deferred object.
  65753. */
  65754. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65755. /**
  65756. * The reject method of the promise associated with this deferred object.
  65757. */
  65758. readonly reject: (reason?: any) => void;
  65759. /**
  65760. * Constructor for this deferred object.
  65761. */
  65762. constructor();
  65763. }
  65764. }
  65765. declare module "babylonjs/Misc/meshExploder" {
  65766. import { Mesh } from "babylonjs/Meshes/mesh";
  65767. /**
  65768. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65769. */
  65770. export class MeshExploder {
  65771. private _centerMesh;
  65772. private _meshes;
  65773. private _meshesOrigins;
  65774. private _toCenterVectors;
  65775. private _scaledDirection;
  65776. private _newPosition;
  65777. private _centerPosition;
  65778. /**
  65779. * Explodes meshes from a center mesh.
  65780. * @param meshes The meshes to explode.
  65781. * @param centerMesh The mesh to be center of explosion.
  65782. */
  65783. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65784. private _setCenterMesh;
  65785. /**
  65786. * Get class name
  65787. * @returns "MeshExploder"
  65788. */
  65789. getClassName(): string;
  65790. /**
  65791. * "Exploded meshes"
  65792. * @returns Array of meshes with the centerMesh at index 0.
  65793. */
  65794. getMeshes(): Array<Mesh>;
  65795. /**
  65796. * Explodes meshes giving a specific direction
  65797. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65798. */
  65799. explode(direction?: number): void;
  65800. }
  65801. }
  65802. declare module "babylonjs/Misc/filesInput" {
  65803. import { Engine } from "babylonjs/Engines/engine";
  65804. import { Scene } from "babylonjs/scene";
  65805. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65806. /**
  65807. * Class used to help managing file picking and drag'n'drop
  65808. */
  65809. export class FilesInput {
  65810. /**
  65811. * List of files ready to be loaded
  65812. */
  65813. static readonly FilesToLoad: {
  65814. [key: string]: File;
  65815. };
  65816. /**
  65817. * Callback called when a file is processed
  65818. */
  65819. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65820. private _engine;
  65821. private _currentScene;
  65822. private _sceneLoadedCallback;
  65823. private _progressCallback;
  65824. private _additionalRenderLoopLogicCallback;
  65825. private _textureLoadingCallback;
  65826. private _startingProcessingFilesCallback;
  65827. private _onReloadCallback;
  65828. private _errorCallback;
  65829. private _elementToMonitor;
  65830. private _sceneFileToLoad;
  65831. private _filesToLoad;
  65832. /**
  65833. * Creates a new FilesInput
  65834. * @param engine defines the rendering engine
  65835. * @param scene defines the hosting scene
  65836. * @param sceneLoadedCallback callback called when scene is loaded
  65837. * @param progressCallback callback called to track progress
  65838. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65839. * @param textureLoadingCallback callback called when a texture is loading
  65840. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65841. * @param onReloadCallback callback called when a reload is requested
  65842. * @param errorCallback callback call if an error occurs
  65843. */
  65844. 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);
  65845. private _dragEnterHandler;
  65846. private _dragOverHandler;
  65847. private _dropHandler;
  65848. /**
  65849. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65850. * @param elementToMonitor defines the DOM element to track
  65851. */
  65852. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65853. /**
  65854. * Release all associated resources
  65855. */
  65856. dispose(): void;
  65857. private renderFunction;
  65858. private drag;
  65859. private drop;
  65860. private _traverseFolder;
  65861. private _processFiles;
  65862. /**
  65863. * Load files from a drop event
  65864. * @param event defines the drop event to use as source
  65865. */
  65866. loadFiles(event: any): void;
  65867. private _processReload;
  65868. /**
  65869. * Reload the current scene from the loaded files
  65870. */
  65871. reload(): void;
  65872. }
  65873. }
  65874. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65875. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65876. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65877. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65878. }
  65879. declare module "babylonjs/Misc/sceneOptimizer" {
  65880. import { Scene, IDisposable } from "babylonjs/scene";
  65881. import { Observable } from "babylonjs/Misc/observable";
  65882. /**
  65883. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65885. */
  65886. export class SceneOptimization {
  65887. /**
  65888. * Defines the priority of this optimization (0 by default which means first in the list)
  65889. */
  65890. priority: number;
  65891. /**
  65892. * Gets a string describing the action executed by the current optimization
  65893. * @returns description string
  65894. */
  65895. getDescription(): string;
  65896. /**
  65897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65898. * @param scene defines the current scene where to apply this optimization
  65899. * @param optimizer defines the current optimizer
  65900. * @returns true if everything that can be done was applied
  65901. */
  65902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65903. /**
  65904. * Creates the SceneOptimization object
  65905. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65906. * @param desc defines the description associated with the optimization
  65907. */
  65908. constructor(
  65909. /**
  65910. * Defines the priority of this optimization (0 by default which means first in the list)
  65911. */
  65912. priority?: number);
  65913. }
  65914. /**
  65915. * Defines an optimization used to reduce the size of render target textures
  65916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65917. */
  65918. export class TextureOptimization extends SceneOptimization {
  65919. /**
  65920. * Defines the priority of this optimization (0 by default which means first in the list)
  65921. */
  65922. priority: number;
  65923. /**
  65924. * 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
  65925. */
  65926. maximumSize: number;
  65927. /**
  65928. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65929. */
  65930. step: number;
  65931. /**
  65932. * Gets a string describing the action executed by the current optimization
  65933. * @returns description string
  65934. */
  65935. getDescription(): string;
  65936. /**
  65937. * Creates the TextureOptimization object
  65938. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65939. * @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
  65940. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65941. */
  65942. constructor(
  65943. /**
  65944. * Defines the priority of this optimization (0 by default which means first in the list)
  65945. */
  65946. priority?: number,
  65947. /**
  65948. * 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
  65949. */
  65950. maximumSize?: number,
  65951. /**
  65952. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65953. */
  65954. step?: number);
  65955. /**
  65956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65957. * @param scene defines the current scene where to apply this optimization
  65958. * @param optimizer defines the current optimizer
  65959. * @returns true if everything that can be done was applied
  65960. */
  65961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65962. }
  65963. /**
  65964. * Defines an optimization used to increase or decrease the rendering resolution
  65965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65966. */
  65967. export class HardwareScalingOptimization extends SceneOptimization {
  65968. /**
  65969. * Defines the priority of this optimization (0 by default which means first in the list)
  65970. */
  65971. priority: number;
  65972. /**
  65973. * Defines the maximum scale to use (2 by default)
  65974. */
  65975. maximumScale: number;
  65976. /**
  65977. * Defines the step to use between two passes (0.5 by default)
  65978. */
  65979. step: number;
  65980. private _currentScale;
  65981. private _directionOffset;
  65982. /**
  65983. * Gets a string describing the action executed by the current optimization
  65984. * @return description string
  65985. */
  65986. getDescription(): string;
  65987. /**
  65988. * Creates the HardwareScalingOptimization object
  65989. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65990. * @param maximumScale defines the maximum scale to use (2 by default)
  65991. * @param step defines the step to use between two passes (0.5 by default)
  65992. */
  65993. constructor(
  65994. /**
  65995. * Defines the priority of this optimization (0 by default which means first in the list)
  65996. */
  65997. priority?: number,
  65998. /**
  65999. * Defines the maximum scale to use (2 by default)
  66000. */
  66001. maximumScale?: number,
  66002. /**
  66003. * Defines the step to use between two passes (0.5 by default)
  66004. */
  66005. step?: number);
  66006. /**
  66007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66008. * @param scene defines the current scene where to apply this optimization
  66009. * @param optimizer defines the current optimizer
  66010. * @returns true if everything that can be done was applied
  66011. */
  66012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66013. }
  66014. /**
  66015. * Defines an optimization used to remove shadows
  66016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66017. */
  66018. export class ShadowsOptimization extends SceneOptimization {
  66019. /**
  66020. * Gets a string describing the action executed by the current optimization
  66021. * @return description string
  66022. */
  66023. getDescription(): string;
  66024. /**
  66025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66026. * @param scene defines the current scene where to apply this optimization
  66027. * @param optimizer defines the current optimizer
  66028. * @returns true if everything that can be done was applied
  66029. */
  66030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66031. }
  66032. /**
  66033. * Defines an optimization used to turn post-processes off
  66034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66035. */
  66036. export class PostProcessesOptimization extends SceneOptimization {
  66037. /**
  66038. * Gets a string describing the action executed by the current optimization
  66039. * @return description string
  66040. */
  66041. getDescription(): string;
  66042. /**
  66043. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66044. * @param scene defines the current scene where to apply this optimization
  66045. * @param optimizer defines the current optimizer
  66046. * @returns true if everything that can be done was applied
  66047. */
  66048. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66049. }
  66050. /**
  66051. * Defines an optimization used to turn lens flares off
  66052. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66053. */
  66054. export class LensFlaresOptimization extends SceneOptimization {
  66055. /**
  66056. * Gets a string describing the action executed by the current optimization
  66057. * @return description string
  66058. */
  66059. getDescription(): string;
  66060. /**
  66061. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66062. * @param scene defines the current scene where to apply this optimization
  66063. * @param optimizer defines the current optimizer
  66064. * @returns true if everything that can be done was applied
  66065. */
  66066. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66067. }
  66068. /**
  66069. * Defines an optimization based on user defined callback.
  66070. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66071. */
  66072. export class CustomOptimization extends SceneOptimization {
  66073. /**
  66074. * Callback called to apply the custom optimization.
  66075. */
  66076. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66077. /**
  66078. * Callback called to get custom description
  66079. */
  66080. onGetDescription: () => string;
  66081. /**
  66082. * Gets a string describing the action executed by the current optimization
  66083. * @returns description string
  66084. */
  66085. getDescription(): string;
  66086. /**
  66087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66088. * @param scene defines the current scene where to apply this optimization
  66089. * @param optimizer defines the current optimizer
  66090. * @returns true if everything that can be done was applied
  66091. */
  66092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66093. }
  66094. /**
  66095. * Defines an optimization used to turn particles off
  66096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66097. */
  66098. export class ParticlesOptimization extends SceneOptimization {
  66099. /**
  66100. * Gets a string describing the action executed by the current optimization
  66101. * @return description string
  66102. */
  66103. getDescription(): string;
  66104. /**
  66105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66106. * @param scene defines the current scene where to apply this optimization
  66107. * @param optimizer defines the current optimizer
  66108. * @returns true if everything that can be done was applied
  66109. */
  66110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66111. }
  66112. /**
  66113. * Defines an optimization used to turn render targets off
  66114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66115. */
  66116. export class RenderTargetsOptimization extends SceneOptimization {
  66117. /**
  66118. * Gets a string describing the action executed by the current optimization
  66119. * @return description string
  66120. */
  66121. getDescription(): string;
  66122. /**
  66123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66124. * @param scene defines the current scene where to apply this optimization
  66125. * @param optimizer defines the current optimizer
  66126. * @returns true if everything that can be done was applied
  66127. */
  66128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66129. }
  66130. /**
  66131. * Defines an optimization used to merge meshes with compatible materials
  66132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66133. */
  66134. export class MergeMeshesOptimization extends SceneOptimization {
  66135. private static _UpdateSelectionTree;
  66136. /**
  66137. * Gets or sets a boolean which defines if optimization octree has to be updated
  66138. */
  66139. /**
  66140. * Gets or sets a boolean which defines if optimization octree has to be updated
  66141. */
  66142. static UpdateSelectionTree: boolean;
  66143. /**
  66144. * Gets a string describing the action executed by the current optimization
  66145. * @return description string
  66146. */
  66147. getDescription(): string;
  66148. private _canBeMerged;
  66149. /**
  66150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66151. * @param scene defines the current scene where to apply this optimization
  66152. * @param optimizer defines the current optimizer
  66153. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66154. * @returns true if everything that can be done was applied
  66155. */
  66156. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66157. }
  66158. /**
  66159. * Defines a list of options used by SceneOptimizer
  66160. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66161. */
  66162. export class SceneOptimizerOptions {
  66163. /**
  66164. * Defines the target frame rate to reach (60 by default)
  66165. */
  66166. targetFrameRate: number;
  66167. /**
  66168. * Defines the interval between two checkes (2000ms by default)
  66169. */
  66170. trackerDuration: number;
  66171. /**
  66172. * Gets the list of optimizations to apply
  66173. */
  66174. optimizations: SceneOptimization[];
  66175. /**
  66176. * Creates a new list of options used by SceneOptimizer
  66177. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66178. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66179. */
  66180. constructor(
  66181. /**
  66182. * Defines the target frame rate to reach (60 by default)
  66183. */
  66184. targetFrameRate?: number,
  66185. /**
  66186. * Defines the interval between two checkes (2000ms by default)
  66187. */
  66188. trackerDuration?: number);
  66189. /**
  66190. * Add a new optimization
  66191. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66192. * @returns the current SceneOptimizerOptions
  66193. */
  66194. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66195. /**
  66196. * Add a new custom optimization
  66197. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66198. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66199. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66200. * @returns the current SceneOptimizerOptions
  66201. */
  66202. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66203. /**
  66204. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66205. * @param targetFrameRate defines the target frame rate (60 by default)
  66206. * @returns a SceneOptimizerOptions object
  66207. */
  66208. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66209. /**
  66210. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66211. * @param targetFrameRate defines the target frame rate (60 by default)
  66212. * @returns a SceneOptimizerOptions object
  66213. */
  66214. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66215. /**
  66216. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66217. * @param targetFrameRate defines the target frame rate (60 by default)
  66218. * @returns a SceneOptimizerOptions object
  66219. */
  66220. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66221. }
  66222. /**
  66223. * Class used to run optimizations in order to reach a target frame rate
  66224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66225. */
  66226. export class SceneOptimizer implements IDisposable {
  66227. private _isRunning;
  66228. private _options;
  66229. private _scene;
  66230. private _currentPriorityLevel;
  66231. private _targetFrameRate;
  66232. private _trackerDuration;
  66233. private _currentFrameRate;
  66234. private _sceneDisposeObserver;
  66235. private _improvementMode;
  66236. /**
  66237. * Defines an observable called when the optimizer reaches the target frame rate
  66238. */
  66239. onSuccessObservable: Observable<SceneOptimizer>;
  66240. /**
  66241. * Defines an observable called when the optimizer enables an optimization
  66242. */
  66243. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66244. /**
  66245. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66246. */
  66247. onFailureObservable: Observable<SceneOptimizer>;
  66248. /**
  66249. * Gets a boolean indicating if the optimizer is in improvement mode
  66250. */
  66251. readonly isInImprovementMode: boolean;
  66252. /**
  66253. * Gets the current priority level (0 at start)
  66254. */
  66255. readonly currentPriorityLevel: number;
  66256. /**
  66257. * Gets the current frame rate checked by the SceneOptimizer
  66258. */
  66259. readonly currentFrameRate: number;
  66260. /**
  66261. * Gets or sets the current target frame rate (60 by default)
  66262. */
  66263. /**
  66264. * Gets or sets the current target frame rate (60 by default)
  66265. */
  66266. targetFrameRate: number;
  66267. /**
  66268. * Gets or sets the current interval between two checks (every 2000ms by default)
  66269. */
  66270. /**
  66271. * Gets or sets the current interval between two checks (every 2000ms by default)
  66272. */
  66273. trackerDuration: number;
  66274. /**
  66275. * Gets the list of active optimizations
  66276. */
  66277. readonly optimizations: SceneOptimization[];
  66278. /**
  66279. * Creates a new SceneOptimizer
  66280. * @param scene defines the scene to work on
  66281. * @param options defines the options to use with the SceneOptimizer
  66282. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66283. * @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)
  66284. */
  66285. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66286. /**
  66287. * Stops the current optimizer
  66288. */
  66289. stop(): void;
  66290. /**
  66291. * Reset the optimizer to initial step (current priority level = 0)
  66292. */
  66293. reset(): void;
  66294. /**
  66295. * Start the optimizer. By default it will try to reach a specific framerate
  66296. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66297. */
  66298. start(): void;
  66299. private _checkCurrentState;
  66300. /**
  66301. * Release all resources
  66302. */
  66303. dispose(): void;
  66304. /**
  66305. * Helper function to create a SceneOptimizer with one single line of code
  66306. * @param scene defines the scene to work on
  66307. * @param options defines the options to use with the SceneOptimizer
  66308. * @param onSuccess defines a callback to call on success
  66309. * @param onFailure defines a callback to call on failure
  66310. * @returns the new SceneOptimizer object
  66311. */
  66312. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66313. }
  66314. }
  66315. declare module "babylonjs/Misc/sceneSerializer" {
  66316. import { Scene } from "babylonjs/scene";
  66317. /**
  66318. * Class used to serialize a scene into a string
  66319. */
  66320. export class SceneSerializer {
  66321. /**
  66322. * Clear cache used by a previous serialization
  66323. */
  66324. static ClearCache(): void;
  66325. /**
  66326. * Serialize a scene into a JSON compatible object
  66327. * @param scene defines the scene to serialize
  66328. * @returns a JSON compatible object
  66329. */
  66330. static Serialize(scene: Scene): any;
  66331. /**
  66332. * Serialize a mesh into a JSON compatible object
  66333. * @param toSerialize defines the mesh to serialize
  66334. * @param withParents defines if parents must be serialized as well
  66335. * @param withChildren defines if children must be serialized as well
  66336. * @returns a JSON compatible object
  66337. */
  66338. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66339. }
  66340. }
  66341. declare module "babylonjs/Misc/textureTools" {
  66342. import { Texture } from "babylonjs/Materials/Textures/texture";
  66343. /**
  66344. * Class used to host texture specific utilities
  66345. */
  66346. export class TextureTools {
  66347. /**
  66348. * Uses the GPU to create a copy texture rescaled at a given size
  66349. * @param texture Texture to copy from
  66350. * @param width defines the desired width
  66351. * @param height defines the desired height
  66352. * @param useBilinearMode defines if bilinear mode has to be used
  66353. * @return the generated texture
  66354. */
  66355. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66356. }
  66357. }
  66358. declare module "babylonjs/Misc/videoRecorder" {
  66359. import { Nullable } from "babylonjs/types";
  66360. import { Engine } from "babylonjs/Engines/engine";
  66361. /**
  66362. * This represents the different options available for the video capture.
  66363. */
  66364. export interface VideoRecorderOptions {
  66365. /** Defines the mime type of the video. */
  66366. mimeType: string;
  66367. /** Defines the FPS the video should be recorded at. */
  66368. fps: number;
  66369. /** Defines the chunk size for the recording data. */
  66370. recordChunckSize: number;
  66371. /** The audio tracks to attach to the recording. */
  66372. audioTracks?: MediaStreamTrack[];
  66373. }
  66374. /**
  66375. * This can help with recording videos from BabylonJS.
  66376. * This is based on the available WebRTC functionalities of the browser.
  66377. *
  66378. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66379. */
  66380. export class VideoRecorder {
  66381. private static readonly _defaultOptions;
  66382. /**
  66383. * Returns whether or not the VideoRecorder is available in your browser.
  66384. * @param engine Defines the Babylon Engine.
  66385. * @returns true if supported otherwise false.
  66386. */
  66387. static IsSupported(engine: Engine): boolean;
  66388. private readonly _options;
  66389. private _canvas;
  66390. private _mediaRecorder;
  66391. private _recordedChunks;
  66392. private _fileName;
  66393. private _resolve;
  66394. private _reject;
  66395. /**
  66396. * True when a recording is already in progress.
  66397. */
  66398. readonly isRecording: boolean;
  66399. /**
  66400. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66401. * @param engine Defines the BabylonJS Engine you wish to record.
  66402. * @param options Defines options that can be used to customize the capture.
  66403. */
  66404. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66405. /**
  66406. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66407. */
  66408. stopRecording(): void;
  66409. /**
  66410. * Starts recording the canvas for a max duration specified in parameters.
  66411. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66412. * If null no automatic download will start and you can rely on the promise to get the data back.
  66413. * @param maxDuration Defines the maximum recording time in seconds.
  66414. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66415. * @return A promise callback at the end of the recording with the video data in Blob.
  66416. */
  66417. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66418. /**
  66419. * Releases internal resources used during the recording.
  66420. */
  66421. dispose(): void;
  66422. private _handleDataAvailable;
  66423. private _handleError;
  66424. private _handleStop;
  66425. }
  66426. }
  66427. declare module "babylonjs/Misc/screenshotTools" {
  66428. import { Camera } from "babylonjs/Cameras/camera";
  66429. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66430. import { Engine } from "babylonjs/Engines/engine";
  66431. /**
  66432. * Class containing a set of static utilities functions for screenshots
  66433. */
  66434. export class ScreenshotTools {
  66435. /**
  66436. * Captures a screenshot of the current rendering
  66437. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66438. * @param engine defines the rendering engine
  66439. * @param camera defines the source camera
  66440. * @param size This parameter can be set to a single number or to an object with the
  66441. * following (optional) properties: precision, width, height. If a single number is passed,
  66442. * it will be used for both width and height. If an object is passed, the screenshot size
  66443. * will be derived from the parameters. The precision property is a multiplier allowing
  66444. * rendering at a higher or lower resolution
  66445. * @param successCallback defines the callback receives a single parameter which contains the
  66446. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66447. * src parameter of an <img> to display it
  66448. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66449. * Check your browser for supported MIME types
  66450. */
  66451. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66452. /**
  66453. * Captures a screenshot of the current rendering
  66454. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66455. * @param engine defines the rendering engine
  66456. * @param camera defines the source camera
  66457. * @param size This parameter can be set to a single number or to an object with the
  66458. * following (optional) properties: precision, width, height. If a single number is passed,
  66459. * it will be used for both width and height. If an object is passed, the screenshot size
  66460. * will be derived from the parameters. The precision property is a multiplier allowing
  66461. * rendering at a higher or lower resolution
  66462. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66463. * Check your browser for supported MIME types
  66464. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66465. * to the src parameter of an <img> to display it
  66466. */
  66467. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66468. /**
  66469. * Generates an image screenshot from the specified camera.
  66470. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66471. * @param engine The engine to use for rendering
  66472. * @param camera The camera to use for rendering
  66473. * @param size This parameter can be set to a single number or to an object with the
  66474. * following (optional) properties: precision, width, height. If a single number is passed,
  66475. * it will be used for both width and height. If an object is passed, the screenshot size
  66476. * will be derived from the parameters. The precision property is a multiplier allowing
  66477. * rendering at a higher or lower resolution
  66478. * @param successCallback The callback receives a single parameter which contains the
  66479. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66480. * src parameter of an <img> to display it
  66481. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66482. * Check your browser for supported MIME types
  66483. * @param samples Texture samples (default: 1)
  66484. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66485. * @param fileName A name for for the downloaded file.
  66486. */
  66487. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66488. /**
  66489. * Generates an image screenshot from the specified camera.
  66490. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66491. * @param engine The engine to use for rendering
  66492. * @param camera The camera to use for rendering
  66493. * @param size This parameter can be set to a single number or to an object with the
  66494. * following (optional) properties: precision, width, height. If a single number is passed,
  66495. * it will be used for both width and height. If an object is passed, the screenshot size
  66496. * will be derived from the parameters. The precision property is a multiplier allowing
  66497. * rendering at a higher or lower resolution
  66498. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66499. * Check your browser for supported MIME types
  66500. * @param samples Texture samples (default: 1)
  66501. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66502. * @param fileName A name for for the downloaded file.
  66503. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66504. * to the src parameter of an <img> to display it
  66505. */
  66506. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66507. /**
  66508. * Gets height and width for screenshot size
  66509. * @private
  66510. */
  66511. private static _getScreenshotSize;
  66512. }
  66513. }
  66514. declare module "babylonjs/Misc/index" {
  66515. export * from "babylonjs/Misc/andOrNotEvaluator";
  66516. export * from "babylonjs/Misc/assetsManager";
  66517. export * from "babylonjs/Misc/dds";
  66518. export * from "babylonjs/Misc/decorators";
  66519. export * from "babylonjs/Misc/deferred";
  66520. export * from "babylonjs/Misc/environmentTextureTools";
  66521. export * from "babylonjs/Misc/meshExploder";
  66522. export * from "babylonjs/Misc/filesInput";
  66523. export * from "babylonjs/Misc/HighDynamicRange/index";
  66524. export * from "babylonjs/Misc/khronosTextureContainer";
  66525. export * from "babylonjs/Misc/observable";
  66526. export * from "babylonjs/Misc/performanceMonitor";
  66527. export * from "babylonjs/Misc/promise";
  66528. export * from "babylonjs/Misc/sceneOptimizer";
  66529. export * from "babylonjs/Misc/sceneSerializer";
  66530. export * from "babylonjs/Misc/smartArray";
  66531. export * from "babylonjs/Misc/stringDictionary";
  66532. export * from "babylonjs/Misc/tags";
  66533. export * from "babylonjs/Misc/textureTools";
  66534. export * from "babylonjs/Misc/tga";
  66535. export * from "babylonjs/Misc/tools";
  66536. export * from "babylonjs/Misc/videoRecorder";
  66537. export * from "babylonjs/Misc/virtualJoystick";
  66538. export * from "babylonjs/Misc/workerPool";
  66539. export * from "babylonjs/Misc/logger";
  66540. export * from "babylonjs/Misc/typeStore";
  66541. export * from "babylonjs/Misc/filesInputStore";
  66542. export * from "babylonjs/Misc/deepCopier";
  66543. export * from "babylonjs/Misc/pivotTools";
  66544. export * from "babylonjs/Misc/precisionDate";
  66545. export * from "babylonjs/Misc/screenshotTools";
  66546. export * from "babylonjs/Misc/typeStore";
  66547. export * from "babylonjs/Misc/webRequest";
  66548. export * from "babylonjs/Misc/iInspectable";
  66549. export * from "babylonjs/Misc/brdfTextureTools";
  66550. export * from "babylonjs/Misc/rgbdTextureTools";
  66551. export * from "babylonjs/Misc/gradients";
  66552. export * from "babylonjs/Misc/perfCounter";
  66553. export * from "babylonjs/Misc/fileRequest";
  66554. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66555. export * from "babylonjs/Misc/retryStrategy";
  66556. export * from "babylonjs/Misc/loadFileError";
  66557. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66558. }
  66559. declare module "babylonjs/index" {
  66560. export * from "babylonjs/abstractScene";
  66561. export * from "babylonjs/Actions/index";
  66562. export * from "babylonjs/Animations/index";
  66563. export * from "babylonjs/assetContainer";
  66564. export * from "babylonjs/Audio/index";
  66565. export * from "babylonjs/Behaviors/index";
  66566. export * from "babylonjs/Bones/index";
  66567. export * from "babylonjs/Cameras/index";
  66568. export * from "babylonjs/Collisions/index";
  66569. export * from "babylonjs/Culling/index";
  66570. export * from "babylonjs/Debug/index";
  66571. export * from "babylonjs/Engines/index";
  66572. export * from "babylonjs/Events/index";
  66573. export * from "babylonjs/Gamepads/index";
  66574. export * from "babylonjs/Gizmos/index";
  66575. export * from "babylonjs/Helpers/index";
  66576. export * from "babylonjs/Instrumentation/index";
  66577. export * from "babylonjs/Layers/index";
  66578. export * from "babylonjs/LensFlares/index";
  66579. export * from "babylonjs/Lights/index";
  66580. export * from "babylonjs/Loading/index";
  66581. export * from "babylonjs/Materials/index";
  66582. export * from "babylonjs/Maths/index";
  66583. export * from "babylonjs/Meshes/index";
  66584. export * from "babylonjs/Morph/index";
  66585. export * from "babylonjs/Navigation/index";
  66586. export * from "babylonjs/node";
  66587. export * from "babylonjs/Offline/index";
  66588. export * from "babylonjs/Particles/index";
  66589. export * from "babylonjs/Physics/index";
  66590. export * from "babylonjs/PostProcesses/index";
  66591. export * from "babylonjs/Probes/index";
  66592. export * from "babylonjs/Rendering/index";
  66593. export * from "babylonjs/scene";
  66594. export * from "babylonjs/sceneComponent";
  66595. export * from "babylonjs/Sprites/index";
  66596. export * from "babylonjs/States/index";
  66597. export * from "babylonjs/Misc/index";
  66598. export * from "babylonjs/types";
  66599. }
  66600. declare module "babylonjs/Animations/pathCursor" {
  66601. import { Vector3 } from "babylonjs/Maths/math.vector";
  66602. import { Path2 } from "babylonjs/Maths/math.path";
  66603. /**
  66604. * A cursor which tracks a point on a path
  66605. */
  66606. export class PathCursor {
  66607. private path;
  66608. /**
  66609. * Stores path cursor callbacks for when an onchange event is triggered
  66610. */
  66611. private _onchange;
  66612. /**
  66613. * The value of the path cursor
  66614. */
  66615. value: number;
  66616. /**
  66617. * The animation array of the path cursor
  66618. */
  66619. animations: Animation[];
  66620. /**
  66621. * Initializes the path cursor
  66622. * @param path The path to track
  66623. */
  66624. constructor(path: Path2);
  66625. /**
  66626. * Gets the cursor point on the path
  66627. * @returns A point on the path cursor at the cursor location
  66628. */
  66629. getPoint(): Vector3;
  66630. /**
  66631. * Moves the cursor ahead by the step amount
  66632. * @param step The amount to move the cursor forward
  66633. * @returns This path cursor
  66634. */
  66635. moveAhead(step?: number): PathCursor;
  66636. /**
  66637. * Moves the cursor behind by the step amount
  66638. * @param step The amount to move the cursor back
  66639. * @returns This path cursor
  66640. */
  66641. moveBack(step?: number): PathCursor;
  66642. /**
  66643. * Moves the cursor by the step amount
  66644. * If the step amount is greater than one, an exception is thrown
  66645. * @param step The amount to move the cursor
  66646. * @returns This path cursor
  66647. */
  66648. move(step: number): PathCursor;
  66649. /**
  66650. * Ensures that the value is limited between zero and one
  66651. * @returns This path cursor
  66652. */
  66653. private ensureLimits;
  66654. /**
  66655. * Runs onchange callbacks on change (used by the animation engine)
  66656. * @returns This path cursor
  66657. */
  66658. private raiseOnChange;
  66659. /**
  66660. * Executes a function on change
  66661. * @param f A path cursor onchange callback
  66662. * @returns This path cursor
  66663. */
  66664. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66665. }
  66666. }
  66667. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66668. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66669. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66670. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66671. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66672. }
  66673. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66674. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66675. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66676. }
  66677. declare module "babylonjs/Engines/Processors/index" {
  66678. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66679. export * from "babylonjs/Engines/Processors/Expressions/index";
  66680. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66681. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66682. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66683. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66684. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66685. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66686. }
  66687. declare module "babylonjs/Legacy/legacy" {
  66688. import * as Babylon from "babylonjs/index";
  66689. export * from "babylonjs/index";
  66690. }
  66691. declare module "babylonjs/Shaders/blur.fragment" {
  66692. /** @hidden */
  66693. export var blurPixelShader: {
  66694. name: string;
  66695. shader: string;
  66696. };
  66697. }
  66698. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66699. /** @hidden */
  66700. export var pointCloudVertexDeclaration: {
  66701. name: string;
  66702. shader: string;
  66703. };
  66704. }
  66705. declare module "babylonjs" {
  66706. export * from "babylonjs/Legacy/legacy";
  66707. }
  66708. declare module BABYLON {
  66709. /** Alias type for value that can be null */
  66710. export type Nullable<T> = T | null;
  66711. /**
  66712. * Alias type for number that are floats
  66713. * @ignorenaming
  66714. */
  66715. export type float = number;
  66716. /**
  66717. * Alias type for number that are doubles.
  66718. * @ignorenaming
  66719. */
  66720. export type double = number;
  66721. /**
  66722. * Alias type for number that are integer
  66723. * @ignorenaming
  66724. */
  66725. export type int = number;
  66726. /** Alias type for number array or Float32Array */
  66727. export type FloatArray = number[] | Float32Array;
  66728. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66729. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66730. /**
  66731. * Alias for types that can be used by a Buffer or VertexBuffer.
  66732. */
  66733. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66734. /**
  66735. * Alias type for primitive types
  66736. * @ignorenaming
  66737. */
  66738. type Primitive = undefined | null | boolean | string | number | Function;
  66739. /**
  66740. * Type modifier to make all the properties of an object Readonly
  66741. */
  66742. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66743. /**
  66744. * Type modifier to make all the properties of an object Readonly recursively
  66745. */
  66746. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66747. /**
  66748. * Type modifier to make object properties readonly.
  66749. */
  66750. export type DeepImmutableObject<T> = {
  66751. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66752. };
  66753. /** @hidden */
  66754. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66755. }
  66756. }
  66757. declare module BABYLON {
  66758. /**
  66759. * A class serves as a medium between the observable and its observers
  66760. */
  66761. export class EventState {
  66762. /**
  66763. * Create a new EventState
  66764. * @param mask defines the mask associated with this state
  66765. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66766. * @param target defines the original target of the state
  66767. * @param currentTarget defines the current target of the state
  66768. */
  66769. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66770. /**
  66771. * Initialize the current event state
  66772. * @param mask defines the mask associated with this state
  66773. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66774. * @param target defines the original target of the state
  66775. * @param currentTarget defines the current target of the state
  66776. * @returns the current event state
  66777. */
  66778. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66779. /**
  66780. * An Observer can set this property to true to prevent subsequent observers of being notified
  66781. */
  66782. skipNextObservers: boolean;
  66783. /**
  66784. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66785. */
  66786. mask: number;
  66787. /**
  66788. * The object that originally notified the event
  66789. */
  66790. target?: any;
  66791. /**
  66792. * The current object in the bubbling phase
  66793. */
  66794. currentTarget?: any;
  66795. /**
  66796. * This will be populated with the return value of the last function that was executed.
  66797. * If it is the first function in the callback chain it will be the event data.
  66798. */
  66799. lastReturnValue?: any;
  66800. }
  66801. /**
  66802. * Represent an Observer registered to a given Observable object.
  66803. */
  66804. export class Observer<T> {
  66805. /**
  66806. * Defines the callback to call when the observer is notified
  66807. */
  66808. callback: (eventData: T, eventState: EventState) => void;
  66809. /**
  66810. * Defines the mask of the observer (used to filter notifications)
  66811. */
  66812. mask: number;
  66813. /**
  66814. * Defines the current scope used to restore the JS context
  66815. */
  66816. scope: any;
  66817. /** @hidden */
  66818. _willBeUnregistered: boolean;
  66819. /**
  66820. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66821. */
  66822. unregisterOnNextCall: boolean;
  66823. /**
  66824. * Creates a new observer
  66825. * @param callback defines the callback to call when the observer is notified
  66826. * @param mask defines the mask of the observer (used to filter notifications)
  66827. * @param scope defines the current scope used to restore the JS context
  66828. */
  66829. constructor(
  66830. /**
  66831. * Defines the callback to call when the observer is notified
  66832. */
  66833. callback: (eventData: T, eventState: EventState) => void,
  66834. /**
  66835. * Defines the mask of the observer (used to filter notifications)
  66836. */
  66837. mask: number,
  66838. /**
  66839. * Defines the current scope used to restore the JS context
  66840. */
  66841. scope?: any);
  66842. }
  66843. /**
  66844. * Represent a list of observers registered to multiple Observables object.
  66845. */
  66846. export class MultiObserver<T> {
  66847. private _observers;
  66848. private _observables;
  66849. /**
  66850. * Release associated resources
  66851. */
  66852. dispose(): void;
  66853. /**
  66854. * Raise a callback when one of the observable will notify
  66855. * @param observables defines a list of observables to watch
  66856. * @param callback defines the callback to call on notification
  66857. * @param mask defines the mask used to filter notifications
  66858. * @param scope defines the current scope used to restore the JS context
  66859. * @returns the new MultiObserver
  66860. */
  66861. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66862. }
  66863. /**
  66864. * The Observable class is a simple implementation of the Observable pattern.
  66865. *
  66866. * 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.
  66867. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66868. * 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).
  66869. * 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.
  66870. */
  66871. export class Observable<T> {
  66872. private _observers;
  66873. private _eventState;
  66874. private _onObserverAdded;
  66875. /**
  66876. * Gets the list of observers
  66877. */
  66878. readonly observers: Array<Observer<T>>;
  66879. /**
  66880. * Creates a new observable
  66881. * @param onObserverAdded defines a callback to call when a new observer is added
  66882. */
  66883. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66884. /**
  66885. * Create a new Observer with the specified callback
  66886. * @param callback the callback that will be executed for that Observer
  66887. * @param mask the mask used to filter observers
  66888. * @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.
  66889. * @param scope optional scope for the callback to be called from
  66890. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66891. * @returns the new observer created for the callback
  66892. */
  66893. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66894. /**
  66895. * Create a new Observer with the specified callback and unregisters after the next notification
  66896. * @param callback the callback that will be executed for that Observer
  66897. * @returns the new observer created for the callback
  66898. */
  66899. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66900. /**
  66901. * Remove an Observer from the Observable object
  66902. * @param observer the instance of the Observer to remove
  66903. * @returns false if it doesn't belong to this Observable
  66904. */
  66905. remove(observer: Nullable<Observer<T>>): boolean;
  66906. /**
  66907. * Remove a callback from the Observable object
  66908. * @param callback the callback to remove
  66909. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66910. * @returns false if it doesn't belong to this Observable
  66911. */
  66912. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66913. private _deferUnregister;
  66914. private _remove;
  66915. /**
  66916. * Moves the observable to the top of the observer list making it get called first when notified
  66917. * @param observer the observer to move
  66918. */
  66919. makeObserverTopPriority(observer: Observer<T>): void;
  66920. /**
  66921. * Moves the observable to the bottom of the observer list making it get called last when notified
  66922. * @param observer the observer to move
  66923. */
  66924. makeObserverBottomPriority(observer: Observer<T>): void;
  66925. /**
  66926. * Notify all Observers by calling their respective callback with the given data
  66927. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66928. * @param eventData defines the data to send to all observers
  66929. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66930. * @param target defines the original target of the state
  66931. * @param currentTarget defines the current target of the state
  66932. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66933. */
  66934. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66935. /**
  66936. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66937. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66938. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66939. * and it is crucial that all callbacks will be executed.
  66940. * The order of the callbacks is kept, callbacks are not executed parallel.
  66941. *
  66942. * @param eventData The data to be sent to each callback
  66943. * @param mask is used to filter observers defaults to -1
  66944. * @param target defines the callback target (see EventState)
  66945. * @param currentTarget defines he current object in the bubbling phase
  66946. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66947. */
  66948. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66949. /**
  66950. * Notify a specific observer
  66951. * @param observer defines the observer to notify
  66952. * @param eventData defines the data to be sent to each callback
  66953. * @param mask is used to filter observers defaults to -1
  66954. */
  66955. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66956. /**
  66957. * Gets a boolean indicating if the observable has at least one observer
  66958. * @returns true is the Observable has at least one Observer registered
  66959. */
  66960. hasObservers(): boolean;
  66961. /**
  66962. * Clear the list of observers
  66963. */
  66964. clear(): void;
  66965. /**
  66966. * Clone the current observable
  66967. * @returns a new observable
  66968. */
  66969. clone(): Observable<T>;
  66970. /**
  66971. * Does this observable handles observer registered with a given mask
  66972. * @param mask defines the mask to be tested
  66973. * @return whether or not one observer registered with the given mask is handeled
  66974. **/
  66975. hasSpecificMask(mask?: number): boolean;
  66976. }
  66977. }
  66978. declare module BABYLON {
  66979. /**
  66980. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66981. * Babylon.js
  66982. */
  66983. export class DomManagement {
  66984. /**
  66985. * Checks if the window object exists
  66986. * @returns true if the window object exists
  66987. */
  66988. static IsWindowObjectExist(): boolean;
  66989. /**
  66990. * Checks if the navigator object exists
  66991. * @returns true if the navigator object exists
  66992. */
  66993. static IsNavigatorAvailable(): boolean;
  66994. /**
  66995. * Extracts text content from a DOM element hierarchy
  66996. * @param element defines the root element
  66997. * @returns a string
  66998. */
  66999. static GetDOMTextContent(element: HTMLElement): string;
  67000. }
  67001. }
  67002. declare module BABYLON {
  67003. /**
  67004. * Logger used througouht the application to allow configuration of
  67005. * the log level required for the messages.
  67006. */
  67007. export class Logger {
  67008. /**
  67009. * No log
  67010. */
  67011. static readonly NoneLogLevel: number;
  67012. /**
  67013. * Only message logs
  67014. */
  67015. static readonly MessageLogLevel: number;
  67016. /**
  67017. * Only warning logs
  67018. */
  67019. static readonly WarningLogLevel: number;
  67020. /**
  67021. * Only error logs
  67022. */
  67023. static readonly ErrorLogLevel: number;
  67024. /**
  67025. * All logs
  67026. */
  67027. static readonly AllLogLevel: number;
  67028. private static _LogCache;
  67029. /**
  67030. * Gets a value indicating the number of loading errors
  67031. * @ignorenaming
  67032. */
  67033. static errorsCount: number;
  67034. /**
  67035. * Callback called when a new log is added
  67036. */
  67037. static OnNewCacheEntry: (entry: string) => void;
  67038. private static _AddLogEntry;
  67039. private static _FormatMessage;
  67040. private static _LogDisabled;
  67041. private static _LogEnabled;
  67042. private static _WarnDisabled;
  67043. private static _WarnEnabled;
  67044. private static _ErrorDisabled;
  67045. private static _ErrorEnabled;
  67046. /**
  67047. * Log a message to the console
  67048. */
  67049. static Log: (message: string) => void;
  67050. /**
  67051. * Write a warning message to the console
  67052. */
  67053. static Warn: (message: string) => void;
  67054. /**
  67055. * Write an error message to the console
  67056. */
  67057. static Error: (message: string) => void;
  67058. /**
  67059. * Gets current log cache (list of logs)
  67060. */
  67061. static readonly LogCache: string;
  67062. /**
  67063. * Clears the log cache
  67064. */
  67065. static ClearLogCache(): void;
  67066. /**
  67067. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67068. */
  67069. static LogLevels: number;
  67070. }
  67071. }
  67072. declare module BABYLON {
  67073. /** @hidden */
  67074. export class _TypeStore {
  67075. /** @hidden */
  67076. static RegisteredTypes: {
  67077. [key: string]: Object;
  67078. };
  67079. /** @hidden */
  67080. static GetClass(fqdn: string): any;
  67081. }
  67082. }
  67083. declare module BABYLON {
  67084. /**
  67085. * Class containing a set of static utilities functions for deep copy.
  67086. */
  67087. export class DeepCopier {
  67088. /**
  67089. * Tries to copy an object by duplicating every property
  67090. * @param source defines the source object
  67091. * @param destination defines the target object
  67092. * @param doNotCopyList defines a list of properties to avoid
  67093. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67094. */
  67095. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67096. }
  67097. }
  67098. declare module BABYLON {
  67099. /**
  67100. * Class containing a set of static utilities functions for precision date
  67101. */
  67102. export class PrecisionDate {
  67103. /**
  67104. * Gets either window.performance.now() if supported or Date.now() else
  67105. */
  67106. static readonly Now: number;
  67107. }
  67108. }
  67109. declare module BABYLON {
  67110. /** @hidden */
  67111. export class _DevTools {
  67112. static WarnImport(name: string): string;
  67113. }
  67114. }
  67115. declare module BABYLON {
  67116. /**
  67117. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67118. */
  67119. export class WebRequest {
  67120. private _xhr;
  67121. /**
  67122. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67123. * i.e. when loading files, where the server/service expects an Authorization header
  67124. */
  67125. static CustomRequestHeaders: {
  67126. [key: string]: string;
  67127. };
  67128. /**
  67129. * Add callback functions in this array to update all the requests before they get sent to the network
  67130. */
  67131. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67132. private _injectCustomRequestHeaders;
  67133. /**
  67134. * Gets or sets a function to be called when loading progress changes
  67135. */
  67136. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67137. /**
  67138. * Returns client's state
  67139. */
  67140. readonly readyState: number;
  67141. /**
  67142. * Returns client's status
  67143. */
  67144. readonly status: number;
  67145. /**
  67146. * Returns client's status as a text
  67147. */
  67148. readonly statusText: string;
  67149. /**
  67150. * Returns client's response
  67151. */
  67152. readonly response: any;
  67153. /**
  67154. * Returns client's response url
  67155. */
  67156. readonly responseURL: string;
  67157. /**
  67158. * Returns client's response as text
  67159. */
  67160. readonly responseText: string;
  67161. /**
  67162. * Gets or sets the expected response type
  67163. */
  67164. responseType: XMLHttpRequestResponseType;
  67165. /** @hidden */
  67166. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67167. /** @hidden */
  67168. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67169. /**
  67170. * Cancels any network activity
  67171. */
  67172. abort(): void;
  67173. /**
  67174. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67175. * @param body defines an optional request body
  67176. */
  67177. send(body?: Document | BodyInit | null): void;
  67178. /**
  67179. * Sets the request method, request URL
  67180. * @param method defines the method to use (GET, POST, etc..)
  67181. * @param url defines the url to connect with
  67182. */
  67183. open(method: string, url: string): void;
  67184. }
  67185. }
  67186. declare module BABYLON {
  67187. /**
  67188. * File request interface
  67189. */
  67190. export interface IFileRequest {
  67191. /**
  67192. * Raised when the request is complete (success or error).
  67193. */
  67194. onCompleteObservable: Observable<IFileRequest>;
  67195. /**
  67196. * Aborts the request for a file.
  67197. */
  67198. abort: () => void;
  67199. }
  67200. }
  67201. declare module BABYLON {
  67202. /**
  67203. * Scalar computation library
  67204. */
  67205. export class Scalar {
  67206. /**
  67207. * Two pi constants convenient for computation.
  67208. */
  67209. static TwoPi: number;
  67210. /**
  67211. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67212. * @param a number
  67213. * @param b number
  67214. * @param epsilon (default = 1.401298E-45)
  67215. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67216. */
  67217. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  67218. /**
  67219. * Returns a string : the upper case translation of the number i to hexadecimal.
  67220. * @param i number
  67221. * @returns the upper case translation of the number i to hexadecimal.
  67222. */
  67223. static ToHex(i: number): string;
  67224. /**
  67225. * Returns -1 if value is negative and +1 is value is positive.
  67226. * @param value the value
  67227. * @returns the value itself if it's equal to zero.
  67228. */
  67229. static Sign(value: number): number;
  67230. /**
  67231. * Returns the value itself if it's between min and max.
  67232. * Returns min if the value is lower than min.
  67233. * Returns max if the value is greater than max.
  67234. * @param value the value to clmap
  67235. * @param min the min value to clamp to (default: 0)
  67236. * @param max the max value to clamp to (default: 1)
  67237. * @returns the clamped value
  67238. */
  67239. static Clamp(value: number, min?: number, max?: number): number;
  67240. /**
  67241. * the log2 of value.
  67242. * @param value the value to compute log2 of
  67243. * @returns the log2 of value.
  67244. */
  67245. static Log2(value: number): number;
  67246. /**
  67247. * Loops the value, so that it is never larger than length and never smaller than 0.
  67248. *
  67249. * This is similar to the modulo operator but it works with floating point numbers.
  67250. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67251. * With t = 5 and length = 2.5, the result would be 0.0.
  67252. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67253. * @param value the value
  67254. * @param length the length
  67255. * @returns the looped value
  67256. */
  67257. static Repeat(value: number, length: number): number;
  67258. /**
  67259. * Normalize the value between 0.0 and 1.0 using min and max values
  67260. * @param value value to normalize
  67261. * @param min max to normalize between
  67262. * @param max min to normalize between
  67263. * @returns the normalized value
  67264. */
  67265. static Normalize(value: number, min: number, max: number): number;
  67266. /**
  67267. * Denormalize the value from 0.0 and 1.0 using min and max values
  67268. * @param normalized value to denormalize
  67269. * @param min max to denormalize between
  67270. * @param max min to denormalize between
  67271. * @returns the denormalized value
  67272. */
  67273. static Denormalize(normalized: number, min: number, max: number): number;
  67274. /**
  67275. * Calculates the shortest difference between two given angles given in degrees.
  67276. * @param current current angle in degrees
  67277. * @param target target angle in degrees
  67278. * @returns the delta
  67279. */
  67280. static DeltaAngle(current: number, target: number): number;
  67281. /**
  67282. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67283. * @param tx value
  67284. * @param length length
  67285. * @returns The returned value will move back and forth between 0 and length
  67286. */
  67287. static PingPong(tx: number, length: number): number;
  67288. /**
  67289. * Interpolates between min and max with smoothing at the limits.
  67290. *
  67291. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67292. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67293. * @param from from
  67294. * @param to to
  67295. * @param tx value
  67296. * @returns the smooth stepped value
  67297. */
  67298. static SmoothStep(from: number, to: number, tx: number): number;
  67299. /**
  67300. * Moves a value current towards target.
  67301. *
  67302. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67303. * Negative values of maxDelta pushes the value away from target.
  67304. * @param current current value
  67305. * @param target target value
  67306. * @param maxDelta max distance to move
  67307. * @returns resulting value
  67308. */
  67309. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67310. /**
  67311. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67312. *
  67313. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67314. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67315. * @param current current value
  67316. * @param target target value
  67317. * @param maxDelta max distance to move
  67318. * @returns resulting angle
  67319. */
  67320. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67321. /**
  67322. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67323. * @param start start value
  67324. * @param end target value
  67325. * @param amount amount to lerp between
  67326. * @returns the lerped value
  67327. */
  67328. static Lerp(start: number, end: number, amount: number): number;
  67329. /**
  67330. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67331. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67332. * @param start start value
  67333. * @param end target value
  67334. * @param amount amount to lerp between
  67335. * @returns the lerped value
  67336. */
  67337. static LerpAngle(start: number, end: number, amount: number): number;
  67338. /**
  67339. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67340. * @param a start value
  67341. * @param b target value
  67342. * @param value value between a and b
  67343. * @returns the inverseLerp value
  67344. */
  67345. static InverseLerp(a: number, b: number, value: number): number;
  67346. /**
  67347. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67348. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67349. * @param value1 spline value
  67350. * @param tangent1 spline value
  67351. * @param value2 spline value
  67352. * @param tangent2 spline value
  67353. * @param amount input value
  67354. * @returns hermite result
  67355. */
  67356. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67357. /**
  67358. * Returns a random float number between and min and max values
  67359. * @param min min value of random
  67360. * @param max max value of random
  67361. * @returns random value
  67362. */
  67363. static RandomRange(min: number, max: number): number;
  67364. /**
  67365. * This function returns percentage of a number in a given range.
  67366. *
  67367. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67368. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67369. * @param number to convert to percentage
  67370. * @param min min range
  67371. * @param max max range
  67372. * @returns the percentage
  67373. */
  67374. static RangeToPercent(number: number, min: number, max: number): number;
  67375. /**
  67376. * This function returns number that corresponds to the percentage in a given range.
  67377. *
  67378. * PercentToRange(0.34,0,100) will return 34.
  67379. * @param percent to convert to number
  67380. * @param min min range
  67381. * @param max max range
  67382. * @returns the number
  67383. */
  67384. static PercentToRange(percent: number, min: number, max: number): number;
  67385. /**
  67386. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67387. * @param angle The angle to normalize in radian.
  67388. * @return The converted angle.
  67389. */
  67390. static NormalizeRadians(angle: number): number;
  67391. }
  67392. }
  67393. declare module BABYLON {
  67394. /**
  67395. * Constant used to convert a value to gamma space
  67396. * @ignorenaming
  67397. */
  67398. export const ToGammaSpace: number;
  67399. /**
  67400. * Constant used to convert a value to linear space
  67401. * @ignorenaming
  67402. */
  67403. export const ToLinearSpace = 2.2;
  67404. /**
  67405. * Constant used to define the minimal number value in Babylon.js
  67406. * @ignorenaming
  67407. */
  67408. let Epsilon: number;
  67409. }
  67410. declare module BABYLON {
  67411. /**
  67412. * Class used to represent a viewport on screen
  67413. */
  67414. export class Viewport {
  67415. /** viewport left coordinate */
  67416. x: number;
  67417. /** viewport top coordinate */
  67418. y: number;
  67419. /**viewport width */
  67420. width: number;
  67421. /** viewport height */
  67422. height: number;
  67423. /**
  67424. * Creates a Viewport object located at (x, y) and sized (width, height)
  67425. * @param x defines viewport left coordinate
  67426. * @param y defines viewport top coordinate
  67427. * @param width defines the viewport width
  67428. * @param height defines the viewport height
  67429. */
  67430. constructor(
  67431. /** viewport left coordinate */
  67432. x: number,
  67433. /** viewport top coordinate */
  67434. y: number,
  67435. /**viewport width */
  67436. width: number,
  67437. /** viewport height */
  67438. height: number);
  67439. /**
  67440. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67441. * @param renderWidth defines the rendering width
  67442. * @param renderHeight defines the rendering height
  67443. * @returns a new Viewport
  67444. */
  67445. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67446. /**
  67447. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67448. * @param renderWidth defines the rendering width
  67449. * @param renderHeight defines the rendering height
  67450. * @param ref defines the target viewport
  67451. * @returns the current viewport
  67452. */
  67453. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67454. /**
  67455. * Returns a new Viewport copied from the current one
  67456. * @returns a new Viewport
  67457. */
  67458. clone(): Viewport;
  67459. }
  67460. }
  67461. declare module BABYLON {
  67462. /**
  67463. * Class containing a set of static utilities functions for arrays.
  67464. */
  67465. export class ArrayTools {
  67466. /**
  67467. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67468. * @param size the number of element to construct and put in the array
  67469. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67470. * @returns a new array filled with new objects
  67471. */
  67472. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67473. }
  67474. }
  67475. declare module BABYLON {
  67476. /**
  67477. * @hidden
  67478. */
  67479. export interface IColor4Like {
  67480. r: float;
  67481. g: float;
  67482. b: float;
  67483. a: float;
  67484. }
  67485. /**
  67486. * @hidden
  67487. */
  67488. export interface IColor3Like {
  67489. r: float;
  67490. g: float;
  67491. b: float;
  67492. }
  67493. /**
  67494. * @hidden
  67495. */
  67496. export interface IVector4Like {
  67497. x: float;
  67498. y: float;
  67499. z: float;
  67500. w: float;
  67501. }
  67502. /**
  67503. * @hidden
  67504. */
  67505. export interface IVector3Like {
  67506. x: float;
  67507. y: float;
  67508. z: float;
  67509. }
  67510. /**
  67511. * @hidden
  67512. */
  67513. export interface IVector2Like {
  67514. x: float;
  67515. y: float;
  67516. }
  67517. /**
  67518. * @hidden
  67519. */
  67520. export interface IMatrixLike {
  67521. toArray(): DeepImmutable<Float32Array>;
  67522. updateFlag: int;
  67523. }
  67524. /**
  67525. * @hidden
  67526. */
  67527. export interface IViewportLike {
  67528. x: float;
  67529. y: float;
  67530. width: float;
  67531. height: float;
  67532. }
  67533. /**
  67534. * @hidden
  67535. */
  67536. export interface IPlaneLike {
  67537. normal: IVector3Like;
  67538. d: float;
  67539. normalize(): void;
  67540. }
  67541. }
  67542. declare module BABYLON {
  67543. /**
  67544. * Class representing a vector containing 2 coordinates
  67545. */
  67546. export class Vector2 {
  67547. /** defines the first coordinate */
  67548. x: number;
  67549. /** defines the second coordinate */
  67550. y: number;
  67551. /**
  67552. * Creates a new Vector2 from the given x and y coordinates
  67553. * @param x defines the first coordinate
  67554. * @param y defines the second coordinate
  67555. */
  67556. constructor(
  67557. /** defines the first coordinate */
  67558. x?: number,
  67559. /** defines the second coordinate */
  67560. y?: number);
  67561. /**
  67562. * Gets a string with the Vector2 coordinates
  67563. * @returns a string with the Vector2 coordinates
  67564. */
  67565. toString(): string;
  67566. /**
  67567. * Gets class name
  67568. * @returns the string "Vector2"
  67569. */
  67570. getClassName(): string;
  67571. /**
  67572. * Gets current vector hash code
  67573. * @returns the Vector2 hash code as a number
  67574. */
  67575. getHashCode(): number;
  67576. /**
  67577. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67578. * @param array defines the source array
  67579. * @param index defines the offset in source array
  67580. * @returns the current Vector2
  67581. */
  67582. toArray(array: FloatArray, index?: number): Vector2;
  67583. /**
  67584. * Copy the current vector to an array
  67585. * @returns a new array with 2 elements: the Vector2 coordinates.
  67586. */
  67587. asArray(): number[];
  67588. /**
  67589. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67590. * @param source defines the source Vector2
  67591. * @returns the current updated Vector2
  67592. */
  67593. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67594. /**
  67595. * Sets the Vector2 coordinates with the given floats
  67596. * @param x defines the first coordinate
  67597. * @param y defines the second coordinate
  67598. * @returns the current updated Vector2
  67599. */
  67600. copyFromFloats(x: number, y: number): Vector2;
  67601. /**
  67602. * Sets the Vector2 coordinates with the given floats
  67603. * @param x defines the first coordinate
  67604. * @param y defines the second coordinate
  67605. * @returns the current updated Vector2
  67606. */
  67607. set(x: number, y: number): Vector2;
  67608. /**
  67609. * Add another vector with the current one
  67610. * @param otherVector defines the other vector
  67611. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67612. */
  67613. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67614. /**
  67615. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67616. * @param otherVector defines the other vector
  67617. * @param result defines the target vector
  67618. * @returns the unmodified current Vector2
  67619. */
  67620. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67621. /**
  67622. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67623. * @param otherVector defines the other vector
  67624. * @returns the current updated Vector2
  67625. */
  67626. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67627. /**
  67628. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67629. * @param otherVector defines the other vector
  67630. * @returns a new Vector2
  67631. */
  67632. addVector3(otherVector: Vector3): Vector2;
  67633. /**
  67634. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67635. * @param otherVector defines the other vector
  67636. * @returns a new Vector2
  67637. */
  67638. subtract(otherVector: Vector2): Vector2;
  67639. /**
  67640. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67641. * @param otherVector defines the other vector
  67642. * @param result defines the target vector
  67643. * @returns the unmodified current Vector2
  67644. */
  67645. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67646. /**
  67647. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67648. * @param otherVector defines the other vector
  67649. * @returns the current updated Vector2
  67650. */
  67651. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67652. /**
  67653. * Multiplies in place the current Vector2 coordinates by the given ones
  67654. * @param otherVector defines the other vector
  67655. * @returns the current updated Vector2
  67656. */
  67657. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67658. /**
  67659. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67660. * @param otherVector defines the other vector
  67661. * @returns a new Vector2
  67662. */
  67663. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67664. /**
  67665. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67666. * @param otherVector defines the other vector
  67667. * @param result defines the target vector
  67668. * @returns the unmodified current Vector2
  67669. */
  67670. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67671. /**
  67672. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67673. * @param x defines the first coordinate
  67674. * @param y defines the second coordinate
  67675. * @returns a new Vector2
  67676. */
  67677. multiplyByFloats(x: number, y: number): Vector2;
  67678. /**
  67679. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67680. * @param otherVector defines the other vector
  67681. * @returns a new Vector2
  67682. */
  67683. divide(otherVector: Vector2): Vector2;
  67684. /**
  67685. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67686. * @param otherVector defines the other vector
  67687. * @param result defines the target vector
  67688. * @returns the unmodified current Vector2
  67689. */
  67690. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67691. /**
  67692. * Divides the current Vector2 coordinates by the given ones
  67693. * @param otherVector defines the other vector
  67694. * @returns the current updated Vector2
  67695. */
  67696. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67697. /**
  67698. * Gets a new Vector2 with current Vector2 negated coordinates
  67699. * @returns a new Vector2
  67700. */
  67701. negate(): Vector2;
  67702. /**
  67703. * Multiply the Vector2 coordinates by scale
  67704. * @param scale defines the scaling factor
  67705. * @returns the current updated Vector2
  67706. */
  67707. scaleInPlace(scale: number): Vector2;
  67708. /**
  67709. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67710. * @param scale defines the scaling factor
  67711. * @returns a new Vector2
  67712. */
  67713. scale(scale: number): Vector2;
  67714. /**
  67715. * Scale the current Vector2 values by a factor to a given Vector2
  67716. * @param scale defines the scale factor
  67717. * @param result defines the Vector2 object where to store the result
  67718. * @returns the unmodified current Vector2
  67719. */
  67720. scaleToRef(scale: number, result: Vector2): Vector2;
  67721. /**
  67722. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67723. * @param scale defines the scale factor
  67724. * @param result defines the Vector2 object where to store the result
  67725. * @returns the unmodified current Vector2
  67726. */
  67727. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67728. /**
  67729. * Gets a boolean if two vectors are equals
  67730. * @param otherVector defines the other vector
  67731. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67732. */
  67733. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67734. /**
  67735. * Gets a boolean if two vectors are equals (using an epsilon value)
  67736. * @param otherVector defines the other vector
  67737. * @param epsilon defines the minimal distance to consider equality
  67738. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67739. */
  67740. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67741. /**
  67742. * Gets a new Vector2 from current Vector2 floored values
  67743. * @returns a new Vector2
  67744. */
  67745. floor(): Vector2;
  67746. /**
  67747. * Gets a new Vector2 from current Vector2 floored values
  67748. * @returns a new Vector2
  67749. */
  67750. fract(): Vector2;
  67751. /**
  67752. * Gets the length of the vector
  67753. * @returns the vector length (float)
  67754. */
  67755. length(): number;
  67756. /**
  67757. * Gets the vector squared length
  67758. * @returns the vector squared length (float)
  67759. */
  67760. lengthSquared(): number;
  67761. /**
  67762. * Normalize the vector
  67763. * @returns the current updated Vector2
  67764. */
  67765. normalize(): Vector2;
  67766. /**
  67767. * Gets a new Vector2 copied from the Vector2
  67768. * @returns a new Vector2
  67769. */
  67770. clone(): Vector2;
  67771. /**
  67772. * Gets a new Vector2(0, 0)
  67773. * @returns a new Vector2
  67774. */
  67775. static Zero(): Vector2;
  67776. /**
  67777. * Gets a new Vector2(1, 1)
  67778. * @returns a new Vector2
  67779. */
  67780. static One(): Vector2;
  67781. /**
  67782. * Gets a new Vector2 set from the given index element of the given array
  67783. * @param array defines the data source
  67784. * @param offset defines the offset in the data source
  67785. * @returns a new Vector2
  67786. */
  67787. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67788. /**
  67789. * Sets "result" from the given index element of the given array
  67790. * @param array defines the data source
  67791. * @param offset defines the offset in the data source
  67792. * @param result defines the target vector
  67793. */
  67794. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67795. /**
  67796. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67797. * @param value1 defines 1st point of control
  67798. * @param value2 defines 2nd point of control
  67799. * @param value3 defines 3rd point of control
  67800. * @param value4 defines 4th point of control
  67801. * @param amount defines the interpolation factor
  67802. * @returns a new Vector2
  67803. */
  67804. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67805. /**
  67806. * 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".
  67807. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67808. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67809. * @param value defines the value to clamp
  67810. * @param min defines the lower limit
  67811. * @param max defines the upper limit
  67812. * @returns a new Vector2
  67813. */
  67814. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67815. /**
  67816. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67817. * @param value1 defines the 1st control point
  67818. * @param tangent1 defines the outgoing tangent
  67819. * @param value2 defines the 2nd control point
  67820. * @param tangent2 defines the incoming tangent
  67821. * @param amount defines the interpolation factor
  67822. * @returns a new Vector2
  67823. */
  67824. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67825. /**
  67826. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67827. * @param start defines the start vector
  67828. * @param end defines the end vector
  67829. * @param amount defines the interpolation factor
  67830. * @returns a new Vector2
  67831. */
  67832. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67833. /**
  67834. * Gets the dot product of the vector "left" and the vector "right"
  67835. * @param left defines first vector
  67836. * @param right defines second vector
  67837. * @returns the dot product (float)
  67838. */
  67839. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67840. /**
  67841. * Returns a new Vector2 equal to the normalized given vector
  67842. * @param vector defines the vector to normalize
  67843. * @returns a new Vector2
  67844. */
  67845. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67846. /**
  67847. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67848. * @param left defines 1st vector
  67849. * @param right defines 2nd vector
  67850. * @returns a new Vector2
  67851. */
  67852. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67853. /**
  67854. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67855. * @param left defines 1st vector
  67856. * @param right defines 2nd vector
  67857. * @returns a new Vector2
  67858. */
  67859. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67860. /**
  67861. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67862. * @param vector defines the vector to transform
  67863. * @param transformation defines the matrix to apply
  67864. * @returns a new Vector2
  67865. */
  67866. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67867. /**
  67868. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67869. * @param vector defines the vector to transform
  67870. * @param transformation defines the matrix to apply
  67871. * @param result defines the target vector
  67872. */
  67873. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67874. /**
  67875. * Determines if a given vector is included in a triangle
  67876. * @param p defines the vector to test
  67877. * @param p0 defines 1st triangle point
  67878. * @param p1 defines 2nd triangle point
  67879. * @param p2 defines 3rd triangle point
  67880. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67881. */
  67882. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67883. /**
  67884. * Gets the distance between the vectors "value1" and "value2"
  67885. * @param value1 defines first vector
  67886. * @param value2 defines second vector
  67887. * @returns the distance between vectors
  67888. */
  67889. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67890. /**
  67891. * Returns the squared distance between the vectors "value1" and "value2"
  67892. * @param value1 defines first vector
  67893. * @param value2 defines second vector
  67894. * @returns the squared distance between vectors
  67895. */
  67896. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67897. /**
  67898. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67899. * @param value1 defines first vector
  67900. * @param value2 defines second vector
  67901. * @returns a new Vector2
  67902. */
  67903. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67904. /**
  67905. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67906. * @param p defines the middle point
  67907. * @param segA defines one point of the segment
  67908. * @param segB defines the other point of the segment
  67909. * @returns the shortest distance
  67910. */
  67911. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67912. }
  67913. /**
  67914. * Classed used to store (x,y,z) vector representation
  67915. * A Vector3 is the main object used in 3D geometry
  67916. * It can represent etiher the coordinates of a point the space, either a direction
  67917. * Reminder: js uses a left handed forward facing system
  67918. */
  67919. export class Vector3 {
  67920. /**
  67921. * Defines the first coordinates (on X axis)
  67922. */
  67923. x: number;
  67924. /**
  67925. * Defines the second coordinates (on Y axis)
  67926. */
  67927. y: number;
  67928. /**
  67929. * Defines the third coordinates (on Z axis)
  67930. */
  67931. z: number;
  67932. private static _UpReadOnly;
  67933. private static _ZeroReadOnly;
  67934. /**
  67935. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67936. * @param x defines the first coordinates (on X axis)
  67937. * @param y defines the second coordinates (on Y axis)
  67938. * @param z defines the third coordinates (on Z axis)
  67939. */
  67940. constructor(
  67941. /**
  67942. * Defines the first coordinates (on X axis)
  67943. */
  67944. x?: number,
  67945. /**
  67946. * Defines the second coordinates (on Y axis)
  67947. */
  67948. y?: number,
  67949. /**
  67950. * Defines the third coordinates (on Z axis)
  67951. */
  67952. z?: number);
  67953. /**
  67954. * Creates a string representation of the Vector3
  67955. * @returns a string with the Vector3 coordinates.
  67956. */
  67957. toString(): string;
  67958. /**
  67959. * Gets the class name
  67960. * @returns the string "Vector3"
  67961. */
  67962. getClassName(): string;
  67963. /**
  67964. * Creates the Vector3 hash code
  67965. * @returns a number which tends to be unique between Vector3 instances
  67966. */
  67967. getHashCode(): number;
  67968. /**
  67969. * Creates an array containing three elements : the coordinates of the Vector3
  67970. * @returns a new array of numbers
  67971. */
  67972. asArray(): number[];
  67973. /**
  67974. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67975. * @param array defines the destination array
  67976. * @param index defines the offset in the destination array
  67977. * @returns the current Vector3
  67978. */
  67979. toArray(array: FloatArray, index?: number): Vector3;
  67980. /**
  67981. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67982. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67983. */
  67984. toQuaternion(): Quaternion;
  67985. /**
  67986. * Adds the given vector to the current Vector3
  67987. * @param otherVector defines the second operand
  67988. * @returns the current updated Vector3
  67989. */
  67990. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67991. /**
  67992. * Adds the given coordinates to the current Vector3
  67993. * @param x defines the x coordinate of the operand
  67994. * @param y defines the y coordinate of the operand
  67995. * @param z defines the z coordinate of the operand
  67996. * @returns the current updated Vector3
  67997. */
  67998. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67999. /**
  68000. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  68001. * @param otherVector defines the second operand
  68002. * @returns the resulting Vector3
  68003. */
  68004. add(otherVector: DeepImmutable<Vector3>): Vector3;
  68005. /**
  68006. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  68007. * @param otherVector defines the second operand
  68008. * @param result defines the Vector3 object where to store the result
  68009. * @returns the current Vector3
  68010. */
  68011. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68012. /**
  68013. * Subtract the given vector from the current Vector3
  68014. * @param otherVector defines the second operand
  68015. * @returns the current updated Vector3
  68016. */
  68017. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68018. /**
  68019. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  68020. * @param otherVector defines the second operand
  68021. * @returns the resulting Vector3
  68022. */
  68023. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  68024. /**
  68025. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  68026. * @param otherVector defines the second operand
  68027. * @param result defines the Vector3 object where to store the result
  68028. * @returns the current Vector3
  68029. */
  68030. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68031. /**
  68032. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  68033. * @param x defines the x coordinate of the operand
  68034. * @param y defines the y coordinate of the operand
  68035. * @param z defines the z coordinate of the operand
  68036. * @returns the resulting Vector3
  68037. */
  68038. subtractFromFloats(x: number, y: number, z: number): Vector3;
  68039. /**
  68040. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  68041. * @param x defines the x coordinate of the operand
  68042. * @param y defines the y coordinate of the operand
  68043. * @param z defines the z coordinate of the operand
  68044. * @param result defines the Vector3 object where to store the result
  68045. * @returns the current Vector3
  68046. */
  68047. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  68048. /**
  68049. * Gets a new Vector3 set with the current Vector3 negated coordinates
  68050. * @returns a new Vector3
  68051. */
  68052. negate(): Vector3;
  68053. /**
  68054. * Multiplies the Vector3 coordinates by the float "scale"
  68055. * @param scale defines the multiplier factor
  68056. * @returns the current updated Vector3
  68057. */
  68058. scaleInPlace(scale: number): Vector3;
  68059. /**
  68060. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  68061. * @param scale defines the multiplier factor
  68062. * @returns a new Vector3
  68063. */
  68064. scale(scale: number): Vector3;
  68065. /**
  68066. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  68067. * @param scale defines the multiplier factor
  68068. * @param result defines the Vector3 object where to store the result
  68069. * @returns the current Vector3
  68070. */
  68071. scaleToRef(scale: number, result: Vector3): Vector3;
  68072. /**
  68073. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  68074. * @param scale defines the scale factor
  68075. * @param result defines the Vector3 object where to store the result
  68076. * @returns the unmodified current Vector3
  68077. */
  68078. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  68079. /**
  68080. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  68081. * @param otherVector defines the second operand
  68082. * @returns true if both vectors are equals
  68083. */
  68084. equals(otherVector: DeepImmutable<Vector3>): boolean;
  68085. /**
  68086. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  68087. * @param otherVector defines the second operand
  68088. * @param epsilon defines the minimal distance to define values as equals
  68089. * @returns true if both vectors are distant less than epsilon
  68090. */
  68091. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  68092. /**
  68093. * Returns true if the current Vector3 coordinates equals the given floats
  68094. * @param x defines the x coordinate of the operand
  68095. * @param y defines the y coordinate of the operand
  68096. * @param z defines the z coordinate of the operand
  68097. * @returns true if both vectors are equals
  68098. */
  68099. equalsToFloats(x: number, y: number, z: number): boolean;
  68100. /**
  68101. * Multiplies the current Vector3 coordinates by the given ones
  68102. * @param otherVector defines the second operand
  68103. * @returns the current updated Vector3
  68104. */
  68105. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68106. /**
  68107. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  68108. * @param otherVector defines the second operand
  68109. * @returns the new Vector3
  68110. */
  68111. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  68112. /**
  68113. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  68114. * @param otherVector defines the second operand
  68115. * @param result defines the Vector3 object where to store the result
  68116. * @returns the current Vector3
  68117. */
  68118. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68119. /**
  68120. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  68121. * @param x defines the x coordinate of the operand
  68122. * @param y defines the y coordinate of the operand
  68123. * @param z defines the z coordinate of the operand
  68124. * @returns the new Vector3
  68125. */
  68126. multiplyByFloats(x: number, y: number, z: number): Vector3;
  68127. /**
  68128. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  68129. * @param otherVector defines the second operand
  68130. * @returns the new Vector3
  68131. */
  68132. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  68133. /**
  68134. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  68135. * @param otherVector defines the second operand
  68136. * @param result defines the Vector3 object where to store the result
  68137. * @returns the current Vector3
  68138. */
  68139. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68140. /**
  68141. * Divides the current Vector3 coordinates by the given ones.
  68142. * @param otherVector defines the second operand
  68143. * @returns the current updated Vector3
  68144. */
  68145. divideInPlace(otherVector: Vector3): Vector3;
  68146. /**
  68147. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  68148. * @param other defines the second operand
  68149. * @returns the current updated Vector3
  68150. */
  68151. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68152. /**
  68153. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  68154. * @param other defines the second operand
  68155. * @returns the current updated Vector3
  68156. */
  68157. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68158. /**
  68159. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68160. * @param x defines the x coordinate of the operand
  68161. * @param y defines the y coordinate of the operand
  68162. * @param z defines the z coordinate of the operand
  68163. * @returns the current updated Vector3
  68164. */
  68165. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68166. /**
  68167. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68168. * @param x defines the x coordinate of the operand
  68169. * @param y defines the y coordinate of the operand
  68170. * @param z defines the z coordinate of the operand
  68171. * @returns the current updated Vector3
  68172. */
  68173. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68174. /**
  68175. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68176. * Check if is non uniform within a certain amount of decimal places to account for this
  68177. * @param epsilon the amount the values can differ
  68178. * @returns if the the vector is non uniform to a certain number of decimal places
  68179. */
  68180. isNonUniformWithinEpsilon(epsilon: number): boolean;
  68181. /**
  68182. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68183. */
  68184. readonly isNonUniform: boolean;
  68185. /**
  68186. * Gets a new Vector3 from current Vector3 floored values
  68187. * @returns a new Vector3
  68188. */
  68189. floor(): Vector3;
  68190. /**
  68191. * Gets a new Vector3 from current Vector3 floored values
  68192. * @returns a new Vector3
  68193. */
  68194. fract(): Vector3;
  68195. /**
  68196. * Gets the length of the Vector3
  68197. * @returns the length of the Vector3
  68198. */
  68199. length(): number;
  68200. /**
  68201. * Gets the squared length of the Vector3
  68202. * @returns squared length of the Vector3
  68203. */
  68204. lengthSquared(): number;
  68205. /**
  68206. * Normalize the current Vector3.
  68207. * Please note that this is an in place operation.
  68208. * @returns the current updated Vector3
  68209. */
  68210. normalize(): Vector3;
  68211. /**
  68212. * Reorders the x y z properties of the vector in place
  68213. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68214. * @returns the current updated vector
  68215. */
  68216. reorderInPlace(order: string): this;
  68217. /**
  68218. * Rotates the vector around 0,0,0 by a quaternion
  68219. * @param quaternion the rotation quaternion
  68220. * @param result vector to store the result
  68221. * @returns the resulting vector
  68222. */
  68223. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  68224. /**
  68225. * Rotates a vector around a given point
  68226. * @param quaternion the rotation quaternion
  68227. * @param point the point to rotate around
  68228. * @param result vector to store the result
  68229. * @returns the resulting vector
  68230. */
  68231. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  68232. /**
  68233. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  68234. * The cross product is then orthogonal to both current and "other"
  68235. * @param other defines the right operand
  68236. * @returns the cross product
  68237. */
  68238. cross(other: Vector3): Vector3;
  68239. /**
  68240. * Normalize the current Vector3 with the given input length.
  68241. * Please note that this is an in place operation.
  68242. * @param len the length of the vector
  68243. * @returns the current updated Vector3
  68244. */
  68245. normalizeFromLength(len: number): Vector3;
  68246. /**
  68247. * Normalize the current Vector3 to a new vector
  68248. * @returns the new Vector3
  68249. */
  68250. normalizeToNew(): Vector3;
  68251. /**
  68252. * Normalize the current Vector3 to the reference
  68253. * @param reference define the Vector3 to update
  68254. * @returns the updated Vector3
  68255. */
  68256. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  68257. /**
  68258. * Creates a new Vector3 copied from the current Vector3
  68259. * @returns the new Vector3
  68260. */
  68261. clone(): Vector3;
  68262. /**
  68263. * Copies the given vector coordinates to the current Vector3 ones
  68264. * @param source defines the source Vector3
  68265. * @returns the current updated Vector3
  68266. */
  68267. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  68268. /**
  68269. * Copies the given floats to the current Vector3 coordinates
  68270. * @param x defines the x coordinate of the operand
  68271. * @param y defines the y coordinate of the operand
  68272. * @param z defines the z coordinate of the operand
  68273. * @returns the current updated Vector3
  68274. */
  68275. copyFromFloats(x: number, y: number, z: number): Vector3;
  68276. /**
  68277. * Copies the given floats to the current Vector3 coordinates
  68278. * @param x defines the x coordinate of the operand
  68279. * @param y defines the y coordinate of the operand
  68280. * @param z defines the z coordinate of the operand
  68281. * @returns the current updated Vector3
  68282. */
  68283. set(x: number, y: number, z: number): Vector3;
  68284. /**
  68285. * Copies the given float to the current Vector3 coordinates
  68286. * @param v defines the x, y and z coordinates of the operand
  68287. * @returns the current updated Vector3
  68288. */
  68289. setAll(v: number): Vector3;
  68290. /**
  68291. * Get the clip factor between two vectors
  68292. * @param vector0 defines the first operand
  68293. * @param vector1 defines the second operand
  68294. * @param axis defines the axis to use
  68295. * @param size defines the size along the axis
  68296. * @returns the clip factor
  68297. */
  68298. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  68299. /**
  68300. * Get angle between two vectors
  68301. * @param vector0 angle between vector0 and vector1
  68302. * @param vector1 angle between vector0 and vector1
  68303. * @param normal direction of the normal
  68304. * @return the angle between vector0 and vector1
  68305. */
  68306. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68307. /**
  68308. * Returns a new Vector3 set from the index "offset" of the given array
  68309. * @param array defines the source array
  68310. * @param offset defines the offset in the source array
  68311. * @returns the new Vector3
  68312. */
  68313. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68314. /**
  68315. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68316. * This function is deprecated. Use FromArray instead
  68317. * @param array defines the source array
  68318. * @param offset defines the offset in the source array
  68319. * @returns the new Vector3
  68320. */
  68321. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68322. /**
  68323. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68324. * @param array defines the source array
  68325. * @param offset defines the offset in the source array
  68326. * @param result defines the Vector3 where to store the result
  68327. */
  68328. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68329. /**
  68330. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68331. * This function is deprecated. Use FromArrayToRef instead.
  68332. * @param array defines the source array
  68333. * @param offset defines the offset in the source array
  68334. * @param result defines the Vector3 where to store the result
  68335. */
  68336. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68337. /**
  68338. * Sets the given vector "result" with the given floats.
  68339. * @param x defines the x coordinate of the source
  68340. * @param y defines the y coordinate of the source
  68341. * @param z defines the z coordinate of the source
  68342. * @param result defines the Vector3 where to store the result
  68343. */
  68344. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68345. /**
  68346. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68347. * @returns a new empty Vector3
  68348. */
  68349. static Zero(): Vector3;
  68350. /**
  68351. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68352. * @returns a new unit Vector3
  68353. */
  68354. static One(): Vector3;
  68355. /**
  68356. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68357. * @returns a new up Vector3
  68358. */
  68359. static Up(): Vector3;
  68360. /**
  68361. * Gets a up Vector3 that must not be updated
  68362. */
  68363. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68364. /**
  68365. * Gets a zero Vector3 that must not be updated
  68366. */
  68367. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68368. /**
  68369. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68370. * @returns a new down Vector3
  68371. */
  68372. static Down(): Vector3;
  68373. /**
  68374. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68375. * @returns a new forward Vector3
  68376. */
  68377. static Forward(): Vector3;
  68378. /**
  68379. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68380. * @returns a new forward Vector3
  68381. */
  68382. static Backward(): Vector3;
  68383. /**
  68384. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68385. * @returns a new right Vector3
  68386. */
  68387. static Right(): Vector3;
  68388. /**
  68389. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68390. * @returns a new left Vector3
  68391. */
  68392. static Left(): Vector3;
  68393. /**
  68394. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68395. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68396. * @param vector defines the Vector3 to transform
  68397. * @param transformation defines the transformation matrix
  68398. * @returns the transformed Vector3
  68399. */
  68400. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68401. /**
  68402. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68403. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68404. * @param vector defines the Vector3 to transform
  68405. * @param transformation defines the transformation matrix
  68406. * @param result defines the Vector3 where to store the result
  68407. */
  68408. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68409. /**
  68410. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68411. * This method computes tranformed coordinates only, not transformed direction vectors
  68412. * @param x define the x coordinate of the source vector
  68413. * @param y define the y coordinate of the source vector
  68414. * @param z define the z coordinate of the source vector
  68415. * @param transformation defines the transformation matrix
  68416. * @param result defines the Vector3 where to store the result
  68417. */
  68418. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68419. /**
  68420. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68421. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68422. * @param vector defines the Vector3 to transform
  68423. * @param transformation defines the transformation matrix
  68424. * @returns the new Vector3
  68425. */
  68426. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68427. /**
  68428. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68429. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68430. * @param vector defines the Vector3 to transform
  68431. * @param transformation defines the transformation matrix
  68432. * @param result defines the Vector3 where to store the result
  68433. */
  68434. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68435. /**
  68436. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68437. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68438. * @param x define the x coordinate of the source vector
  68439. * @param y define the y coordinate of the source vector
  68440. * @param z define the z coordinate of the source vector
  68441. * @param transformation defines the transformation matrix
  68442. * @param result defines the Vector3 where to store the result
  68443. */
  68444. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68445. /**
  68446. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68447. * @param value1 defines the first control point
  68448. * @param value2 defines the second control point
  68449. * @param value3 defines the third control point
  68450. * @param value4 defines the fourth control point
  68451. * @param amount defines the amount on the spline to use
  68452. * @returns the new Vector3
  68453. */
  68454. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68455. /**
  68456. * 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"
  68457. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68458. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68459. * @param value defines the current value
  68460. * @param min defines the lower range value
  68461. * @param max defines the upper range value
  68462. * @returns the new Vector3
  68463. */
  68464. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68465. /**
  68466. * 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"
  68467. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68468. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68469. * @param value defines the current value
  68470. * @param min defines the lower range value
  68471. * @param max defines the upper range value
  68472. * @param result defines the Vector3 where to store the result
  68473. */
  68474. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68475. /**
  68476. * Checks if a given vector is inside a specific range
  68477. * @param v defines the vector to test
  68478. * @param min defines the minimum range
  68479. * @param max defines the maximum range
  68480. */
  68481. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68482. /**
  68483. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68484. * @param value1 defines the first control point
  68485. * @param tangent1 defines the first tangent vector
  68486. * @param value2 defines the second control point
  68487. * @param tangent2 defines the second tangent vector
  68488. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68489. * @returns the new Vector3
  68490. */
  68491. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68492. /**
  68493. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68494. * @param start defines the start value
  68495. * @param end defines the end value
  68496. * @param amount max defines amount between both (between 0 and 1)
  68497. * @returns the new Vector3
  68498. */
  68499. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68500. /**
  68501. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68502. * @param start defines the start value
  68503. * @param end defines the end value
  68504. * @param amount max defines amount between both (between 0 and 1)
  68505. * @param result defines the Vector3 where to store the result
  68506. */
  68507. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68508. /**
  68509. * Returns the dot product (float) between the vectors "left" and "right"
  68510. * @param left defines the left operand
  68511. * @param right defines the right operand
  68512. * @returns the dot product
  68513. */
  68514. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68515. /**
  68516. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68517. * The cross product is then orthogonal to both "left" and "right"
  68518. * @param left defines the left operand
  68519. * @param right defines the right operand
  68520. * @returns the cross product
  68521. */
  68522. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68523. /**
  68524. * Sets the given vector "result" with the cross product of "left" and "right"
  68525. * The cross product is then orthogonal to both "left" and "right"
  68526. * @param left defines the left operand
  68527. * @param right defines the right operand
  68528. * @param result defines the Vector3 where to store the result
  68529. */
  68530. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68531. /**
  68532. * Returns a new Vector3 as the normalization of the given vector
  68533. * @param vector defines the Vector3 to normalize
  68534. * @returns the new Vector3
  68535. */
  68536. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68537. /**
  68538. * Sets the given vector "result" with the normalization of the given first vector
  68539. * @param vector defines the Vector3 to normalize
  68540. * @param result defines the Vector3 where to store the result
  68541. */
  68542. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68543. /**
  68544. * Project a Vector3 onto screen space
  68545. * @param vector defines the Vector3 to project
  68546. * @param world defines the world matrix to use
  68547. * @param transform defines the transform (view x projection) matrix to use
  68548. * @param viewport defines the screen viewport to use
  68549. * @returns the new Vector3
  68550. */
  68551. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68552. /** @hidden */
  68553. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68554. /**
  68555. * Unproject from screen space to object space
  68556. * @param source defines the screen space Vector3 to use
  68557. * @param viewportWidth defines the current width of the viewport
  68558. * @param viewportHeight defines the current height of the viewport
  68559. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68560. * @param transform defines the transform (view x projection) matrix to use
  68561. * @returns the new Vector3
  68562. */
  68563. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68564. /**
  68565. * Unproject from screen space to object space
  68566. * @param source defines the screen space Vector3 to use
  68567. * @param viewportWidth defines the current width of the viewport
  68568. * @param viewportHeight defines the current height of the viewport
  68569. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68570. * @param view defines the view matrix to use
  68571. * @param projection defines the projection matrix to use
  68572. * @returns the new Vector3
  68573. */
  68574. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68575. /**
  68576. * Unproject from screen space to object space
  68577. * @param source defines the screen space Vector3 to use
  68578. * @param viewportWidth defines the current width of the viewport
  68579. * @param viewportHeight defines the current height of the viewport
  68580. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68581. * @param view defines the view matrix to use
  68582. * @param projection defines the projection matrix to use
  68583. * @param result defines the Vector3 where to store the result
  68584. */
  68585. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68586. /**
  68587. * Unproject from screen space to object space
  68588. * @param sourceX defines the screen space x coordinate to use
  68589. * @param sourceY defines the screen space y coordinate to use
  68590. * @param sourceZ defines the screen space z coordinate to use
  68591. * @param viewportWidth defines the current width of the viewport
  68592. * @param viewportHeight defines the current height of the viewport
  68593. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68594. * @param view defines the view matrix to use
  68595. * @param projection defines the projection matrix to use
  68596. * @param result defines the Vector3 where to store the result
  68597. */
  68598. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68599. /**
  68600. * Gets the minimal coordinate values between two Vector3
  68601. * @param left defines the first operand
  68602. * @param right defines the second operand
  68603. * @returns the new Vector3
  68604. */
  68605. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68606. /**
  68607. * Gets the maximal coordinate values between two Vector3
  68608. * @param left defines the first operand
  68609. * @param right defines the second operand
  68610. * @returns the new Vector3
  68611. */
  68612. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68613. /**
  68614. * Returns the distance between the vectors "value1" and "value2"
  68615. * @param value1 defines the first operand
  68616. * @param value2 defines the second operand
  68617. * @returns the distance
  68618. */
  68619. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68620. /**
  68621. * Returns the squared distance between the vectors "value1" and "value2"
  68622. * @param value1 defines the first operand
  68623. * @param value2 defines the second operand
  68624. * @returns the squared distance
  68625. */
  68626. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68627. /**
  68628. * Returns a new Vector3 located at the center between "value1" and "value2"
  68629. * @param value1 defines the first operand
  68630. * @param value2 defines the second operand
  68631. * @returns the new Vector3
  68632. */
  68633. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68634. /**
  68635. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68636. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68637. * to something in order to rotate it from its local system to the given target system
  68638. * Note: axis1, axis2 and axis3 are normalized during this operation
  68639. * @param axis1 defines the first axis
  68640. * @param axis2 defines the second axis
  68641. * @param axis3 defines the third axis
  68642. * @returns a new Vector3
  68643. */
  68644. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68645. /**
  68646. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68647. * @param axis1 defines the first axis
  68648. * @param axis2 defines the second axis
  68649. * @param axis3 defines the third axis
  68650. * @param ref defines the Vector3 where to store the result
  68651. */
  68652. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68653. }
  68654. /**
  68655. * Vector4 class created for EulerAngle class conversion to Quaternion
  68656. */
  68657. export class Vector4 {
  68658. /** x value of the vector */
  68659. x: number;
  68660. /** y value of the vector */
  68661. y: number;
  68662. /** z value of the vector */
  68663. z: number;
  68664. /** w value of the vector */
  68665. w: number;
  68666. /**
  68667. * Creates a Vector4 object from the given floats.
  68668. * @param x x value of the vector
  68669. * @param y y value of the vector
  68670. * @param z z value of the vector
  68671. * @param w w value of the vector
  68672. */
  68673. constructor(
  68674. /** x value of the vector */
  68675. x: number,
  68676. /** y value of the vector */
  68677. y: number,
  68678. /** z value of the vector */
  68679. z: number,
  68680. /** w value of the vector */
  68681. w: number);
  68682. /**
  68683. * Returns the string with the Vector4 coordinates.
  68684. * @returns a string containing all the vector values
  68685. */
  68686. toString(): string;
  68687. /**
  68688. * Returns the string "Vector4".
  68689. * @returns "Vector4"
  68690. */
  68691. getClassName(): string;
  68692. /**
  68693. * Returns the Vector4 hash code.
  68694. * @returns a unique hash code
  68695. */
  68696. getHashCode(): number;
  68697. /**
  68698. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68699. * @returns the resulting array
  68700. */
  68701. asArray(): number[];
  68702. /**
  68703. * Populates the given array from the given index with the Vector4 coordinates.
  68704. * @param array array to populate
  68705. * @param index index of the array to start at (default: 0)
  68706. * @returns the Vector4.
  68707. */
  68708. toArray(array: FloatArray, index?: number): Vector4;
  68709. /**
  68710. * Adds the given vector to the current Vector4.
  68711. * @param otherVector the vector to add
  68712. * @returns the updated Vector4.
  68713. */
  68714. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68715. /**
  68716. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68717. * @param otherVector the vector to add
  68718. * @returns the resulting vector
  68719. */
  68720. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68721. /**
  68722. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68723. * @param otherVector the vector to add
  68724. * @param result the vector to store the result
  68725. * @returns the current Vector4.
  68726. */
  68727. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68728. /**
  68729. * Subtract in place the given vector from the current Vector4.
  68730. * @param otherVector the vector to subtract
  68731. * @returns the updated Vector4.
  68732. */
  68733. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68734. /**
  68735. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68736. * @param otherVector the vector to add
  68737. * @returns the new vector with the result
  68738. */
  68739. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68740. /**
  68741. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68742. * @param otherVector the vector to subtract
  68743. * @param result the vector to store the result
  68744. * @returns the current Vector4.
  68745. */
  68746. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68747. /**
  68748. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68749. */
  68750. /**
  68751. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68752. * @param x value to subtract
  68753. * @param y value to subtract
  68754. * @param z value to subtract
  68755. * @param w value to subtract
  68756. * @returns new vector containing the result
  68757. */
  68758. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68759. /**
  68760. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68761. * @param x value to subtract
  68762. * @param y value to subtract
  68763. * @param z value to subtract
  68764. * @param w value to subtract
  68765. * @param result the vector to store the result in
  68766. * @returns the current Vector4.
  68767. */
  68768. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68769. /**
  68770. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68771. * @returns a new vector with the negated values
  68772. */
  68773. negate(): Vector4;
  68774. /**
  68775. * Multiplies the current Vector4 coordinates by scale (float).
  68776. * @param scale the number to scale with
  68777. * @returns the updated Vector4.
  68778. */
  68779. scaleInPlace(scale: number): Vector4;
  68780. /**
  68781. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68782. * @param scale the number to scale with
  68783. * @returns a new vector with the result
  68784. */
  68785. scale(scale: number): Vector4;
  68786. /**
  68787. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68788. * @param scale the number to scale with
  68789. * @param result a vector to store the result in
  68790. * @returns the current Vector4.
  68791. */
  68792. scaleToRef(scale: number, result: Vector4): Vector4;
  68793. /**
  68794. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68795. * @param scale defines the scale factor
  68796. * @param result defines the Vector4 object where to store the result
  68797. * @returns the unmodified current Vector4
  68798. */
  68799. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68800. /**
  68801. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68802. * @param otherVector the vector to compare against
  68803. * @returns true if they are equal
  68804. */
  68805. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68806. /**
  68807. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68808. * @param otherVector vector to compare against
  68809. * @param epsilon (Default: very small number)
  68810. * @returns true if they are equal
  68811. */
  68812. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68813. /**
  68814. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68815. * @param x x value to compare against
  68816. * @param y y value to compare against
  68817. * @param z z value to compare against
  68818. * @param w w value to compare against
  68819. * @returns true if equal
  68820. */
  68821. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68822. /**
  68823. * Multiplies in place the current Vector4 by the given one.
  68824. * @param otherVector vector to multiple with
  68825. * @returns the updated Vector4.
  68826. */
  68827. multiplyInPlace(otherVector: Vector4): Vector4;
  68828. /**
  68829. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68830. * @param otherVector vector to multiple with
  68831. * @returns resulting new vector
  68832. */
  68833. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68834. /**
  68835. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68836. * @param otherVector vector to multiple with
  68837. * @param result vector to store the result
  68838. * @returns the current Vector4.
  68839. */
  68840. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68841. /**
  68842. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68843. * @param x x value multiply with
  68844. * @param y y value multiply with
  68845. * @param z z value multiply with
  68846. * @param w w value multiply with
  68847. * @returns resulting new vector
  68848. */
  68849. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68850. /**
  68851. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68852. * @param otherVector vector to devide with
  68853. * @returns resulting new vector
  68854. */
  68855. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68856. /**
  68857. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68858. * @param otherVector vector to devide with
  68859. * @param result vector to store the result
  68860. * @returns the current Vector4.
  68861. */
  68862. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68863. /**
  68864. * Divides the current Vector3 coordinates by the given ones.
  68865. * @param otherVector vector to devide with
  68866. * @returns the updated Vector3.
  68867. */
  68868. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68869. /**
  68870. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68871. * @param other defines the second operand
  68872. * @returns the current updated Vector4
  68873. */
  68874. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68875. /**
  68876. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68877. * @param other defines the second operand
  68878. * @returns the current updated Vector4
  68879. */
  68880. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68881. /**
  68882. * Gets a new Vector4 from current Vector4 floored values
  68883. * @returns a new Vector4
  68884. */
  68885. floor(): Vector4;
  68886. /**
  68887. * Gets a new Vector4 from current Vector3 floored values
  68888. * @returns a new Vector4
  68889. */
  68890. fract(): Vector4;
  68891. /**
  68892. * Returns the Vector4 length (float).
  68893. * @returns the length
  68894. */
  68895. length(): number;
  68896. /**
  68897. * Returns the Vector4 squared length (float).
  68898. * @returns the length squared
  68899. */
  68900. lengthSquared(): number;
  68901. /**
  68902. * Normalizes in place the Vector4.
  68903. * @returns the updated Vector4.
  68904. */
  68905. normalize(): Vector4;
  68906. /**
  68907. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68908. * @returns this converted to a new vector3
  68909. */
  68910. toVector3(): Vector3;
  68911. /**
  68912. * Returns a new Vector4 copied from the current one.
  68913. * @returns the new cloned vector
  68914. */
  68915. clone(): Vector4;
  68916. /**
  68917. * Updates the current Vector4 with the given one coordinates.
  68918. * @param source the source vector to copy from
  68919. * @returns the updated Vector4.
  68920. */
  68921. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68922. /**
  68923. * Updates the current Vector4 coordinates with the given floats.
  68924. * @param x float to copy from
  68925. * @param y float to copy from
  68926. * @param z float to copy from
  68927. * @param w float to copy from
  68928. * @returns the updated Vector4.
  68929. */
  68930. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68931. /**
  68932. * Updates the current Vector4 coordinates with the given floats.
  68933. * @param x float to set from
  68934. * @param y float to set from
  68935. * @param z float to set from
  68936. * @param w float to set from
  68937. * @returns the updated Vector4.
  68938. */
  68939. set(x: number, y: number, z: number, w: number): Vector4;
  68940. /**
  68941. * Copies the given float to the current Vector3 coordinates
  68942. * @param v defines the x, y, z and w coordinates of the operand
  68943. * @returns the current updated Vector3
  68944. */
  68945. setAll(v: number): Vector4;
  68946. /**
  68947. * Returns a new Vector4 set from the starting index of the given array.
  68948. * @param array the array to pull values from
  68949. * @param offset the offset into the array to start at
  68950. * @returns the new vector
  68951. */
  68952. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68953. /**
  68954. * Updates the given vector "result" from the starting index of the given array.
  68955. * @param array the array to pull values from
  68956. * @param offset the offset into the array to start at
  68957. * @param result the vector to store the result in
  68958. */
  68959. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68960. /**
  68961. * Updates the given vector "result" from the starting index of the given Float32Array.
  68962. * @param array the array to pull values from
  68963. * @param offset the offset into the array to start at
  68964. * @param result the vector to store the result in
  68965. */
  68966. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68967. /**
  68968. * Updates the given vector "result" coordinates from the given floats.
  68969. * @param x float to set from
  68970. * @param y float to set from
  68971. * @param z float to set from
  68972. * @param w float to set from
  68973. * @param result the vector to the floats in
  68974. */
  68975. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68976. /**
  68977. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68978. * @returns the new vector
  68979. */
  68980. static Zero(): Vector4;
  68981. /**
  68982. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68983. * @returns the new vector
  68984. */
  68985. static One(): Vector4;
  68986. /**
  68987. * Returns a new normalized Vector4 from the given one.
  68988. * @param vector the vector to normalize
  68989. * @returns the vector
  68990. */
  68991. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68992. /**
  68993. * Updates the given vector "result" from the normalization of the given one.
  68994. * @param vector the vector to normalize
  68995. * @param result the vector to store the result in
  68996. */
  68997. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68998. /**
  68999. * Returns a vector with the minimum values from the left and right vectors
  69000. * @param left left vector to minimize
  69001. * @param right right vector to minimize
  69002. * @returns a new vector with the minimum of the left and right vector values
  69003. */
  69004. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69005. /**
  69006. * Returns a vector with the maximum values from the left and right vectors
  69007. * @param left left vector to maximize
  69008. * @param right right vector to maximize
  69009. * @returns a new vector with the maximum of the left and right vector values
  69010. */
  69011. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69012. /**
  69013. * Returns the distance (float) between the vectors "value1" and "value2".
  69014. * @param value1 value to calulate the distance between
  69015. * @param value2 value to calulate the distance between
  69016. * @return the distance between the two vectors
  69017. */
  69018. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69019. /**
  69020. * Returns the squared distance (float) between the vectors "value1" and "value2".
  69021. * @param value1 value to calulate the distance between
  69022. * @param value2 value to calulate the distance between
  69023. * @return the distance between the two vectors squared
  69024. */
  69025. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69026. /**
  69027. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  69028. * @param value1 value to calulate the center between
  69029. * @param value2 value to calulate the center between
  69030. * @return the center between the two vectors
  69031. */
  69032. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  69033. /**
  69034. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  69035. * This methods computes transformed normalized direction vectors only.
  69036. * @param vector the vector to transform
  69037. * @param transformation the transformation matrix to apply
  69038. * @returns the new vector
  69039. */
  69040. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  69041. /**
  69042. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  69043. * This methods computes transformed normalized direction vectors only.
  69044. * @param vector the vector to transform
  69045. * @param transformation the transformation matrix to apply
  69046. * @param result the vector to store the result in
  69047. */
  69048. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69049. /**
  69050. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  69051. * This methods computes transformed normalized direction vectors only.
  69052. * @param x value to transform
  69053. * @param y value to transform
  69054. * @param z value to transform
  69055. * @param w value to transform
  69056. * @param transformation the transformation matrix to apply
  69057. * @param result the vector to store the results in
  69058. */
  69059. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69060. /**
  69061. * Creates a new Vector4 from a Vector3
  69062. * @param source defines the source data
  69063. * @param w defines the 4th component (default is 0)
  69064. * @returns a new Vector4
  69065. */
  69066. static FromVector3(source: Vector3, w?: number): Vector4;
  69067. }
  69068. /**
  69069. * Class used to store quaternion data
  69070. * @see https://en.wikipedia.org/wiki/Quaternion
  69071. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  69072. */
  69073. export class Quaternion {
  69074. /** defines the first component (0 by default) */
  69075. x: number;
  69076. /** defines the second component (0 by default) */
  69077. y: number;
  69078. /** defines the third component (0 by default) */
  69079. z: number;
  69080. /** defines the fourth component (1.0 by default) */
  69081. w: number;
  69082. /**
  69083. * Creates a new Quaternion from the given floats
  69084. * @param x defines the first component (0 by default)
  69085. * @param y defines the second component (0 by default)
  69086. * @param z defines the third component (0 by default)
  69087. * @param w defines the fourth component (1.0 by default)
  69088. */
  69089. constructor(
  69090. /** defines the first component (0 by default) */
  69091. x?: number,
  69092. /** defines the second component (0 by default) */
  69093. y?: number,
  69094. /** defines the third component (0 by default) */
  69095. z?: number,
  69096. /** defines the fourth component (1.0 by default) */
  69097. w?: number);
  69098. /**
  69099. * Gets a string representation for the current quaternion
  69100. * @returns a string with the Quaternion coordinates
  69101. */
  69102. toString(): string;
  69103. /**
  69104. * Gets the class name of the quaternion
  69105. * @returns the string "Quaternion"
  69106. */
  69107. getClassName(): string;
  69108. /**
  69109. * Gets a hash code for this quaternion
  69110. * @returns the quaternion hash code
  69111. */
  69112. getHashCode(): number;
  69113. /**
  69114. * Copy the quaternion to an array
  69115. * @returns a new array populated with 4 elements from the quaternion coordinates
  69116. */
  69117. asArray(): number[];
  69118. /**
  69119. * Check if two quaternions are equals
  69120. * @param otherQuaternion defines the second operand
  69121. * @return true if the current quaternion and the given one coordinates are strictly equals
  69122. */
  69123. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  69124. /**
  69125. * Clone the current quaternion
  69126. * @returns a new quaternion copied from the current one
  69127. */
  69128. clone(): Quaternion;
  69129. /**
  69130. * Copy a quaternion to the current one
  69131. * @param other defines the other quaternion
  69132. * @returns the updated current quaternion
  69133. */
  69134. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  69135. /**
  69136. * Updates the current quaternion with the given float coordinates
  69137. * @param x defines the x coordinate
  69138. * @param y defines the y coordinate
  69139. * @param z defines the z coordinate
  69140. * @param w defines the w coordinate
  69141. * @returns the updated current quaternion
  69142. */
  69143. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  69144. /**
  69145. * Updates the current quaternion from the given float coordinates
  69146. * @param x defines the x coordinate
  69147. * @param y defines the y coordinate
  69148. * @param z defines the z coordinate
  69149. * @param w defines the w coordinate
  69150. * @returns the updated current quaternion
  69151. */
  69152. set(x: number, y: number, z: number, w: number): Quaternion;
  69153. /**
  69154. * Adds two quaternions
  69155. * @param other defines the second operand
  69156. * @returns a new quaternion as the addition result of the given one and the current quaternion
  69157. */
  69158. add(other: DeepImmutable<Quaternion>): Quaternion;
  69159. /**
  69160. * Add a quaternion to the current one
  69161. * @param other defines the quaternion to add
  69162. * @returns the current quaternion
  69163. */
  69164. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  69165. /**
  69166. * Subtract two quaternions
  69167. * @param other defines the second operand
  69168. * @returns a new quaternion as the subtraction result of the given one from the current one
  69169. */
  69170. subtract(other: Quaternion): Quaternion;
  69171. /**
  69172. * Multiplies the current quaternion by a scale factor
  69173. * @param value defines the scale factor
  69174. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  69175. */
  69176. scale(value: number): Quaternion;
  69177. /**
  69178. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  69179. * @param scale defines the scale factor
  69180. * @param result defines the Quaternion object where to store the result
  69181. * @returns the unmodified current quaternion
  69182. */
  69183. scaleToRef(scale: number, result: Quaternion): Quaternion;
  69184. /**
  69185. * Multiplies in place the current quaternion by a scale factor
  69186. * @param value defines the scale factor
  69187. * @returns the current modified quaternion
  69188. */
  69189. scaleInPlace(value: number): Quaternion;
  69190. /**
  69191. * Scale the current quaternion values by a factor and add the result to a given quaternion
  69192. * @param scale defines the scale factor
  69193. * @param result defines the Quaternion object where to store the result
  69194. * @returns the unmodified current quaternion
  69195. */
  69196. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  69197. /**
  69198. * Multiplies two quaternions
  69199. * @param q1 defines the second operand
  69200. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  69201. */
  69202. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  69203. /**
  69204. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  69205. * @param q1 defines the second operand
  69206. * @param result defines the target quaternion
  69207. * @returns the current quaternion
  69208. */
  69209. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  69210. /**
  69211. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  69212. * @param q1 defines the second operand
  69213. * @returns the currentupdated quaternion
  69214. */
  69215. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  69216. /**
  69217. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  69218. * @param ref defines the target quaternion
  69219. * @returns the current quaternion
  69220. */
  69221. conjugateToRef(ref: Quaternion): Quaternion;
  69222. /**
  69223. * Conjugates in place (1-q) the current quaternion
  69224. * @returns the current updated quaternion
  69225. */
  69226. conjugateInPlace(): Quaternion;
  69227. /**
  69228. * Conjugates in place (1-q) the current quaternion
  69229. * @returns a new quaternion
  69230. */
  69231. conjugate(): Quaternion;
  69232. /**
  69233. * Gets length of current quaternion
  69234. * @returns the quaternion length (float)
  69235. */
  69236. length(): number;
  69237. /**
  69238. * Normalize in place the current quaternion
  69239. * @returns the current updated quaternion
  69240. */
  69241. normalize(): Quaternion;
  69242. /**
  69243. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  69244. * @param order is a reserved parameter and is ignore for now
  69245. * @returns a new Vector3 containing the Euler angles
  69246. */
  69247. toEulerAngles(order?: string): Vector3;
  69248. /**
  69249. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  69250. * @param result defines the vector which will be filled with the Euler angles
  69251. * @param order is a reserved parameter and is ignore for now
  69252. * @returns the current unchanged quaternion
  69253. */
  69254. toEulerAnglesToRef(result: Vector3): Quaternion;
  69255. /**
  69256. * Updates the given rotation matrix with the current quaternion values
  69257. * @param result defines the target matrix
  69258. * @returns the current unchanged quaternion
  69259. */
  69260. toRotationMatrix(result: Matrix): Quaternion;
  69261. /**
  69262. * Updates the current quaternion from the given rotation matrix values
  69263. * @param matrix defines the source matrix
  69264. * @returns the current updated quaternion
  69265. */
  69266. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69267. /**
  69268. * Creates a new quaternion from a rotation matrix
  69269. * @param matrix defines the source matrix
  69270. * @returns a new quaternion created from the given rotation matrix values
  69271. */
  69272. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69273. /**
  69274. * Updates the given quaternion with the given rotation matrix values
  69275. * @param matrix defines the source matrix
  69276. * @param result defines the target quaternion
  69277. */
  69278. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  69279. /**
  69280. * Returns the dot product (float) between the quaternions "left" and "right"
  69281. * @param left defines the left operand
  69282. * @param right defines the right operand
  69283. * @returns the dot product
  69284. */
  69285. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  69286. /**
  69287. * Checks if the two quaternions are close to each other
  69288. * @param quat0 defines the first quaternion to check
  69289. * @param quat1 defines the second quaternion to check
  69290. * @returns true if the two quaternions are close to each other
  69291. */
  69292. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  69293. /**
  69294. * Creates an empty quaternion
  69295. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  69296. */
  69297. static Zero(): Quaternion;
  69298. /**
  69299. * Inverse a given quaternion
  69300. * @param q defines the source quaternion
  69301. * @returns a new quaternion as the inverted current quaternion
  69302. */
  69303. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69304. /**
  69305. * Inverse a given quaternion
  69306. * @param q defines the source quaternion
  69307. * @param result the quaternion the result will be stored in
  69308. * @returns the result quaternion
  69309. */
  69310. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69311. /**
  69312. * Creates an identity quaternion
  69313. * @returns the identity quaternion
  69314. */
  69315. static Identity(): Quaternion;
  69316. /**
  69317. * Gets a boolean indicating if the given quaternion is identity
  69318. * @param quaternion defines the quaternion to check
  69319. * @returns true if the quaternion is identity
  69320. */
  69321. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69322. /**
  69323. * Creates a quaternion from a rotation around an axis
  69324. * @param axis defines the axis to use
  69325. * @param angle defines the angle to use
  69326. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69327. */
  69328. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69329. /**
  69330. * Creates a rotation around an axis and stores it into the given quaternion
  69331. * @param axis defines the axis to use
  69332. * @param angle defines the angle to use
  69333. * @param result defines the target quaternion
  69334. * @returns the target quaternion
  69335. */
  69336. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69337. /**
  69338. * Creates a new quaternion from data stored into an array
  69339. * @param array defines the data source
  69340. * @param offset defines the offset in the source array where the data starts
  69341. * @returns a new quaternion
  69342. */
  69343. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69344. /**
  69345. * Create a quaternion from Euler rotation angles
  69346. * @param x Pitch
  69347. * @param y Yaw
  69348. * @param z Roll
  69349. * @returns the new Quaternion
  69350. */
  69351. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69352. /**
  69353. * Updates a quaternion from Euler rotation angles
  69354. * @param x Pitch
  69355. * @param y Yaw
  69356. * @param z Roll
  69357. * @param result the quaternion to store the result
  69358. * @returns the updated quaternion
  69359. */
  69360. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69361. /**
  69362. * Create a quaternion from Euler rotation vector
  69363. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69364. * @returns the new Quaternion
  69365. */
  69366. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69367. /**
  69368. * Updates a quaternion from Euler rotation vector
  69369. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69370. * @param result the quaternion to store the result
  69371. * @returns the updated quaternion
  69372. */
  69373. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69374. /**
  69375. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69376. * @param yaw defines the rotation around Y axis
  69377. * @param pitch defines the rotation around X axis
  69378. * @param roll defines the rotation around Z axis
  69379. * @returns the new quaternion
  69380. */
  69381. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69382. /**
  69383. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69384. * @param yaw defines the rotation around Y axis
  69385. * @param pitch defines the rotation around X axis
  69386. * @param roll defines the rotation around Z axis
  69387. * @param result defines the target quaternion
  69388. */
  69389. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69390. /**
  69391. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69392. * @param alpha defines the rotation around first axis
  69393. * @param beta defines the rotation around second axis
  69394. * @param gamma defines the rotation around third axis
  69395. * @returns the new quaternion
  69396. */
  69397. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69398. /**
  69399. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69400. * @param alpha defines the rotation around first axis
  69401. * @param beta defines the rotation around second axis
  69402. * @param gamma defines the rotation around third axis
  69403. * @param result defines the target quaternion
  69404. */
  69405. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69406. /**
  69407. * 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)
  69408. * @param axis1 defines the first axis
  69409. * @param axis2 defines the second axis
  69410. * @param axis3 defines the third axis
  69411. * @returns the new quaternion
  69412. */
  69413. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69414. /**
  69415. * 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
  69416. * @param axis1 defines the first axis
  69417. * @param axis2 defines the second axis
  69418. * @param axis3 defines the third axis
  69419. * @param ref defines the target quaternion
  69420. */
  69421. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69422. /**
  69423. * Interpolates between two quaternions
  69424. * @param left defines first quaternion
  69425. * @param right defines second quaternion
  69426. * @param amount defines the gradient to use
  69427. * @returns the new interpolated quaternion
  69428. */
  69429. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69430. /**
  69431. * Interpolates between two quaternions and stores it into a target quaternion
  69432. * @param left defines first quaternion
  69433. * @param right defines second quaternion
  69434. * @param amount defines the gradient to use
  69435. * @param result defines the target quaternion
  69436. */
  69437. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69438. /**
  69439. * Interpolate between two quaternions using Hermite interpolation
  69440. * @param value1 defines first quaternion
  69441. * @param tangent1 defines the incoming tangent
  69442. * @param value2 defines second quaternion
  69443. * @param tangent2 defines the outgoing tangent
  69444. * @param amount defines the target quaternion
  69445. * @returns the new interpolated quaternion
  69446. */
  69447. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69448. }
  69449. /**
  69450. * Class used to store matrix data (4x4)
  69451. */
  69452. export class Matrix {
  69453. private static _updateFlagSeed;
  69454. private static _identityReadOnly;
  69455. private _isIdentity;
  69456. private _isIdentityDirty;
  69457. private _isIdentity3x2;
  69458. private _isIdentity3x2Dirty;
  69459. /**
  69460. * Gets the update flag of the matrix which is an unique number for the matrix.
  69461. * It will be incremented every time the matrix data change.
  69462. * You can use it to speed the comparison between two versions of the same matrix.
  69463. */
  69464. updateFlag: number;
  69465. private readonly _m;
  69466. /**
  69467. * Gets the internal data of the matrix
  69468. */
  69469. readonly m: DeepImmutable<Float32Array>;
  69470. /** @hidden */
  69471. _markAsUpdated(): void;
  69472. /** @hidden */
  69473. private _updateIdentityStatus;
  69474. /**
  69475. * Creates an empty matrix (filled with zeros)
  69476. */
  69477. constructor();
  69478. /**
  69479. * Check if the current matrix is identity
  69480. * @returns true is the matrix is the identity matrix
  69481. */
  69482. isIdentity(): boolean;
  69483. /**
  69484. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69485. * @returns true is the matrix is the identity matrix
  69486. */
  69487. isIdentityAs3x2(): boolean;
  69488. /**
  69489. * Gets the determinant of the matrix
  69490. * @returns the matrix determinant
  69491. */
  69492. determinant(): number;
  69493. /**
  69494. * Returns the matrix as a Float32Array
  69495. * @returns the matrix underlying array
  69496. */
  69497. toArray(): DeepImmutable<Float32Array>;
  69498. /**
  69499. * Returns the matrix as a Float32Array
  69500. * @returns the matrix underlying array.
  69501. */
  69502. asArray(): DeepImmutable<Float32Array>;
  69503. /**
  69504. * Inverts the current matrix in place
  69505. * @returns the current inverted matrix
  69506. */
  69507. invert(): Matrix;
  69508. /**
  69509. * Sets all the matrix elements to zero
  69510. * @returns the current matrix
  69511. */
  69512. reset(): Matrix;
  69513. /**
  69514. * Adds the current matrix with a second one
  69515. * @param other defines the matrix to add
  69516. * @returns a new matrix as the addition of the current matrix and the given one
  69517. */
  69518. add(other: DeepImmutable<Matrix>): Matrix;
  69519. /**
  69520. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69521. * @param other defines the matrix to add
  69522. * @param result defines the target matrix
  69523. * @returns the current matrix
  69524. */
  69525. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69526. /**
  69527. * Adds in place the given matrix to the current matrix
  69528. * @param other defines the second operand
  69529. * @returns the current updated matrix
  69530. */
  69531. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69532. /**
  69533. * Sets the given matrix to the current inverted Matrix
  69534. * @param other defines the target matrix
  69535. * @returns the unmodified current matrix
  69536. */
  69537. invertToRef(other: Matrix): Matrix;
  69538. /**
  69539. * add a value at the specified position in the current Matrix
  69540. * @param index the index of the value within the matrix. between 0 and 15.
  69541. * @param value the value to be added
  69542. * @returns the current updated matrix
  69543. */
  69544. addAtIndex(index: number, value: number): Matrix;
  69545. /**
  69546. * mutiply the specified position in the current Matrix by a value
  69547. * @param index the index of the value within the matrix. between 0 and 15.
  69548. * @param value the value to be added
  69549. * @returns the current updated matrix
  69550. */
  69551. multiplyAtIndex(index: number, value: number): Matrix;
  69552. /**
  69553. * Inserts the translation vector (using 3 floats) in the current matrix
  69554. * @param x defines the 1st component of the translation
  69555. * @param y defines the 2nd component of the translation
  69556. * @param z defines the 3rd component of the translation
  69557. * @returns the current updated matrix
  69558. */
  69559. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69560. /**
  69561. * Adds the translation vector (using 3 floats) in the current matrix
  69562. * @param x defines the 1st component of the translation
  69563. * @param y defines the 2nd component of the translation
  69564. * @param z defines the 3rd component of the translation
  69565. * @returns the current updated matrix
  69566. */
  69567. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69568. /**
  69569. * Inserts the translation vector in the current matrix
  69570. * @param vector3 defines the translation to insert
  69571. * @returns the current updated matrix
  69572. */
  69573. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69574. /**
  69575. * Gets the translation value of the current matrix
  69576. * @returns a new Vector3 as the extracted translation from the matrix
  69577. */
  69578. getTranslation(): Vector3;
  69579. /**
  69580. * Fill a Vector3 with the extracted translation from the matrix
  69581. * @param result defines the Vector3 where to store the translation
  69582. * @returns the current matrix
  69583. */
  69584. getTranslationToRef(result: Vector3): Matrix;
  69585. /**
  69586. * Remove rotation and scaling part from the matrix
  69587. * @returns the updated matrix
  69588. */
  69589. removeRotationAndScaling(): Matrix;
  69590. /**
  69591. * Multiply two matrices
  69592. * @param other defines the second operand
  69593. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69594. */
  69595. multiply(other: DeepImmutable<Matrix>): Matrix;
  69596. /**
  69597. * Copy the current matrix from the given one
  69598. * @param other defines the source matrix
  69599. * @returns the current updated matrix
  69600. */
  69601. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69602. /**
  69603. * Populates the given array from the starting index with the current matrix values
  69604. * @param array defines the target array
  69605. * @param offset defines the offset in the target array where to start storing values
  69606. * @returns the current matrix
  69607. */
  69608. copyToArray(array: Float32Array, offset?: number): Matrix;
  69609. /**
  69610. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69611. * @param other defines the second operand
  69612. * @param result defines the matrix where to store the multiplication
  69613. * @returns the current matrix
  69614. */
  69615. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69616. /**
  69617. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69618. * @param other defines the second operand
  69619. * @param result defines the array where to store the multiplication
  69620. * @param offset defines the offset in the target array where to start storing values
  69621. * @returns the current matrix
  69622. */
  69623. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69624. /**
  69625. * Check equality between this matrix and a second one
  69626. * @param value defines the second matrix to compare
  69627. * @returns true is the current matrix and the given one values are strictly equal
  69628. */
  69629. equals(value: DeepImmutable<Matrix>): boolean;
  69630. /**
  69631. * Clone the current matrix
  69632. * @returns a new matrix from the current matrix
  69633. */
  69634. clone(): Matrix;
  69635. /**
  69636. * Returns the name of the current matrix class
  69637. * @returns the string "Matrix"
  69638. */
  69639. getClassName(): string;
  69640. /**
  69641. * Gets the hash code of the current matrix
  69642. * @returns the hash code
  69643. */
  69644. getHashCode(): number;
  69645. /**
  69646. * Decomposes the current Matrix into a translation, rotation and scaling components
  69647. * @param scale defines the scale vector3 given as a reference to update
  69648. * @param rotation defines the rotation quaternion given as a reference to update
  69649. * @param translation defines the translation vector3 given as a reference to update
  69650. * @returns true if operation was successful
  69651. */
  69652. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69653. /**
  69654. * Gets specific row of the matrix
  69655. * @param index defines the number of the row to get
  69656. * @returns the index-th row of the current matrix as a new Vector4
  69657. */
  69658. getRow(index: number): Nullable<Vector4>;
  69659. /**
  69660. * Sets the index-th row of the current matrix to the vector4 values
  69661. * @param index defines the number of the row to set
  69662. * @param row defines the target vector4
  69663. * @returns the updated current matrix
  69664. */
  69665. setRow(index: number, row: Vector4): Matrix;
  69666. /**
  69667. * Compute the transpose of the matrix
  69668. * @returns the new transposed matrix
  69669. */
  69670. transpose(): Matrix;
  69671. /**
  69672. * Compute the transpose of the matrix and store it in a given matrix
  69673. * @param result defines the target matrix
  69674. * @returns the current matrix
  69675. */
  69676. transposeToRef(result: Matrix): Matrix;
  69677. /**
  69678. * Sets the index-th row of the current matrix with the given 4 x float values
  69679. * @param index defines the row index
  69680. * @param x defines the x component to set
  69681. * @param y defines the y component to set
  69682. * @param z defines the z component to set
  69683. * @param w defines the w component to set
  69684. * @returns the updated current matrix
  69685. */
  69686. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69687. /**
  69688. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69689. * @param scale defines the scale factor
  69690. * @returns a new matrix
  69691. */
  69692. scale(scale: number): Matrix;
  69693. /**
  69694. * Scale the current matrix values by a factor to a given result matrix
  69695. * @param scale defines the scale factor
  69696. * @param result defines the matrix to store the result
  69697. * @returns the current matrix
  69698. */
  69699. scaleToRef(scale: number, result: Matrix): Matrix;
  69700. /**
  69701. * Scale the current matrix values by a factor and add the result to a given matrix
  69702. * @param scale defines the scale factor
  69703. * @param result defines the Matrix to store the result
  69704. * @returns the current matrix
  69705. */
  69706. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69707. /**
  69708. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69709. * @param ref matrix to store the result
  69710. */
  69711. toNormalMatrix(ref: Matrix): void;
  69712. /**
  69713. * Gets only rotation part of the current matrix
  69714. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69715. */
  69716. getRotationMatrix(): Matrix;
  69717. /**
  69718. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69719. * @param result defines the target matrix to store data to
  69720. * @returns the current matrix
  69721. */
  69722. getRotationMatrixToRef(result: Matrix): Matrix;
  69723. /**
  69724. * Toggles model matrix from being right handed to left handed in place and vice versa
  69725. */
  69726. toggleModelMatrixHandInPlace(): void;
  69727. /**
  69728. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69729. */
  69730. toggleProjectionMatrixHandInPlace(): void;
  69731. /**
  69732. * Creates a matrix from an array
  69733. * @param array defines the source array
  69734. * @param offset defines an offset in the source array
  69735. * @returns a new Matrix set from the starting index of the given array
  69736. */
  69737. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69738. /**
  69739. * Copy the content of an array into a given matrix
  69740. * @param array defines the source array
  69741. * @param offset defines an offset in the source array
  69742. * @param result defines the target matrix
  69743. */
  69744. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69745. /**
  69746. * Stores an array into a matrix after having multiplied each component by a given factor
  69747. * @param array defines the source array
  69748. * @param offset defines the offset in the source array
  69749. * @param scale defines the scaling factor
  69750. * @param result defines the target matrix
  69751. */
  69752. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69753. /**
  69754. * Gets an identity matrix that must not be updated
  69755. */
  69756. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69757. /**
  69758. * Stores a list of values (16) inside a given matrix
  69759. * @param initialM11 defines 1st value of 1st row
  69760. * @param initialM12 defines 2nd value of 1st row
  69761. * @param initialM13 defines 3rd value of 1st row
  69762. * @param initialM14 defines 4th value of 1st row
  69763. * @param initialM21 defines 1st value of 2nd row
  69764. * @param initialM22 defines 2nd value of 2nd row
  69765. * @param initialM23 defines 3rd value of 2nd row
  69766. * @param initialM24 defines 4th value of 2nd row
  69767. * @param initialM31 defines 1st value of 3rd row
  69768. * @param initialM32 defines 2nd value of 3rd row
  69769. * @param initialM33 defines 3rd value of 3rd row
  69770. * @param initialM34 defines 4th value of 3rd row
  69771. * @param initialM41 defines 1st value of 4th row
  69772. * @param initialM42 defines 2nd value of 4th row
  69773. * @param initialM43 defines 3rd value of 4th row
  69774. * @param initialM44 defines 4th value of 4th row
  69775. * @param result defines the target matrix
  69776. */
  69777. 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;
  69778. /**
  69779. * Creates new matrix from a list of values (16)
  69780. * @param initialM11 defines 1st value of 1st row
  69781. * @param initialM12 defines 2nd value of 1st row
  69782. * @param initialM13 defines 3rd value of 1st row
  69783. * @param initialM14 defines 4th value of 1st row
  69784. * @param initialM21 defines 1st value of 2nd row
  69785. * @param initialM22 defines 2nd value of 2nd row
  69786. * @param initialM23 defines 3rd value of 2nd row
  69787. * @param initialM24 defines 4th value of 2nd row
  69788. * @param initialM31 defines 1st value of 3rd row
  69789. * @param initialM32 defines 2nd value of 3rd row
  69790. * @param initialM33 defines 3rd value of 3rd row
  69791. * @param initialM34 defines 4th value of 3rd row
  69792. * @param initialM41 defines 1st value of 4th row
  69793. * @param initialM42 defines 2nd value of 4th row
  69794. * @param initialM43 defines 3rd value of 4th row
  69795. * @param initialM44 defines 4th value of 4th row
  69796. * @returns the new matrix
  69797. */
  69798. 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;
  69799. /**
  69800. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69801. * @param scale defines the scale vector3
  69802. * @param rotation defines the rotation quaternion
  69803. * @param translation defines the translation vector3
  69804. * @returns a new matrix
  69805. */
  69806. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69807. /**
  69808. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69809. * @param scale defines the scale vector3
  69810. * @param rotation defines the rotation quaternion
  69811. * @param translation defines the translation vector3
  69812. * @param result defines the target matrix
  69813. */
  69814. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69815. /**
  69816. * Creates a new identity matrix
  69817. * @returns a new identity matrix
  69818. */
  69819. static Identity(): Matrix;
  69820. /**
  69821. * Creates a new identity matrix and stores the result in a given matrix
  69822. * @param result defines the target matrix
  69823. */
  69824. static IdentityToRef(result: Matrix): void;
  69825. /**
  69826. * Creates a new zero matrix
  69827. * @returns a new zero matrix
  69828. */
  69829. static Zero(): Matrix;
  69830. /**
  69831. * Creates a new rotation matrix for "angle" radians around the X axis
  69832. * @param angle defines the angle (in radians) to use
  69833. * @return the new matrix
  69834. */
  69835. static RotationX(angle: number): Matrix;
  69836. /**
  69837. * Creates a new matrix as the invert of a given matrix
  69838. * @param source defines the source matrix
  69839. * @returns the new matrix
  69840. */
  69841. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69842. /**
  69843. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69844. * @param angle defines the angle (in radians) to use
  69845. * @param result defines the target matrix
  69846. */
  69847. static RotationXToRef(angle: number, result: Matrix): void;
  69848. /**
  69849. * Creates a new rotation matrix for "angle" radians around the Y axis
  69850. * @param angle defines the angle (in radians) to use
  69851. * @return the new matrix
  69852. */
  69853. static RotationY(angle: number): Matrix;
  69854. /**
  69855. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69856. * @param angle defines the angle (in radians) to use
  69857. * @param result defines the target matrix
  69858. */
  69859. static RotationYToRef(angle: number, result: Matrix): void;
  69860. /**
  69861. * Creates a new rotation matrix for "angle" radians around the Z axis
  69862. * @param angle defines the angle (in radians) to use
  69863. * @return the new matrix
  69864. */
  69865. static RotationZ(angle: number): Matrix;
  69866. /**
  69867. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69868. * @param angle defines the angle (in radians) to use
  69869. * @param result defines the target matrix
  69870. */
  69871. static RotationZToRef(angle: number, result: Matrix): void;
  69872. /**
  69873. * Creates a new rotation matrix for "angle" radians around the given axis
  69874. * @param axis defines the axis to use
  69875. * @param angle defines the angle (in radians) to use
  69876. * @return the new matrix
  69877. */
  69878. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69879. /**
  69880. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69881. * @param axis defines the axis to use
  69882. * @param angle defines the angle (in radians) to use
  69883. * @param result defines the target matrix
  69884. */
  69885. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69886. /**
  69887. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69888. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69889. * @param from defines the vector to align
  69890. * @param to defines the vector to align to
  69891. * @param result defines the target matrix
  69892. */
  69893. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69894. /**
  69895. * Creates a rotation matrix
  69896. * @param yaw defines the yaw angle in radians (Y axis)
  69897. * @param pitch defines the pitch angle in radians (X axis)
  69898. * @param roll defines the roll angle in radians (X axis)
  69899. * @returns the new rotation matrix
  69900. */
  69901. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69902. /**
  69903. * Creates a rotation matrix and stores it in a given matrix
  69904. * @param yaw defines the yaw angle in radians (Y axis)
  69905. * @param pitch defines the pitch angle in radians (X axis)
  69906. * @param roll defines the roll angle in radians (X axis)
  69907. * @param result defines the target matrix
  69908. */
  69909. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69910. /**
  69911. * Creates a scaling matrix
  69912. * @param x defines the scale factor on X axis
  69913. * @param y defines the scale factor on Y axis
  69914. * @param z defines the scale factor on Z axis
  69915. * @returns the new matrix
  69916. */
  69917. static Scaling(x: number, y: number, z: number): Matrix;
  69918. /**
  69919. * Creates a scaling matrix and stores it in a given matrix
  69920. * @param x defines the scale factor on X axis
  69921. * @param y defines the scale factor on Y axis
  69922. * @param z defines the scale factor on Z axis
  69923. * @param result defines the target matrix
  69924. */
  69925. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69926. /**
  69927. * Creates a translation matrix
  69928. * @param x defines the translation on X axis
  69929. * @param y defines the translation on Y axis
  69930. * @param z defines the translationon Z axis
  69931. * @returns the new matrix
  69932. */
  69933. static Translation(x: number, y: number, z: number): Matrix;
  69934. /**
  69935. * Creates a translation matrix and stores it in a given matrix
  69936. * @param x defines the translation on X axis
  69937. * @param y defines the translation on Y axis
  69938. * @param z defines the translationon Z axis
  69939. * @param result defines the target matrix
  69940. */
  69941. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69942. /**
  69943. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69944. * @param startValue defines the start value
  69945. * @param endValue defines the end value
  69946. * @param gradient defines the gradient factor
  69947. * @returns the new matrix
  69948. */
  69949. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69950. /**
  69951. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69952. * @param startValue defines the start value
  69953. * @param endValue defines the end value
  69954. * @param gradient defines the gradient factor
  69955. * @param result defines the Matrix object where to store data
  69956. */
  69957. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69958. /**
  69959. * Builds a new matrix whose values are computed by:
  69960. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69961. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69962. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69963. * @param startValue defines the first matrix
  69964. * @param endValue defines the second matrix
  69965. * @param gradient defines the gradient between the two matrices
  69966. * @returns the new matrix
  69967. */
  69968. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69969. /**
  69970. * Update a matrix to values which are computed by:
  69971. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69972. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69973. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69974. * @param startValue defines the first matrix
  69975. * @param endValue defines the second matrix
  69976. * @param gradient defines the gradient between the two matrices
  69977. * @param result defines the target matrix
  69978. */
  69979. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69980. /**
  69981. * 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"
  69982. * This function works in left handed mode
  69983. * @param eye defines the final position of the entity
  69984. * @param target defines where the entity should look at
  69985. * @param up defines the up vector for the entity
  69986. * @returns the new matrix
  69987. */
  69988. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69989. /**
  69990. * 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".
  69991. * This function works in left handed mode
  69992. * @param eye defines the final position of the entity
  69993. * @param target defines where the entity should look at
  69994. * @param up defines the up vector for the entity
  69995. * @param result defines the target matrix
  69996. */
  69997. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69998. /**
  69999. * 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"
  70000. * This function works in right handed mode
  70001. * @param eye defines the final position of the entity
  70002. * @param target defines where the entity should look at
  70003. * @param up defines the up vector for the entity
  70004. * @returns the new matrix
  70005. */
  70006. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  70007. /**
  70008. * 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".
  70009. * This function works in right handed mode
  70010. * @param eye defines the final position of the entity
  70011. * @param target defines where the entity should look at
  70012. * @param up defines the up vector for the entity
  70013. * @param result defines the target matrix
  70014. */
  70015. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  70016. /**
  70017. * Create a left-handed orthographic projection matrix
  70018. * @param width defines the viewport width
  70019. * @param height defines the viewport height
  70020. * @param znear defines the near clip plane
  70021. * @param zfar defines the far clip plane
  70022. * @returns a new matrix as a left-handed orthographic projection matrix
  70023. */
  70024. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70025. /**
  70026. * Store a left-handed orthographic projection to a given matrix
  70027. * @param width defines the viewport width
  70028. * @param height defines the viewport height
  70029. * @param znear defines the near clip plane
  70030. * @param zfar defines the far clip plane
  70031. * @param result defines the target matrix
  70032. */
  70033. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  70034. /**
  70035. * Create a left-handed orthographic projection matrix
  70036. * @param left defines the viewport left coordinate
  70037. * @param right defines the viewport right coordinate
  70038. * @param bottom defines the viewport bottom coordinate
  70039. * @param top defines the viewport top coordinate
  70040. * @param znear defines the near clip plane
  70041. * @param zfar defines the far clip plane
  70042. * @returns a new matrix as a left-handed orthographic projection matrix
  70043. */
  70044. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70045. /**
  70046. * Stores a left-handed orthographic projection into a given matrix
  70047. * @param left defines the viewport left coordinate
  70048. * @param right defines the viewport right coordinate
  70049. * @param bottom defines the viewport bottom coordinate
  70050. * @param top defines the viewport top coordinate
  70051. * @param znear defines the near clip plane
  70052. * @param zfar defines the far clip plane
  70053. * @param result defines the target matrix
  70054. */
  70055. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70056. /**
  70057. * Creates a right-handed orthographic projection matrix
  70058. * @param left defines the viewport left coordinate
  70059. * @param right defines the viewport right coordinate
  70060. * @param bottom defines the viewport bottom coordinate
  70061. * @param top defines the viewport top coordinate
  70062. * @param znear defines the near clip plane
  70063. * @param zfar defines the far clip plane
  70064. * @returns a new matrix as a right-handed orthographic projection matrix
  70065. */
  70066. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70067. /**
  70068. * Stores a right-handed orthographic projection into a given matrix
  70069. * @param left defines the viewport left coordinate
  70070. * @param right defines the viewport right coordinate
  70071. * @param bottom defines the viewport bottom coordinate
  70072. * @param top defines the viewport top coordinate
  70073. * @param znear defines the near clip plane
  70074. * @param zfar defines the far clip plane
  70075. * @param result defines the target matrix
  70076. */
  70077. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70078. /**
  70079. * Creates a left-handed perspective projection matrix
  70080. * @param width defines the viewport width
  70081. * @param height defines the viewport height
  70082. * @param znear defines the near clip plane
  70083. * @param zfar defines the far clip plane
  70084. * @returns a new matrix as a left-handed perspective projection matrix
  70085. */
  70086. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70087. /**
  70088. * Creates a left-handed perspective projection matrix
  70089. * @param fov defines the horizontal field of view
  70090. * @param aspect defines the aspect ratio
  70091. * @param znear defines the near clip plane
  70092. * @param zfar defines the far clip plane
  70093. * @returns a new matrix as a left-handed perspective projection matrix
  70094. */
  70095. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70096. /**
  70097. * Stores a left-handed perspective projection into a given matrix
  70098. * @param fov defines the horizontal field of view
  70099. * @param aspect defines the aspect ratio
  70100. * @param znear defines the near clip plane
  70101. * @param zfar defines the far clip plane
  70102. * @param result defines the target matrix
  70103. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70104. */
  70105. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70106. /**
  70107. * Creates a right-handed perspective projection matrix
  70108. * @param fov defines the horizontal field of view
  70109. * @param aspect defines the aspect ratio
  70110. * @param znear defines the near clip plane
  70111. * @param zfar defines the far clip plane
  70112. * @returns a new matrix as a right-handed perspective projection matrix
  70113. */
  70114. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70115. /**
  70116. * Stores a right-handed perspective projection into a given matrix
  70117. * @param fov defines the horizontal field of view
  70118. * @param aspect defines the aspect ratio
  70119. * @param znear defines the near clip plane
  70120. * @param zfar defines the far clip plane
  70121. * @param result defines the target matrix
  70122. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70123. */
  70124. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70125. /**
  70126. * Stores a perspective projection for WebVR info a given matrix
  70127. * @param fov defines the field of view
  70128. * @param znear defines the near clip plane
  70129. * @param zfar defines the far clip plane
  70130. * @param result defines the target matrix
  70131. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  70132. */
  70133. static PerspectiveFovWebVRToRef(fov: {
  70134. upDegrees: number;
  70135. downDegrees: number;
  70136. leftDegrees: number;
  70137. rightDegrees: number;
  70138. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  70139. /**
  70140. * Computes a complete transformation matrix
  70141. * @param viewport defines the viewport to use
  70142. * @param world defines the world matrix
  70143. * @param view defines the view matrix
  70144. * @param projection defines the projection matrix
  70145. * @param zmin defines the near clip plane
  70146. * @param zmax defines the far clip plane
  70147. * @returns the transformation matrix
  70148. */
  70149. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  70150. /**
  70151. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  70152. * @param matrix defines the matrix to use
  70153. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  70154. */
  70155. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  70156. /**
  70157. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  70158. * @param matrix defines the matrix to use
  70159. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  70160. */
  70161. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  70162. /**
  70163. * Compute the transpose of a given matrix
  70164. * @param matrix defines the matrix to transpose
  70165. * @returns the new matrix
  70166. */
  70167. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  70168. /**
  70169. * Compute the transpose of a matrix and store it in a target matrix
  70170. * @param matrix defines the matrix to transpose
  70171. * @param result defines the target matrix
  70172. */
  70173. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  70174. /**
  70175. * Computes a reflection matrix from a plane
  70176. * @param plane defines the reflection plane
  70177. * @returns a new matrix
  70178. */
  70179. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  70180. /**
  70181. * Computes a reflection matrix from a plane
  70182. * @param plane defines the reflection plane
  70183. * @param result defines the target matrix
  70184. */
  70185. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  70186. /**
  70187. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  70188. * @param xaxis defines the value of the 1st axis
  70189. * @param yaxis defines the value of the 2nd axis
  70190. * @param zaxis defines the value of the 3rd axis
  70191. * @param result defines the target matrix
  70192. */
  70193. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  70194. /**
  70195. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  70196. * @param quat defines the quaternion to use
  70197. * @param result defines the target matrix
  70198. */
  70199. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  70200. }
  70201. /**
  70202. * @hidden
  70203. */
  70204. export class TmpVectors {
  70205. static Vector2: Vector2[];
  70206. static Vector3: Vector3[];
  70207. static Vector4: Vector4[];
  70208. static Quaternion: Quaternion[];
  70209. static Matrix: Matrix[];
  70210. }
  70211. }
  70212. declare module BABYLON {
  70213. /**
  70214. * Class used to hold a RBG color
  70215. */
  70216. export class Color3 {
  70217. /**
  70218. * Defines the red component (between 0 and 1, default is 0)
  70219. */
  70220. r: number;
  70221. /**
  70222. * Defines the green component (between 0 and 1, default is 0)
  70223. */
  70224. g: number;
  70225. /**
  70226. * Defines the blue component (between 0 and 1, default is 0)
  70227. */
  70228. b: number;
  70229. /**
  70230. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70231. * @param r defines the red component (between 0 and 1, default is 0)
  70232. * @param g defines the green component (between 0 and 1, default is 0)
  70233. * @param b defines the blue component (between 0 and 1, default is 0)
  70234. */
  70235. constructor(
  70236. /**
  70237. * Defines the red component (between 0 and 1, default is 0)
  70238. */
  70239. r?: number,
  70240. /**
  70241. * Defines the green component (between 0 and 1, default is 0)
  70242. */
  70243. g?: number,
  70244. /**
  70245. * Defines the blue component (between 0 and 1, default is 0)
  70246. */
  70247. b?: number);
  70248. /**
  70249. * Creates a string with the Color3 current values
  70250. * @returns the string representation of the Color3 object
  70251. */
  70252. toString(): string;
  70253. /**
  70254. * Returns the string "Color3"
  70255. * @returns "Color3"
  70256. */
  70257. getClassName(): string;
  70258. /**
  70259. * Compute the Color3 hash code
  70260. * @returns an unique number that can be used to hash Color3 objects
  70261. */
  70262. getHashCode(): number;
  70263. /**
  70264. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70265. * @param array defines the array where to store the r,g,b components
  70266. * @param index defines an optional index in the target array to define where to start storing values
  70267. * @returns the current Color3 object
  70268. */
  70269. toArray(array: FloatArray, index?: number): Color3;
  70270. /**
  70271. * Returns a new Color4 object from the current Color3 and the given alpha
  70272. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70273. * @returns a new Color4 object
  70274. */
  70275. toColor4(alpha?: number): Color4;
  70276. /**
  70277. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70278. * @returns the new array
  70279. */
  70280. asArray(): number[];
  70281. /**
  70282. * Returns the luminance value
  70283. * @returns a float value
  70284. */
  70285. toLuminance(): number;
  70286. /**
  70287. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70288. * @param otherColor defines the second operand
  70289. * @returns the new Color3 object
  70290. */
  70291. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70292. /**
  70293. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70294. * @param otherColor defines the second operand
  70295. * @param result defines the Color3 object where to store the result
  70296. * @returns the current Color3
  70297. */
  70298. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70299. /**
  70300. * Determines equality between Color3 objects
  70301. * @param otherColor defines the second operand
  70302. * @returns true if the rgb values are equal to the given ones
  70303. */
  70304. equals(otherColor: DeepImmutable<Color3>): boolean;
  70305. /**
  70306. * Determines equality between the current Color3 object and a set of r,b,g values
  70307. * @param r defines the red component to check
  70308. * @param g defines the green component to check
  70309. * @param b defines the blue component to check
  70310. * @returns true if the rgb values are equal to the given ones
  70311. */
  70312. equalsFloats(r: number, g: number, b: number): boolean;
  70313. /**
  70314. * Multiplies in place each rgb value by scale
  70315. * @param scale defines the scaling factor
  70316. * @returns the updated Color3
  70317. */
  70318. scale(scale: number): Color3;
  70319. /**
  70320. * Multiplies the rgb values by scale and stores the result into "result"
  70321. * @param scale defines the scaling factor
  70322. * @param result defines the Color3 object where to store the result
  70323. * @returns the unmodified current Color3
  70324. */
  70325. scaleToRef(scale: number, result: Color3): Color3;
  70326. /**
  70327. * Scale the current Color3 values by a factor and add the result to a given Color3
  70328. * @param scale defines the scale factor
  70329. * @param result defines color to store the result into
  70330. * @returns the unmodified current Color3
  70331. */
  70332. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70333. /**
  70334. * Clamps the rgb values by the min and max values and stores the result into "result"
  70335. * @param min defines minimum clamping value (default is 0)
  70336. * @param max defines maximum clamping value (default is 1)
  70337. * @param result defines color to store the result into
  70338. * @returns the original Color3
  70339. */
  70340. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70341. /**
  70342. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70343. * @param otherColor defines the second operand
  70344. * @returns the new Color3
  70345. */
  70346. add(otherColor: DeepImmutable<Color3>): Color3;
  70347. /**
  70348. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70349. * @param otherColor defines the second operand
  70350. * @param result defines Color3 object to store the result into
  70351. * @returns the unmodified current Color3
  70352. */
  70353. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70354. /**
  70355. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70356. * @param otherColor defines the second operand
  70357. * @returns the new Color3
  70358. */
  70359. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70360. /**
  70361. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70362. * @param otherColor defines the second operand
  70363. * @param result defines Color3 object to store the result into
  70364. * @returns the unmodified current Color3
  70365. */
  70366. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70367. /**
  70368. * Copy the current object
  70369. * @returns a new Color3 copied the current one
  70370. */
  70371. clone(): Color3;
  70372. /**
  70373. * Copies the rgb values from the source in the current Color3
  70374. * @param source defines the source Color3 object
  70375. * @returns the updated Color3 object
  70376. */
  70377. copyFrom(source: DeepImmutable<Color3>): Color3;
  70378. /**
  70379. * Updates the Color3 rgb values from the given floats
  70380. * @param r defines the red component to read from
  70381. * @param g defines the green component to read from
  70382. * @param b defines the blue component to read from
  70383. * @returns the current Color3 object
  70384. */
  70385. copyFromFloats(r: number, g: number, b: number): Color3;
  70386. /**
  70387. * Updates the Color3 rgb values from the given floats
  70388. * @param r defines the red component to read from
  70389. * @param g defines the green component to read from
  70390. * @param b defines the blue component to read from
  70391. * @returns the current Color3 object
  70392. */
  70393. set(r: number, g: number, b: number): Color3;
  70394. /**
  70395. * Compute the Color3 hexadecimal code as a string
  70396. * @returns a string containing the hexadecimal representation of the Color3 object
  70397. */
  70398. toHexString(): string;
  70399. /**
  70400. * Computes a new Color3 converted from the current one to linear space
  70401. * @returns a new Color3 object
  70402. */
  70403. toLinearSpace(): Color3;
  70404. /**
  70405. * Converts current color in rgb space to HSV values
  70406. * @returns a new color3 representing the HSV values
  70407. */
  70408. toHSV(): Color3;
  70409. /**
  70410. * Converts current color in rgb space to HSV values
  70411. * @param result defines the Color3 where to store the HSV values
  70412. */
  70413. toHSVToRef(result: Color3): void;
  70414. /**
  70415. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70416. * @param convertedColor defines the Color3 object where to store the linear space version
  70417. * @returns the unmodified Color3
  70418. */
  70419. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70420. /**
  70421. * Computes a new Color3 converted from the current one to gamma space
  70422. * @returns a new Color3 object
  70423. */
  70424. toGammaSpace(): Color3;
  70425. /**
  70426. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70427. * @param convertedColor defines the Color3 object where to store the gamma space version
  70428. * @returns the unmodified Color3
  70429. */
  70430. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70431. private static _BlackReadOnly;
  70432. /**
  70433. * Convert Hue, saturation and value to a Color3 (RGB)
  70434. * @param hue defines the hue
  70435. * @param saturation defines the saturation
  70436. * @param value defines the value
  70437. * @param result defines the Color3 where to store the RGB values
  70438. */
  70439. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70440. /**
  70441. * Creates a new Color3 from the string containing valid hexadecimal values
  70442. * @param hex defines a string containing valid hexadecimal values
  70443. * @returns a new Color3 object
  70444. */
  70445. static FromHexString(hex: string): Color3;
  70446. /**
  70447. * Creates a new Color3 from the starting index of the given array
  70448. * @param array defines the source array
  70449. * @param offset defines an offset in the source array
  70450. * @returns a new Color3 object
  70451. */
  70452. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70453. /**
  70454. * Creates a new Color3 from integer values (< 256)
  70455. * @param r defines the red component to read from (value between 0 and 255)
  70456. * @param g defines the green component to read from (value between 0 and 255)
  70457. * @param b defines the blue component to read from (value between 0 and 255)
  70458. * @returns a new Color3 object
  70459. */
  70460. static FromInts(r: number, g: number, b: number): Color3;
  70461. /**
  70462. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70463. * @param start defines the start Color3 value
  70464. * @param end defines the end Color3 value
  70465. * @param amount defines the gradient value between start and end
  70466. * @returns a new Color3 object
  70467. */
  70468. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70469. /**
  70470. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70471. * @param left defines the start value
  70472. * @param right defines the end value
  70473. * @param amount defines the gradient factor
  70474. * @param result defines the Color3 object where to store the result
  70475. */
  70476. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70477. /**
  70478. * Returns a Color3 value containing a red color
  70479. * @returns a new Color3 object
  70480. */
  70481. static Red(): Color3;
  70482. /**
  70483. * Returns a Color3 value containing a green color
  70484. * @returns a new Color3 object
  70485. */
  70486. static Green(): Color3;
  70487. /**
  70488. * Returns a Color3 value containing a blue color
  70489. * @returns a new Color3 object
  70490. */
  70491. static Blue(): Color3;
  70492. /**
  70493. * Returns a Color3 value containing a black color
  70494. * @returns a new Color3 object
  70495. */
  70496. static Black(): Color3;
  70497. /**
  70498. * Gets a Color3 value containing a black color that must not be updated
  70499. */
  70500. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70501. /**
  70502. * Returns a Color3 value containing a white color
  70503. * @returns a new Color3 object
  70504. */
  70505. static White(): Color3;
  70506. /**
  70507. * Returns a Color3 value containing a purple color
  70508. * @returns a new Color3 object
  70509. */
  70510. static Purple(): Color3;
  70511. /**
  70512. * Returns a Color3 value containing a magenta color
  70513. * @returns a new Color3 object
  70514. */
  70515. static Magenta(): Color3;
  70516. /**
  70517. * Returns a Color3 value containing a yellow color
  70518. * @returns a new Color3 object
  70519. */
  70520. static Yellow(): Color3;
  70521. /**
  70522. * Returns a Color3 value containing a gray color
  70523. * @returns a new Color3 object
  70524. */
  70525. static Gray(): Color3;
  70526. /**
  70527. * Returns a Color3 value containing a teal color
  70528. * @returns a new Color3 object
  70529. */
  70530. static Teal(): Color3;
  70531. /**
  70532. * Returns a Color3 value containing a random color
  70533. * @returns a new Color3 object
  70534. */
  70535. static Random(): Color3;
  70536. }
  70537. /**
  70538. * Class used to hold a RBGA color
  70539. */
  70540. export class Color4 {
  70541. /**
  70542. * Defines the red component (between 0 and 1, default is 0)
  70543. */
  70544. r: number;
  70545. /**
  70546. * Defines the green component (between 0 and 1, default is 0)
  70547. */
  70548. g: number;
  70549. /**
  70550. * Defines the blue component (between 0 and 1, default is 0)
  70551. */
  70552. b: number;
  70553. /**
  70554. * Defines the alpha component (between 0 and 1, default is 1)
  70555. */
  70556. a: number;
  70557. /**
  70558. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70559. * @param r defines the red component (between 0 and 1, default is 0)
  70560. * @param g defines the green component (between 0 and 1, default is 0)
  70561. * @param b defines the blue component (between 0 and 1, default is 0)
  70562. * @param a defines the alpha component (between 0 and 1, default is 1)
  70563. */
  70564. constructor(
  70565. /**
  70566. * Defines the red component (between 0 and 1, default is 0)
  70567. */
  70568. r?: number,
  70569. /**
  70570. * Defines the green component (between 0 and 1, default is 0)
  70571. */
  70572. g?: number,
  70573. /**
  70574. * Defines the blue component (between 0 and 1, default is 0)
  70575. */
  70576. b?: number,
  70577. /**
  70578. * Defines the alpha component (between 0 and 1, default is 1)
  70579. */
  70580. a?: number);
  70581. /**
  70582. * Adds in place the given Color4 values to the current Color4 object
  70583. * @param right defines the second operand
  70584. * @returns the current updated Color4 object
  70585. */
  70586. addInPlace(right: DeepImmutable<Color4>): Color4;
  70587. /**
  70588. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70589. * @returns the new array
  70590. */
  70591. asArray(): number[];
  70592. /**
  70593. * Stores from the starting index in the given array the Color4 successive values
  70594. * @param array defines the array where to store the r,g,b components
  70595. * @param index defines an optional index in the target array to define where to start storing values
  70596. * @returns the current Color4 object
  70597. */
  70598. toArray(array: number[], index?: number): Color4;
  70599. /**
  70600. * Determines equality between Color4 objects
  70601. * @param otherColor defines the second operand
  70602. * @returns true if the rgba values are equal to the given ones
  70603. */
  70604. equals(otherColor: DeepImmutable<Color4>): boolean;
  70605. /**
  70606. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70607. * @param right defines the second operand
  70608. * @returns a new Color4 object
  70609. */
  70610. add(right: DeepImmutable<Color4>): Color4;
  70611. /**
  70612. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70613. * @param right defines the second operand
  70614. * @returns a new Color4 object
  70615. */
  70616. subtract(right: DeepImmutable<Color4>): Color4;
  70617. /**
  70618. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70619. * @param right defines the second operand
  70620. * @param result defines the Color4 object where to store the result
  70621. * @returns the current Color4 object
  70622. */
  70623. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70624. /**
  70625. * Creates a new Color4 with the current Color4 values multiplied by scale
  70626. * @param scale defines the scaling factor to apply
  70627. * @returns a new Color4 object
  70628. */
  70629. scale(scale: number): Color4;
  70630. /**
  70631. * Multiplies the current Color4 values by scale and stores the result in "result"
  70632. * @param scale defines the scaling factor to apply
  70633. * @param result defines the Color4 object where to store the result
  70634. * @returns the current unmodified Color4
  70635. */
  70636. scaleToRef(scale: number, result: Color4): Color4;
  70637. /**
  70638. * Scale the current Color4 values by a factor and add the result to a given Color4
  70639. * @param scale defines the scale factor
  70640. * @param result defines the Color4 object where to store the result
  70641. * @returns the unmodified current Color4
  70642. */
  70643. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70644. /**
  70645. * Clamps the rgb values by the min and max values and stores the result into "result"
  70646. * @param min defines minimum clamping value (default is 0)
  70647. * @param max defines maximum clamping value (default is 1)
  70648. * @param result defines color to store the result into.
  70649. * @returns the cuurent Color4
  70650. */
  70651. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70652. /**
  70653. * Multipy an Color4 value by another and return a new Color4 object
  70654. * @param color defines the Color4 value to multiply by
  70655. * @returns a new Color4 object
  70656. */
  70657. multiply(color: Color4): Color4;
  70658. /**
  70659. * Multipy a Color4 value by another and push the result in a reference value
  70660. * @param color defines the Color4 value to multiply by
  70661. * @param result defines the Color4 to fill the result in
  70662. * @returns the result Color4
  70663. */
  70664. multiplyToRef(color: Color4, result: Color4): Color4;
  70665. /**
  70666. * Creates a string with the Color4 current values
  70667. * @returns the string representation of the Color4 object
  70668. */
  70669. toString(): string;
  70670. /**
  70671. * Returns the string "Color4"
  70672. * @returns "Color4"
  70673. */
  70674. getClassName(): string;
  70675. /**
  70676. * Compute the Color4 hash code
  70677. * @returns an unique number that can be used to hash Color4 objects
  70678. */
  70679. getHashCode(): number;
  70680. /**
  70681. * Creates a new Color4 copied from the current one
  70682. * @returns a new Color4 object
  70683. */
  70684. clone(): Color4;
  70685. /**
  70686. * Copies the given Color4 values into the current one
  70687. * @param source defines the source Color4 object
  70688. * @returns the current updated Color4 object
  70689. */
  70690. copyFrom(source: Color4): Color4;
  70691. /**
  70692. * Copies the given float values into the current one
  70693. * @param r defines the red component to read from
  70694. * @param g defines the green component to read from
  70695. * @param b defines the blue component to read from
  70696. * @param a defines the alpha component to read from
  70697. * @returns the current updated Color4 object
  70698. */
  70699. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70700. /**
  70701. * Copies the given float values into the current one
  70702. * @param r defines the red component to read from
  70703. * @param g defines the green component to read from
  70704. * @param b defines the blue component to read from
  70705. * @param a defines the alpha component to read from
  70706. * @returns the current updated Color4 object
  70707. */
  70708. set(r: number, g: number, b: number, a: number): Color4;
  70709. /**
  70710. * Compute the Color4 hexadecimal code as a string
  70711. * @returns a string containing the hexadecimal representation of the Color4 object
  70712. */
  70713. toHexString(): string;
  70714. /**
  70715. * Computes a new Color4 converted from the current one to linear space
  70716. * @returns a new Color4 object
  70717. */
  70718. toLinearSpace(): Color4;
  70719. /**
  70720. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70721. * @param convertedColor defines the Color4 object where to store the linear space version
  70722. * @returns the unmodified Color4
  70723. */
  70724. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70725. /**
  70726. * Computes a new Color4 converted from the current one to gamma space
  70727. * @returns a new Color4 object
  70728. */
  70729. toGammaSpace(): Color4;
  70730. /**
  70731. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70732. * @param convertedColor defines the Color4 object where to store the gamma space version
  70733. * @returns the unmodified Color4
  70734. */
  70735. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70736. /**
  70737. * Creates a new Color4 from the string containing valid hexadecimal values
  70738. * @param hex defines a string containing valid hexadecimal values
  70739. * @returns a new Color4 object
  70740. */
  70741. static FromHexString(hex: string): Color4;
  70742. /**
  70743. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70744. * @param left defines the start value
  70745. * @param right defines the end value
  70746. * @param amount defines the gradient factor
  70747. * @returns a new Color4 object
  70748. */
  70749. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70750. /**
  70751. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70752. * @param left defines the start value
  70753. * @param right defines the end value
  70754. * @param amount defines the gradient factor
  70755. * @param result defines the Color4 object where to store data
  70756. */
  70757. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70758. /**
  70759. * Creates a new Color4 from a Color3 and an alpha value
  70760. * @param color3 defines the source Color3 to read from
  70761. * @param alpha defines the alpha component (1.0 by default)
  70762. * @returns a new Color4 object
  70763. */
  70764. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70765. /**
  70766. * Creates a new Color4 from the starting index element of the given array
  70767. * @param array defines the source array to read from
  70768. * @param offset defines the offset in the source array
  70769. * @returns a new Color4 object
  70770. */
  70771. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70772. /**
  70773. * Creates a new Color3 from integer values (< 256)
  70774. * @param r defines the red component to read from (value between 0 and 255)
  70775. * @param g defines the green component to read from (value between 0 and 255)
  70776. * @param b defines the blue component to read from (value between 0 and 255)
  70777. * @param a defines the alpha component to read from (value between 0 and 255)
  70778. * @returns a new Color3 object
  70779. */
  70780. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70781. /**
  70782. * Check the content of a given array and convert it to an array containing RGBA data
  70783. * If the original array was already containing count * 4 values then it is returned directly
  70784. * @param colors defines the array to check
  70785. * @param count defines the number of RGBA data to expect
  70786. * @returns an array containing count * 4 values (RGBA)
  70787. */
  70788. static CheckColors4(colors: number[], count: number): number[];
  70789. }
  70790. /**
  70791. * @hidden
  70792. */
  70793. export class TmpColors {
  70794. static Color3: Color3[];
  70795. static Color4: Color4[];
  70796. }
  70797. }
  70798. declare module BABYLON {
  70799. /**
  70800. * Class representing spherical harmonics coefficients to the 3rd degree
  70801. */
  70802. export class SphericalHarmonics {
  70803. /**
  70804. * Defines whether or not the harmonics have been prescaled for rendering.
  70805. */
  70806. preScaled: boolean;
  70807. /**
  70808. * The l0,0 coefficients of the spherical harmonics
  70809. */
  70810. l00: Vector3;
  70811. /**
  70812. * The l1,-1 coefficients of the spherical harmonics
  70813. */
  70814. l1_1: Vector3;
  70815. /**
  70816. * The l1,0 coefficients of the spherical harmonics
  70817. */
  70818. l10: Vector3;
  70819. /**
  70820. * The l1,1 coefficients of the spherical harmonics
  70821. */
  70822. l11: Vector3;
  70823. /**
  70824. * The l2,-2 coefficients of the spherical harmonics
  70825. */
  70826. l2_2: Vector3;
  70827. /**
  70828. * The l2,-1 coefficients of the spherical harmonics
  70829. */
  70830. l2_1: Vector3;
  70831. /**
  70832. * The l2,0 coefficients of the spherical harmonics
  70833. */
  70834. l20: Vector3;
  70835. /**
  70836. * The l2,1 coefficients of the spherical harmonics
  70837. */
  70838. l21: Vector3;
  70839. /**
  70840. * The l2,2 coefficients of the spherical harmonics
  70841. */
  70842. l22: Vector3;
  70843. /**
  70844. * Adds a light to the spherical harmonics
  70845. * @param direction the direction of the light
  70846. * @param color the color of the light
  70847. * @param deltaSolidAngle the delta solid angle of the light
  70848. */
  70849. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70850. /**
  70851. * Scales the spherical harmonics by the given amount
  70852. * @param scale the amount to scale
  70853. */
  70854. scaleInPlace(scale: number): void;
  70855. /**
  70856. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70857. *
  70858. * ```
  70859. * E_lm = A_l * L_lm
  70860. * ```
  70861. *
  70862. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70863. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70864. * the scaling factors are given in equation 9.
  70865. */
  70866. convertIncidentRadianceToIrradiance(): void;
  70867. /**
  70868. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70869. *
  70870. * ```
  70871. * L = (1/pi) * E * rho
  70872. * ```
  70873. *
  70874. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70875. */
  70876. convertIrradianceToLambertianRadiance(): void;
  70877. /**
  70878. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70879. * required operations at run time.
  70880. *
  70881. * This is simply done by scaling back the SH with Ylm constants parameter.
  70882. * The trigonometric part being applied by the shader at run time.
  70883. */
  70884. preScaleForRendering(): void;
  70885. /**
  70886. * Constructs a spherical harmonics from an array.
  70887. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70888. * @returns the spherical harmonics
  70889. */
  70890. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70891. /**
  70892. * Gets the spherical harmonics from polynomial
  70893. * @param polynomial the spherical polynomial
  70894. * @returns the spherical harmonics
  70895. */
  70896. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70897. }
  70898. /**
  70899. * Class representing spherical polynomial coefficients to the 3rd degree
  70900. */
  70901. export class SphericalPolynomial {
  70902. private _harmonics;
  70903. /**
  70904. * The spherical harmonics used to create the polynomials.
  70905. */
  70906. readonly preScaledHarmonics: SphericalHarmonics;
  70907. /**
  70908. * The x coefficients of the spherical polynomial
  70909. */
  70910. x: Vector3;
  70911. /**
  70912. * The y coefficients of the spherical polynomial
  70913. */
  70914. y: Vector3;
  70915. /**
  70916. * The z coefficients of the spherical polynomial
  70917. */
  70918. z: Vector3;
  70919. /**
  70920. * The xx coefficients of the spherical polynomial
  70921. */
  70922. xx: Vector3;
  70923. /**
  70924. * The yy coefficients of the spherical polynomial
  70925. */
  70926. yy: Vector3;
  70927. /**
  70928. * The zz coefficients of the spherical polynomial
  70929. */
  70930. zz: Vector3;
  70931. /**
  70932. * The xy coefficients of the spherical polynomial
  70933. */
  70934. xy: Vector3;
  70935. /**
  70936. * The yz coefficients of the spherical polynomial
  70937. */
  70938. yz: Vector3;
  70939. /**
  70940. * The zx coefficients of the spherical polynomial
  70941. */
  70942. zx: Vector3;
  70943. /**
  70944. * Adds an ambient color to the spherical polynomial
  70945. * @param color the color to add
  70946. */
  70947. addAmbient(color: Color3): void;
  70948. /**
  70949. * Scales the spherical polynomial by the given amount
  70950. * @param scale the amount to scale
  70951. */
  70952. scaleInPlace(scale: number): void;
  70953. /**
  70954. * Gets the spherical polynomial from harmonics
  70955. * @param harmonics the spherical harmonics
  70956. * @returns the spherical polynomial
  70957. */
  70958. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  70959. /**
  70960. * Constructs a spherical polynomial from an array.
  70961. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  70962. * @returns the spherical polynomial
  70963. */
  70964. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  70965. }
  70966. }
  70967. declare module BABYLON {
  70968. /**
  70969. * Define options used to create a render target texture
  70970. */
  70971. export class RenderTargetCreationOptions {
  70972. /**
  70973. * Specifies is mipmaps must be generated
  70974. */
  70975. generateMipMaps?: boolean;
  70976. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  70977. generateDepthBuffer?: boolean;
  70978. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  70979. generateStencilBuffer?: boolean;
  70980. /** Defines texture type (int by default) */
  70981. type?: number;
  70982. /** Defines sampling mode (trilinear by default) */
  70983. samplingMode?: number;
  70984. /** Defines format (RGBA by default) */
  70985. format?: number;
  70986. }
  70987. }
  70988. declare module BABYLON {
  70989. /**
  70990. * @hidden
  70991. **/
  70992. export class _TimeToken {
  70993. _startTimeQuery: Nullable<WebGLQuery>;
  70994. _endTimeQuery: Nullable<WebGLQuery>;
  70995. _timeElapsedQuery: Nullable<WebGLQuery>;
  70996. _timeElapsedQueryEnded: boolean;
  70997. }
  70998. }
  70999. declare module BABYLON {
  71000. /** Defines the cross module used constants to avoid circular dependncies */
  71001. export class Constants {
  71002. /** Defines that alpha blending is disabled */
  71003. static readonly ALPHA_DISABLE: number;
  71004. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  71005. static readonly ALPHA_ADD: number;
  71006. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71007. static readonly ALPHA_COMBINE: number;
  71008. /** Defines that alpha blending to DEST - SRC * DEST */
  71009. static readonly ALPHA_SUBTRACT: number;
  71010. /** Defines that alpha blending to SRC * DEST */
  71011. static readonly ALPHA_MULTIPLY: number;
  71012. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  71013. static readonly ALPHA_MAXIMIZED: number;
  71014. /** Defines that alpha blending to SRC + DEST */
  71015. static readonly ALPHA_ONEONE: number;
  71016. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  71017. static readonly ALPHA_PREMULTIPLIED: number;
  71018. /**
  71019. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  71020. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71021. */
  71022. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71023. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  71024. static readonly ALPHA_INTERPOLATE: number;
  71025. /**
  71026. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  71027. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71028. */
  71029. static readonly ALPHA_SCREENMODE: number;
  71030. /**
  71031. * Defines that alpha blending to SRC + DST
  71032. * Alpha will be set to SRC ALPHA + DST ALPHA
  71033. */
  71034. static readonly ALPHA_ONEONE_ONEONE: number;
  71035. /**
  71036. * Defines that alpha blending to SRC * DST ALPHA + DST
  71037. * Alpha will be set to 0
  71038. */
  71039. static readonly ALPHA_ALPHATOCOLOR: number;
  71040. /**
  71041. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  71042. */
  71043. static readonly ALPHA_REVERSEONEMINUS: number;
  71044. /**
  71045. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  71046. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71047. */
  71048. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71049. /**
  71050. * Defines that alpha blending to SRC + DST
  71051. * Alpha will be set to SRC ALPHA
  71052. */
  71053. static readonly ALPHA_ONEONE_ONEZERO: number;
  71054. /** Defines that alpha blending equation a SUM */
  71055. static readonly ALPHA_EQUATION_ADD: number;
  71056. /** Defines that alpha blending equation a SUBSTRACTION */
  71057. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71058. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71059. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71060. /** Defines that alpha blending equation a MAX operation */
  71061. static readonly ALPHA_EQUATION_MAX: number;
  71062. /** Defines that alpha blending equation a MIN operation */
  71063. static readonly ALPHA_EQUATION_MIN: number;
  71064. /**
  71065. * Defines that alpha blending equation a DARKEN operation:
  71066. * It takes the min of the src and sums the alpha channels.
  71067. */
  71068. static readonly ALPHA_EQUATION_DARKEN: number;
  71069. /** Defines that the ressource is not delayed*/
  71070. static readonly DELAYLOADSTATE_NONE: number;
  71071. /** Defines that the ressource was successfully delay loaded */
  71072. static readonly DELAYLOADSTATE_LOADED: number;
  71073. /** Defines that the ressource is currently delay loading */
  71074. static readonly DELAYLOADSTATE_LOADING: number;
  71075. /** Defines that the ressource is delayed and has not started loading */
  71076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71078. static readonly NEVER: number;
  71079. /** 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 */
  71080. static readonly ALWAYS: number;
  71081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71082. static readonly LESS: number;
  71083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71084. static readonly EQUAL: number;
  71085. /** 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 */
  71086. static readonly LEQUAL: number;
  71087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71088. static readonly GREATER: number;
  71089. /** 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 */
  71090. static readonly GEQUAL: number;
  71091. /** 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 */
  71092. static readonly NOTEQUAL: number;
  71093. /** Passed to stencilOperation to specify that stencil value must be kept */
  71094. static readonly KEEP: number;
  71095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71096. static readonly REPLACE: number;
  71097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71098. static readonly INCR: number;
  71099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71100. static readonly DECR: number;
  71101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71102. static readonly INVERT: number;
  71103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71104. static readonly INCR_WRAP: number;
  71105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71106. static readonly DECR_WRAP: number;
  71107. /** Texture is not repeating outside of 0..1 UVs */
  71108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71109. /** Texture is repeating outside of 0..1 UVs */
  71110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71111. /** Texture is repeating and mirrored */
  71112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71113. /** ALPHA */
  71114. static readonly TEXTUREFORMAT_ALPHA: number;
  71115. /** LUMINANCE */
  71116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71117. /** LUMINANCE_ALPHA */
  71118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71119. /** RGB */
  71120. static readonly TEXTUREFORMAT_RGB: number;
  71121. /** RGBA */
  71122. static readonly TEXTUREFORMAT_RGBA: number;
  71123. /** RED */
  71124. static readonly TEXTUREFORMAT_RED: number;
  71125. /** RED (2nd reference) */
  71126. static readonly TEXTUREFORMAT_R: number;
  71127. /** RG */
  71128. static readonly TEXTUREFORMAT_RG: number;
  71129. /** RED_INTEGER */
  71130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71131. /** RED_INTEGER (2nd reference) */
  71132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71133. /** RG_INTEGER */
  71134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71135. /** RGB_INTEGER */
  71136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71137. /** RGBA_INTEGER */
  71138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71139. /** UNSIGNED_BYTE */
  71140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71141. /** UNSIGNED_BYTE (2nd reference) */
  71142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71143. /** FLOAT */
  71144. static readonly TEXTURETYPE_FLOAT: number;
  71145. /** HALF_FLOAT */
  71146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71147. /** BYTE */
  71148. static readonly TEXTURETYPE_BYTE: number;
  71149. /** SHORT */
  71150. static readonly TEXTURETYPE_SHORT: number;
  71151. /** UNSIGNED_SHORT */
  71152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71153. /** INT */
  71154. static readonly TEXTURETYPE_INT: number;
  71155. /** UNSIGNED_INT */
  71156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71157. /** UNSIGNED_SHORT_4_4_4_4 */
  71158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71159. /** UNSIGNED_SHORT_5_5_5_1 */
  71160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71161. /** UNSIGNED_SHORT_5_6_5 */
  71162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71163. /** UNSIGNED_INT_2_10_10_10_REV */
  71164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71165. /** UNSIGNED_INT_24_8 */
  71166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71167. /** UNSIGNED_INT_10F_11F_11F_REV */
  71168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71169. /** UNSIGNED_INT_5_9_9_9_REV */
  71170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71173. /** nearest is mag = nearest and min = nearest and mip = linear */
  71174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71175. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71176. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71177. /** Trilinear is mag = linear and min = linear and mip = linear */
  71178. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71179. /** nearest is mag = nearest and min = nearest and mip = linear */
  71180. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71181. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71182. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71183. /** Trilinear is mag = linear and min = linear and mip = linear */
  71184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71185. /** mag = nearest and min = nearest and mip = nearest */
  71186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71187. /** mag = nearest and min = linear and mip = nearest */
  71188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71189. /** mag = nearest and min = linear and mip = linear */
  71190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71191. /** mag = nearest and min = linear and mip = none */
  71192. static readonly TEXTURE_NEAREST_LINEAR: number;
  71193. /** mag = nearest and min = nearest and mip = none */
  71194. static readonly TEXTURE_NEAREST_NEAREST: number;
  71195. /** mag = linear and min = nearest and mip = nearest */
  71196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71197. /** mag = linear and min = nearest and mip = linear */
  71198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71199. /** mag = linear and min = linear and mip = none */
  71200. static readonly TEXTURE_LINEAR_LINEAR: number;
  71201. /** mag = linear and min = nearest and mip = none */
  71202. static readonly TEXTURE_LINEAR_NEAREST: number;
  71203. /** Explicit coordinates mode */
  71204. static readonly TEXTURE_EXPLICIT_MODE: number;
  71205. /** Spherical coordinates mode */
  71206. static readonly TEXTURE_SPHERICAL_MODE: number;
  71207. /** Planar coordinates mode */
  71208. static readonly TEXTURE_PLANAR_MODE: number;
  71209. /** Cubic coordinates mode */
  71210. static readonly TEXTURE_CUBIC_MODE: number;
  71211. /** Projection coordinates mode */
  71212. static readonly TEXTURE_PROJECTION_MODE: number;
  71213. /** Skybox coordinates mode */
  71214. static readonly TEXTURE_SKYBOX_MODE: number;
  71215. /** Inverse Cubic coordinates mode */
  71216. static readonly TEXTURE_INVCUBIC_MODE: number;
  71217. /** Equirectangular coordinates mode */
  71218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71219. /** Equirectangular Fixed coordinates mode */
  71220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71221. /** Equirectangular Fixed Mirrored coordinates mode */
  71222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71224. static readonly SCALEMODE_FLOOR: number;
  71225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71226. static readonly SCALEMODE_NEAREST: number;
  71227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71228. static readonly SCALEMODE_CEILING: number;
  71229. /**
  71230. * The dirty texture flag value
  71231. */
  71232. static readonly MATERIAL_TextureDirtyFlag: number;
  71233. /**
  71234. * The dirty light flag value
  71235. */
  71236. static readonly MATERIAL_LightDirtyFlag: number;
  71237. /**
  71238. * The dirty fresnel flag value
  71239. */
  71240. static readonly MATERIAL_FresnelDirtyFlag: number;
  71241. /**
  71242. * The dirty attribute flag value
  71243. */
  71244. static readonly MATERIAL_AttributesDirtyFlag: number;
  71245. /**
  71246. * The dirty misc flag value
  71247. */
  71248. static readonly MATERIAL_MiscDirtyFlag: number;
  71249. /**
  71250. * The all dirty flag value
  71251. */
  71252. static readonly MATERIAL_AllDirtyFlag: number;
  71253. /**
  71254. * Returns the triangle fill mode
  71255. */
  71256. static readonly MATERIAL_TriangleFillMode: number;
  71257. /**
  71258. * Returns the wireframe mode
  71259. */
  71260. static readonly MATERIAL_WireFrameFillMode: number;
  71261. /**
  71262. * Returns the point fill mode
  71263. */
  71264. static readonly MATERIAL_PointFillMode: number;
  71265. /**
  71266. * Returns the point list draw mode
  71267. */
  71268. static readonly MATERIAL_PointListDrawMode: number;
  71269. /**
  71270. * Returns the line list draw mode
  71271. */
  71272. static readonly MATERIAL_LineListDrawMode: number;
  71273. /**
  71274. * Returns the line loop draw mode
  71275. */
  71276. static readonly MATERIAL_LineLoopDrawMode: number;
  71277. /**
  71278. * Returns the line strip draw mode
  71279. */
  71280. static readonly MATERIAL_LineStripDrawMode: number;
  71281. /**
  71282. * Returns the triangle strip draw mode
  71283. */
  71284. static readonly MATERIAL_TriangleStripDrawMode: number;
  71285. /**
  71286. * Returns the triangle fan draw mode
  71287. */
  71288. static readonly MATERIAL_TriangleFanDrawMode: number;
  71289. /**
  71290. * Stores the clock-wise side orientation
  71291. */
  71292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71293. /**
  71294. * Stores the counter clock-wise side orientation
  71295. */
  71296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71297. /**
  71298. * Nothing
  71299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71300. */
  71301. static readonly ACTION_NothingTrigger: number;
  71302. /**
  71303. * On pick
  71304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71305. */
  71306. static readonly ACTION_OnPickTrigger: number;
  71307. /**
  71308. * On left pick
  71309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71310. */
  71311. static readonly ACTION_OnLeftPickTrigger: number;
  71312. /**
  71313. * On right pick
  71314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71315. */
  71316. static readonly ACTION_OnRightPickTrigger: number;
  71317. /**
  71318. * On center pick
  71319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71320. */
  71321. static readonly ACTION_OnCenterPickTrigger: number;
  71322. /**
  71323. * On pick down
  71324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71325. */
  71326. static readonly ACTION_OnPickDownTrigger: number;
  71327. /**
  71328. * On double pick
  71329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71330. */
  71331. static readonly ACTION_OnDoublePickTrigger: number;
  71332. /**
  71333. * On pick up
  71334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71335. */
  71336. static readonly ACTION_OnPickUpTrigger: number;
  71337. /**
  71338. * On pick out.
  71339. * This trigger will only be raised if you also declared a OnPickDown
  71340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71341. */
  71342. static readonly ACTION_OnPickOutTrigger: number;
  71343. /**
  71344. * On long press
  71345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71346. */
  71347. static readonly ACTION_OnLongPressTrigger: number;
  71348. /**
  71349. * On pointer over
  71350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71351. */
  71352. static readonly ACTION_OnPointerOverTrigger: number;
  71353. /**
  71354. * On pointer out
  71355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71356. */
  71357. static readonly ACTION_OnPointerOutTrigger: number;
  71358. /**
  71359. * On every frame
  71360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71361. */
  71362. static readonly ACTION_OnEveryFrameTrigger: number;
  71363. /**
  71364. * On intersection enter
  71365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71366. */
  71367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71368. /**
  71369. * On intersection exit
  71370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71371. */
  71372. static readonly ACTION_OnIntersectionExitTrigger: number;
  71373. /**
  71374. * On key down
  71375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71376. */
  71377. static readonly ACTION_OnKeyDownTrigger: number;
  71378. /**
  71379. * On key up
  71380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71381. */
  71382. static readonly ACTION_OnKeyUpTrigger: number;
  71383. /**
  71384. * Billboard mode will only apply to Y axis
  71385. */
  71386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71387. /**
  71388. * Billboard mode will apply to all axes
  71389. */
  71390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71391. /**
  71392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71393. */
  71394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71395. /**
  71396. * Gets or sets base Assets URL
  71397. */
  71398. static PARTICLES_BaseAssetsUrl: string;
  71399. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71400. * Test order :
  71401. * Is the bounding sphere outside the frustum ?
  71402. * If not, are the bounding box vertices outside the frustum ?
  71403. * It not, then the cullable object is in the frustum.
  71404. */
  71405. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71406. /** Culling strategy : Bounding Sphere Only.
  71407. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71408. * It's also less accurate than the standard because some not visible objects can still be selected.
  71409. * Test : is the bounding sphere outside the frustum ?
  71410. * If not, then the cullable object is in the frustum.
  71411. */
  71412. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71413. /** Culling strategy : Optimistic Inclusion.
  71414. * This in an inclusion test first, then the standard exclusion test.
  71415. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71416. * 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.
  71417. * Anyway, it's as accurate as the standard strategy.
  71418. * Test :
  71419. * Is the cullable object bounding sphere center in the frustum ?
  71420. * If not, apply the default culling strategy.
  71421. */
  71422. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71423. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71424. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71425. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71426. * 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.
  71427. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71428. * Test :
  71429. * Is the cullable object bounding sphere center in the frustum ?
  71430. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71431. */
  71432. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71433. /**
  71434. * No logging while loading
  71435. */
  71436. static readonly SCENELOADER_NO_LOGGING: number;
  71437. /**
  71438. * Minimal logging while loading
  71439. */
  71440. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71441. /**
  71442. * Summary logging while loading
  71443. */
  71444. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71445. /**
  71446. * Detailled logging while loading
  71447. */
  71448. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71449. }
  71450. }
  71451. declare module BABYLON {
  71452. /**
  71453. * This represents the required contract to create a new type of texture loader.
  71454. */
  71455. export interface IInternalTextureLoader {
  71456. /**
  71457. * Defines wether the loader supports cascade loading the different faces.
  71458. */
  71459. supportCascades: boolean;
  71460. /**
  71461. * This returns if the loader support the current file information.
  71462. * @param extension defines the file extension of the file being loaded
  71463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71464. * @param fallback defines the fallback internal texture if any
  71465. * @param isBase64 defines whether the texture is encoded as a base64
  71466. * @param isBuffer defines whether the texture data are stored as a buffer
  71467. * @returns true if the loader can load the specified file
  71468. */
  71469. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71470. /**
  71471. * Transform the url before loading if required.
  71472. * @param rootUrl the url of the texture
  71473. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71474. * @returns the transformed texture
  71475. */
  71476. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71477. /**
  71478. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71479. * @param rootUrl the url of the texture
  71480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71481. * @returns the fallback texture
  71482. */
  71483. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71484. /**
  71485. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71486. * @param data contains the texture data
  71487. * @param texture defines the BabylonJS internal texture
  71488. * @param createPolynomials will be true if polynomials have been requested
  71489. * @param onLoad defines the callback to trigger once the texture is ready
  71490. * @param onError defines the callback to trigger in case of error
  71491. */
  71492. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71493. /**
  71494. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71495. * @param data contains the texture data
  71496. * @param texture defines the BabylonJS internal texture
  71497. * @param callback defines the method to call once ready to upload
  71498. */
  71499. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71500. }
  71501. }
  71502. declare module BABYLON {
  71503. /**
  71504. * Class used to store and describe the pipeline context associated with an effect
  71505. */
  71506. export interface IPipelineContext {
  71507. /**
  71508. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71509. */
  71510. isAsync: boolean;
  71511. /**
  71512. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71513. */
  71514. isReady: boolean;
  71515. /** @hidden */
  71516. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71517. }
  71518. }
  71519. declare module BABYLON {
  71520. /**
  71521. * Class used to store gfx data (like WebGLBuffer)
  71522. */
  71523. export class DataBuffer {
  71524. /**
  71525. * Gets or sets the number of objects referencing this buffer
  71526. */
  71527. references: number;
  71528. /** Gets or sets the size of the underlying buffer */
  71529. capacity: number;
  71530. /**
  71531. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71532. */
  71533. is32Bits: boolean;
  71534. /**
  71535. * Gets the underlying buffer
  71536. */
  71537. readonly underlyingResource: any;
  71538. }
  71539. }
  71540. declare module BABYLON {
  71541. /** @hidden */
  71542. export interface IShaderProcessor {
  71543. attributeProcessor?: (attribute: string) => string;
  71544. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71545. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71546. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71547. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71548. lineProcessor?: (line: string, isFragment: boolean) => string;
  71549. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71550. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71551. }
  71552. }
  71553. declare module BABYLON {
  71554. /** @hidden */
  71555. export interface ProcessingOptions {
  71556. defines: string[];
  71557. indexParameters: any;
  71558. isFragment: boolean;
  71559. shouldUseHighPrecisionShader: boolean;
  71560. supportsUniformBuffers: boolean;
  71561. shadersRepository: string;
  71562. includesShadersStore: {
  71563. [key: string]: string;
  71564. };
  71565. processor?: IShaderProcessor;
  71566. version: string;
  71567. platformName: string;
  71568. lookForClosingBracketForUniformBuffer?: boolean;
  71569. }
  71570. }
  71571. declare module BABYLON {
  71572. /**
  71573. * Helper to manipulate strings
  71574. */
  71575. export class StringTools {
  71576. /**
  71577. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71578. * @param str Source string
  71579. * @param suffix Suffix to search for in the source string
  71580. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71581. */
  71582. static EndsWith(str: string, suffix: string): boolean;
  71583. /**
  71584. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71585. * @param str Source string
  71586. * @param suffix Suffix to search for in the source string
  71587. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71588. */
  71589. static StartsWith(str: string, suffix: string): boolean;
  71590. }
  71591. }
  71592. declare module BABYLON {
  71593. /** @hidden */
  71594. export class ShaderCodeNode {
  71595. line: string;
  71596. children: ShaderCodeNode[];
  71597. additionalDefineKey?: string;
  71598. additionalDefineValue?: string;
  71599. isValid(preprocessors: {
  71600. [key: string]: string;
  71601. }): boolean;
  71602. process(preprocessors: {
  71603. [key: string]: string;
  71604. }, options: ProcessingOptions): string;
  71605. }
  71606. }
  71607. declare module BABYLON {
  71608. /** @hidden */
  71609. export class ShaderCodeCursor {
  71610. private _lines;
  71611. lineIndex: number;
  71612. readonly currentLine: string;
  71613. readonly canRead: boolean;
  71614. lines: string[];
  71615. }
  71616. }
  71617. declare module BABYLON {
  71618. /** @hidden */
  71619. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71620. process(preprocessors: {
  71621. [key: string]: string;
  71622. }, options: ProcessingOptions): string;
  71623. }
  71624. }
  71625. declare module BABYLON {
  71626. /** @hidden */
  71627. export class ShaderDefineExpression {
  71628. isTrue(preprocessors: {
  71629. [key: string]: string;
  71630. }): boolean;
  71631. }
  71632. }
  71633. declare module BABYLON {
  71634. /** @hidden */
  71635. export class ShaderCodeTestNode extends ShaderCodeNode {
  71636. testExpression: ShaderDefineExpression;
  71637. isValid(preprocessors: {
  71638. [key: string]: string;
  71639. }): boolean;
  71640. }
  71641. }
  71642. declare module BABYLON {
  71643. /** @hidden */
  71644. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71645. define: string;
  71646. not: boolean;
  71647. constructor(define: string, not?: boolean);
  71648. isTrue(preprocessors: {
  71649. [key: string]: string;
  71650. }): boolean;
  71651. }
  71652. }
  71653. declare module BABYLON {
  71654. /** @hidden */
  71655. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71656. leftOperand: ShaderDefineExpression;
  71657. rightOperand: ShaderDefineExpression;
  71658. isTrue(preprocessors: {
  71659. [key: string]: string;
  71660. }): boolean;
  71661. }
  71662. }
  71663. declare module BABYLON {
  71664. /** @hidden */
  71665. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71666. leftOperand: ShaderDefineExpression;
  71667. rightOperand: ShaderDefineExpression;
  71668. isTrue(preprocessors: {
  71669. [key: string]: string;
  71670. }): boolean;
  71671. }
  71672. }
  71673. declare module BABYLON {
  71674. /** @hidden */
  71675. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71676. define: string;
  71677. operand: string;
  71678. testValue: string;
  71679. constructor(define: string, operand: string, testValue: string);
  71680. isTrue(preprocessors: {
  71681. [key: string]: string;
  71682. }): boolean;
  71683. }
  71684. }
  71685. declare module BABYLON {
  71686. /**
  71687. * @ignore
  71688. * Application error to support additional information when loading a file
  71689. */
  71690. export class LoadFileError extends Error {
  71691. /** defines the optional web request */
  71692. request?: WebRequest | undefined;
  71693. private static _setPrototypeOf;
  71694. /**
  71695. * Creates a new LoadFileError
  71696. * @param message defines the message of the error
  71697. * @param request defines the optional web request
  71698. */
  71699. constructor(message: string,
  71700. /** defines the optional web request */
  71701. request?: WebRequest | undefined);
  71702. }
  71703. }
  71704. declare module BABYLON {
  71705. /**
  71706. * Class used to enable access to offline support
  71707. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71708. */
  71709. export interface IOfflineProvider {
  71710. /**
  71711. * Gets a boolean indicating if scene must be saved in the database
  71712. */
  71713. enableSceneOffline: boolean;
  71714. /**
  71715. * Gets a boolean indicating if textures must be saved in the database
  71716. */
  71717. enableTexturesOffline: boolean;
  71718. /**
  71719. * Open the offline support and make it available
  71720. * @param successCallback defines the callback to call on success
  71721. * @param errorCallback defines the callback to call on error
  71722. */
  71723. open(successCallback: () => void, errorCallback: () => void): void;
  71724. /**
  71725. * Loads an image from the offline support
  71726. * @param url defines the url to load from
  71727. * @param image defines the target DOM image
  71728. */
  71729. loadImage(url: string, image: HTMLImageElement): void;
  71730. /**
  71731. * Loads a file from offline support
  71732. * @param url defines the URL to load from
  71733. * @param sceneLoaded defines a callback to call on success
  71734. * @param progressCallBack defines a callback to call when progress changed
  71735. * @param errorCallback defines a callback to call on error
  71736. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71737. */
  71738. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71739. }
  71740. }
  71741. declare module BABYLON {
  71742. /**
  71743. * Class used to help managing file picking and drag'n'drop
  71744. * File Storage
  71745. */
  71746. export class FilesInputStore {
  71747. /**
  71748. * List of files ready to be loaded
  71749. */
  71750. static FilesToLoad: {
  71751. [key: string]: File;
  71752. };
  71753. }
  71754. }
  71755. declare module BABYLON {
  71756. /**
  71757. * Class used to define a retry strategy when error happens while loading assets
  71758. */
  71759. export class RetryStrategy {
  71760. /**
  71761. * Function used to defines an exponential back off strategy
  71762. * @param maxRetries defines the maximum number of retries (3 by default)
  71763. * @param baseInterval defines the interval between retries
  71764. * @returns the strategy function to use
  71765. */
  71766. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71767. }
  71768. }
  71769. declare module BABYLON {
  71770. /**
  71771. * @hidden
  71772. */
  71773. export class FileTools {
  71774. /**
  71775. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71776. */
  71777. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71778. /**
  71779. * Gets or sets the base URL to use to load assets
  71780. */
  71781. static BaseUrl: string;
  71782. /**
  71783. * Default behaviour for cors in the application.
  71784. * It can be a string if the expected behavior is identical in the entire app.
  71785. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71786. */
  71787. static CorsBehavior: string | ((url: string | string[]) => string);
  71788. /**
  71789. * Gets or sets a function used to pre-process url before using them to load assets
  71790. */
  71791. static PreprocessUrl: (url: string) => string;
  71792. /**
  71793. * Removes unwanted characters from an url
  71794. * @param url defines the url to clean
  71795. * @returns the cleaned url
  71796. */
  71797. private static _CleanUrl;
  71798. /**
  71799. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71800. * @param url define the url we are trying
  71801. * @param element define the dom element where to configure the cors policy
  71802. */
  71803. static SetCorsBehavior(url: string | string[], element: {
  71804. crossOrigin: string | null;
  71805. }): void;
  71806. /**
  71807. * Loads an image as an HTMLImageElement.
  71808. * @param input url string, ArrayBuffer, or Blob to load
  71809. * @param onLoad callback called when the image successfully loads
  71810. * @param onError callback called when the image fails to load
  71811. * @param offlineProvider offline provider for caching
  71812. * @returns the HTMLImageElement of the loaded image
  71813. */
  71814. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71815. /**
  71816. * Loads a file
  71817. * @param fileToLoad defines the file to load
  71818. * @param callback defines the callback to call when data is loaded
  71819. * @param progressCallBack defines the callback to call during loading process
  71820. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71821. * @returns a file request object
  71822. */
  71823. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71824. /**
  71825. * Loads a file
  71826. * @param url url string, ArrayBuffer, or Blob to load
  71827. * @param onSuccess callback called when the file successfully loads
  71828. * @param onProgress callback called while file is loading (if the server supports this mode)
  71829. * @param offlineProvider defines the offline provider for caching
  71830. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71831. * @param onError callback called when the file fails to load
  71832. * @returns a file request object
  71833. */
  71834. 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;
  71835. /**
  71836. * Checks if the loaded document was accessed via `file:`-Protocol.
  71837. * @returns boolean
  71838. */
  71839. static IsFileURL(): boolean;
  71840. }
  71841. }
  71842. declare module BABYLON {
  71843. /** @hidden */
  71844. export class ShaderProcessor {
  71845. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71846. private static _ProcessPrecision;
  71847. private static _ExtractOperation;
  71848. private static _BuildSubExpression;
  71849. private static _BuildExpression;
  71850. private static _MoveCursorWithinIf;
  71851. private static _MoveCursor;
  71852. private static _EvaluatePreProcessors;
  71853. private static _PreparePreProcessors;
  71854. private static _ProcessShaderConversion;
  71855. private static _ProcessIncludes;
  71856. }
  71857. }
  71858. declare module BABYLON {
  71859. /**
  71860. * Interface used to define common properties for effect fallbacks
  71861. */
  71862. export interface IEffectFallbacks {
  71863. /**
  71864. * Removes the defines that should be removed when falling back.
  71865. * @param currentDefines defines the current define statements for the shader.
  71866. * @param effect defines the current effect we try to compile
  71867. * @returns The resulting defines with defines of the current rank removed.
  71868. */
  71869. reduce(currentDefines: string, effect: Effect): string;
  71870. /**
  71871. * Removes the fallback from the bound mesh.
  71872. */
  71873. unBindMesh(): void;
  71874. /**
  71875. * Checks to see if more fallbacks are still availible.
  71876. */
  71877. hasMoreFallbacks: boolean;
  71878. }
  71879. }
  71880. declare module BABYLON {
  71881. /**
  71882. * Class used to evalaute queries containing `and` and `or` operators
  71883. */
  71884. export class AndOrNotEvaluator {
  71885. /**
  71886. * Evaluate a query
  71887. * @param query defines the query to evaluate
  71888. * @param evaluateCallback defines the callback used to filter result
  71889. * @returns true if the query matches
  71890. */
  71891. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71892. private static _HandleParenthesisContent;
  71893. private static _SimplifyNegation;
  71894. }
  71895. }
  71896. declare module BABYLON {
  71897. /**
  71898. * Class used to store custom tags
  71899. */
  71900. export class Tags {
  71901. /**
  71902. * Adds support for tags on the given object
  71903. * @param obj defines the object to use
  71904. */
  71905. static EnableFor(obj: any): void;
  71906. /**
  71907. * Removes tags support
  71908. * @param obj defines the object to use
  71909. */
  71910. static DisableFor(obj: any): void;
  71911. /**
  71912. * Gets a boolean indicating if the given object has tags
  71913. * @param obj defines the object to use
  71914. * @returns a boolean
  71915. */
  71916. static HasTags(obj: any): boolean;
  71917. /**
  71918. * Gets the tags available on a given object
  71919. * @param obj defines the object to use
  71920. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71921. * @returns the tags
  71922. */
  71923. static GetTags(obj: any, asString?: boolean): any;
  71924. /**
  71925. * Adds tags to an object
  71926. * @param obj defines the object to use
  71927. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71928. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71929. */
  71930. static AddTagsTo(obj: any, tagsString: string): void;
  71931. /**
  71932. * @hidden
  71933. */
  71934. static _AddTagTo(obj: any, tag: string): void;
  71935. /**
  71936. * Removes specific tags from a specific object
  71937. * @param obj defines the object to use
  71938. * @param tagsString defines the tags to remove
  71939. */
  71940. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71941. /**
  71942. * @hidden
  71943. */
  71944. static _RemoveTagFrom(obj: any, tag: string): void;
  71945. /**
  71946. * Defines if tags hosted on an object match a given query
  71947. * @param obj defines the object to use
  71948. * @param tagsQuery defines the tag query
  71949. * @returns a boolean
  71950. */
  71951. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71952. }
  71953. }
  71954. declare module BABYLON {
  71955. /**
  71956. * Defines potential orientation for back face culling
  71957. */
  71958. export enum Orientation {
  71959. /**
  71960. * Clockwise
  71961. */
  71962. CW = 0,
  71963. /** Counter clockwise */
  71964. CCW = 1
  71965. }
  71966. /** Class used to represent a Bezier curve */
  71967. export class BezierCurve {
  71968. /**
  71969. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71970. * @param t defines the time
  71971. * @param x1 defines the left coordinate on X axis
  71972. * @param y1 defines the left coordinate on Y axis
  71973. * @param x2 defines the right coordinate on X axis
  71974. * @param y2 defines the right coordinate on Y axis
  71975. * @returns the interpolated value
  71976. */
  71977. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71978. }
  71979. /**
  71980. * Defines angle representation
  71981. */
  71982. export class Angle {
  71983. private _radians;
  71984. /**
  71985. * Creates an Angle object of "radians" radians (float).
  71986. * @param radians the angle in radians
  71987. */
  71988. constructor(radians: number);
  71989. /**
  71990. * Get value in degrees
  71991. * @returns the Angle value in degrees (float)
  71992. */
  71993. degrees(): number;
  71994. /**
  71995. * Get value in radians
  71996. * @returns the Angle value in radians (float)
  71997. */
  71998. radians(): number;
  71999. /**
  72000. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72001. * @param a defines first vector
  72002. * @param b defines second vector
  72003. * @returns a new Angle
  72004. */
  72005. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72006. /**
  72007. * Gets a new Angle object from the given float in radians
  72008. * @param radians defines the angle value in radians
  72009. * @returns a new Angle
  72010. */
  72011. static FromRadians(radians: number): Angle;
  72012. /**
  72013. * Gets a new Angle object from the given float in degrees
  72014. * @param degrees defines the angle value in degrees
  72015. * @returns a new Angle
  72016. */
  72017. static FromDegrees(degrees: number): Angle;
  72018. }
  72019. /**
  72020. * This represents an arc in a 2d space.
  72021. */
  72022. export class Arc2 {
  72023. /** Defines the start point of the arc */
  72024. startPoint: Vector2;
  72025. /** Defines the mid point of the arc */
  72026. midPoint: Vector2;
  72027. /** Defines the end point of the arc */
  72028. endPoint: Vector2;
  72029. /**
  72030. * Defines the center point of the arc.
  72031. */
  72032. centerPoint: Vector2;
  72033. /**
  72034. * Defines the radius of the arc.
  72035. */
  72036. radius: number;
  72037. /**
  72038. * Defines the angle of the arc (from mid point to end point).
  72039. */
  72040. angle: Angle;
  72041. /**
  72042. * Defines the start angle of the arc (from start point to middle point).
  72043. */
  72044. startAngle: Angle;
  72045. /**
  72046. * Defines the orientation of the arc (clock wise/counter clock wise).
  72047. */
  72048. orientation: Orientation;
  72049. /**
  72050. * Creates an Arc object from the three given points : start, middle and end.
  72051. * @param startPoint Defines the start point of the arc
  72052. * @param midPoint Defines the midlle point of the arc
  72053. * @param endPoint Defines the end point of the arc
  72054. */
  72055. constructor(
  72056. /** Defines the start point of the arc */
  72057. startPoint: Vector2,
  72058. /** Defines the mid point of the arc */
  72059. midPoint: Vector2,
  72060. /** Defines the end point of the arc */
  72061. endPoint: Vector2);
  72062. }
  72063. /**
  72064. * Represents a 2D path made up of multiple 2D points
  72065. */
  72066. export class Path2 {
  72067. private _points;
  72068. private _length;
  72069. /**
  72070. * If the path start and end point are the same
  72071. */
  72072. closed: boolean;
  72073. /**
  72074. * Creates a Path2 object from the starting 2D coordinates x and y.
  72075. * @param x the starting points x value
  72076. * @param y the starting points y value
  72077. */
  72078. constructor(x: number, y: number);
  72079. /**
  72080. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72081. * @param x the added points x value
  72082. * @param y the added points y value
  72083. * @returns the updated Path2.
  72084. */
  72085. addLineTo(x: number, y: number): Path2;
  72086. /**
  72087. * 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.
  72088. * @param midX middle point x value
  72089. * @param midY middle point y value
  72090. * @param endX end point x value
  72091. * @param endY end point y value
  72092. * @param numberOfSegments (default: 36)
  72093. * @returns the updated Path2.
  72094. */
  72095. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72096. /**
  72097. * Closes the Path2.
  72098. * @returns the Path2.
  72099. */
  72100. close(): Path2;
  72101. /**
  72102. * Gets the sum of the distance between each sequential point in the path
  72103. * @returns the Path2 total length (float).
  72104. */
  72105. length(): number;
  72106. /**
  72107. * Gets the points which construct the path
  72108. * @returns the Path2 internal array of points.
  72109. */
  72110. getPoints(): Vector2[];
  72111. /**
  72112. * Retreives the point at the distance aways from the starting point
  72113. * @param normalizedLengthPosition the length along the path to retreive the point from
  72114. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72115. */
  72116. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72117. /**
  72118. * Creates a new path starting from an x and y position
  72119. * @param x starting x value
  72120. * @param y starting y value
  72121. * @returns a new Path2 starting at the coordinates (x, y).
  72122. */
  72123. static StartingAt(x: number, y: number): Path2;
  72124. }
  72125. /**
  72126. * Represents a 3D path made up of multiple 3D points
  72127. */
  72128. export class Path3D {
  72129. /**
  72130. * an array of Vector3, the curve axis of the Path3D
  72131. */
  72132. path: Vector3[];
  72133. private _curve;
  72134. private _distances;
  72135. private _tangents;
  72136. private _normals;
  72137. private _binormals;
  72138. private _raw;
  72139. /**
  72140. * new Path3D(path, normal, raw)
  72141. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72142. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72143. * @param path an array of Vector3, the curve axis of the Path3D
  72144. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72145. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72146. */
  72147. constructor(
  72148. /**
  72149. * an array of Vector3, the curve axis of the Path3D
  72150. */
  72151. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72152. /**
  72153. * Returns the Path3D array of successive Vector3 designing its curve.
  72154. * @returns the Path3D array of successive Vector3 designing its curve.
  72155. */
  72156. getCurve(): Vector3[];
  72157. /**
  72158. * Returns an array populated with tangent vectors on each Path3D curve point.
  72159. * @returns an array populated with tangent vectors on each Path3D curve point.
  72160. */
  72161. getTangents(): Vector3[];
  72162. /**
  72163. * Returns an array populated with normal vectors on each Path3D curve point.
  72164. * @returns an array populated with normal vectors on each Path3D curve point.
  72165. */
  72166. getNormals(): Vector3[];
  72167. /**
  72168. * Returns an array populated with binormal vectors on each Path3D curve point.
  72169. * @returns an array populated with binormal vectors on each Path3D curve point.
  72170. */
  72171. getBinormals(): Vector3[];
  72172. /**
  72173. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72174. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72175. */
  72176. getDistances(): number[];
  72177. /**
  72178. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72179. * @param path path which all values are copied into the curves points
  72180. * @param firstNormal which should be projected onto the curve
  72181. * @returns the same object updated.
  72182. */
  72183. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72184. private _compute;
  72185. private _getFirstNonNullVector;
  72186. private _getLastNonNullVector;
  72187. private _normalVector;
  72188. }
  72189. /**
  72190. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72191. * A Curve3 is designed from a series of successive Vector3.
  72192. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72193. */
  72194. export class Curve3 {
  72195. private _points;
  72196. private _length;
  72197. /**
  72198. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72199. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72200. * @param v1 (Vector3) the control point
  72201. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72202. * @param nbPoints (integer) the wanted number of points in the curve
  72203. * @returns the created Curve3
  72204. */
  72205. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72206. /**
  72207. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72208. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72209. * @param v1 (Vector3) the first control point
  72210. * @param v2 (Vector3) the second control point
  72211. * @param v3 (Vector3) the end point of the Cubic Bezier
  72212. * @param nbPoints (integer) the wanted number of points in the curve
  72213. * @returns the created Curve3
  72214. */
  72215. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72216. /**
  72217. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72218. * @param p1 (Vector3) the origin point of the Hermite Spline
  72219. * @param t1 (Vector3) the tangent vector at the origin point
  72220. * @param p2 (Vector3) the end point of the Hermite Spline
  72221. * @param t2 (Vector3) the tangent vector at the end point
  72222. * @param nbPoints (integer) the wanted number of points in the curve
  72223. * @returns the created Curve3
  72224. */
  72225. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72226. /**
  72227. * Returns a Curve3 object along a CatmullRom Spline curve :
  72228. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72229. * @param nbPoints (integer) the wanted number of points between each curve control points
  72230. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72231. * @returns the created Curve3
  72232. */
  72233. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72234. /**
  72235. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72236. * A Curve3 is designed from a series of successive Vector3.
  72237. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72238. * @param points points which make up the curve
  72239. */
  72240. constructor(points: Vector3[]);
  72241. /**
  72242. * @returns the Curve3 stored array of successive Vector3
  72243. */
  72244. getPoints(): Vector3[];
  72245. /**
  72246. * @returns the computed length (float) of the curve.
  72247. */
  72248. length(): number;
  72249. /**
  72250. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72251. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72252. * curveA and curveB keep unchanged.
  72253. * @param curve the curve to continue from this curve
  72254. * @returns the newly constructed curve
  72255. */
  72256. continue(curve: DeepImmutable<Curve3>): Curve3;
  72257. private _computeLength;
  72258. }
  72259. }
  72260. declare module BABYLON {
  72261. /**
  72262. * This represents the main contract an easing function should follow.
  72263. * Easing functions are used throughout the animation system.
  72264. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72265. */
  72266. export interface IEasingFunction {
  72267. /**
  72268. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72269. * of the easing function.
  72270. * The link below provides some of the most common examples of easing functions.
  72271. * @see https://easings.net/
  72272. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72273. * @returns the corresponding value on the curve defined by the easing function
  72274. */
  72275. ease(gradient: number): number;
  72276. }
  72277. /**
  72278. * Base class used for every default easing function.
  72279. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72280. */
  72281. export class EasingFunction implements IEasingFunction {
  72282. /**
  72283. * Interpolation follows the mathematical formula associated with the easing function.
  72284. */
  72285. static readonly EASINGMODE_EASEIN: number;
  72286. /**
  72287. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72288. */
  72289. static readonly EASINGMODE_EASEOUT: number;
  72290. /**
  72291. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72292. */
  72293. static readonly EASINGMODE_EASEINOUT: number;
  72294. private _easingMode;
  72295. /**
  72296. * Sets the easing mode of the current function.
  72297. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72298. */
  72299. setEasingMode(easingMode: number): void;
  72300. /**
  72301. * Gets the current easing mode.
  72302. * @returns the easing mode
  72303. */
  72304. getEasingMode(): number;
  72305. /**
  72306. * @hidden
  72307. */
  72308. easeInCore(gradient: number): number;
  72309. /**
  72310. * Given an input gradient between 0 and 1, this returns the corresponding value
  72311. * of the easing function.
  72312. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72313. * @returns the corresponding value on the curve defined by the easing function
  72314. */
  72315. ease(gradient: number): number;
  72316. }
  72317. /**
  72318. * Easing function with a circle shape (see link below).
  72319. * @see https://easings.net/#easeInCirc
  72320. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72321. */
  72322. export class CircleEase extends EasingFunction implements IEasingFunction {
  72323. /** @hidden */
  72324. easeInCore(gradient: number): number;
  72325. }
  72326. /**
  72327. * Easing function with a ease back shape (see link below).
  72328. * @see https://easings.net/#easeInBack
  72329. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72330. */
  72331. export class BackEase extends EasingFunction implements IEasingFunction {
  72332. /** Defines the amplitude of the function */
  72333. amplitude: number;
  72334. /**
  72335. * Instantiates a back ease easing
  72336. * @see https://easings.net/#easeInBack
  72337. * @param amplitude Defines the amplitude of the function
  72338. */
  72339. constructor(
  72340. /** Defines the amplitude of the function */
  72341. amplitude?: number);
  72342. /** @hidden */
  72343. easeInCore(gradient: number): number;
  72344. }
  72345. /**
  72346. * Easing function with a bouncing shape (see link below).
  72347. * @see https://easings.net/#easeInBounce
  72348. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72349. */
  72350. export class BounceEase extends EasingFunction implements IEasingFunction {
  72351. /** Defines the number of bounces */
  72352. bounces: number;
  72353. /** Defines the amplitude of the bounce */
  72354. bounciness: number;
  72355. /**
  72356. * Instantiates a bounce easing
  72357. * @see https://easings.net/#easeInBounce
  72358. * @param bounces Defines the number of bounces
  72359. * @param bounciness Defines the amplitude of the bounce
  72360. */
  72361. constructor(
  72362. /** Defines the number of bounces */
  72363. bounces?: number,
  72364. /** Defines the amplitude of the bounce */
  72365. bounciness?: number);
  72366. /** @hidden */
  72367. easeInCore(gradient: number): number;
  72368. }
  72369. /**
  72370. * Easing function with a power of 3 shape (see link below).
  72371. * @see https://easings.net/#easeInCubic
  72372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72373. */
  72374. export class CubicEase extends EasingFunction implements IEasingFunction {
  72375. /** @hidden */
  72376. easeInCore(gradient: number): number;
  72377. }
  72378. /**
  72379. * Easing function with an elastic shape (see link below).
  72380. * @see https://easings.net/#easeInElastic
  72381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72382. */
  72383. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72384. /** Defines the number of oscillations*/
  72385. oscillations: number;
  72386. /** Defines the amplitude of the oscillations*/
  72387. springiness: number;
  72388. /**
  72389. * Instantiates an elastic easing function
  72390. * @see https://easings.net/#easeInElastic
  72391. * @param oscillations Defines the number of oscillations
  72392. * @param springiness Defines the amplitude of the oscillations
  72393. */
  72394. constructor(
  72395. /** Defines the number of oscillations*/
  72396. oscillations?: number,
  72397. /** Defines the amplitude of the oscillations*/
  72398. springiness?: number);
  72399. /** @hidden */
  72400. easeInCore(gradient: number): number;
  72401. }
  72402. /**
  72403. * Easing function with an exponential shape (see link below).
  72404. * @see https://easings.net/#easeInExpo
  72405. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72406. */
  72407. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72408. /** Defines the exponent of the function */
  72409. exponent: number;
  72410. /**
  72411. * Instantiates an exponential easing function
  72412. * @see https://easings.net/#easeInExpo
  72413. * @param exponent Defines the exponent of the function
  72414. */
  72415. constructor(
  72416. /** Defines the exponent of the function */
  72417. exponent?: number);
  72418. /** @hidden */
  72419. easeInCore(gradient: number): number;
  72420. }
  72421. /**
  72422. * Easing function with a power shape (see link below).
  72423. * @see https://easings.net/#easeInQuad
  72424. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72425. */
  72426. export class PowerEase extends EasingFunction implements IEasingFunction {
  72427. /** Defines the power of the function */
  72428. power: number;
  72429. /**
  72430. * Instantiates an power base easing function
  72431. * @see https://easings.net/#easeInQuad
  72432. * @param power Defines the power of the function
  72433. */
  72434. constructor(
  72435. /** Defines the power of the function */
  72436. power?: number);
  72437. /** @hidden */
  72438. easeInCore(gradient: number): number;
  72439. }
  72440. /**
  72441. * Easing function with a power of 2 shape (see link below).
  72442. * @see https://easings.net/#easeInQuad
  72443. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72444. */
  72445. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72446. /** @hidden */
  72447. easeInCore(gradient: number): number;
  72448. }
  72449. /**
  72450. * Easing function with a power of 4 shape (see link below).
  72451. * @see https://easings.net/#easeInQuart
  72452. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72453. */
  72454. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72455. /** @hidden */
  72456. easeInCore(gradient: number): number;
  72457. }
  72458. /**
  72459. * Easing function with a power of 5 shape (see link below).
  72460. * @see https://easings.net/#easeInQuint
  72461. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72462. */
  72463. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72464. /** @hidden */
  72465. easeInCore(gradient: number): number;
  72466. }
  72467. /**
  72468. * Easing function with a sin shape (see link below).
  72469. * @see https://easings.net/#easeInSine
  72470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72471. */
  72472. export class SineEase extends EasingFunction implements IEasingFunction {
  72473. /** @hidden */
  72474. easeInCore(gradient: number): number;
  72475. }
  72476. /**
  72477. * Easing function with a bezier shape (see link below).
  72478. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72480. */
  72481. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72482. /** Defines the x component of the start tangent in the bezier curve */
  72483. x1: number;
  72484. /** Defines the y component of the start tangent in the bezier curve */
  72485. y1: number;
  72486. /** Defines the x component of the end tangent in the bezier curve */
  72487. x2: number;
  72488. /** Defines the y component of the end tangent in the bezier curve */
  72489. y2: number;
  72490. /**
  72491. * Instantiates a bezier function
  72492. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72493. * @param x1 Defines the x component of the start tangent in the bezier curve
  72494. * @param y1 Defines the y component of the start tangent in the bezier curve
  72495. * @param x2 Defines the x component of the end tangent in the bezier curve
  72496. * @param y2 Defines the y component of the end tangent in the bezier curve
  72497. */
  72498. constructor(
  72499. /** Defines the x component of the start tangent in the bezier curve */
  72500. x1?: number,
  72501. /** Defines the y component of the start tangent in the bezier curve */
  72502. y1?: number,
  72503. /** Defines the x component of the end tangent in the bezier curve */
  72504. x2?: number,
  72505. /** Defines the y component of the end tangent in the bezier curve */
  72506. y2?: number);
  72507. /** @hidden */
  72508. easeInCore(gradient: number): number;
  72509. }
  72510. }
  72511. declare module BABYLON {
  72512. /**
  72513. * Defines an interface which represents an animation key frame
  72514. */
  72515. export interface IAnimationKey {
  72516. /**
  72517. * Frame of the key frame
  72518. */
  72519. frame: number;
  72520. /**
  72521. * Value at the specifies key frame
  72522. */
  72523. value: any;
  72524. /**
  72525. * The input tangent for the cubic hermite spline
  72526. */
  72527. inTangent?: any;
  72528. /**
  72529. * The output tangent for the cubic hermite spline
  72530. */
  72531. outTangent?: any;
  72532. /**
  72533. * The animation interpolation type
  72534. */
  72535. interpolation?: AnimationKeyInterpolation;
  72536. }
  72537. /**
  72538. * Enum for the animation key frame interpolation type
  72539. */
  72540. export enum AnimationKeyInterpolation {
  72541. /**
  72542. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72543. */
  72544. STEP = 1
  72545. }
  72546. }
  72547. declare module BABYLON {
  72548. /**
  72549. * Represents the range of an animation
  72550. */
  72551. export class AnimationRange {
  72552. /**The name of the animation range**/
  72553. name: string;
  72554. /**The starting frame of the animation */
  72555. from: number;
  72556. /**The ending frame of the animation*/
  72557. to: number;
  72558. /**
  72559. * Initializes the range of an animation
  72560. * @param name The name of the animation range
  72561. * @param from The starting frame of the animation
  72562. * @param to The ending frame of the animation
  72563. */
  72564. constructor(
  72565. /**The name of the animation range**/
  72566. name: string,
  72567. /**The starting frame of the animation */
  72568. from: number,
  72569. /**The ending frame of the animation*/
  72570. to: number);
  72571. /**
  72572. * Makes a copy of the animation range
  72573. * @returns A copy of the animation range
  72574. */
  72575. clone(): AnimationRange;
  72576. }
  72577. }
  72578. declare module BABYLON {
  72579. /**
  72580. * Composed of a frame, and an action function
  72581. */
  72582. export class AnimationEvent {
  72583. /** The frame for which the event is triggered **/
  72584. frame: number;
  72585. /** The event to perform when triggered **/
  72586. action: (currentFrame: number) => void;
  72587. /** Specifies if the event should be triggered only once**/
  72588. onlyOnce?: boolean | undefined;
  72589. /**
  72590. * Specifies if the animation event is done
  72591. */
  72592. isDone: boolean;
  72593. /**
  72594. * Initializes the animation event
  72595. * @param frame The frame for which the event is triggered
  72596. * @param action The event to perform when triggered
  72597. * @param onlyOnce Specifies if the event should be triggered only once
  72598. */
  72599. constructor(
  72600. /** The frame for which the event is triggered **/
  72601. frame: number,
  72602. /** The event to perform when triggered **/
  72603. action: (currentFrame: number) => void,
  72604. /** Specifies if the event should be triggered only once**/
  72605. onlyOnce?: boolean | undefined);
  72606. /** @hidden */
  72607. _clone(): AnimationEvent;
  72608. }
  72609. }
  72610. declare module BABYLON {
  72611. /**
  72612. * Interface used to define a behavior
  72613. */
  72614. export interface Behavior<T> {
  72615. /** gets or sets behavior's name */
  72616. name: string;
  72617. /**
  72618. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72619. */
  72620. init(): void;
  72621. /**
  72622. * Called when the behavior is attached to a target
  72623. * @param target defines the target where the behavior is attached to
  72624. */
  72625. attach(target: T): void;
  72626. /**
  72627. * Called when the behavior is detached from its target
  72628. */
  72629. detach(): void;
  72630. }
  72631. /**
  72632. * Interface implemented by classes supporting behaviors
  72633. */
  72634. export interface IBehaviorAware<T> {
  72635. /**
  72636. * Attach a behavior
  72637. * @param behavior defines the behavior to attach
  72638. * @returns the current host
  72639. */
  72640. addBehavior(behavior: Behavior<T>): T;
  72641. /**
  72642. * Remove a behavior from the current object
  72643. * @param behavior defines the behavior to detach
  72644. * @returns the current host
  72645. */
  72646. removeBehavior(behavior: Behavior<T>): T;
  72647. /**
  72648. * Gets a behavior using its name to search
  72649. * @param name defines the name to search
  72650. * @returns the behavior or null if not found
  72651. */
  72652. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72653. }
  72654. }
  72655. declare module BABYLON {
  72656. /**
  72657. * Defines an array and its length.
  72658. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72659. */
  72660. export interface ISmartArrayLike<T> {
  72661. /**
  72662. * The data of the array.
  72663. */
  72664. data: Array<T>;
  72665. /**
  72666. * The active length of the array.
  72667. */
  72668. length: number;
  72669. }
  72670. /**
  72671. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72672. */
  72673. export class SmartArray<T> implements ISmartArrayLike<T> {
  72674. /**
  72675. * The full set of data from the array.
  72676. */
  72677. data: Array<T>;
  72678. /**
  72679. * The active length of the array.
  72680. */
  72681. length: number;
  72682. protected _id: number;
  72683. /**
  72684. * Instantiates a Smart Array.
  72685. * @param capacity defines the default capacity of the array.
  72686. */
  72687. constructor(capacity: number);
  72688. /**
  72689. * Pushes a value at the end of the active data.
  72690. * @param value defines the object to push in the array.
  72691. */
  72692. push(value: T): void;
  72693. /**
  72694. * Iterates over the active data and apply the lambda to them.
  72695. * @param func defines the action to apply on each value.
  72696. */
  72697. forEach(func: (content: T) => void): void;
  72698. /**
  72699. * Sorts the full sets of data.
  72700. * @param compareFn defines the comparison function to apply.
  72701. */
  72702. sort(compareFn: (a: T, b: T) => number): void;
  72703. /**
  72704. * Resets the active data to an empty array.
  72705. */
  72706. reset(): void;
  72707. /**
  72708. * Releases all the data from the array as well as the array.
  72709. */
  72710. dispose(): void;
  72711. /**
  72712. * Concats the active data with a given array.
  72713. * @param array defines the data to concatenate with.
  72714. */
  72715. concat(array: any): void;
  72716. /**
  72717. * Returns the position of a value in the active data.
  72718. * @param value defines the value to find the index for
  72719. * @returns the index if found in the active data otherwise -1
  72720. */
  72721. indexOf(value: T): number;
  72722. /**
  72723. * Returns whether an element is part of the active data.
  72724. * @param value defines the value to look for
  72725. * @returns true if found in the active data otherwise false
  72726. */
  72727. contains(value: T): boolean;
  72728. private static _GlobalId;
  72729. }
  72730. /**
  72731. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72732. * The data in this array can only be present once
  72733. */
  72734. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72735. private _duplicateId;
  72736. /**
  72737. * Pushes a value at the end of the active data.
  72738. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72739. * @param value defines the object to push in the array.
  72740. */
  72741. push(value: T): void;
  72742. /**
  72743. * Pushes a value at the end of the active data.
  72744. * If the data is already present, it won t be added again
  72745. * @param value defines the object to push in the array.
  72746. * @returns true if added false if it was already present
  72747. */
  72748. pushNoDuplicate(value: T): boolean;
  72749. /**
  72750. * Resets the active data to an empty array.
  72751. */
  72752. reset(): void;
  72753. /**
  72754. * Concats the active data with a given array.
  72755. * This ensures no dupplicate will be present in the result.
  72756. * @param array defines the data to concatenate with.
  72757. */
  72758. concatWithNoDuplicate(array: any): void;
  72759. }
  72760. }
  72761. declare module BABYLON {
  72762. /**
  72763. * @ignore
  72764. * This is a list of all the different input types that are available in the application.
  72765. * Fo instance: ArcRotateCameraGamepadInput...
  72766. */
  72767. export var CameraInputTypes: {};
  72768. /**
  72769. * This is the contract to implement in order to create a new input class.
  72770. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72771. */
  72772. export interface ICameraInput<TCamera extends Camera> {
  72773. /**
  72774. * Defines the camera the input is attached to.
  72775. */
  72776. camera: Nullable<TCamera>;
  72777. /**
  72778. * Gets the class name of the current intput.
  72779. * @returns the class name
  72780. */
  72781. getClassName(): string;
  72782. /**
  72783. * Get the friendly name associated with the input class.
  72784. * @returns the input friendly name
  72785. */
  72786. getSimpleName(): string;
  72787. /**
  72788. * Attach the input controls to a specific dom element to get the input from.
  72789. * @param element Defines the element the controls should be listened from
  72790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72791. */
  72792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72793. /**
  72794. * Detach the current controls from the specified dom element.
  72795. * @param element Defines the element to stop listening the inputs from
  72796. */
  72797. detachControl(element: Nullable<HTMLElement>): void;
  72798. /**
  72799. * Update the current camera state depending on the inputs that have been used this frame.
  72800. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72801. */
  72802. checkInputs?: () => void;
  72803. }
  72804. /**
  72805. * Represents a map of input types to input instance or input index to input instance.
  72806. */
  72807. export interface CameraInputsMap<TCamera extends Camera> {
  72808. /**
  72809. * Accessor to the input by input type.
  72810. */
  72811. [name: string]: ICameraInput<TCamera>;
  72812. /**
  72813. * Accessor to the input by input index.
  72814. */
  72815. [idx: number]: ICameraInput<TCamera>;
  72816. }
  72817. /**
  72818. * This represents the input manager used within a camera.
  72819. * It helps dealing with all the different kind of input attached to a camera.
  72820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72821. */
  72822. export class CameraInputsManager<TCamera extends Camera> {
  72823. /**
  72824. * Defines the list of inputs attahed to the camera.
  72825. */
  72826. attached: CameraInputsMap<TCamera>;
  72827. /**
  72828. * Defines the dom element the camera is collecting inputs from.
  72829. * This is null if the controls have not been attached.
  72830. */
  72831. attachedElement: Nullable<HTMLElement>;
  72832. /**
  72833. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72834. */
  72835. noPreventDefault: boolean;
  72836. /**
  72837. * Defined the camera the input manager belongs to.
  72838. */
  72839. camera: TCamera;
  72840. /**
  72841. * Update the current camera state depending on the inputs that have been used this frame.
  72842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72843. */
  72844. checkInputs: () => void;
  72845. /**
  72846. * Instantiate a new Camera Input Manager.
  72847. * @param camera Defines the camera the input manager blongs to
  72848. */
  72849. constructor(camera: TCamera);
  72850. /**
  72851. * Add an input method to a camera
  72852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72853. * @param input camera input method
  72854. */
  72855. add(input: ICameraInput<TCamera>): void;
  72856. /**
  72857. * Remove a specific input method from a camera
  72858. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72859. * @param inputToRemove camera input method
  72860. */
  72861. remove(inputToRemove: ICameraInput<TCamera>): void;
  72862. /**
  72863. * Remove a specific input type from a camera
  72864. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72865. * @param inputType the type of the input to remove
  72866. */
  72867. removeByType(inputType: string): void;
  72868. private _addCheckInputs;
  72869. /**
  72870. * Attach the input controls to the currently attached dom element to listen the events from.
  72871. * @param input Defines the input to attach
  72872. */
  72873. attachInput(input: ICameraInput<TCamera>): void;
  72874. /**
  72875. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72876. * @param element Defines the dom element to collect the events from
  72877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72878. */
  72879. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72880. /**
  72881. * Detach the current manager inputs controls from a specific dom element.
  72882. * @param element Defines the dom element to collect the events from
  72883. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72884. */
  72885. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72886. /**
  72887. * Rebuild the dynamic inputCheck function from the current list of
  72888. * defined inputs in the manager.
  72889. */
  72890. rebuildInputCheck(): void;
  72891. /**
  72892. * Remove all attached input methods from a camera
  72893. */
  72894. clear(): void;
  72895. /**
  72896. * Serialize the current input manager attached to a camera.
  72897. * This ensures than once parsed,
  72898. * the input associated to the camera will be identical to the current ones
  72899. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72900. */
  72901. serialize(serializedCamera: any): void;
  72902. /**
  72903. * Parses an input manager serialized JSON to restore the previous list of inputs
  72904. * and states associated to a camera.
  72905. * @param parsedCamera Defines the JSON to parse
  72906. */
  72907. parse(parsedCamera: any): void;
  72908. }
  72909. }
  72910. declare module BABYLON {
  72911. /**
  72912. * Class used to store data that will be store in GPU memory
  72913. */
  72914. export class Buffer {
  72915. private _engine;
  72916. private _buffer;
  72917. /** @hidden */
  72918. _data: Nullable<DataArray>;
  72919. private _updatable;
  72920. private _instanced;
  72921. /**
  72922. * Gets the byte stride.
  72923. */
  72924. readonly byteStride: number;
  72925. /**
  72926. * Constructor
  72927. * @param engine the engine
  72928. * @param data the data to use for this buffer
  72929. * @param updatable whether the data is updatable
  72930. * @param stride the stride (optional)
  72931. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72932. * @param instanced whether the buffer is instanced (optional)
  72933. * @param useBytes set to true if the stride in in bytes (optional)
  72934. */
  72935. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72936. /**
  72937. * Create a new VertexBuffer based on the current buffer
  72938. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72939. * @param offset defines offset in the buffer (0 by default)
  72940. * @param size defines the size in floats of attributes (position is 3 for instance)
  72941. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72942. * @param instanced defines if the vertex buffer contains indexed data
  72943. * @param useBytes defines if the offset and stride are in bytes
  72944. * @returns the new vertex buffer
  72945. */
  72946. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72947. /**
  72948. * Gets a boolean indicating if the Buffer is updatable?
  72949. * @returns true if the buffer is updatable
  72950. */
  72951. isUpdatable(): boolean;
  72952. /**
  72953. * Gets current buffer's data
  72954. * @returns a DataArray or null
  72955. */
  72956. getData(): Nullable<DataArray>;
  72957. /**
  72958. * Gets underlying native buffer
  72959. * @returns underlying native buffer
  72960. */
  72961. getBuffer(): Nullable<DataBuffer>;
  72962. /**
  72963. * Gets the stride in float32 units (i.e. byte stride / 4).
  72964. * May not be an integer if the byte stride is not divisible by 4.
  72965. * DEPRECATED. Use byteStride instead.
  72966. * @returns the stride in float32 units
  72967. */
  72968. getStrideSize(): number;
  72969. /**
  72970. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72971. * @param data defines the data to store
  72972. */
  72973. create(data?: Nullable<DataArray>): void;
  72974. /** @hidden */
  72975. _rebuild(): void;
  72976. /**
  72977. * Update current buffer data
  72978. * @param data defines the data to store
  72979. */
  72980. update(data: DataArray): void;
  72981. /**
  72982. * Updates the data directly.
  72983. * @param data the new data
  72984. * @param offset the new offset
  72985. * @param vertexCount the vertex count (optional)
  72986. * @param useBytes set to true if the offset is in bytes
  72987. */
  72988. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72989. /**
  72990. * Release all resources
  72991. */
  72992. dispose(): void;
  72993. }
  72994. /**
  72995. * Specialized buffer used to store vertex data
  72996. */
  72997. export class VertexBuffer {
  72998. /** @hidden */
  72999. _buffer: Buffer;
  73000. private _kind;
  73001. private _size;
  73002. private _ownsBuffer;
  73003. private _instanced;
  73004. private _instanceDivisor;
  73005. /**
  73006. * The byte type.
  73007. */
  73008. static readonly BYTE: number;
  73009. /**
  73010. * The unsigned byte type.
  73011. */
  73012. static readonly UNSIGNED_BYTE: number;
  73013. /**
  73014. * The short type.
  73015. */
  73016. static readonly SHORT: number;
  73017. /**
  73018. * The unsigned short type.
  73019. */
  73020. static readonly UNSIGNED_SHORT: number;
  73021. /**
  73022. * The integer type.
  73023. */
  73024. static readonly INT: number;
  73025. /**
  73026. * The unsigned integer type.
  73027. */
  73028. static readonly UNSIGNED_INT: number;
  73029. /**
  73030. * The float type.
  73031. */
  73032. static readonly FLOAT: number;
  73033. /**
  73034. * Gets or sets the instance divisor when in instanced mode
  73035. */
  73036. instanceDivisor: number;
  73037. /**
  73038. * Gets the byte stride.
  73039. */
  73040. readonly byteStride: number;
  73041. /**
  73042. * Gets the byte offset.
  73043. */
  73044. readonly byteOffset: number;
  73045. /**
  73046. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73047. */
  73048. readonly normalized: boolean;
  73049. /**
  73050. * Gets the data type of each component in the array.
  73051. */
  73052. readonly type: number;
  73053. /**
  73054. * Constructor
  73055. * @param engine the engine
  73056. * @param data the data to use for this vertex buffer
  73057. * @param kind the vertex buffer kind
  73058. * @param updatable whether the data is updatable
  73059. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73060. * @param stride the stride (optional)
  73061. * @param instanced whether the buffer is instanced (optional)
  73062. * @param offset the offset of the data (optional)
  73063. * @param size the number of components (optional)
  73064. * @param type the type of the component (optional)
  73065. * @param normalized whether the data contains normalized data (optional)
  73066. * @param useBytes set to true if stride and offset are in bytes (optional)
  73067. */
  73068. 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);
  73069. /** @hidden */
  73070. _rebuild(): void;
  73071. /**
  73072. * Returns the kind of the VertexBuffer (string)
  73073. * @returns a string
  73074. */
  73075. getKind(): string;
  73076. /**
  73077. * Gets a boolean indicating if the VertexBuffer is updatable?
  73078. * @returns true if the buffer is updatable
  73079. */
  73080. isUpdatable(): boolean;
  73081. /**
  73082. * Gets current buffer's data
  73083. * @returns a DataArray or null
  73084. */
  73085. getData(): Nullable<DataArray>;
  73086. /**
  73087. * Gets underlying native buffer
  73088. * @returns underlying native buffer
  73089. */
  73090. getBuffer(): Nullable<DataBuffer>;
  73091. /**
  73092. * Gets the stride in float32 units (i.e. byte stride / 4).
  73093. * May not be an integer if the byte stride is not divisible by 4.
  73094. * DEPRECATED. Use byteStride instead.
  73095. * @returns the stride in float32 units
  73096. */
  73097. getStrideSize(): number;
  73098. /**
  73099. * Returns the offset as a multiple of the type byte length.
  73100. * DEPRECATED. Use byteOffset instead.
  73101. * @returns the offset in bytes
  73102. */
  73103. getOffset(): number;
  73104. /**
  73105. * Returns the number of components per vertex attribute (integer)
  73106. * @returns the size in float
  73107. */
  73108. getSize(): number;
  73109. /**
  73110. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73111. * @returns true if this buffer is instanced
  73112. */
  73113. getIsInstanced(): boolean;
  73114. /**
  73115. * Returns the instancing divisor, zero for non-instanced (integer).
  73116. * @returns a number
  73117. */
  73118. getInstanceDivisor(): number;
  73119. /**
  73120. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73121. * @param data defines the data to store
  73122. */
  73123. create(data?: DataArray): void;
  73124. /**
  73125. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73126. * This function will create a new buffer if the current one is not updatable
  73127. * @param data defines the data to store
  73128. */
  73129. update(data: DataArray): void;
  73130. /**
  73131. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73132. * Returns the directly updated WebGLBuffer.
  73133. * @param data the new data
  73134. * @param offset the new offset
  73135. * @param useBytes set to true if the offset is in bytes
  73136. */
  73137. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73138. /**
  73139. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73140. */
  73141. dispose(): void;
  73142. /**
  73143. * Enumerates each value of this vertex buffer as numbers.
  73144. * @param count the number of values to enumerate
  73145. * @param callback the callback function called for each value
  73146. */
  73147. forEach(count: number, callback: (value: number, index: number) => void): void;
  73148. /**
  73149. * Positions
  73150. */
  73151. static readonly PositionKind: string;
  73152. /**
  73153. * Normals
  73154. */
  73155. static readonly NormalKind: string;
  73156. /**
  73157. * Tangents
  73158. */
  73159. static readonly TangentKind: string;
  73160. /**
  73161. * Texture coordinates
  73162. */
  73163. static readonly UVKind: string;
  73164. /**
  73165. * Texture coordinates 2
  73166. */
  73167. static readonly UV2Kind: string;
  73168. /**
  73169. * Texture coordinates 3
  73170. */
  73171. static readonly UV3Kind: string;
  73172. /**
  73173. * Texture coordinates 4
  73174. */
  73175. static readonly UV4Kind: string;
  73176. /**
  73177. * Texture coordinates 5
  73178. */
  73179. static readonly UV5Kind: string;
  73180. /**
  73181. * Texture coordinates 6
  73182. */
  73183. static readonly UV6Kind: string;
  73184. /**
  73185. * Colors
  73186. */
  73187. static readonly ColorKind: string;
  73188. /**
  73189. * Matrix indices (for bones)
  73190. */
  73191. static readonly MatricesIndicesKind: string;
  73192. /**
  73193. * Matrix weights (for bones)
  73194. */
  73195. static readonly MatricesWeightsKind: string;
  73196. /**
  73197. * Additional matrix indices (for bones)
  73198. */
  73199. static readonly MatricesIndicesExtraKind: string;
  73200. /**
  73201. * Additional matrix weights (for bones)
  73202. */
  73203. static readonly MatricesWeightsExtraKind: string;
  73204. /**
  73205. * Deduces the stride given a kind.
  73206. * @param kind The kind string to deduce
  73207. * @returns The deduced stride
  73208. */
  73209. static DeduceStride(kind: string): number;
  73210. /**
  73211. * Gets the byte length of the given type.
  73212. * @param type the type
  73213. * @returns the number of bytes
  73214. */
  73215. static GetTypeByteLength(type: number): number;
  73216. /**
  73217. * Enumerates each value of the given parameters as numbers.
  73218. * @param data the data to enumerate
  73219. * @param byteOffset the byte offset of the data
  73220. * @param byteStride the byte stride of the data
  73221. * @param componentCount the number of components per element
  73222. * @param componentType the type of the component
  73223. * @param count the number of values to enumerate
  73224. * @param normalized whether the data is normalized
  73225. * @param callback the callback function called for each value
  73226. */
  73227. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73228. private static _GetFloatValue;
  73229. }
  73230. }
  73231. declare module BABYLON {
  73232. /**
  73233. * @hidden
  73234. */
  73235. export class IntersectionInfo {
  73236. bu: Nullable<number>;
  73237. bv: Nullable<number>;
  73238. distance: number;
  73239. faceId: number;
  73240. subMeshId: number;
  73241. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73242. }
  73243. }
  73244. declare module BABYLON {
  73245. /**
  73246. * Represens a plane by the equation ax + by + cz + d = 0
  73247. */
  73248. export class Plane {
  73249. private static _TmpMatrix;
  73250. /**
  73251. * Normal of the plane (a,b,c)
  73252. */
  73253. normal: Vector3;
  73254. /**
  73255. * d component of the plane
  73256. */
  73257. d: number;
  73258. /**
  73259. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73260. * @param a a component of the plane
  73261. * @param b b component of the plane
  73262. * @param c c component of the plane
  73263. * @param d d component of the plane
  73264. */
  73265. constructor(a: number, b: number, c: number, d: number);
  73266. /**
  73267. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73268. */
  73269. asArray(): number[];
  73270. /**
  73271. * @returns a new plane copied from the current Plane.
  73272. */
  73273. clone(): Plane;
  73274. /**
  73275. * @returns the string "Plane".
  73276. */
  73277. getClassName(): string;
  73278. /**
  73279. * @returns the Plane hash code.
  73280. */
  73281. getHashCode(): number;
  73282. /**
  73283. * Normalize the current Plane in place.
  73284. * @returns the updated Plane.
  73285. */
  73286. normalize(): Plane;
  73287. /**
  73288. * Applies a transformation the plane and returns the result
  73289. * @param transformation the transformation matrix to be applied to the plane
  73290. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73291. */
  73292. transform(transformation: DeepImmutable<Matrix>): Plane;
  73293. /**
  73294. * Calcualtte the dot product between the point and the plane normal
  73295. * @param point point to calculate the dot product with
  73296. * @returns the dot product (float) of the point coordinates and the plane normal.
  73297. */
  73298. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73299. /**
  73300. * Updates the current Plane from the plane defined by the three given points.
  73301. * @param point1 one of the points used to contruct the plane
  73302. * @param point2 one of the points used to contruct the plane
  73303. * @param point3 one of the points used to contruct the plane
  73304. * @returns the updated Plane.
  73305. */
  73306. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73307. /**
  73308. * Checks if the plane is facing a given direction
  73309. * @param direction the direction to check if the plane is facing
  73310. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73311. * @returns True is the vector "direction" is the same side than the plane normal.
  73312. */
  73313. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73314. /**
  73315. * Calculates the distance to a point
  73316. * @param point point to calculate distance to
  73317. * @returns the signed distance (float) from the given point to the Plane.
  73318. */
  73319. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73320. /**
  73321. * Creates a plane from an array
  73322. * @param array the array to create a plane from
  73323. * @returns a new Plane from the given array.
  73324. */
  73325. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73326. /**
  73327. * Creates a plane from three points
  73328. * @param point1 point used to create the plane
  73329. * @param point2 point used to create the plane
  73330. * @param point3 point used to create the plane
  73331. * @returns a new Plane defined by the three given points.
  73332. */
  73333. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73334. /**
  73335. * Creates a plane from an origin point and a normal
  73336. * @param origin origin of the plane to be constructed
  73337. * @param normal normal of the plane to be constructed
  73338. * @returns a new Plane the normal vector to this plane at the given origin point.
  73339. * Note : the vector "normal" is updated because normalized.
  73340. */
  73341. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73342. /**
  73343. * Calculates the distance from a plane and a point
  73344. * @param origin origin of the plane to be constructed
  73345. * @param normal normal of the plane to be constructed
  73346. * @param point point to calculate distance to
  73347. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73348. */
  73349. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73350. }
  73351. }
  73352. declare module BABYLON {
  73353. /**
  73354. * Class used to store bounding sphere information
  73355. */
  73356. export class BoundingSphere {
  73357. /**
  73358. * Gets the center of the bounding sphere in local space
  73359. */
  73360. readonly center: Vector3;
  73361. /**
  73362. * Radius of the bounding sphere in local space
  73363. */
  73364. radius: number;
  73365. /**
  73366. * Gets the center of the bounding sphere in world space
  73367. */
  73368. readonly centerWorld: Vector3;
  73369. /**
  73370. * Radius of the bounding sphere in world space
  73371. */
  73372. radiusWorld: number;
  73373. /**
  73374. * Gets the minimum vector in local space
  73375. */
  73376. readonly minimum: Vector3;
  73377. /**
  73378. * Gets the maximum vector in local space
  73379. */
  73380. readonly maximum: Vector3;
  73381. private _worldMatrix;
  73382. private static readonly TmpVector3;
  73383. /**
  73384. * Creates a new bounding sphere
  73385. * @param min defines the minimum vector (in local space)
  73386. * @param max defines the maximum vector (in local space)
  73387. * @param worldMatrix defines the new world matrix
  73388. */
  73389. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73390. /**
  73391. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73392. * @param min defines the new minimum vector (in local space)
  73393. * @param max defines the new maximum vector (in local space)
  73394. * @param worldMatrix defines the new world matrix
  73395. */
  73396. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73397. /**
  73398. * Scale the current bounding sphere by applying a scale factor
  73399. * @param factor defines the scale factor to apply
  73400. * @returns the current bounding box
  73401. */
  73402. scale(factor: number): BoundingSphere;
  73403. /**
  73404. * Gets the world matrix of the bounding box
  73405. * @returns a matrix
  73406. */
  73407. getWorldMatrix(): DeepImmutable<Matrix>;
  73408. /** @hidden */
  73409. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73410. /**
  73411. * Tests if the bounding sphere is intersecting the frustum planes
  73412. * @param frustumPlanes defines the frustum planes to test
  73413. * @returns true if there is an intersection
  73414. */
  73415. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73416. /**
  73417. * Tests if the bounding sphere center is in between the frustum planes.
  73418. * Used for optimistic fast inclusion.
  73419. * @param frustumPlanes defines the frustum planes to test
  73420. * @returns true if the sphere center is in between the frustum planes
  73421. */
  73422. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73423. /**
  73424. * Tests if a point is inside the bounding sphere
  73425. * @param point defines the point to test
  73426. * @returns true if the point is inside the bounding sphere
  73427. */
  73428. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73429. /**
  73430. * Checks if two sphere intersct
  73431. * @param sphere0 sphere 0
  73432. * @param sphere1 sphere 1
  73433. * @returns true if the speres intersect
  73434. */
  73435. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73436. }
  73437. }
  73438. declare module BABYLON {
  73439. /**
  73440. * Class used to store bounding box information
  73441. */
  73442. export class BoundingBox implements ICullable {
  73443. /**
  73444. * Gets the 8 vectors representing the bounding box in local space
  73445. */
  73446. readonly vectors: Vector3[];
  73447. /**
  73448. * Gets the center of the bounding box in local space
  73449. */
  73450. readonly center: Vector3;
  73451. /**
  73452. * Gets the center of the bounding box in world space
  73453. */
  73454. readonly centerWorld: Vector3;
  73455. /**
  73456. * Gets the extend size in local space
  73457. */
  73458. readonly extendSize: Vector3;
  73459. /**
  73460. * Gets the extend size in world space
  73461. */
  73462. readonly extendSizeWorld: Vector3;
  73463. /**
  73464. * Gets the OBB (object bounding box) directions
  73465. */
  73466. readonly directions: Vector3[];
  73467. /**
  73468. * Gets the 8 vectors representing the bounding box in world space
  73469. */
  73470. readonly vectorsWorld: Vector3[];
  73471. /**
  73472. * Gets the minimum vector in world space
  73473. */
  73474. readonly minimumWorld: Vector3;
  73475. /**
  73476. * Gets the maximum vector in world space
  73477. */
  73478. readonly maximumWorld: Vector3;
  73479. /**
  73480. * Gets the minimum vector in local space
  73481. */
  73482. readonly minimum: Vector3;
  73483. /**
  73484. * Gets the maximum vector in local space
  73485. */
  73486. readonly maximum: Vector3;
  73487. private _worldMatrix;
  73488. private static readonly TmpVector3;
  73489. /**
  73490. * @hidden
  73491. */
  73492. _tag: number;
  73493. /**
  73494. * Creates a new bounding box
  73495. * @param min defines the minimum vector (in local space)
  73496. * @param max defines the maximum vector (in local space)
  73497. * @param worldMatrix defines the new world matrix
  73498. */
  73499. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73500. /**
  73501. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73502. * @param min defines the new minimum vector (in local space)
  73503. * @param max defines the new maximum vector (in local space)
  73504. * @param worldMatrix defines the new world matrix
  73505. */
  73506. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73507. /**
  73508. * Scale the current bounding box by applying a scale factor
  73509. * @param factor defines the scale factor to apply
  73510. * @returns the current bounding box
  73511. */
  73512. scale(factor: number): BoundingBox;
  73513. /**
  73514. * Gets the world matrix of the bounding box
  73515. * @returns a matrix
  73516. */
  73517. getWorldMatrix(): DeepImmutable<Matrix>;
  73518. /** @hidden */
  73519. _update(world: DeepImmutable<Matrix>): void;
  73520. /**
  73521. * Tests if the bounding box is intersecting the frustum planes
  73522. * @param frustumPlanes defines the frustum planes to test
  73523. * @returns true if there is an intersection
  73524. */
  73525. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73526. /**
  73527. * Tests if the bounding box is entirely inside the frustum planes
  73528. * @param frustumPlanes defines the frustum planes to test
  73529. * @returns true if there is an inclusion
  73530. */
  73531. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73532. /**
  73533. * Tests if a point is inside the bounding box
  73534. * @param point defines the point to test
  73535. * @returns true if the point is inside the bounding box
  73536. */
  73537. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73538. /**
  73539. * Tests if the bounding box intersects with a bounding sphere
  73540. * @param sphere defines the sphere to test
  73541. * @returns true if there is an intersection
  73542. */
  73543. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73544. /**
  73545. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73546. * @param min defines the min vector to use
  73547. * @param max defines the max vector to use
  73548. * @returns true if there is an intersection
  73549. */
  73550. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73551. /**
  73552. * Tests if two bounding boxes are intersections
  73553. * @param box0 defines the first box to test
  73554. * @param box1 defines the second box to test
  73555. * @returns true if there is an intersection
  73556. */
  73557. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73558. /**
  73559. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73560. * @param minPoint defines the minimum vector of the bounding box
  73561. * @param maxPoint defines the maximum vector of the bounding box
  73562. * @param sphereCenter defines the sphere center
  73563. * @param sphereRadius defines the sphere radius
  73564. * @returns true if there is an intersection
  73565. */
  73566. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73567. /**
  73568. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73569. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73570. * @param frustumPlanes defines the frustum planes to test
  73571. * @return true if there is an inclusion
  73572. */
  73573. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73574. /**
  73575. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73576. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73577. * @param frustumPlanes defines the frustum planes to test
  73578. * @return true if there is an intersection
  73579. */
  73580. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73581. }
  73582. }
  73583. declare module BABYLON {
  73584. /** @hidden */
  73585. export class Collider {
  73586. /** Define if a collision was found */
  73587. collisionFound: boolean;
  73588. /**
  73589. * Define last intersection point in local space
  73590. */
  73591. intersectionPoint: Vector3;
  73592. /**
  73593. * Define last collided mesh
  73594. */
  73595. collidedMesh: Nullable<AbstractMesh>;
  73596. private _collisionPoint;
  73597. private _planeIntersectionPoint;
  73598. private _tempVector;
  73599. private _tempVector2;
  73600. private _tempVector3;
  73601. private _tempVector4;
  73602. private _edge;
  73603. private _baseToVertex;
  73604. private _destinationPoint;
  73605. private _slidePlaneNormal;
  73606. private _displacementVector;
  73607. /** @hidden */
  73608. _radius: Vector3;
  73609. /** @hidden */
  73610. _retry: number;
  73611. private _velocity;
  73612. private _basePoint;
  73613. private _epsilon;
  73614. /** @hidden */
  73615. _velocityWorldLength: number;
  73616. /** @hidden */
  73617. _basePointWorld: Vector3;
  73618. private _velocityWorld;
  73619. private _normalizedVelocity;
  73620. /** @hidden */
  73621. _initialVelocity: Vector3;
  73622. /** @hidden */
  73623. _initialPosition: Vector3;
  73624. private _nearestDistance;
  73625. private _collisionMask;
  73626. collisionMask: number;
  73627. /**
  73628. * Gets the plane normal used to compute the sliding response (in local space)
  73629. */
  73630. readonly slidePlaneNormal: Vector3;
  73631. /** @hidden */
  73632. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73633. /** @hidden */
  73634. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73635. /** @hidden */
  73636. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73637. /** @hidden */
  73638. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73639. /** @hidden */
  73640. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73641. /** @hidden */
  73642. _getResponse(pos: Vector3, vel: Vector3): void;
  73643. }
  73644. }
  73645. declare module BABYLON {
  73646. /**
  73647. * Interface for cullable objects
  73648. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73649. */
  73650. export interface ICullable {
  73651. /**
  73652. * Checks if the object or part of the object is in the frustum
  73653. * @param frustumPlanes Camera near/planes
  73654. * @returns true if the object is in frustum otherwise false
  73655. */
  73656. isInFrustum(frustumPlanes: Plane[]): boolean;
  73657. /**
  73658. * Checks if a cullable object (mesh...) is in the camera frustum
  73659. * Unlike isInFrustum this cheks the full bounding box
  73660. * @param frustumPlanes Camera near/planes
  73661. * @returns true if the object is in frustum otherwise false
  73662. */
  73663. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73664. }
  73665. /**
  73666. * Info for a bounding data of a mesh
  73667. */
  73668. export class BoundingInfo implements ICullable {
  73669. /**
  73670. * Bounding box for the mesh
  73671. */
  73672. readonly boundingBox: BoundingBox;
  73673. /**
  73674. * Bounding sphere for the mesh
  73675. */
  73676. readonly boundingSphere: BoundingSphere;
  73677. private _isLocked;
  73678. private static readonly TmpVector3;
  73679. /**
  73680. * Constructs bounding info
  73681. * @param minimum min vector of the bounding box/sphere
  73682. * @param maximum max vector of the bounding box/sphere
  73683. * @param worldMatrix defines the new world matrix
  73684. */
  73685. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73686. /**
  73687. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73688. * @param min defines the new minimum vector (in local space)
  73689. * @param max defines the new maximum vector (in local space)
  73690. * @param worldMatrix defines the new world matrix
  73691. */
  73692. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73693. /**
  73694. * min vector of the bounding box/sphere
  73695. */
  73696. readonly minimum: Vector3;
  73697. /**
  73698. * max vector of the bounding box/sphere
  73699. */
  73700. readonly maximum: Vector3;
  73701. /**
  73702. * If the info is locked and won't be updated to avoid perf overhead
  73703. */
  73704. isLocked: boolean;
  73705. /**
  73706. * Updates the bounding sphere and box
  73707. * @param world world matrix to be used to update
  73708. */
  73709. update(world: DeepImmutable<Matrix>): void;
  73710. /**
  73711. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73712. * @param center New center of the bounding info
  73713. * @param extend New extend of the bounding info
  73714. * @returns the current bounding info
  73715. */
  73716. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73717. /**
  73718. * Scale the current bounding info by applying a scale factor
  73719. * @param factor defines the scale factor to apply
  73720. * @returns the current bounding info
  73721. */
  73722. scale(factor: number): BoundingInfo;
  73723. /**
  73724. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73725. * @param frustumPlanes defines the frustum to test
  73726. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73727. * @returns true if the bounding info is in the frustum planes
  73728. */
  73729. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73730. /**
  73731. * Gets the world distance between the min and max points of the bounding box
  73732. */
  73733. readonly diagonalLength: number;
  73734. /**
  73735. * Checks if a cullable object (mesh...) is in the camera frustum
  73736. * Unlike isInFrustum this cheks the full bounding box
  73737. * @param frustumPlanes Camera near/planes
  73738. * @returns true if the object is in frustum otherwise false
  73739. */
  73740. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73741. /** @hidden */
  73742. _checkCollision(collider: Collider): boolean;
  73743. /**
  73744. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73745. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73746. * @param point the point to check intersection with
  73747. * @returns if the point intersects
  73748. */
  73749. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73750. /**
  73751. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73752. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73753. * @param boundingInfo the bounding info to check intersection with
  73754. * @param precise if the intersection should be done using OBB
  73755. * @returns if the bounding info intersects
  73756. */
  73757. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73758. }
  73759. }
  73760. declare module BABYLON {
  73761. /**
  73762. * Extracts minimum and maximum values from a list of indexed positions
  73763. * @param positions defines the positions to use
  73764. * @param indices defines the indices to the positions
  73765. * @param indexStart defines the start index
  73766. * @param indexCount defines the end index
  73767. * @param bias defines bias value to add to the result
  73768. * @return minimum and maximum values
  73769. */
  73770. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73771. minimum: Vector3;
  73772. maximum: Vector3;
  73773. };
  73774. /**
  73775. * Extracts minimum and maximum values from a list of positions
  73776. * @param positions defines the positions to use
  73777. * @param start defines the start index in the positions array
  73778. * @param count defines the number of positions to handle
  73779. * @param bias defines bias value to add to the result
  73780. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73781. * @return minimum and maximum values
  73782. */
  73783. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73784. minimum: Vector3;
  73785. maximum: Vector3;
  73786. };
  73787. }
  73788. declare module BABYLON {
  73789. /** @hidden */
  73790. export class WebGLDataBuffer extends DataBuffer {
  73791. private _buffer;
  73792. constructor(resource: WebGLBuffer);
  73793. readonly underlyingResource: any;
  73794. }
  73795. }
  73796. declare module BABYLON {
  73797. /** @hidden */
  73798. export class WebGLPipelineContext implements IPipelineContext {
  73799. engine: ThinEngine;
  73800. program: Nullable<WebGLProgram>;
  73801. context?: WebGLRenderingContext;
  73802. vertexShader?: WebGLShader;
  73803. fragmentShader?: WebGLShader;
  73804. isParallelCompiled: boolean;
  73805. onCompiled?: () => void;
  73806. transformFeedback?: WebGLTransformFeedback | null;
  73807. readonly isAsync: boolean;
  73808. readonly isReady: boolean;
  73809. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73810. }
  73811. }
  73812. declare module BABYLON {
  73813. interface ThinEngine {
  73814. /**
  73815. * Create an uniform buffer
  73816. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73817. * @param elements defines the content of the uniform buffer
  73818. * @returns the webGL uniform buffer
  73819. */
  73820. createUniformBuffer(elements: FloatArray): DataBuffer;
  73821. /**
  73822. * Create a dynamic uniform buffer
  73823. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73824. * @param elements defines the content of the uniform buffer
  73825. * @returns the webGL uniform buffer
  73826. */
  73827. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73828. /**
  73829. * Update an existing uniform buffer
  73830. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73831. * @param uniformBuffer defines the target uniform buffer
  73832. * @param elements defines the content to update
  73833. * @param offset defines the offset in the uniform buffer where update should start
  73834. * @param count defines the size of the data to update
  73835. */
  73836. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73837. /**
  73838. * Bind an uniform buffer to the current webGL context
  73839. * @param buffer defines the buffer to bind
  73840. */
  73841. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73842. /**
  73843. * Bind a buffer to the current webGL context at a given location
  73844. * @param buffer defines the buffer to bind
  73845. * @param location defines the index where to bind the buffer
  73846. */
  73847. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73848. /**
  73849. * Bind a specific block at a given index in a specific shader program
  73850. * @param pipelineContext defines the pipeline context to use
  73851. * @param blockName defines the block name
  73852. * @param index defines the index where to bind the block
  73853. */
  73854. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73855. }
  73856. }
  73857. declare module BABYLON {
  73858. /**
  73859. * Uniform buffer objects.
  73860. *
  73861. * Handles blocks of uniform on the GPU.
  73862. *
  73863. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73864. *
  73865. * For more information, please refer to :
  73866. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73867. */
  73868. export class UniformBuffer {
  73869. private _engine;
  73870. private _buffer;
  73871. private _data;
  73872. private _bufferData;
  73873. private _dynamic?;
  73874. private _uniformLocations;
  73875. private _uniformSizes;
  73876. private _uniformLocationPointer;
  73877. private _needSync;
  73878. private _noUBO;
  73879. private _currentEffect;
  73880. private static _MAX_UNIFORM_SIZE;
  73881. private static _tempBuffer;
  73882. /**
  73883. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73884. * This is dynamic to allow compat with webgl 1 and 2.
  73885. * You will need to pass the name of the uniform as well as the value.
  73886. */
  73887. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73888. /**
  73889. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73890. * This is dynamic to allow compat with webgl 1 and 2.
  73891. * You will need to pass the name of the uniform as well as the value.
  73892. */
  73893. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73894. /**
  73895. * Lambda to Update a single float in a uniform buffer.
  73896. * This is dynamic to allow compat with webgl 1 and 2.
  73897. * You will need to pass the name of the uniform as well as the value.
  73898. */
  73899. updateFloat: (name: string, x: number) => void;
  73900. /**
  73901. * Lambda to Update a vec2 of float in a uniform buffer.
  73902. * This is dynamic to allow compat with webgl 1 and 2.
  73903. * You will need to pass the name of the uniform as well as the value.
  73904. */
  73905. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73906. /**
  73907. * Lambda to Update a vec3 of float in a uniform buffer.
  73908. * This is dynamic to allow compat with webgl 1 and 2.
  73909. * You will need to pass the name of the uniform as well as the value.
  73910. */
  73911. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73912. /**
  73913. * Lambda to Update a vec4 of float in a uniform buffer.
  73914. * This is dynamic to allow compat with webgl 1 and 2.
  73915. * You will need to pass the name of the uniform as well as the value.
  73916. */
  73917. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73918. /**
  73919. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73920. * This is dynamic to allow compat with webgl 1 and 2.
  73921. * You will need to pass the name of the uniform as well as the value.
  73922. */
  73923. updateMatrix: (name: string, mat: Matrix) => void;
  73924. /**
  73925. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73926. * This is dynamic to allow compat with webgl 1 and 2.
  73927. * You will need to pass the name of the uniform as well as the value.
  73928. */
  73929. updateVector3: (name: string, vector: Vector3) => void;
  73930. /**
  73931. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73932. * This is dynamic to allow compat with webgl 1 and 2.
  73933. * You will need to pass the name of the uniform as well as the value.
  73934. */
  73935. updateVector4: (name: string, vector: Vector4) => void;
  73936. /**
  73937. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73938. * This is dynamic to allow compat with webgl 1 and 2.
  73939. * You will need to pass the name of the uniform as well as the value.
  73940. */
  73941. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73942. /**
  73943. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73944. * This is dynamic to allow compat with webgl 1 and 2.
  73945. * You will need to pass the name of the uniform as well as the value.
  73946. */
  73947. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73948. /**
  73949. * Instantiates a new Uniform buffer objects.
  73950. *
  73951. * Handles blocks of uniform on the GPU.
  73952. *
  73953. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73954. *
  73955. * For more information, please refer to :
  73956. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73957. * @param engine Define the engine the buffer is associated with
  73958. * @param data Define the data contained in the buffer
  73959. * @param dynamic Define if the buffer is updatable
  73960. */
  73961. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73962. /**
  73963. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73964. * or just falling back on setUniformXXX calls.
  73965. */
  73966. readonly useUbo: boolean;
  73967. /**
  73968. * Indicates if the WebGL underlying uniform buffer is in sync
  73969. * with the javascript cache data.
  73970. */
  73971. readonly isSync: boolean;
  73972. /**
  73973. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73974. * Also, a dynamic UniformBuffer will disable cache verification and always
  73975. * update the underlying WebGL uniform buffer to the GPU.
  73976. * @returns if Dynamic, otherwise false
  73977. */
  73978. isDynamic(): boolean;
  73979. /**
  73980. * The data cache on JS side.
  73981. * @returns the underlying data as a float array
  73982. */
  73983. getData(): Float32Array;
  73984. /**
  73985. * The underlying WebGL Uniform buffer.
  73986. * @returns the webgl buffer
  73987. */
  73988. getBuffer(): Nullable<DataBuffer>;
  73989. /**
  73990. * std140 layout specifies how to align data within an UBO structure.
  73991. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73992. * for specs.
  73993. */
  73994. private _fillAlignment;
  73995. /**
  73996. * Adds an uniform in the buffer.
  73997. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73998. * for the layout to be correct !
  73999. * @param name Name of the uniform, as used in the uniform block in the shader.
  74000. * @param size Data size, or data directly.
  74001. */
  74002. addUniform(name: string, size: number | number[]): void;
  74003. /**
  74004. * Adds a Matrix 4x4 to the uniform buffer.
  74005. * @param name Name of the uniform, as used in the uniform block in the shader.
  74006. * @param mat A 4x4 matrix.
  74007. */
  74008. addMatrix(name: string, mat: Matrix): void;
  74009. /**
  74010. * Adds a vec2 to the uniform buffer.
  74011. * @param name Name of the uniform, as used in the uniform block in the shader.
  74012. * @param x Define the x component value of the vec2
  74013. * @param y Define the y component value of the vec2
  74014. */
  74015. addFloat2(name: string, x: number, y: number): void;
  74016. /**
  74017. * Adds a vec3 to the uniform buffer.
  74018. * @param name Name of the uniform, as used in the uniform block in the shader.
  74019. * @param x Define the x component value of the vec3
  74020. * @param y Define the y component value of the vec3
  74021. * @param z Define the z component value of the vec3
  74022. */
  74023. addFloat3(name: string, x: number, y: number, z: number): void;
  74024. /**
  74025. * Adds a vec3 to the uniform buffer.
  74026. * @param name Name of the uniform, as used in the uniform block in the shader.
  74027. * @param color Define the vec3 from a Color
  74028. */
  74029. addColor3(name: string, color: Color3): void;
  74030. /**
  74031. * Adds a vec4 to the uniform buffer.
  74032. * @param name Name of the uniform, as used in the uniform block in the shader.
  74033. * @param color Define the rgb components from a Color
  74034. * @param alpha Define the a component of the vec4
  74035. */
  74036. addColor4(name: string, color: Color3, alpha: number): void;
  74037. /**
  74038. * Adds a vec3 to the uniform buffer.
  74039. * @param name Name of the uniform, as used in the uniform block in the shader.
  74040. * @param vector Define the vec3 components from a Vector
  74041. */
  74042. addVector3(name: string, vector: Vector3): void;
  74043. /**
  74044. * Adds a Matrix 3x3 to the uniform buffer.
  74045. * @param name Name of the uniform, as used in the uniform block in the shader.
  74046. */
  74047. addMatrix3x3(name: string): void;
  74048. /**
  74049. * Adds a Matrix 2x2 to the uniform buffer.
  74050. * @param name Name of the uniform, as used in the uniform block in the shader.
  74051. */
  74052. addMatrix2x2(name: string): void;
  74053. /**
  74054. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74055. */
  74056. create(): void;
  74057. /** @hidden */
  74058. _rebuild(): void;
  74059. /**
  74060. * Updates the WebGL Uniform Buffer on the GPU.
  74061. * If the `dynamic` flag is set to true, no cache comparison is done.
  74062. * Otherwise, the buffer will be updated only if the cache differs.
  74063. */
  74064. update(): void;
  74065. /**
  74066. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74067. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74068. * @param data Define the flattened data
  74069. * @param size Define the size of the data.
  74070. */
  74071. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74072. private _valueCache;
  74073. private _cacheMatrix;
  74074. private _updateMatrix3x3ForUniform;
  74075. private _updateMatrix3x3ForEffect;
  74076. private _updateMatrix2x2ForEffect;
  74077. private _updateMatrix2x2ForUniform;
  74078. private _updateFloatForEffect;
  74079. private _updateFloatForUniform;
  74080. private _updateFloat2ForEffect;
  74081. private _updateFloat2ForUniform;
  74082. private _updateFloat3ForEffect;
  74083. private _updateFloat3ForUniform;
  74084. private _updateFloat4ForEffect;
  74085. private _updateFloat4ForUniform;
  74086. private _updateMatrixForEffect;
  74087. private _updateMatrixForUniform;
  74088. private _updateVector3ForEffect;
  74089. private _updateVector3ForUniform;
  74090. private _updateVector4ForEffect;
  74091. private _updateVector4ForUniform;
  74092. private _updateColor3ForEffect;
  74093. private _updateColor3ForUniform;
  74094. private _updateColor4ForEffect;
  74095. private _updateColor4ForUniform;
  74096. /**
  74097. * Sets a sampler uniform on the effect.
  74098. * @param name Define the name of the sampler.
  74099. * @param texture Define the texture to set in the sampler
  74100. */
  74101. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74102. /**
  74103. * Directly updates the value of the uniform in the cache AND on the GPU.
  74104. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74105. * @param data Define the flattened data
  74106. */
  74107. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74108. /**
  74109. * Binds this uniform buffer to an effect.
  74110. * @param effect Define the effect to bind the buffer to
  74111. * @param name Name of the uniform block in the shader.
  74112. */
  74113. bindToEffect(effect: Effect, name: string): void;
  74114. /**
  74115. * Disposes the uniform buffer.
  74116. */
  74117. dispose(): void;
  74118. }
  74119. }
  74120. declare module BABYLON {
  74121. /**
  74122. * Enum that determines the text-wrapping mode to use.
  74123. */
  74124. export enum InspectableType {
  74125. /**
  74126. * Checkbox for booleans
  74127. */
  74128. Checkbox = 0,
  74129. /**
  74130. * Sliders for numbers
  74131. */
  74132. Slider = 1,
  74133. /**
  74134. * Vector3
  74135. */
  74136. Vector3 = 2,
  74137. /**
  74138. * Quaternions
  74139. */
  74140. Quaternion = 3,
  74141. /**
  74142. * Color3
  74143. */
  74144. Color3 = 4,
  74145. /**
  74146. * String
  74147. */
  74148. String = 5
  74149. }
  74150. /**
  74151. * Interface used to define custom inspectable properties.
  74152. * This interface is used by the inspector to display custom property grids
  74153. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74154. */
  74155. export interface IInspectable {
  74156. /**
  74157. * Gets the label to display
  74158. */
  74159. label: string;
  74160. /**
  74161. * Gets the name of the property to edit
  74162. */
  74163. propertyName: string;
  74164. /**
  74165. * Gets the type of the editor to use
  74166. */
  74167. type: InspectableType;
  74168. /**
  74169. * Gets the minimum value of the property when using in "slider" mode
  74170. */
  74171. min?: number;
  74172. /**
  74173. * Gets the maximum value of the property when using in "slider" mode
  74174. */
  74175. max?: number;
  74176. /**
  74177. * Gets the setp to use when using in "slider" mode
  74178. */
  74179. step?: number;
  74180. }
  74181. }
  74182. declare module BABYLON {
  74183. /**
  74184. * Class used to provide helper for timing
  74185. */
  74186. export class TimingTools {
  74187. /**
  74188. * Polyfill for setImmediate
  74189. * @param action defines the action to execute after the current execution block
  74190. */
  74191. static SetImmediate(action: () => void): void;
  74192. }
  74193. }
  74194. declare module BABYLON {
  74195. /**
  74196. * Class used to enable instatition of objects by class name
  74197. */
  74198. export class InstantiationTools {
  74199. /**
  74200. * Use this object to register external classes like custom textures or material
  74201. * to allow the laoders to instantiate them
  74202. */
  74203. static RegisteredExternalClasses: {
  74204. [key: string]: Object;
  74205. };
  74206. /**
  74207. * Tries to instantiate a new object from a given class name
  74208. * @param className defines the class name to instantiate
  74209. * @returns the new object or null if the system was not able to do the instantiation
  74210. */
  74211. static Instantiate(className: string): any;
  74212. }
  74213. }
  74214. declare module BABYLON {
  74215. /**
  74216. * Define options used to create a depth texture
  74217. */
  74218. export class DepthTextureCreationOptions {
  74219. /** Specifies whether or not a stencil should be allocated in the texture */
  74220. generateStencil?: boolean;
  74221. /** Specifies whether or not bilinear filtering is enable on the texture */
  74222. bilinearFiltering?: boolean;
  74223. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74224. comparisonFunction?: number;
  74225. /** Specifies if the created texture is a cube texture */
  74226. isCube?: boolean;
  74227. }
  74228. }
  74229. declare module BABYLON {
  74230. interface ThinEngine {
  74231. /**
  74232. * Creates a depth stencil cube texture.
  74233. * This is only available in WebGL 2.
  74234. * @param size The size of face edge in the cube texture.
  74235. * @param options The options defining the cube texture.
  74236. * @returns The cube texture
  74237. */
  74238. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74239. /**
  74240. * Creates a cube texture
  74241. * @param rootUrl defines the url where the files to load is located
  74242. * @param scene defines the current scene
  74243. * @param files defines the list of files to load (1 per face)
  74244. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74245. * @param onLoad defines an optional callback raised when the texture is loaded
  74246. * @param onError defines an optional callback raised if there is an issue to load the texture
  74247. * @param format defines the format of the data
  74248. * @param forcedExtension defines the extension to use to pick the right loader
  74249. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74250. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74251. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74252. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74253. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74254. * @returns the cube texture as an InternalTexture
  74255. */
  74256. 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;
  74257. /**
  74258. * Creates a cube texture
  74259. * @param rootUrl defines the url where the files to load is located
  74260. * @param scene defines the current scene
  74261. * @param files defines the list of files to load (1 per face)
  74262. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74263. * @param onLoad defines an optional callback raised when the texture is loaded
  74264. * @param onError defines an optional callback raised if there is an issue to load the texture
  74265. * @param format defines the format of the data
  74266. * @param forcedExtension defines the extension to use to pick the right loader
  74267. * @returns the cube texture as an InternalTexture
  74268. */
  74269. 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;
  74270. /**
  74271. * Creates a cube texture
  74272. * @param rootUrl defines the url where the files to load is located
  74273. * @param scene defines the current scene
  74274. * @param files defines the list of files to load (1 per face)
  74275. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74276. * @param onLoad defines an optional callback raised when the texture is loaded
  74277. * @param onError defines an optional callback raised if there is an issue to load the texture
  74278. * @param format defines the format of the data
  74279. * @param forcedExtension defines the extension to use to pick the right loader
  74280. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74281. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74282. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74283. * @returns the cube texture as an InternalTexture
  74284. */
  74285. 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;
  74286. /** @hidden */
  74287. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74288. /** @hidden */
  74289. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74290. /** @hidden */
  74291. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74292. /** @hidden */
  74293. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74294. }
  74295. }
  74296. declare module BABYLON {
  74297. /**
  74298. * Class for creating a cube texture
  74299. */
  74300. export class CubeTexture extends BaseTexture {
  74301. private _delayedOnLoad;
  74302. /**
  74303. * The url of the texture
  74304. */
  74305. url: string;
  74306. /**
  74307. * Gets or sets the center of the bounding box associated with the cube texture.
  74308. * It must define where the camera used to render the texture was set
  74309. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74310. */
  74311. boundingBoxPosition: Vector3;
  74312. private _boundingBoxSize;
  74313. /**
  74314. * Gets or sets the size of the bounding box associated with the cube texture
  74315. * When defined, the cubemap will switch to local mode
  74316. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74317. * @example https://www.babylonjs-playground.com/#RNASML
  74318. */
  74319. /**
  74320. * Returns the bounding box size
  74321. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74322. */
  74323. boundingBoxSize: Vector3;
  74324. protected _rotationY: number;
  74325. /**
  74326. * Sets texture matrix rotation angle around Y axis in radians.
  74327. */
  74328. /**
  74329. * Gets texture matrix rotation angle around Y axis radians.
  74330. */
  74331. rotationY: number;
  74332. /**
  74333. * Are mip maps generated for this texture or not.
  74334. */
  74335. readonly noMipmap: boolean;
  74336. private _noMipmap;
  74337. private _files;
  74338. protected _forcedExtension: Nullable<string>;
  74339. private _extensions;
  74340. private _textureMatrix;
  74341. private _format;
  74342. private _createPolynomials;
  74343. /** @hidden */
  74344. _prefiltered: boolean;
  74345. /**
  74346. * Creates a cube texture from an array of image urls
  74347. * @param files defines an array of image urls
  74348. * @param scene defines the hosting scene
  74349. * @param noMipmap specifies if mip maps are not used
  74350. * @returns a cube texture
  74351. */
  74352. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74353. /**
  74354. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74355. * @param url defines the url of the prefiltered texture
  74356. * @param scene defines the scene the texture is attached to
  74357. * @param forcedExtension defines the extension of the file if different from the url
  74358. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74359. * @return the prefiltered texture
  74360. */
  74361. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74362. /**
  74363. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74364. * as prefiltered data.
  74365. * @param rootUrl defines the url of the texture or the root name of the six images
  74366. * @param scene defines the scene the texture is attached to
  74367. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74368. * @param noMipmap defines if mipmaps should be created or not
  74369. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74370. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74371. * @param onError defines a callback triggered in case of error during load
  74372. * @param format defines the internal format to use for the texture once loaded
  74373. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74374. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74375. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74376. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74377. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74378. * @return the cube texture
  74379. */
  74380. 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);
  74381. /**
  74382. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74383. */
  74384. readonly isPrefiltered: boolean;
  74385. /**
  74386. * Get the current class name of the texture useful for serialization or dynamic coding.
  74387. * @returns "CubeTexture"
  74388. */
  74389. getClassName(): string;
  74390. /**
  74391. * Update the url (and optional buffer) of this texture if url was null during construction.
  74392. * @param url the url of the texture
  74393. * @param forcedExtension defines the extension to use
  74394. * @param onLoad callback called when the texture is loaded (defaults to null)
  74395. */
  74396. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74397. /**
  74398. * Delays loading of the cube texture
  74399. * @param forcedExtension defines the extension to use
  74400. */
  74401. delayLoad(forcedExtension?: string): void;
  74402. /**
  74403. * Returns the reflection texture matrix
  74404. * @returns the reflection texture matrix
  74405. */
  74406. getReflectionTextureMatrix(): Matrix;
  74407. /**
  74408. * Sets the reflection texture matrix
  74409. * @param value Reflection texture matrix
  74410. */
  74411. setReflectionTextureMatrix(value: Matrix): void;
  74412. /**
  74413. * Parses text to create a cube texture
  74414. * @param parsedTexture define the serialized text to read from
  74415. * @param scene defines the hosting scene
  74416. * @param rootUrl defines the root url of the cube texture
  74417. * @returns a cube texture
  74418. */
  74419. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74420. /**
  74421. * Makes a clone, or deep copy, of the cube texture
  74422. * @returns a new cube texture
  74423. */
  74424. clone(): CubeTexture;
  74425. }
  74426. }
  74427. declare module BABYLON {
  74428. /**
  74429. * Manages the defines for the Material
  74430. */
  74431. export class MaterialDefines {
  74432. /** @hidden */
  74433. protected _keys: string[];
  74434. private _isDirty;
  74435. /** @hidden */
  74436. _renderId: number;
  74437. /** @hidden */
  74438. _areLightsDirty: boolean;
  74439. /** @hidden */
  74440. _areLightsDisposed: boolean;
  74441. /** @hidden */
  74442. _areAttributesDirty: boolean;
  74443. /** @hidden */
  74444. _areTexturesDirty: boolean;
  74445. /** @hidden */
  74446. _areFresnelDirty: boolean;
  74447. /** @hidden */
  74448. _areMiscDirty: boolean;
  74449. /** @hidden */
  74450. _areImageProcessingDirty: boolean;
  74451. /** @hidden */
  74452. _normals: boolean;
  74453. /** @hidden */
  74454. _uvs: boolean;
  74455. /** @hidden */
  74456. _needNormals: boolean;
  74457. /** @hidden */
  74458. _needUVs: boolean;
  74459. [id: string]: any;
  74460. /**
  74461. * Specifies if the material needs to be re-calculated
  74462. */
  74463. readonly isDirty: boolean;
  74464. /**
  74465. * Marks the material to indicate that it has been re-calculated
  74466. */
  74467. markAsProcessed(): void;
  74468. /**
  74469. * Marks the material to indicate that it needs to be re-calculated
  74470. */
  74471. markAsUnprocessed(): void;
  74472. /**
  74473. * Marks the material to indicate all of its defines need to be re-calculated
  74474. */
  74475. markAllAsDirty(): void;
  74476. /**
  74477. * Marks the material to indicate that image processing needs to be re-calculated
  74478. */
  74479. markAsImageProcessingDirty(): void;
  74480. /**
  74481. * Marks the material to indicate the lights need to be re-calculated
  74482. * @param disposed Defines whether the light is dirty due to dispose or not
  74483. */
  74484. markAsLightDirty(disposed?: boolean): void;
  74485. /**
  74486. * Marks the attribute state as changed
  74487. */
  74488. markAsAttributesDirty(): void;
  74489. /**
  74490. * Marks the texture state as changed
  74491. */
  74492. markAsTexturesDirty(): void;
  74493. /**
  74494. * Marks the fresnel state as changed
  74495. */
  74496. markAsFresnelDirty(): void;
  74497. /**
  74498. * Marks the misc state as changed
  74499. */
  74500. markAsMiscDirty(): void;
  74501. /**
  74502. * Rebuilds the material defines
  74503. */
  74504. rebuild(): void;
  74505. /**
  74506. * Specifies if two material defines are equal
  74507. * @param other - A material define instance to compare to
  74508. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74509. */
  74510. isEqual(other: MaterialDefines): boolean;
  74511. /**
  74512. * Clones this instance's defines to another instance
  74513. * @param other - material defines to clone values to
  74514. */
  74515. cloneTo(other: MaterialDefines): void;
  74516. /**
  74517. * Resets the material define values
  74518. */
  74519. reset(): void;
  74520. /**
  74521. * Converts the material define values to a string
  74522. * @returns - String of material define information
  74523. */
  74524. toString(): string;
  74525. }
  74526. }
  74527. declare module BABYLON {
  74528. /**
  74529. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74530. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74531. * 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;
  74532. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74533. */
  74534. export class ColorCurves {
  74535. private _dirty;
  74536. private _tempColor;
  74537. private _globalCurve;
  74538. private _highlightsCurve;
  74539. private _midtonesCurve;
  74540. private _shadowsCurve;
  74541. private _positiveCurve;
  74542. private _negativeCurve;
  74543. private _globalHue;
  74544. private _globalDensity;
  74545. private _globalSaturation;
  74546. private _globalExposure;
  74547. /**
  74548. * Gets the global Hue value.
  74549. * 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).
  74550. */
  74551. /**
  74552. * Sets the global Hue value.
  74553. * 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).
  74554. */
  74555. globalHue: number;
  74556. /**
  74557. * Gets the global Density value.
  74558. * 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.
  74559. * Values less than zero provide a filter of opposite hue.
  74560. */
  74561. /**
  74562. * Sets the global Density value.
  74563. * 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.
  74564. * Values less than zero provide a filter of opposite hue.
  74565. */
  74566. globalDensity: number;
  74567. /**
  74568. * Gets the global Saturation value.
  74569. * 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.
  74570. */
  74571. /**
  74572. * Sets the global Saturation value.
  74573. * 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.
  74574. */
  74575. globalSaturation: number;
  74576. /**
  74577. * Gets the global Exposure value.
  74578. * 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.
  74579. */
  74580. /**
  74581. * Sets the global Exposure value.
  74582. * 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.
  74583. */
  74584. globalExposure: number;
  74585. private _highlightsHue;
  74586. private _highlightsDensity;
  74587. private _highlightsSaturation;
  74588. private _highlightsExposure;
  74589. /**
  74590. * Gets the highlights Hue value.
  74591. * 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).
  74592. */
  74593. /**
  74594. * Sets the highlights Hue value.
  74595. * 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).
  74596. */
  74597. highlightsHue: number;
  74598. /**
  74599. * Gets the highlights Density value.
  74600. * 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.
  74601. * Values less than zero provide a filter of opposite hue.
  74602. */
  74603. /**
  74604. * Sets the highlights Density value.
  74605. * 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.
  74606. * Values less than zero provide a filter of opposite hue.
  74607. */
  74608. highlightsDensity: number;
  74609. /**
  74610. * Gets the highlights Saturation value.
  74611. * 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.
  74612. */
  74613. /**
  74614. * Sets the highlights Saturation value.
  74615. * 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.
  74616. */
  74617. highlightsSaturation: number;
  74618. /**
  74619. * Gets the highlights Exposure value.
  74620. * 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.
  74621. */
  74622. /**
  74623. * Sets the highlights Exposure value.
  74624. * 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.
  74625. */
  74626. highlightsExposure: number;
  74627. private _midtonesHue;
  74628. private _midtonesDensity;
  74629. private _midtonesSaturation;
  74630. private _midtonesExposure;
  74631. /**
  74632. * Gets the midtones Hue value.
  74633. * 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).
  74634. */
  74635. /**
  74636. * Sets the midtones Hue value.
  74637. * 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).
  74638. */
  74639. midtonesHue: number;
  74640. /**
  74641. * Gets the midtones Density value.
  74642. * 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.
  74643. * Values less than zero provide a filter of opposite hue.
  74644. */
  74645. /**
  74646. * Sets the midtones Density value.
  74647. * 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.
  74648. * Values less than zero provide a filter of opposite hue.
  74649. */
  74650. midtonesDensity: number;
  74651. /**
  74652. * Gets the midtones Saturation value.
  74653. * 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.
  74654. */
  74655. /**
  74656. * Sets the midtones Saturation value.
  74657. * 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.
  74658. */
  74659. midtonesSaturation: number;
  74660. /**
  74661. * Gets the midtones Exposure value.
  74662. * 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.
  74663. */
  74664. /**
  74665. * Sets the midtones Exposure value.
  74666. * 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.
  74667. */
  74668. midtonesExposure: number;
  74669. private _shadowsHue;
  74670. private _shadowsDensity;
  74671. private _shadowsSaturation;
  74672. private _shadowsExposure;
  74673. /**
  74674. * Gets the shadows Hue value.
  74675. * 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).
  74676. */
  74677. /**
  74678. * Sets the shadows Hue value.
  74679. * 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).
  74680. */
  74681. shadowsHue: number;
  74682. /**
  74683. * Gets the shadows Density value.
  74684. * 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.
  74685. * Values less than zero provide a filter of opposite hue.
  74686. */
  74687. /**
  74688. * Sets the shadows Density value.
  74689. * 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.
  74690. * Values less than zero provide a filter of opposite hue.
  74691. */
  74692. shadowsDensity: number;
  74693. /**
  74694. * Gets the shadows Saturation value.
  74695. * 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.
  74696. */
  74697. /**
  74698. * Sets the shadows Saturation value.
  74699. * 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.
  74700. */
  74701. shadowsSaturation: number;
  74702. /**
  74703. * Gets the shadows Exposure value.
  74704. * 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.
  74705. */
  74706. /**
  74707. * Sets the shadows Exposure value.
  74708. * 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.
  74709. */
  74710. shadowsExposure: number;
  74711. /**
  74712. * Returns the class name
  74713. * @returns The class name
  74714. */
  74715. getClassName(): string;
  74716. /**
  74717. * Binds the color curves to the shader.
  74718. * @param colorCurves The color curve to bind
  74719. * @param effect The effect to bind to
  74720. * @param positiveUniform The positive uniform shader parameter
  74721. * @param neutralUniform The neutral uniform shader parameter
  74722. * @param negativeUniform The negative uniform shader parameter
  74723. */
  74724. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74725. /**
  74726. * Prepare the list of uniforms associated with the ColorCurves effects.
  74727. * @param uniformsList The list of uniforms used in the effect
  74728. */
  74729. static PrepareUniforms(uniformsList: string[]): void;
  74730. /**
  74731. * Returns color grading data based on a hue, density, saturation and exposure value.
  74732. * @param filterHue The hue of the color filter.
  74733. * @param filterDensity The density of the color filter.
  74734. * @param saturation The saturation.
  74735. * @param exposure The exposure.
  74736. * @param result The result data container.
  74737. */
  74738. private getColorGradingDataToRef;
  74739. /**
  74740. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74741. * @param value The input slider value in range [-100,100].
  74742. * @returns Adjusted value.
  74743. */
  74744. private static applyColorGradingSliderNonlinear;
  74745. /**
  74746. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74747. * @param hue The hue (H) input.
  74748. * @param saturation The saturation (S) input.
  74749. * @param brightness The brightness (B) input.
  74750. * @result An RGBA color represented as Vector4.
  74751. */
  74752. private static fromHSBToRef;
  74753. /**
  74754. * Returns a value clamped between min and max
  74755. * @param value The value to clamp
  74756. * @param min The minimum of value
  74757. * @param max The maximum of value
  74758. * @returns The clamped value.
  74759. */
  74760. private static clamp;
  74761. /**
  74762. * Clones the current color curve instance.
  74763. * @return The cloned curves
  74764. */
  74765. clone(): ColorCurves;
  74766. /**
  74767. * Serializes the current color curve instance to a json representation.
  74768. * @return a JSON representation
  74769. */
  74770. serialize(): any;
  74771. /**
  74772. * Parses the color curve from a json representation.
  74773. * @param source the JSON source to parse
  74774. * @return The parsed curves
  74775. */
  74776. static Parse(source: any): ColorCurves;
  74777. }
  74778. }
  74779. declare module BABYLON {
  74780. /**
  74781. * Interface to follow in your material defines to integrate easily the
  74782. * Image proccessing functions.
  74783. * @hidden
  74784. */
  74785. export interface IImageProcessingConfigurationDefines {
  74786. IMAGEPROCESSING: boolean;
  74787. VIGNETTE: boolean;
  74788. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74789. VIGNETTEBLENDMODEOPAQUE: boolean;
  74790. TONEMAPPING: boolean;
  74791. TONEMAPPING_ACES: boolean;
  74792. CONTRAST: boolean;
  74793. EXPOSURE: boolean;
  74794. COLORCURVES: boolean;
  74795. COLORGRADING: boolean;
  74796. COLORGRADING3D: boolean;
  74797. SAMPLER3DGREENDEPTH: boolean;
  74798. SAMPLER3DBGRMAP: boolean;
  74799. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74800. }
  74801. /**
  74802. * @hidden
  74803. */
  74804. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74805. IMAGEPROCESSING: boolean;
  74806. VIGNETTE: boolean;
  74807. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74808. VIGNETTEBLENDMODEOPAQUE: boolean;
  74809. TONEMAPPING: boolean;
  74810. TONEMAPPING_ACES: boolean;
  74811. CONTRAST: boolean;
  74812. COLORCURVES: boolean;
  74813. COLORGRADING: boolean;
  74814. COLORGRADING3D: boolean;
  74815. SAMPLER3DGREENDEPTH: boolean;
  74816. SAMPLER3DBGRMAP: boolean;
  74817. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74818. EXPOSURE: boolean;
  74819. constructor();
  74820. }
  74821. /**
  74822. * This groups together the common properties used for image processing either in direct forward pass
  74823. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74824. * or not.
  74825. */
  74826. export class ImageProcessingConfiguration {
  74827. /**
  74828. * Default tone mapping applied in BabylonJS.
  74829. */
  74830. static readonly TONEMAPPING_STANDARD: number;
  74831. /**
  74832. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74833. * to other engines rendering to increase portability.
  74834. */
  74835. static readonly TONEMAPPING_ACES: number;
  74836. /**
  74837. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74838. */
  74839. colorCurves: Nullable<ColorCurves>;
  74840. private _colorCurvesEnabled;
  74841. /**
  74842. * Gets wether the color curves effect is enabled.
  74843. */
  74844. /**
  74845. * Sets wether the color curves effect is enabled.
  74846. */
  74847. colorCurvesEnabled: boolean;
  74848. private _colorGradingTexture;
  74849. /**
  74850. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74851. */
  74852. /**
  74853. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74854. */
  74855. colorGradingTexture: Nullable<BaseTexture>;
  74856. private _colorGradingEnabled;
  74857. /**
  74858. * Gets wether the color grading effect is enabled.
  74859. */
  74860. /**
  74861. * Sets wether the color grading effect is enabled.
  74862. */
  74863. colorGradingEnabled: boolean;
  74864. private _colorGradingWithGreenDepth;
  74865. /**
  74866. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74867. */
  74868. /**
  74869. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74870. */
  74871. colorGradingWithGreenDepth: boolean;
  74872. private _colorGradingBGR;
  74873. /**
  74874. * Gets wether the color grading texture contains BGR values.
  74875. */
  74876. /**
  74877. * Sets wether the color grading texture contains BGR values.
  74878. */
  74879. colorGradingBGR: boolean;
  74880. /** @hidden */
  74881. _exposure: number;
  74882. /**
  74883. * Gets the Exposure used in the effect.
  74884. */
  74885. /**
  74886. * Sets the Exposure used in the effect.
  74887. */
  74888. exposure: number;
  74889. private _toneMappingEnabled;
  74890. /**
  74891. * Gets wether the tone mapping effect is enabled.
  74892. */
  74893. /**
  74894. * Sets wether the tone mapping effect is enabled.
  74895. */
  74896. toneMappingEnabled: boolean;
  74897. private _toneMappingType;
  74898. /**
  74899. * Gets the type of tone mapping effect.
  74900. */
  74901. /**
  74902. * Sets the type of tone mapping effect used in BabylonJS.
  74903. */
  74904. toneMappingType: number;
  74905. protected _contrast: number;
  74906. /**
  74907. * Gets the contrast used in the effect.
  74908. */
  74909. /**
  74910. * Sets the contrast used in the effect.
  74911. */
  74912. contrast: number;
  74913. /**
  74914. * Vignette stretch size.
  74915. */
  74916. vignetteStretch: number;
  74917. /**
  74918. * Vignette centre X Offset.
  74919. */
  74920. vignetteCentreX: number;
  74921. /**
  74922. * Vignette centre Y Offset.
  74923. */
  74924. vignetteCentreY: number;
  74925. /**
  74926. * Vignette weight or intensity of the vignette effect.
  74927. */
  74928. vignetteWeight: number;
  74929. /**
  74930. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74931. * if vignetteEnabled is set to true.
  74932. */
  74933. vignetteColor: Color4;
  74934. /**
  74935. * Camera field of view used by the Vignette effect.
  74936. */
  74937. vignetteCameraFov: number;
  74938. private _vignetteBlendMode;
  74939. /**
  74940. * Gets the vignette blend mode allowing different kind of effect.
  74941. */
  74942. /**
  74943. * Sets the vignette blend mode allowing different kind of effect.
  74944. */
  74945. vignetteBlendMode: number;
  74946. private _vignetteEnabled;
  74947. /**
  74948. * Gets wether the vignette effect is enabled.
  74949. */
  74950. /**
  74951. * Sets wether the vignette effect is enabled.
  74952. */
  74953. vignetteEnabled: boolean;
  74954. private _applyByPostProcess;
  74955. /**
  74956. * Gets wether the image processing is applied through a post process or not.
  74957. */
  74958. /**
  74959. * Sets wether the image processing is applied through a post process or not.
  74960. */
  74961. applyByPostProcess: boolean;
  74962. private _isEnabled;
  74963. /**
  74964. * Gets wether the image processing is enabled or not.
  74965. */
  74966. /**
  74967. * Sets wether the image processing is enabled or not.
  74968. */
  74969. isEnabled: boolean;
  74970. /**
  74971. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74972. */
  74973. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74974. /**
  74975. * Method called each time the image processing information changes requires to recompile the effect.
  74976. */
  74977. protected _updateParameters(): void;
  74978. /**
  74979. * Gets the current class name.
  74980. * @return "ImageProcessingConfiguration"
  74981. */
  74982. getClassName(): string;
  74983. /**
  74984. * Prepare the list of uniforms associated with the Image Processing effects.
  74985. * @param uniforms The list of uniforms used in the effect
  74986. * @param defines the list of defines currently in use
  74987. */
  74988. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74989. /**
  74990. * Prepare the list of samplers associated with the Image Processing effects.
  74991. * @param samplersList The list of uniforms used in the effect
  74992. * @param defines the list of defines currently in use
  74993. */
  74994. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74995. /**
  74996. * Prepare the list of defines associated to the shader.
  74997. * @param defines the list of defines to complete
  74998. * @param forPostProcess Define if we are currently in post process mode or not
  74999. */
  75000. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75001. /**
  75002. * Returns true if all the image processing information are ready.
  75003. * @returns True if ready, otherwise, false
  75004. */
  75005. isReady(): boolean;
  75006. /**
  75007. * Binds the image processing to the shader.
  75008. * @param effect The effect to bind to
  75009. * @param aspectRatio Define the current aspect ratio of the effect
  75010. */
  75011. bind(effect: Effect, aspectRatio?: number): void;
  75012. /**
  75013. * Clones the current image processing instance.
  75014. * @return The cloned image processing
  75015. */
  75016. clone(): ImageProcessingConfiguration;
  75017. /**
  75018. * Serializes the current image processing instance to a json representation.
  75019. * @return a JSON representation
  75020. */
  75021. serialize(): any;
  75022. /**
  75023. * Parses the image processing from a json representation.
  75024. * @param source the JSON source to parse
  75025. * @return The parsed image processing
  75026. */
  75027. static Parse(source: any): ImageProcessingConfiguration;
  75028. private static _VIGNETTEMODE_MULTIPLY;
  75029. private static _VIGNETTEMODE_OPAQUE;
  75030. /**
  75031. * Used to apply the vignette as a mix with the pixel color.
  75032. */
  75033. static readonly VIGNETTEMODE_MULTIPLY: number;
  75034. /**
  75035. * Used to apply the vignette as a replacement of the pixel color.
  75036. */
  75037. static readonly VIGNETTEMODE_OPAQUE: number;
  75038. }
  75039. }
  75040. declare module BABYLON {
  75041. /** @hidden */
  75042. export var postprocessVertexShader: {
  75043. name: string;
  75044. shader: string;
  75045. };
  75046. }
  75047. declare module BABYLON {
  75048. /** Defines supported spaces */
  75049. export enum Space {
  75050. /** Local (object) space */
  75051. LOCAL = 0,
  75052. /** World space */
  75053. WORLD = 1,
  75054. /** Bone space */
  75055. BONE = 2
  75056. }
  75057. /** Defines the 3 main axes */
  75058. export class Axis {
  75059. /** X axis */
  75060. static X: Vector3;
  75061. /** Y axis */
  75062. static Y: Vector3;
  75063. /** Z axis */
  75064. static Z: Vector3;
  75065. }
  75066. }
  75067. declare module BABYLON {
  75068. /**
  75069. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75070. * This is the base of the follow, arc rotate cameras and Free camera
  75071. * @see http://doc.babylonjs.com/features/cameras
  75072. */
  75073. export class TargetCamera extends Camera {
  75074. private static _RigCamTransformMatrix;
  75075. private static _TargetTransformMatrix;
  75076. private static _TargetFocalPoint;
  75077. /**
  75078. * Define the current direction the camera is moving to
  75079. */
  75080. cameraDirection: Vector3;
  75081. /**
  75082. * Define the current rotation the camera is rotating to
  75083. */
  75084. cameraRotation: Vector2;
  75085. /**
  75086. * When set, the up vector of the camera will be updated by the rotation of the camera
  75087. */
  75088. updateUpVectorFromRotation: boolean;
  75089. private _tmpQuaternion;
  75090. /**
  75091. * Define the current rotation of the camera
  75092. */
  75093. rotation: Vector3;
  75094. /**
  75095. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75096. */
  75097. rotationQuaternion: Quaternion;
  75098. /**
  75099. * Define the current speed of the camera
  75100. */
  75101. speed: number;
  75102. /**
  75103. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75104. * around all axis.
  75105. */
  75106. noRotationConstraint: boolean;
  75107. /**
  75108. * Define the current target of the camera as an object or a position.
  75109. */
  75110. lockedTarget: any;
  75111. /** @hidden */
  75112. _currentTarget: Vector3;
  75113. /** @hidden */
  75114. _initialFocalDistance: number;
  75115. /** @hidden */
  75116. _viewMatrix: Matrix;
  75117. /** @hidden */
  75118. _camMatrix: Matrix;
  75119. /** @hidden */
  75120. _cameraTransformMatrix: Matrix;
  75121. /** @hidden */
  75122. _cameraRotationMatrix: Matrix;
  75123. /** @hidden */
  75124. _referencePoint: Vector3;
  75125. /** @hidden */
  75126. _transformedReferencePoint: Vector3;
  75127. protected _globalCurrentTarget: Vector3;
  75128. protected _globalCurrentUpVector: Vector3;
  75129. /** @hidden */
  75130. _reset: () => void;
  75131. private _defaultUp;
  75132. /**
  75133. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75134. * This is the base of the follow, arc rotate cameras and Free camera
  75135. * @see http://doc.babylonjs.com/features/cameras
  75136. * @param name Defines the name of the camera in the scene
  75137. * @param position Defines the start position of the camera in the scene
  75138. * @param scene Defines the scene the camera belongs to
  75139. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75140. */
  75141. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75142. /**
  75143. * Gets the position in front of the camera at a given distance.
  75144. * @param distance The distance from the camera we want the position to be
  75145. * @returns the position
  75146. */
  75147. getFrontPosition(distance: number): Vector3;
  75148. /** @hidden */
  75149. _getLockedTargetPosition(): Nullable<Vector3>;
  75150. private _storedPosition;
  75151. private _storedRotation;
  75152. private _storedRotationQuaternion;
  75153. /**
  75154. * Store current camera state of the camera (fov, position, rotation, etc..)
  75155. * @returns the camera
  75156. */
  75157. storeState(): Camera;
  75158. /**
  75159. * Restored camera state. You must call storeState() first
  75160. * @returns whether it was successful or not
  75161. * @hidden
  75162. */
  75163. _restoreStateValues(): boolean;
  75164. /** @hidden */
  75165. _initCache(): void;
  75166. /** @hidden */
  75167. _updateCache(ignoreParentClass?: boolean): void;
  75168. /** @hidden */
  75169. _isSynchronizedViewMatrix(): boolean;
  75170. /** @hidden */
  75171. _computeLocalCameraSpeed(): number;
  75172. /**
  75173. * Defines the target the camera should look at.
  75174. * @param target Defines the new target as a Vector or a mesh
  75175. */
  75176. setTarget(target: Vector3): void;
  75177. /**
  75178. * Return the current target position of the camera. This value is expressed in local space.
  75179. * @returns the target position
  75180. */
  75181. getTarget(): Vector3;
  75182. /** @hidden */
  75183. _decideIfNeedsToMove(): boolean;
  75184. /** @hidden */
  75185. _updatePosition(): void;
  75186. /** @hidden */
  75187. _checkInputs(): void;
  75188. protected _updateCameraRotationMatrix(): void;
  75189. /**
  75190. * 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)
  75191. * @returns the current camera
  75192. */
  75193. private _rotateUpVectorWithCameraRotationMatrix;
  75194. private _cachedRotationZ;
  75195. private _cachedQuaternionRotationZ;
  75196. /** @hidden */
  75197. _getViewMatrix(): Matrix;
  75198. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75199. /**
  75200. * @hidden
  75201. */
  75202. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75203. /**
  75204. * @hidden
  75205. */
  75206. _updateRigCameras(): void;
  75207. private _getRigCamPositionAndTarget;
  75208. /**
  75209. * Gets the current object class name.
  75210. * @return the class name
  75211. */
  75212. getClassName(): string;
  75213. }
  75214. }
  75215. declare module BABYLON {
  75216. /**
  75217. * Gather the list of keyboard event types as constants.
  75218. */
  75219. export class KeyboardEventTypes {
  75220. /**
  75221. * The keydown event is fired when a key becomes active (pressed).
  75222. */
  75223. static readonly KEYDOWN: number;
  75224. /**
  75225. * The keyup event is fired when a key has been released.
  75226. */
  75227. static readonly KEYUP: number;
  75228. }
  75229. /**
  75230. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75231. */
  75232. export class KeyboardInfo {
  75233. /**
  75234. * Defines the type of event (KeyboardEventTypes)
  75235. */
  75236. type: number;
  75237. /**
  75238. * Defines the related dom event
  75239. */
  75240. event: KeyboardEvent;
  75241. /**
  75242. * Instantiates a new keyboard info.
  75243. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75244. * @param type Defines the type of event (KeyboardEventTypes)
  75245. * @param event Defines the related dom event
  75246. */
  75247. constructor(
  75248. /**
  75249. * Defines the type of event (KeyboardEventTypes)
  75250. */
  75251. type: number,
  75252. /**
  75253. * Defines the related dom event
  75254. */
  75255. event: KeyboardEvent);
  75256. }
  75257. /**
  75258. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75259. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75260. */
  75261. export class KeyboardInfoPre extends KeyboardInfo {
  75262. /**
  75263. * Defines the type of event (KeyboardEventTypes)
  75264. */
  75265. type: number;
  75266. /**
  75267. * Defines the related dom event
  75268. */
  75269. event: KeyboardEvent;
  75270. /**
  75271. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75272. */
  75273. skipOnPointerObservable: boolean;
  75274. /**
  75275. * Instantiates a new keyboard pre info.
  75276. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75277. * @param type Defines the type of event (KeyboardEventTypes)
  75278. * @param event Defines the related dom event
  75279. */
  75280. constructor(
  75281. /**
  75282. * Defines the type of event (KeyboardEventTypes)
  75283. */
  75284. type: number,
  75285. /**
  75286. * Defines the related dom event
  75287. */
  75288. event: KeyboardEvent);
  75289. }
  75290. }
  75291. declare module BABYLON {
  75292. /**
  75293. * Manage the keyboard inputs to control the movement of a free camera.
  75294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75295. */
  75296. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75297. /**
  75298. * Defines the camera the input is attached to.
  75299. */
  75300. camera: FreeCamera;
  75301. /**
  75302. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75303. */
  75304. keysUp: number[];
  75305. /**
  75306. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75307. */
  75308. keysDown: number[];
  75309. /**
  75310. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75311. */
  75312. keysLeft: number[];
  75313. /**
  75314. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75315. */
  75316. keysRight: number[];
  75317. private _keys;
  75318. private _onCanvasBlurObserver;
  75319. private _onKeyboardObserver;
  75320. private _engine;
  75321. private _scene;
  75322. /**
  75323. * Attach the input controls to a specific dom element to get the input from.
  75324. * @param element Defines the element the controls should be listened from
  75325. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75326. */
  75327. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75328. /**
  75329. * Detach the current controls from the specified dom element.
  75330. * @param element Defines the element to stop listening the inputs from
  75331. */
  75332. detachControl(element: Nullable<HTMLElement>): void;
  75333. /**
  75334. * Update the current camera state depending on the inputs that have been used this frame.
  75335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75336. */
  75337. checkInputs(): void;
  75338. /**
  75339. * Gets the class name of the current intput.
  75340. * @returns the class name
  75341. */
  75342. getClassName(): string;
  75343. /** @hidden */
  75344. _onLostFocus(): void;
  75345. /**
  75346. * Get the friendly name associated with the input class.
  75347. * @returns the input friendly name
  75348. */
  75349. getSimpleName(): string;
  75350. }
  75351. }
  75352. declare module BABYLON {
  75353. /**
  75354. * Interface describing all the common properties and methods a shadow light needs to implement.
  75355. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75356. * as well as binding the different shadow properties to the effects.
  75357. */
  75358. export interface IShadowLight extends Light {
  75359. /**
  75360. * The light id in the scene (used in scene.findLighById for instance)
  75361. */
  75362. id: string;
  75363. /**
  75364. * The position the shdow will be casted from.
  75365. */
  75366. position: Vector3;
  75367. /**
  75368. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75369. */
  75370. direction: Vector3;
  75371. /**
  75372. * The transformed position. Position of the light in world space taking parenting in account.
  75373. */
  75374. transformedPosition: Vector3;
  75375. /**
  75376. * The transformed direction. Direction of the light in world space taking parenting in account.
  75377. */
  75378. transformedDirection: Vector3;
  75379. /**
  75380. * The friendly name of the light in the scene.
  75381. */
  75382. name: string;
  75383. /**
  75384. * Defines the shadow projection clipping minimum z value.
  75385. */
  75386. shadowMinZ: number;
  75387. /**
  75388. * Defines the shadow projection clipping maximum z value.
  75389. */
  75390. shadowMaxZ: number;
  75391. /**
  75392. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75393. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75394. */
  75395. computeTransformedInformation(): boolean;
  75396. /**
  75397. * Gets the scene the light belongs to.
  75398. * @returns The scene
  75399. */
  75400. getScene(): Scene;
  75401. /**
  75402. * Callback defining a custom Projection Matrix Builder.
  75403. * This can be used to override the default projection matrix computation.
  75404. */
  75405. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75406. /**
  75407. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75408. * @param matrix The materix to updated with the projection information
  75409. * @param viewMatrix The transform matrix of the light
  75410. * @param renderList The list of mesh to render in the map
  75411. * @returns The current light
  75412. */
  75413. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75414. /**
  75415. * Gets the current depth scale used in ESM.
  75416. * @returns The scale
  75417. */
  75418. getDepthScale(): number;
  75419. /**
  75420. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75421. * @returns true if a cube texture needs to be use
  75422. */
  75423. needCube(): boolean;
  75424. /**
  75425. * Detects if the projection matrix requires to be recomputed this frame.
  75426. * @returns true if it requires to be recomputed otherwise, false.
  75427. */
  75428. needProjectionMatrixCompute(): boolean;
  75429. /**
  75430. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75431. */
  75432. forceProjectionMatrixCompute(): void;
  75433. /**
  75434. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75435. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75436. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75437. */
  75438. getShadowDirection(faceIndex?: number): Vector3;
  75439. /**
  75440. * Gets the minZ used for shadow according to both the scene and the light.
  75441. * @param activeCamera The camera we are returning the min for
  75442. * @returns the depth min z
  75443. */
  75444. getDepthMinZ(activeCamera: Camera): number;
  75445. /**
  75446. * Gets the maxZ used for shadow according to both the scene and the light.
  75447. * @param activeCamera The camera we are returning the max for
  75448. * @returns the depth max z
  75449. */
  75450. getDepthMaxZ(activeCamera: Camera): number;
  75451. }
  75452. /**
  75453. * Base implementation IShadowLight
  75454. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75455. */
  75456. export abstract class ShadowLight extends Light implements IShadowLight {
  75457. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75458. protected _position: Vector3;
  75459. protected _setPosition(value: Vector3): void;
  75460. /**
  75461. * Sets the position the shadow will be casted from. Also use as the light position for both
  75462. * point and spot lights.
  75463. */
  75464. /**
  75465. * Sets the position the shadow will be casted from. Also use as the light position for both
  75466. * point and spot lights.
  75467. */
  75468. position: Vector3;
  75469. protected _direction: Vector3;
  75470. protected _setDirection(value: Vector3): void;
  75471. /**
  75472. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75473. * Also use as the light direction on spot and directional lights.
  75474. */
  75475. /**
  75476. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75477. * Also use as the light direction on spot and directional lights.
  75478. */
  75479. direction: Vector3;
  75480. private _shadowMinZ;
  75481. /**
  75482. * Gets the shadow projection clipping minimum z value.
  75483. */
  75484. /**
  75485. * Sets the shadow projection clipping minimum z value.
  75486. */
  75487. shadowMinZ: number;
  75488. private _shadowMaxZ;
  75489. /**
  75490. * Sets the shadow projection clipping maximum z value.
  75491. */
  75492. /**
  75493. * Gets the shadow projection clipping maximum z value.
  75494. */
  75495. shadowMaxZ: number;
  75496. /**
  75497. * Callback defining a custom Projection Matrix Builder.
  75498. * This can be used to override the default projection matrix computation.
  75499. */
  75500. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75501. /**
  75502. * The transformed position. Position of the light in world space taking parenting in account.
  75503. */
  75504. transformedPosition: Vector3;
  75505. /**
  75506. * The transformed direction. Direction of the light in world space taking parenting in account.
  75507. */
  75508. transformedDirection: Vector3;
  75509. private _needProjectionMatrixCompute;
  75510. /**
  75511. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75512. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75513. */
  75514. computeTransformedInformation(): boolean;
  75515. /**
  75516. * Return the depth scale used for the shadow map.
  75517. * @returns the depth scale.
  75518. */
  75519. getDepthScale(): number;
  75520. /**
  75521. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75522. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75523. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75524. */
  75525. getShadowDirection(faceIndex?: number): Vector3;
  75526. /**
  75527. * Returns the ShadowLight absolute position in the World.
  75528. * @returns the position vector in world space
  75529. */
  75530. getAbsolutePosition(): Vector3;
  75531. /**
  75532. * Sets the ShadowLight direction toward the passed target.
  75533. * @param target The point to target in local space
  75534. * @returns the updated ShadowLight direction
  75535. */
  75536. setDirectionToTarget(target: Vector3): Vector3;
  75537. /**
  75538. * Returns the light rotation in euler definition.
  75539. * @returns the x y z rotation in local space.
  75540. */
  75541. getRotation(): Vector3;
  75542. /**
  75543. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75544. * @returns true if a cube texture needs to be use
  75545. */
  75546. needCube(): boolean;
  75547. /**
  75548. * Detects if the projection matrix requires to be recomputed this frame.
  75549. * @returns true if it requires to be recomputed otherwise, false.
  75550. */
  75551. needProjectionMatrixCompute(): boolean;
  75552. /**
  75553. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75554. */
  75555. forceProjectionMatrixCompute(): void;
  75556. /** @hidden */
  75557. _initCache(): void;
  75558. /** @hidden */
  75559. _isSynchronized(): boolean;
  75560. /**
  75561. * Computes the world matrix of the node
  75562. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75563. * @returns the world matrix
  75564. */
  75565. computeWorldMatrix(force?: boolean): Matrix;
  75566. /**
  75567. * Gets the minZ used for shadow according to both the scene and the light.
  75568. * @param activeCamera The camera we are returning the min for
  75569. * @returns the depth min z
  75570. */
  75571. getDepthMinZ(activeCamera: Camera): number;
  75572. /**
  75573. * Gets the maxZ used for shadow according to both the scene and the light.
  75574. * @param activeCamera The camera we are returning the max for
  75575. * @returns the depth max z
  75576. */
  75577. getDepthMaxZ(activeCamera: Camera): number;
  75578. /**
  75579. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75580. * @param matrix The materix to updated with the projection information
  75581. * @param viewMatrix The transform matrix of the light
  75582. * @param renderList The list of mesh to render in the map
  75583. * @returns The current light
  75584. */
  75585. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75586. }
  75587. }
  75588. declare module BABYLON {
  75589. /**
  75590. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75591. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75592. */
  75593. export class EffectFallbacks implements IEffectFallbacks {
  75594. private _defines;
  75595. private _currentRank;
  75596. private _maxRank;
  75597. private _mesh;
  75598. /**
  75599. * Removes the fallback from the bound mesh.
  75600. */
  75601. unBindMesh(): void;
  75602. /**
  75603. * Adds a fallback on the specified property.
  75604. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75605. * @param define The name of the define in the shader
  75606. */
  75607. addFallback(rank: number, define: string): void;
  75608. /**
  75609. * Sets the mesh to use CPU skinning when needing to fallback.
  75610. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75611. * @param mesh The mesh to use the fallbacks.
  75612. */
  75613. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75614. /**
  75615. * Checks to see if more fallbacks are still availible.
  75616. */
  75617. readonly hasMoreFallbacks: boolean;
  75618. /**
  75619. * Removes the defines that should be removed when falling back.
  75620. * @param currentDefines defines the current define statements for the shader.
  75621. * @param effect defines the current effect we try to compile
  75622. * @returns The resulting defines with defines of the current rank removed.
  75623. */
  75624. reduce(currentDefines: string, effect: Effect): string;
  75625. }
  75626. }
  75627. declare module BABYLON {
  75628. /**
  75629. * "Static Class" containing the most commonly used helper while dealing with material for
  75630. * rendering purpose.
  75631. *
  75632. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75633. *
  75634. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75635. */
  75636. export class MaterialHelper {
  75637. /**
  75638. * Bind the current view position to an effect.
  75639. * @param effect The effect to be bound
  75640. * @param scene The scene the eyes position is used from
  75641. */
  75642. static BindEyePosition(effect: Effect, scene: Scene): void;
  75643. /**
  75644. * Helps preparing the defines values about the UVs in used in the effect.
  75645. * UVs are shared as much as we can accross channels in the shaders.
  75646. * @param texture The texture we are preparing the UVs for
  75647. * @param defines The defines to update
  75648. * @param key The channel key "diffuse", "specular"... used in the shader
  75649. */
  75650. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75651. /**
  75652. * Binds a texture matrix value to its corrsponding uniform
  75653. * @param texture The texture to bind the matrix for
  75654. * @param uniformBuffer The uniform buffer receivin the data
  75655. * @param key The channel key "diffuse", "specular"... used in the shader
  75656. */
  75657. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75658. /**
  75659. * Gets the current status of the fog (should it be enabled?)
  75660. * @param mesh defines the mesh to evaluate for fog support
  75661. * @param scene defines the hosting scene
  75662. * @returns true if fog must be enabled
  75663. */
  75664. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75665. /**
  75666. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75667. * @param mesh defines the current mesh
  75668. * @param scene defines the current scene
  75669. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75670. * @param pointsCloud defines if point cloud rendering has to be turned on
  75671. * @param fogEnabled defines if fog has to be turned on
  75672. * @param alphaTest defines if alpha testing has to be turned on
  75673. * @param defines defines the current list of defines
  75674. */
  75675. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75676. /**
  75677. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75678. * @param scene defines the current scene
  75679. * @param engine defines the current engine
  75680. * @param defines specifies the list of active defines
  75681. * @param useInstances defines if instances have to be turned on
  75682. * @param useClipPlane defines if clip plane have to be turned on
  75683. */
  75684. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75685. /**
  75686. * Prepares the defines for bones
  75687. * @param mesh The mesh containing the geometry data we will draw
  75688. * @param defines The defines to update
  75689. */
  75690. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75691. /**
  75692. * Prepares the defines for morph targets
  75693. * @param mesh The mesh containing the geometry data we will draw
  75694. * @param defines The defines to update
  75695. */
  75696. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75697. /**
  75698. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75699. * @param mesh The mesh containing the geometry data we will draw
  75700. * @param defines The defines to update
  75701. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75702. * @param useBones Precise whether bones should be used or not (override mesh info)
  75703. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75704. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75705. * @returns false if defines are considered not dirty and have not been checked
  75706. */
  75707. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75708. /**
  75709. * Prepares the defines related to multiview
  75710. * @param scene The scene we are intending to draw
  75711. * @param defines The defines to update
  75712. */
  75713. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75714. /**
  75715. * Prepares the defines related to the light information passed in parameter
  75716. * @param scene The scene we are intending to draw
  75717. * @param mesh The mesh the effect is compiling for
  75718. * @param light The light the effect is compiling for
  75719. * @param lightIndex The index of the light
  75720. * @param defines The defines to update
  75721. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75722. * @param state Defines the current state regarding what is needed (normals, etc...)
  75723. */
  75724. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75725. needNormals: boolean;
  75726. needRebuild: boolean;
  75727. shadowEnabled: boolean;
  75728. specularEnabled: boolean;
  75729. lightmapMode: boolean;
  75730. }): void;
  75731. /**
  75732. * Prepares the defines related to the light information passed in parameter
  75733. * @param scene The scene we are intending to draw
  75734. * @param mesh The mesh the effect is compiling for
  75735. * @param defines The defines to update
  75736. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75737. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75738. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75739. * @returns true if normals will be required for the rest of the effect
  75740. */
  75741. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75742. /**
  75743. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75744. * @param lightIndex defines the light index
  75745. * @param uniformsList The uniform list
  75746. * @param samplersList The sampler list
  75747. * @param projectedLightTexture defines if projected texture must be used
  75748. * @param uniformBuffersList defines an optional list of uniform buffers
  75749. */
  75750. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75751. /**
  75752. * Prepares the uniforms and samplers list to be used in the effect
  75753. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75754. * @param samplersList The sampler list
  75755. * @param defines The defines helping in the list generation
  75756. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75757. */
  75758. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75759. /**
  75760. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75761. * @param defines The defines to update while falling back
  75762. * @param fallbacks The authorized effect fallbacks
  75763. * @param maxSimultaneousLights The maximum number of lights allowed
  75764. * @param rank the current rank of the Effect
  75765. * @returns The newly affected rank
  75766. */
  75767. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75768. private static _TmpMorphInfluencers;
  75769. /**
  75770. * Prepares the list of attributes required for morph targets according to the effect defines.
  75771. * @param attribs The current list of supported attribs
  75772. * @param mesh The mesh to prepare the morph targets attributes for
  75773. * @param influencers The number of influencers
  75774. */
  75775. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75776. /**
  75777. * Prepares the list of attributes required for morph targets according to the effect defines.
  75778. * @param attribs The current list of supported attribs
  75779. * @param mesh The mesh to prepare the morph targets attributes for
  75780. * @param defines The current Defines of the effect
  75781. */
  75782. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75783. /**
  75784. * Prepares the list of attributes required for bones according to the effect defines.
  75785. * @param attribs The current list of supported attribs
  75786. * @param mesh The mesh to prepare the bones attributes for
  75787. * @param defines The current Defines of the effect
  75788. * @param fallbacks The current efffect fallback strategy
  75789. */
  75790. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75791. /**
  75792. * Check and prepare the list of attributes required for instances according to the effect defines.
  75793. * @param attribs The current list of supported attribs
  75794. * @param defines The current MaterialDefines of the effect
  75795. */
  75796. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75797. /**
  75798. * Add the list of attributes required for instances to the attribs array.
  75799. * @param attribs The current list of supported attribs
  75800. */
  75801. static PushAttributesForInstances(attribs: string[]): void;
  75802. /**
  75803. * Binds the light shadow information to the effect for the given mesh.
  75804. * @param light The light containing the generator
  75805. * @param scene The scene the lights belongs to
  75806. * @param mesh The mesh we are binding the information to render
  75807. * @param lightIndex The light index in the effect used to render the mesh
  75808. * @param effect The effect we are binding the data to
  75809. */
  75810. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75811. /**
  75812. * Binds the light information to the effect.
  75813. * @param light The light containing the generator
  75814. * @param effect The effect we are binding the data to
  75815. * @param lightIndex The light index in the effect used to render
  75816. */
  75817. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75818. /**
  75819. * Binds the lights information from the scene to the effect for the given mesh.
  75820. * @param light Light to bind
  75821. * @param lightIndex Light index
  75822. * @param scene The scene where the light belongs to
  75823. * @param mesh The mesh we are binding the information to render
  75824. * @param effect The effect we are binding the data to
  75825. * @param useSpecular Defines if specular is supported
  75826. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75827. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75828. */
  75829. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75830. /**
  75831. * Binds the lights information from the scene to the effect for the given mesh.
  75832. * @param scene The scene the lights belongs to
  75833. * @param mesh The mesh we are binding the information to render
  75834. * @param effect The effect we are binding the data to
  75835. * @param defines The generated defines for the effect
  75836. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75837. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75838. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75839. */
  75840. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75841. private static _tempFogColor;
  75842. /**
  75843. * Binds the fog information from the scene to the effect for the given mesh.
  75844. * @param scene The scene the lights belongs to
  75845. * @param mesh The mesh we are binding the information to render
  75846. * @param effect The effect we are binding the data to
  75847. * @param linearSpace Defines if the fog effect is applied in linear space
  75848. */
  75849. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75850. /**
  75851. * Binds the bones information from the mesh to the effect.
  75852. * @param mesh The mesh we are binding the information to render
  75853. * @param effect The effect we are binding the data to
  75854. */
  75855. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75856. /**
  75857. * Binds the morph targets information from the mesh to the effect.
  75858. * @param abstractMesh The mesh we are binding the information to render
  75859. * @param effect The effect we are binding the data to
  75860. */
  75861. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75862. /**
  75863. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75864. * @param defines The generated defines used in the effect
  75865. * @param effect The effect we are binding the data to
  75866. * @param scene The scene we are willing to render with logarithmic scale for
  75867. */
  75868. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75869. /**
  75870. * Binds the clip plane information from the scene to the effect.
  75871. * @param scene The scene the clip plane information are extracted from
  75872. * @param effect The effect we are binding the data to
  75873. */
  75874. static BindClipPlane(effect: Effect, scene: Scene): void;
  75875. }
  75876. }
  75877. declare module BABYLON {
  75878. /** @hidden */
  75879. export var packingFunctions: {
  75880. name: string;
  75881. shader: string;
  75882. };
  75883. }
  75884. declare module BABYLON {
  75885. /** @hidden */
  75886. export var shadowMapPixelShader: {
  75887. name: string;
  75888. shader: string;
  75889. };
  75890. }
  75891. declare module BABYLON {
  75892. /** @hidden */
  75893. export var bonesDeclaration: {
  75894. name: string;
  75895. shader: string;
  75896. };
  75897. }
  75898. declare module BABYLON {
  75899. /** @hidden */
  75900. export var morphTargetsVertexGlobalDeclaration: {
  75901. name: string;
  75902. shader: string;
  75903. };
  75904. }
  75905. declare module BABYLON {
  75906. /** @hidden */
  75907. export var morphTargetsVertexDeclaration: {
  75908. name: string;
  75909. shader: string;
  75910. };
  75911. }
  75912. declare module BABYLON {
  75913. /** @hidden */
  75914. export var instancesDeclaration: {
  75915. name: string;
  75916. shader: string;
  75917. };
  75918. }
  75919. declare module BABYLON {
  75920. /** @hidden */
  75921. export var helperFunctions: {
  75922. name: string;
  75923. shader: string;
  75924. };
  75925. }
  75926. declare module BABYLON {
  75927. /** @hidden */
  75928. export var morphTargetsVertex: {
  75929. name: string;
  75930. shader: string;
  75931. };
  75932. }
  75933. declare module BABYLON {
  75934. /** @hidden */
  75935. export var instancesVertex: {
  75936. name: string;
  75937. shader: string;
  75938. };
  75939. }
  75940. declare module BABYLON {
  75941. /** @hidden */
  75942. export var bonesVertex: {
  75943. name: string;
  75944. shader: string;
  75945. };
  75946. }
  75947. declare module BABYLON {
  75948. /** @hidden */
  75949. export var shadowMapVertexShader: {
  75950. name: string;
  75951. shader: string;
  75952. };
  75953. }
  75954. declare module BABYLON {
  75955. /** @hidden */
  75956. export var depthBoxBlurPixelShader: {
  75957. name: string;
  75958. shader: string;
  75959. };
  75960. }
  75961. declare module BABYLON {
  75962. /**
  75963. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75964. */
  75965. export interface ICustomShaderOptions {
  75966. /**
  75967. * Gets or sets the custom shader name to use
  75968. */
  75969. shaderName: string;
  75970. /**
  75971. * The list of attribute names used in the shader
  75972. */
  75973. attributes?: string[];
  75974. /**
  75975. * The list of unifrom names used in the shader
  75976. */
  75977. uniforms?: string[];
  75978. /**
  75979. * The list of sampler names used in the shader
  75980. */
  75981. samplers?: string[];
  75982. /**
  75983. * The list of defines used in the shader
  75984. */
  75985. defines?: string[];
  75986. }
  75987. /**
  75988. * Interface to implement to create a shadow generator compatible with BJS.
  75989. */
  75990. export interface IShadowGenerator {
  75991. /**
  75992. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75993. * @returns The render target texture if present otherwise, null
  75994. */
  75995. getShadowMap(): Nullable<RenderTargetTexture>;
  75996. /**
  75997. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75998. * @returns The render target texture if the shadow map is present otherwise, null
  75999. */
  76000. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76001. /**
  76002. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76003. * @param subMesh The submesh we want to render in the shadow map
  76004. * @param useInstances Defines wether will draw in the map using instances
  76005. * @returns true if ready otherwise, false
  76006. */
  76007. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76008. /**
  76009. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76010. * @param defines Defines of the material we want to update
  76011. * @param lightIndex Index of the light in the enabled light list of the material
  76012. */
  76013. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76014. /**
  76015. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76016. * defined in the generator but impacting the effect).
  76017. * It implies the unifroms available on the materials are the standard BJS ones.
  76018. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76019. * @param effect The effect we are binfing the information for
  76020. */
  76021. bindShadowLight(lightIndex: string, effect: Effect): void;
  76022. /**
  76023. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76024. * (eq to shadow prjection matrix * light transform matrix)
  76025. * @returns The transform matrix used to create the shadow map
  76026. */
  76027. getTransformMatrix(): Matrix;
  76028. /**
  76029. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76030. * Cube and 2D textures for instance.
  76031. */
  76032. recreateShadowMap(): void;
  76033. /**
  76034. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76035. * @param onCompiled Callback triggered at the and of the effects compilation
  76036. * @param options Sets of optional options forcing the compilation with different modes
  76037. */
  76038. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76039. useInstances: boolean;
  76040. }>): void;
  76041. /**
  76042. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76043. * @param options Sets of optional options forcing the compilation with different modes
  76044. * @returns A promise that resolves when the compilation completes
  76045. */
  76046. forceCompilationAsync(options?: Partial<{
  76047. useInstances: boolean;
  76048. }>): Promise<void>;
  76049. /**
  76050. * Serializes the shadow generator setup to a json object.
  76051. * @returns The serialized JSON object
  76052. */
  76053. serialize(): any;
  76054. /**
  76055. * Disposes the Shadow map and related Textures and effects.
  76056. */
  76057. dispose(): void;
  76058. }
  76059. /**
  76060. * Default implementation IShadowGenerator.
  76061. * This is the main object responsible of generating shadows in the framework.
  76062. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76063. */
  76064. export class ShadowGenerator implements IShadowGenerator {
  76065. /**
  76066. * Shadow generator mode None: no filtering applied.
  76067. */
  76068. static readonly FILTER_NONE: number;
  76069. /**
  76070. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76071. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76072. */
  76073. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76074. /**
  76075. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76076. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76077. */
  76078. static readonly FILTER_POISSONSAMPLING: number;
  76079. /**
  76080. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76081. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76082. */
  76083. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76084. /**
  76085. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76086. * edge artifacts on steep falloff.
  76087. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76088. */
  76089. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76090. /**
  76091. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76092. * edge artifacts on steep falloff.
  76093. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76094. */
  76095. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76096. /**
  76097. * Shadow generator mode PCF: Percentage Closer Filtering
  76098. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76099. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76100. */
  76101. static readonly FILTER_PCF: number;
  76102. /**
  76103. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76104. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76105. * Contact Hardening
  76106. */
  76107. static readonly FILTER_PCSS: number;
  76108. /**
  76109. * Reserved for PCF and PCSS
  76110. * Highest Quality.
  76111. *
  76112. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76113. *
  76114. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76115. */
  76116. static readonly QUALITY_HIGH: number;
  76117. /**
  76118. * Reserved for PCF and PCSS
  76119. * Good tradeoff for quality/perf cross devices
  76120. *
  76121. * Execute PCF on a 3*3 kernel.
  76122. *
  76123. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76124. */
  76125. static readonly QUALITY_MEDIUM: number;
  76126. /**
  76127. * Reserved for PCF and PCSS
  76128. * The lowest quality but the fastest.
  76129. *
  76130. * Execute PCF on a 1*1 kernel.
  76131. *
  76132. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76133. */
  76134. static readonly QUALITY_LOW: number;
  76135. /** Gets or sets the custom shader name to use */
  76136. customShaderOptions: ICustomShaderOptions;
  76137. /**
  76138. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76139. */
  76140. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76141. /**
  76142. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76143. */
  76144. onAfterShadowMapRenderObservable: Observable<Effect>;
  76145. /**
  76146. * Observable triggered before a mesh is rendered in the shadow map.
  76147. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76148. */
  76149. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76150. /**
  76151. * Observable triggered after a mesh is rendered in the shadow map.
  76152. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76153. */
  76154. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76155. private _bias;
  76156. /**
  76157. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76158. */
  76159. /**
  76160. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76161. */
  76162. bias: number;
  76163. private _normalBias;
  76164. /**
  76165. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76166. */
  76167. /**
  76168. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76169. */
  76170. normalBias: number;
  76171. private _blurBoxOffset;
  76172. /**
  76173. * Gets the blur box offset: offset applied during the blur pass.
  76174. * Only useful if useKernelBlur = false
  76175. */
  76176. /**
  76177. * Sets the blur box offset: offset applied during the blur pass.
  76178. * Only useful if useKernelBlur = false
  76179. */
  76180. blurBoxOffset: number;
  76181. private _blurScale;
  76182. /**
  76183. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76184. * 2 means half of the size.
  76185. */
  76186. /**
  76187. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76188. * 2 means half of the size.
  76189. */
  76190. blurScale: number;
  76191. private _blurKernel;
  76192. /**
  76193. * Gets the blur kernel: kernel size of the blur pass.
  76194. * Only useful if useKernelBlur = true
  76195. */
  76196. /**
  76197. * Sets the blur kernel: kernel size of the blur pass.
  76198. * Only useful if useKernelBlur = true
  76199. */
  76200. blurKernel: number;
  76201. private _useKernelBlur;
  76202. /**
  76203. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76204. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76205. */
  76206. /**
  76207. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76208. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76209. */
  76210. useKernelBlur: boolean;
  76211. private _depthScale;
  76212. /**
  76213. * Gets the depth scale used in ESM mode.
  76214. */
  76215. /**
  76216. * Sets the depth scale used in ESM mode.
  76217. * This can override the scale stored on the light.
  76218. */
  76219. depthScale: number;
  76220. private _filter;
  76221. /**
  76222. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76223. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76224. */
  76225. /**
  76226. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76227. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76228. */
  76229. filter: number;
  76230. /**
  76231. * Gets if the current filter is set to Poisson Sampling.
  76232. */
  76233. /**
  76234. * Sets the current filter to Poisson Sampling.
  76235. */
  76236. usePoissonSampling: boolean;
  76237. /**
  76238. * Gets if the current filter is set to ESM.
  76239. */
  76240. /**
  76241. * Sets the current filter is to ESM.
  76242. */
  76243. useExponentialShadowMap: boolean;
  76244. /**
  76245. * Gets if the current filter is set to filtered ESM.
  76246. */
  76247. /**
  76248. * Gets if the current filter is set to filtered ESM.
  76249. */
  76250. useBlurExponentialShadowMap: boolean;
  76251. /**
  76252. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76253. * exponential to prevent steep falloff artifacts).
  76254. */
  76255. /**
  76256. * Sets the current filter to "close ESM" (using the inverse of the
  76257. * exponential to prevent steep falloff artifacts).
  76258. */
  76259. useCloseExponentialShadowMap: boolean;
  76260. /**
  76261. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76262. * exponential to prevent steep falloff artifacts).
  76263. */
  76264. /**
  76265. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76266. * exponential to prevent steep falloff artifacts).
  76267. */
  76268. useBlurCloseExponentialShadowMap: boolean;
  76269. /**
  76270. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76271. */
  76272. /**
  76273. * Sets the current filter to "PCF" (percentage closer filtering).
  76274. */
  76275. usePercentageCloserFiltering: boolean;
  76276. private _filteringQuality;
  76277. /**
  76278. * Gets the PCF or PCSS Quality.
  76279. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76280. */
  76281. /**
  76282. * Sets the PCF or PCSS Quality.
  76283. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76284. */
  76285. filteringQuality: number;
  76286. /**
  76287. * Gets if the current filter is set to "PCSS" (contact hardening).
  76288. */
  76289. /**
  76290. * Sets the current filter to "PCSS" (contact hardening).
  76291. */
  76292. useContactHardeningShadow: boolean;
  76293. private _contactHardeningLightSizeUVRatio;
  76294. /**
  76295. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76296. * Using a ratio helps keeping shape stability independently of the map size.
  76297. *
  76298. * It does not account for the light projection as it was having too much
  76299. * instability during the light setup or during light position changes.
  76300. *
  76301. * Only valid if useContactHardeningShadow is true.
  76302. */
  76303. /**
  76304. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76305. * Using a ratio helps keeping shape stability independently of the map size.
  76306. *
  76307. * It does not account for the light projection as it was having too much
  76308. * instability during the light setup or during light position changes.
  76309. *
  76310. * Only valid if useContactHardeningShadow is true.
  76311. */
  76312. contactHardeningLightSizeUVRatio: number;
  76313. private _darkness;
  76314. /** Gets or sets the actual darkness of a shadow */
  76315. darkness: number;
  76316. /**
  76317. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76318. * 0 means strongest and 1 would means no shadow.
  76319. * @returns the darkness.
  76320. */
  76321. getDarkness(): number;
  76322. /**
  76323. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76324. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76325. * @returns the shadow generator allowing fluent coding.
  76326. */
  76327. setDarkness(darkness: number): ShadowGenerator;
  76328. private _transparencyShadow;
  76329. /** Gets or sets the ability to have transparent shadow */
  76330. transparencyShadow: boolean;
  76331. /**
  76332. * Sets the ability to have transparent shadow (boolean).
  76333. * @param transparent True if transparent else False
  76334. * @returns the shadow generator allowing fluent coding
  76335. */
  76336. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76337. private _shadowMap;
  76338. private _shadowMap2;
  76339. /**
  76340. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76341. * @returns The render target texture if present otherwise, null
  76342. */
  76343. getShadowMap(): Nullable<RenderTargetTexture>;
  76344. /**
  76345. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76346. * @returns The render target texture if the shadow map is present otherwise, null
  76347. */
  76348. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76349. /**
  76350. * Gets the class name of that object
  76351. * @returns "ShadowGenerator"
  76352. */
  76353. getClassName(): string;
  76354. /**
  76355. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76356. * @param mesh Mesh to add
  76357. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76358. * @returns the Shadow Generator itself
  76359. */
  76360. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76361. /**
  76362. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76363. * @param mesh Mesh to remove
  76364. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76365. * @returns the Shadow Generator itself
  76366. */
  76367. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76368. /**
  76369. * Controls the extent to which the shadows fade out at the edge of the frustum
  76370. * Used only by directionals and spots
  76371. */
  76372. frustumEdgeFalloff: number;
  76373. private _light;
  76374. /**
  76375. * Returns the associated light object.
  76376. * @returns the light generating the shadow
  76377. */
  76378. getLight(): IShadowLight;
  76379. /**
  76380. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76381. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76382. * It might on the other hand introduce peter panning.
  76383. */
  76384. forceBackFacesOnly: boolean;
  76385. private _scene;
  76386. private _lightDirection;
  76387. private _effect;
  76388. private _viewMatrix;
  76389. private _projectionMatrix;
  76390. private _transformMatrix;
  76391. private _cachedPosition;
  76392. private _cachedDirection;
  76393. private _cachedDefines;
  76394. private _currentRenderID;
  76395. private _boxBlurPostprocess;
  76396. private _kernelBlurXPostprocess;
  76397. private _kernelBlurYPostprocess;
  76398. private _blurPostProcesses;
  76399. private _mapSize;
  76400. private _currentFaceIndex;
  76401. private _currentFaceIndexCache;
  76402. private _textureType;
  76403. private _defaultTextureMatrix;
  76404. /** @hidden */
  76405. static _SceneComponentInitialization: (scene: Scene) => void;
  76406. /**
  76407. * Creates a ShadowGenerator object.
  76408. * A ShadowGenerator is the required tool to use the shadows.
  76409. * Each light casting shadows needs to use its own ShadowGenerator.
  76410. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76411. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76412. * @param light The light object generating the shadows.
  76413. * @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.
  76414. */
  76415. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76416. private _initializeGenerator;
  76417. private _initializeShadowMap;
  76418. private _initializeBlurRTTAndPostProcesses;
  76419. private _renderForShadowMap;
  76420. private _renderSubMeshForShadowMap;
  76421. private _applyFilterValues;
  76422. /**
  76423. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76424. * @param onCompiled Callback triggered at the and of the effects compilation
  76425. * @param options Sets of optional options forcing the compilation with different modes
  76426. */
  76427. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76428. useInstances: boolean;
  76429. }>): void;
  76430. /**
  76431. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76432. * @param options Sets of optional options forcing the compilation with different modes
  76433. * @returns A promise that resolves when the compilation completes
  76434. */
  76435. forceCompilationAsync(options?: Partial<{
  76436. useInstances: boolean;
  76437. }>): Promise<void>;
  76438. /**
  76439. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76440. * @param subMesh The submesh we want to render in the shadow map
  76441. * @param useInstances Defines wether will draw in the map using instances
  76442. * @returns true if ready otherwise, false
  76443. */
  76444. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76445. /**
  76446. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76447. * @param defines Defines of the material we want to update
  76448. * @param lightIndex Index of the light in the enabled light list of the material
  76449. */
  76450. prepareDefines(defines: any, lightIndex: number): void;
  76451. /**
  76452. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76453. * defined in the generator but impacting the effect).
  76454. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76455. * @param effect The effect we are binfing the information for
  76456. */
  76457. bindShadowLight(lightIndex: string, effect: Effect): void;
  76458. /**
  76459. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76460. * (eq to shadow prjection matrix * light transform matrix)
  76461. * @returns The transform matrix used to create the shadow map
  76462. */
  76463. getTransformMatrix(): Matrix;
  76464. /**
  76465. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76466. * Cube and 2D textures for instance.
  76467. */
  76468. recreateShadowMap(): void;
  76469. private _disposeBlurPostProcesses;
  76470. private _disposeRTTandPostProcesses;
  76471. /**
  76472. * Disposes the ShadowGenerator.
  76473. * Returns nothing.
  76474. */
  76475. dispose(): void;
  76476. /**
  76477. * Serializes the shadow generator setup to a json object.
  76478. * @returns The serialized JSON object
  76479. */
  76480. serialize(): any;
  76481. /**
  76482. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76483. * @param parsedShadowGenerator The JSON object to parse
  76484. * @param scene The scene to create the shadow map for
  76485. * @returns The parsed shadow generator
  76486. */
  76487. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76488. }
  76489. }
  76490. declare module BABYLON {
  76491. /**
  76492. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76493. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76494. * 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.
  76495. */
  76496. export abstract class Light extends Node {
  76497. /**
  76498. * Falloff Default: light is falling off following the material specification:
  76499. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76500. */
  76501. static readonly FALLOFF_DEFAULT: number;
  76502. /**
  76503. * Falloff Physical: light is falling off following the inverse squared distance law.
  76504. */
  76505. static readonly FALLOFF_PHYSICAL: number;
  76506. /**
  76507. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76508. * to enhance interoperability with other engines.
  76509. */
  76510. static readonly FALLOFF_GLTF: number;
  76511. /**
  76512. * Falloff Standard: light is falling off like in the standard material
  76513. * to enhance interoperability with other materials.
  76514. */
  76515. static readonly FALLOFF_STANDARD: number;
  76516. /**
  76517. * If every light affecting the material is in this lightmapMode,
  76518. * material.lightmapTexture adds or multiplies
  76519. * (depends on material.useLightmapAsShadowmap)
  76520. * after every other light calculations.
  76521. */
  76522. static readonly LIGHTMAP_DEFAULT: number;
  76523. /**
  76524. * material.lightmapTexture as only diffuse lighting from this light
  76525. * adds only specular lighting from this light
  76526. * adds dynamic shadows
  76527. */
  76528. static readonly LIGHTMAP_SPECULAR: number;
  76529. /**
  76530. * material.lightmapTexture as only lighting
  76531. * no light calculation from this light
  76532. * only adds dynamic shadows from this light
  76533. */
  76534. static readonly LIGHTMAP_SHADOWSONLY: number;
  76535. /**
  76536. * Each light type uses the default quantity according to its type:
  76537. * point/spot lights use luminous intensity
  76538. * directional lights use illuminance
  76539. */
  76540. static readonly INTENSITYMODE_AUTOMATIC: number;
  76541. /**
  76542. * lumen (lm)
  76543. */
  76544. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76545. /**
  76546. * candela (lm/sr)
  76547. */
  76548. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76549. /**
  76550. * lux (lm/m^2)
  76551. */
  76552. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76553. /**
  76554. * nit (cd/m^2)
  76555. */
  76556. static readonly INTENSITYMODE_LUMINANCE: number;
  76557. /**
  76558. * Light type const id of the point light.
  76559. */
  76560. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76561. /**
  76562. * Light type const id of the directional light.
  76563. */
  76564. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76565. /**
  76566. * Light type const id of the spot light.
  76567. */
  76568. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76569. /**
  76570. * Light type const id of the hemispheric light.
  76571. */
  76572. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76573. /**
  76574. * Diffuse gives the basic color to an object.
  76575. */
  76576. diffuse: Color3;
  76577. /**
  76578. * Specular produces a highlight color on an object.
  76579. * Note: This is note affecting PBR materials.
  76580. */
  76581. specular: Color3;
  76582. /**
  76583. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76584. * falling off base on range or angle.
  76585. * This can be set to any values in Light.FALLOFF_x.
  76586. *
  76587. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76588. * other types of materials.
  76589. */
  76590. falloffType: number;
  76591. /**
  76592. * Strength of the light.
  76593. * Note: By default it is define in the framework own unit.
  76594. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76595. */
  76596. intensity: number;
  76597. private _range;
  76598. protected _inverseSquaredRange: number;
  76599. /**
  76600. * Defines how far from the source the light is impacting in scene units.
  76601. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76602. */
  76603. /**
  76604. * Defines how far from the source the light is impacting in scene units.
  76605. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76606. */
  76607. range: number;
  76608. /**
  76609. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76610. * of light.
  76611. */
  76612. private _photometricScale;
  76613. private _intensityMode;
  76614. /**
  76615. * Gets the photometric scale used to interpret the intensity.
  76616. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76617. */
  76618. /**
  76619. * Sets the photometric scale used to interpret the intensity.
  76620. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76621. */
  76622. intensityMode: number;
  76623. private _radius;
  76624. /**
  76625. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76626. */
  76627. /**
  76628. * sets the light radius used by PBR Materials to simulate soft area lights.
  76629. */
  76630. radius: number;
  76631. private _renderPriority;
  76632. /**
  76633. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76634. * exceeding the number allowed of the materials.
  76635. */
  76636. renderPriority: number;
  76637. private _shadowEnabled;
  76638. /**
  76639. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76640. * the current shadow generator.
  76641. */
  76642. /**
  76643. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76644. * the current shadow generator.
  76645. */
  76646. shadowEnabled: boolean;
  76647. private _includedOnlyMeshes;
  76648. /**
  76649. * Gets the only meshes impacted by this light.
  76650. */
  76651. /**
  76652. * Sets the only meshes impacted by this light.
  76653. */
  76654. includedOnlyMeshes: AbstractMesh[];
  76655. private _excludedMeshes;
  76656. /**
  76657. * Gets the meshes not impacted by this light.
  76658. */
  76659. /**
  76660. * Sets the meshes not impacted by this light.
  76661. */
  76662. excludedMeshes: AbstractMesh[];
  76663. private _excludeWithLayerMask;
  76664. /**
  76665. * Gets the layer id use to find what meshes are not impacted by the light.
  76666. * Inactive if 0
  76667. */
  76668. /**
  76669. * Sets the layer id use to find what meshes are not impacted by the light.
  76670. * Inactive if 0
  76671. */
  76672. excludeWithLayerMask: number;
  76673. private _includeOnlyWithLayerMask;
  76674. /**
  76675. * Gets the layer id use to find what meshes are impacted by the light.
  76676. * Inactive if 0
  76677. */
  76678. /**
  76679. * Sets the layer id use to find what meshes are impacted by the light.
  76680. * Inactive if 0
  76681. */
  76682. includeOnlyWithLayerMask: number;
  76683. private _lightmapMode;
  76684. /**
  76685. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76686. */
  76687. /**
  76688. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76689. */
  76690. lightmapMode: number;
  76691. /**
  76692. * Shadow generator associted to the light.
  76693. * @hidden Internal use only.
  76694. */
  76695. _shadowGenerator: Nullable<IShadowGenerator>;
  76696. /**
  76697. * @hidden Internal use only.
  76698. */
  76699. _excludedMeshesIds: string[];
  76700. /**
  76701. * @hidden Internal use only.
  76702. */
  76703. _includedOnlyMeshesIds: string[];
  76704. /**
  76705. * The current light unifom buffer.
  76706. * @hidden Internal use only.
  76707. */
  76708. _uniformBuffer: UniformBuffer;
  76709. /**
  76710. * Creates a Light object in the scene.
  76711. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76712. * @param name The firendly name of the light
  76713. * @param scene The scene the light belongs too
  76714. */
  76715. constructor(name: string, scene: Scene);
  76716. protected abstract _buildUniformLayout(): void;
  76717. /**
  76718. * Sets the passed Effect "effect" with the Light information.
  76719. * @param effect The effect to update
  76720. * @param lightIndex The index of the light in the effect to update
  76721. * @returns The light
  76722. */
  76723. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76724. /**
  76725. * Sets the passed Effect "effect" with the Light information.
  76726. * @param effect The effect to update
  76727. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76728. * @returns The light
  76729. */
  76730. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76731. /**
  76732. * Returns the string "Light".
  76733. * @returns the class name
  76734. */
  76735. getClassName(): string;
  76736. /** @hidden */
  76737. readonly _isLight: boolean;
  76738. /**
  76739. * Converts the light information to a readable string for debug purpose.
  76740. * @param fullDetails Supports for multiple levels of logging within scene loading
  76741. * @returns the human readable light info
  76742. */
  76743. toString(fullDetails?: boolean): string;
  76744. /** @hidden */
  76745. protected _syncParentEnabledState(): void;
  76746. /**
  76747. * Set the enabled state of this node.
  76748. * @param value - the new enabled state
  76749. */
  76750. setEnabled(value: boolean): void;
  76751. /**
  76752. * Returns the Light associated shadow generator if any.
  76753. * @return the associated shadow generator.
  76754. */
  76755. getShadowGenerator(): Nullable<IShadowGenerator>;
  76756. /**
  76757. * Returns a Vector3, the absolute light position in the World.
  76758. * @returns the world space position of the light
  76759. */
  76760. getAbsolutePosition(): Vector3;
  76761. /**
  76762. * Specifies if the light will affect the passed mesh.
  76763. * @param mesh The mesh to test against the light
  76764. * @return true the mesh is affected otherwise, false.
  76765. */
  76766. canAffectMesh(mesh: AbstractMesh): boolean;
  76767. /**
  76768. * Sort function to order lights for rendering.
  76769. * @param a First Light object to compare to second.
  76770. * @param b Second Light object to compare first.
  76771. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76772. */
  76773. static CompareLightsPriority(a: Light, b: Light): number;
  76774. /**
  76775. * Releases resources associated with this node.
  76776. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76777. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76778. */
  76779. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76780. /**
  76781. * Returns the light type ID (integer).
  76782. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76783. */
  76784. getTypeID(): number;
  76785. /**
  76786. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76787. * @returns the scaled intensity in intensity mode unit
  76788. */
  76789. getScaledIntensity(): number;
  76790. /**
  76791. * Returns a new Light object, named "name", from the current one.
  76792. * @param name The name of the cloned light
  76793. * @returns the new created light
  76794. */
  76795. clone(name: string): Nullable<Light>;
  76796. /**
  76797. * Serializes the current light into a Serialization object.
  76798. * @returns the serialized object.
  76799. */
  76800. serialize(): any;
  76801. /**
  76802. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76803. * This new light is named "name" and added to the passed scene.
  76804. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76805. * @param name The friendly name of the light
  76806. * @param scene The scene the new light will belong to
  76807. * @returns the constructor function
  76808. */
  76809. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76810. /**
  76811. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76812. * @param parsedLight The JSON representation of the light
  76813. * @param scene The scene to create the parsed light in
  76814. * @returns the created light after parsing
  76815. */
  76816. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76817. private _hookArrayForExcluded;
  76818. private _hookArrayForIncludedOnly;
  76819. private _resyncMeshes;
  76820. /**
  76821. * Forces the meshes to update their light related information in their rendering used effects
  76822. * @hidden Internal Use Only
  76823. */
  76824. _markMeshesAsLightDirty(): void;
  76825. /**
  76826. * Recomputes the cached photometric scale if needed.
  76827. */
  76828. private _computePhotometricScale;
  76829. /**
  76830. * Returns the Photometric Scale according to the light type and intensity mode.
  76831. */
  76832. private _getPhotometricScale;
  76833. /**
  76834. * Reorder the light in the scene according to their defined priority.
  76835. * @hidden Internal Use Only
  76836. */
  76837. _reorderLightsInScene(): void;
  76838. /**
  76839. * Prepares the list of defines specific to the light type.
  76840. * @param defines the list of defines
  76841. * @param lightIndex defines the index of the light for the effect
  76842. */
  76843. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76844. }
  76845. }
  76846. declare module BABYLON {
  76847. /**
  76848. * Interface used to define Action
  76849. */
  76850. export interface IAction {
  76851. /**
  76852. * Trigger for the action
  76853. */
  76854. trigger: number;
  76855. /** Options of the trigger */
  76856. triggerOptions: any;
  76857. /**
  76858. * Gets the trigger parameters
  76859. * @returns the trigger parameters
  76860. */
  76861. getTriggerParameter(): any;
  76862. /**
  76863. * Internal only - executes current action event
  76864. * @hidden
  76865. */
  76866. _executeCurrent(evt?: ActionEvent): void;
  76867. /**
  76868. * Serialize placeholder for child classes
  76869. * @param parent of child
  76870. * @returns the serialized object
  76871. */
  76872. serialize(parent: any): any;
  76873. /**
  76874. * Internal only
  76875. * @hidden
  76876. */
  76877. _prepare(): void;
  76878. /**
  76879. * Internal only - manager for action
  76880. * @hidden
  76881. */
  76882. _actionManager: AbstractActionManager;
  76883. /**
  76884. * Adds action to chain of actions, may be a DoNothingAction
  76885. * @param action defines the next action to execute
  76886. * @returns The action passed in
  76887. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76888. */
  76889. then(action: IAction): IAction;
  76890. }
  76891. /**
  76892. * The action to be carried out following a trigger
  76893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76894. */
  76895. export class Action implements IAction {
  76896. /** the trigger, with or without parameters, for the action */
  76897. triggerOptions: any;
  76898. /**
  76899. * Trigger for the action
  76900. */
  76901. trigger: number;
  76902. /**
  76903. * Internal only - manager for action
  76904. * @hidden
  76905. */
  76906. _actionManager: ActionManager;
  76907. private _nextActiveAction;
  76908. private _child;
  76909. private _condition?;
  76910. private _triggerParameter;
  76911. /**
  76912. * An event triggered prior to action being executed.
  76913. */
  76914. onBeforeExecuteObservable: Observable<Action>;
  76915. /**
  76916. * Creates a new Action
  76917. * @param triggerOptions the trigger, with or without parameters, for the action
  76918. * @param condition an optional determinant of action
  76919. */
  76920. constructor(
  76921. /** the trigger, with or without parameters, for the action */
  76922. triggerOptions: any, condition?: Condition);
  76923. /**
  76924. * Internal only
  76925. * @hidden
  76926. */
  76927. _prepare(): void;
  76928. /**
  76929. * Gets the trigger parameters
  76930. * @returns the trigger parameters
  76931. */
  76932. getTriggerParameter(): any;
  76933. /**
  76934. * Internal only - executes current action event
  76935. * @hidden
  76936. */
  76937. _executeCurrent(evt?: ActionEvent): void;
  76938. /**
  76939. * Execute placeholder for child classes
  76940. * @param evt optional action event
  76941. */
  76942. execute(evt?: ActionEvent): void;
  76943. /**
  76944. * Skips to next active action
  76945. */
  76946. skipToNextActiveAction(): void;
  76947. /**
  76948. * Adds action to chain of actions, may be a DoNothingAction
  76949. * @param action defines the next action to execute
  76950. * @returns The action passed in
  76951. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76952. */
  76953. then(action: Action): Action;
  76954. /**
  76955. * Internal only
  76956. * @hidden
  76957. */
  76958. _getProperty(propertyPath: string): string;
  76959. /**
  76960. * Internal only
  76961. * @hidden
  76962. */
  76963. _getEffectiveTarget(target: any, propertyPath: string): any;
  76964. /**
  76965. * Serialize placeholder for child classes
  76966. * @param parent of child
  76967. * @returns the serialized object
  76968. */
  76969. serialize(parent: any): any;
  76970. /**
  76971. * Internal only called by serialize
  76972. * @hidden
  76973. */
  76974. protected _serialize(serializedAction: any, parent?: any): any;
  76975. /**
  76976. * Internal only
  76977. * @hidden
  76978. */
  76979. static _SerializeValueAsString: (value: any) => string;
  76980. /**
  76981. * Internal only
  76982. * @hidden
  76983. */
  76984. static _GetTargetProperty: (target: Node | Scene) => {
  76985. name: string;
  76986. targetType: string;
  76987. value: string;
  76988. };
  76989. }
  76990. }
  76991. declare module BABYLON {
  76992. /**
  76993. * A Condition applied to an Action
  76994. */
  76995. export class Condition {
  76996. /**
  76997. * Internal only - manager for action
  76998. * @hidden
  76999. */
  77000. _actionManager: ActionManager;
  77001. /**
  77002. * Internal only
  77003. * @hidden
  77004. */
  77005. _evaluationId: number;
  77006. /**
  77007. * Internal only
  77008. * @hidden
  77009. */
  77010. _currentResult: boolean;
  77011. /**
  77012. * Creates a new Condition
  77013. * @param actionManager the manager of the action the condition is applied to
  77014. */
  77015. constructor(actionManager: ActionManager);
  77016. /**
  77017. * Check if the current condition is valid
  77018. * @returns a boolean
  77019. */
  77020. isValid(): boolean;
  77021. /**
  77022. * Internal only
  77023. * @hidden
  77024. */
  77025. _getProperty(propertyPath: string): string;
  77026. /**
  77027. * Internal only
  77028. * @hidden
  77029. */
  77030. _getEffectiveTarget(target: any, propertyPath: string): any;
  77031. /**
  77032. * Serialize placeholder for child classes
  77033. * @returns the serialized object
  77034. */
  77035. serialize(): any;
  77036. /**
  77037. * Internal only
  77038. * @hidden
  77039. */
  77040. protected _serialize(serializedCondition: any): any;
  77041. }
  77042. /**
  77043. * Defines specific conditional operators as extensions of Condition
  77044. */
  77045. export class ValueCondition extends Condition {
  77046. /** path to specify the property of the target the conditional operator uses */
  77047. propertyPath: string;
  77048. /** the value compared by the conditional operator against the current value of the property */
  77049. value: any;
  77050. /** the conditional operator, default ValueCondition.IsEqual */
  77051. operator: number;
  77052. /**
  77053. * Internal only
  77054. * @hidden
  77055. */
  77056. private static _IsEqual;
  77057. /**
  77058. * Internal only
  77059. * @hidden
  77060. */
  77061. private static _IsDifferent;
  77062. /**
  77063. * Internal only
  77064. * @hidden
  77065. */
  77066. private static _IsGreater;
  77067. /**
  77068. * Internal only
  77069. * @hidden
  77070. */
  77071. private static _IsLesser;
  77072. /**
  77073. * returns the number for IsEqual
  77074. */
  77075. static readonly IsEqual: number;
  77076. /**
  77077. * Returns the number for IsDifferent
  77078. */
  77079. static readonly IsDifferent: number;
  77080. /**
  77081. * Returns the number for IsGreater
  77082. */
  77083. static readonly IsGreater: number;
  77084. /**
  77085. * Returns the number for IsLesser
  77086. */
  77087. static readonly IsLesser: number;
  77088. /**
  77089. * Internal only The action manager for the condition
  77090. * @hidden
  77091. */
  77092. _actionManager: ActionManager;
  77093. /**
  77094. * Internal only
  77095. * @hidden
  77096. */
  77097. private _target;
  77098. /**
  77099. * Internal only
  77100. * @hidden
  77101. */
  77102. private _effectiveTarget;
  77103. /**
  77104. * Internal only
  77105. * @hidden
  77106. */
  77107. private _property;
  77108. /**
  77109. * Creates a new ValueCondition
  77110. * @param actionManager manager for the action the condition applies to
  77111. * @param target for the action
  77112. * @param propertyPath path to specify the property of the target the conditional operator uses
  77113. * @param value the value compared by the conditional operator against the current value of the property
  77114. * @param operator the conditional operator, default ValueCondition.IsEqual
  77115. */
  77116. constructor(actionManager: ActionManager, target: any,
  77117. /** path to specify the property of the target the conditional operator uses */
  77118. propertyPath: string,
  77119. /** the value compared by the conditional operator against the current value of the property */
  77120. value: any,
  77121. /** the conditional operator, default ValueCondition.IsEqual */
  77122. operator?: number);
  77123. /**
  77124. * Compares the given value with the property value for the specified conditional operator
  77125. * @returns the result of the comparison
  77126. */
  77127. isValid(): boolean;
  77128. /**
  77129. * Serialize the ValueCondition into a JSON compatible object
  77130. * @returns serialization object
  77131. */
  77132. serialize(): any;
  77133. /**
  77134. * Gets the name of the conditional operator for the ValueCondition
  77135. * @param operator the conditional operator
  77136. * @returns the name
  77137. */
  77138. static GetOperatorName(operator: number): string;
  77139. }
  77140. /**
  77141. * Defines a predicate condition as an extension of Condition
  77142. */
  77143. export class PredicateCondition extends Condition {
  77144. /** defines the predicate function used to validate the condition */
  77145. predicate: () => boolean;
  77146. /**
  77147. * Internal only - manager for action
  77148. * @hidden
  77149. */
  77150. _actionManager: ActionManager;
  77151. /**
  77152. * Creates a new PredicateCondition
  77153. * @param actionManager manager for the action the condition applies to
  77154. * @param predicate defines the predicate function used to validate the condition
  77155. */
  77156. constructor(actionManager: ActionManager,
  77157. /** defines the predicate function used to validate the condition */
  77158. predicate: () => boolean);
  77159. /**
  77160. * @returns the validity of the predicate condition
  77161. */
  77162. isValid(): boolean;
  77163. }
  77164. /**
  77165. * Defines a state condition as an extension of Condition
  77166. */
  77167. export class StateCondition extends Condition {
  77168. /** Value to compare with target state */
  77169. value: string;
  77170. /**
  77171. * Internal only - manager for action
  77172. * @hidden
  77173. */
  77174. _actionManager: ActionManager;
  77175. /**
  77176. * Internal only
  77177. * @hidden
  77178. */
  77179. private _target;
  77180. /**
  77181. * Creates a new StateCondition
  77182. * @param actionManager manager for the action the condition applies to
  77183. * @param target of the condition
  77184. * @param value to compare with target state
  77185. */
  77186. constructor(actionManager: ActionManager, target: any,
  77187. /** Value to compare with target state */
  77188. value: string);
  77189. /**
  77190. * Gets a boolean indicating if the current condition is met
  77191. * @returns the validity of the state
  77192. */
  77193. isValid(): boolean;
  77194. /**
  77195. * Serialize the StateCondition into a JSON compatible object
  77196. * @returns serialization object
  77197. */
  77198. serialize(): any;
  77199. }
  77200. }
  77201. declare module BABYLON {
  77202. /**
  77203. * This defines an action responsible to toggle a boolean once triggered.
  77204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77205. */
  77206. export class SwitchBooleanAction extends Action {
  77207. /**
  77208. * The path to the boolean property in the target object
  77209. */
  77210. propertyPath: string;
  77211. private _target;
  77212. private _effectiveTarget;
  77213. private _property;
  77214. /**
  77215. * Instantiate the action
  77216. * @param triggerOptions defines the trigger options
  77217. * @param target defines the object containing the boolean
  77218. * @param propertyPath defines the path to the boolean property in the target object
  77219. * @param condition defines the trigger related conditions
  77220. */
  77221. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77222. /** @hidden */
  77223. _prepare(): void;
  77224. /**
  77225. * Execute the action toggle the boolean value.
  77226. */
  77227. execute(): void;
  77228. /**
  77229. * Serializes the actions and its related information.
  77230. * @param parent defines the object to serialize in
  77231. * @returns the serialized object
  77232. */
  77233. serialize(parent: any): any;
  77234. }
  77235. /**
  77236. * This defines an action responsible to set a the state field of the target
  77237. * to a desired value once triggered.
  77238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77239. */
  77240. export class SetStateAction extends Action {
  77241. /**
  77242. * The value to store in the state field.
  77243. */
  77244. value: string;
  77245. private _target;
  77246. /**
  77247. * Instantiate the action
  77248. * @param triggerOptions defines the trigger options
  77249. * @param target defines the object containing the state property
  77250. * @param value defines the value to store in the state field
  77251. * @param condition defines the trigger related conditions
  77252. */
  77253. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77254. /**
  77255. * Execute the action and store the value on the target state property.
  77256. */
  77257. execute(): void;
  77258. /**
  77259. * Serializes the actions and its related information.
  77260. * @param parent defines the object to serialize in
  77261. * @returns the serialized object
  77262. */
  77263. serialize(parent: any): any;
  77264. }
  77265. /**
  77266. * This defines an action responsible to set a property of the target
  77267. * to a desired value once triggered.
  77268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77269. */
  77270. export class SetValueAction extends Action {
  77271. /**
  77272. * The path of the property to set in the target.
  77273. */
  77274. propertyPath: string;
  77275. /**
  77276. * The value to set in the property
  77277. */
  77278. value: any;
  77279. private _target;
  77280. private _effectiveTarget;
  77281. private _property;
  77282. /**
  77283. * Instantiate the action
  77284. * @param triggerOptions defines the trigger options
  77285. * @param target defines the object containing the property
  77286. * @param propertyPath defines the path of the property to set in the target
  77287. * @param value defines the value to set in the property
  77288. * @param condition defines the trigger related conditions
  77289. */
  77290. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77291. /** @hidden */
  77292. _prepare(): void;
  77293. /**
  77294. * Execute the action and set the targetted property to the desired value.
  77295. */
  77296. execute(): void;
  77297. /**
  77298. * Serializes the actions and its related information.
  77299. * @param parent defines the object to serialize in
  77300. * @returns the serialized object
  77301. */
  77302. serialize(parent: any): any;
  77303. }
  77304. /**
  77305. * This defines an action responsible to increment the target value
  77306. * to a desired value once triggered.
  77307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77308. */
  77309. export class IncrementValueAction extends Action {
  77310. /**
  77311. * The path of the property to increment in the target.
  77312. */
  77313. propertyPath: string;
  77314. /**
  77315. * The value we should increment the property by.
  77316. */
  77317. value: any;
  77318. private _target;
  77319. private _effectiveTarget;
  77320. private _property;
  77321. /**
  77322. * Instantiate the action
  77323. * @param triggerOptions defines the trigger options
  77324. * @param target defines the object containing the property
  77325. * @param propertyPath defines the path of the property to increment in the target
  77326. * @param value defines the value value we should increment the property by
  77327. * @param condition defines the trigger related conditions
  77328. */
  77329. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77330. /** @hidden */
  77331. _prepare(): void;
  77332. /**
  77333. * Execute the action and increment the target of the value amount.
  77334. */
  77335. execute(): void;
  77336. /**
  77337. * Serializes the actions and its related information.
  77338. * @param parent defines the object to serialize in
  77339. * @returns the serialized object
  77340. */
  77341. serialize(parent: any): any;
  77342. }
  77343. /**
  77344. * This defines an action responsible to start an animation once triggered.
  77345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77346. */
  77347. export class PlayAnimationAction extends Action {
  77348. /**
  77349. * Where the animation should start (animation frame)
  77350. */
  77351. from: number;
  77352. /**
  77353. * Where the animation should stop (animation frame)
  77354. */
  77355. to: number;
  77356. /**
  77357. * Define if the animation should loop or stop after the first play.
  77358. */
  77359. loop?: boolean;
  77360. private _target;
  77361. /**
  77362. * Instantiate the action
  77363. * @param triggerOptions defines the trigger options
  77364. * @param target defines the target animation or animation name
  77365. * @param from defines from where the animation should start (animation frame)
  77366. * @param end defines where the animation should stop (animation frame)
  77367. * @param loop defines if the animation should loop or stop after the first play
  77368. * @param condition defines the trigger related conditions
  77369. */
  77370. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77371. /** @hidden */
  77372. _prepare(): void;
  77373. /**
  77374. * Execute the action and play the animation.
  77375. */
  77376. execute(): void;
  77377. /**
  77378. * Serializes the actions and its related information.
  77379. * @param parent defines the object to serialize in
  77380. * @returns the serialized object
  77381. */
  77382. serialize(parent: any): any;
  77383. }
  77384. /**
  77385. * This defines an action responsible to stop an animation once triggered.
  77386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77387. */
  77388. export class StopAnimationAction extends Action {
  77389. private _target;
  77390. /**
  77391. * Instantiate the action
  77392. * @param triggerOptions defines the trigger options
  77393. * @param target defines the target animation or animation name
  77394. * @param condition defines the trigger related conditions
  77395. */
  77396. constructor(triggerOptions: any, target: any, condition?: Condition);
  77397. /** @hidden */
  77398. _prepare(): void;
  77399. /**
  77400. * Execute the action and stop the animation.
  77401. */
  77402. execute(): void;
  77403. /**
  77404. * Serializes the actions and its related information.
  77405. * @param parent defines the object to serialize in
  77406. * @returns the serialized object
  77407. */
  77408. serialize(parent: any): any;
  77409. }
  77410. /**
  77411. * This defines an action responsible that does nothing once triggered.
  77412. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77413. */
  77414. export class DoNothingAction extends Action {
  77415. /**
  77416. * Instantiate the action
  77417. * @param triggerOptions defines the trigger options
  77418. * @param condition defines the trigger related conditions
  77419. */
  77420. constructor(triggerOptions?: any, condition?: Condition);
  77421. /**
  77422. * Execute the action and do nothing.
  77423. */
  77424. execute(): void;
  77425. /**
  77426. * Serializes the actions and its related information.
  77427. * @param parent defines the object to serialize in
  77428. * @returns the serialized object
  77429. */
  77430. serialize(parent: any): any;
  77431. }
  77432. /**
  77433. * This defines an action responsible to trigger several actions once triggered.
  77434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77435. */
  77436. export class CombineAction extends Action {
  77437. /**
  77438. * The list of aggregated animations to run.
  77439. */
  77440. children: Action[];
  77441. /**
  77442. * Instantiate the action
  77443. * @param triggerOptions defines the trigger options
  77444. * @param children defines the list of aggregated animations to run
  77445. * @param condition defines the trigger related conditions
  77446. */
  77447. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77448. /** @hidden */
  77449. _prepare(): void;
  77450. /**
  77451. * Execute the action and executes all the aggregated actions.
  77452. */
  77453. execute(evt: ActionEvent): void;
  77454. /**
  77455. * Serializes the actions and its related information.
  77456. * @param parent defines the object to serialize in
  77457. * @returns the serialized object
  77458. */
  77459. serialize(parent: any): any;
  77460. }
  77461. /**
  77462. * This defines an action responsible to run code (external event) once triggered.
  77463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77464. */
  77465. export class ExecuteCodeAction extends Action {
  77466. /**
  77467. * The callback function to run.
  77468. */
  77469. func: (evt: ActionEvent) => void;
  77470. /**
  77471. * Instantiate the action
  77472. * @param triggerOptions defines the trigger options
  77473. * @param func defines the callback function to run
  77474. * @param condition defines the trigger related conditions
  77475. */
  77476. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77477. /**
  77478. * Execute the action and run the attached code.
  77479. */
  77480. execute(evt: ActionEvent): void;
  77481. }
  77482. /**
  77483. * This defines an action responsible to set the parent property of the target once triggered.
  77484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77485. */
  77486. export class SetParentAction extends Action {
  77487. private _parent;
  77488. private _target;
  77489. /**
  77490. * Instantiate the action
  77491. * @param triggerOptions defines the trigger options
  77492. * @param target defines the target containing the parent property
  77493. * @param parent defines from where the animation should start (animation frame)
  77494. * @param condition defines the trigger related conditions
  77495. */
  77496. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77497. /** @hidden */
  77498. _prepare(): void;
  77499. /**
  77500. * Execute the action and set the parent property.
  77501. */
  77502. execute(): void;
  77503. /**
  77504. * Serializes the actions and its related information.
  77505. * @param parent defines the object to serialize in
  77506. * @returns the serialized object
  77507. */
  77508. serialize(parent: any): any;
  77509. }
  77510. }
  77511. declare module BABYLON {
  77512. /**
  77513. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77514. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77516. */
  77517. export class ActionManager extends AbstractActionManager {
  77518. /**
  77519. * Nothing
  77520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77521. */
  77522. static readonly NothingTrigger: number;
  77523. /**
  77524. * On pick
  77525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77526. */
  77527. static readonly OnPickTrigger: number;
  77528. /**
  77529. * On left pick
  77530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77531. */
  77532. static readonly OnLeftPickTrigger: number;
  77533. /**
  77534. * On right pick
  77535. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77536. */
  77537. static readonly OnRightPickTrigger: number;
  77538. /**
  77539. * On center pick
  77540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77541. */
  77542. static readonly OnCenterPickTrigger: number;
  77543. /**
  77544. * On pick down
  77545. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77546. */
  77547. static readonly OnPickDownTrigger: number;
  77548. /**
  77549. * On double pick
  77550. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77551. */
  77552. static readonly OnDoublePickTrigger: number;
  77553. /**
  77554. * On pick up
  77555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77556. */
  77557. static readonly OnPickUpTrigger: number;
  77558. /**
  77559. * On pick out.
  77560. * This trigger will only be raised if you also declared a OnPickDown
  77561. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77562. */
  77563. static readonly OnPickOutTrigger: number;
  77564. /**
  77565. * On long press
  77566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77567. */
  77568. static readonly OnLongPressTrigger: number;
  77569. /**
  77570. * On pointer over
  77571. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77572. */
  77573. static readonly OnPointerOverTrigger: number;
  77574. /**
  77575. * On pointer out
  77576. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77577. */
  77578. static readonly OnPointerOutTrigger: number;
  77579. /**
  77580. * On every frame
  77581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77582. */
  77583. static readonly OnEveryFrameTrigger: number;
  77584. /**
  77585. * On intersection enter
  77586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77587. */
  77588. static readonly OnIntersectionEnterTrigger: number;
  77589. /**
  77590. * On intersection exit
  77591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77592. */
  77593. static readonly OnIntersectionExitTrigger: number;
  77594. /**
  77595. * On key down
  77596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77597. */
  77598. static readonly OnKeyDownTrigger: number;
  77599. /**
  77600. * On key up
  77601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77602. */
  77603. static readonly OnKeyUpTrigger: number;
  77604. private _scene;
  77605. /**
  77606. * Creates a new action manager
  77607. * @param scene defines the hosting scene
  77608. */
  77609. constructor(scene: Scene);
  77610. /**
  77611. * Releases all associated resources
  77612. */
  77613. dispose(): void;
  77614. /**
  77615. * Gets hosting scene
  77616. * @returns the hosting scene
  77617. */
  77618. getScene(): Scene;
  77619. /**
  77620. * Does this action manager handles actions of any of the given triggers
  77621. * @param triggers defines the triggers to be tested
  77622. * @return a boolean indicating whether one (or more) of the triggers is handled
  77623. */
  77624. hasSpecificTriggers(triggers: number[]): boolean;
  77625. /**
  77626. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77627. * speed.
  77628. * @param triggerA defines the trigger to be tested
  77629. * @param triggerB defines the trigger to be tested
  77630. * @return a boolean indicating whether one (or more) of the triggers is handled
  77631. */
  77632. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77633. /**
  77634. * Does this action manager handles actions of a given trigger
  77635. * @param trigger defines the trigger to be tested
  77636. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77637. * @return whether the trigger is handled
  77638. */
  77639. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77640. /**
  77641. * Does this action manager has pointer triggers
  77642. */
  77643. readonly hasPointerTriggers: boolean;
  77644. /**
  77645. * Does this action manager has pick triggers
  77646. */
  77647. readonly hasPickTriggers: boolean;
  77648. /**
  77649. * Registers an action to this action manager
  77650. * @param action defines the action to be registered
  77651. * @return the action amended (prepared) after registration
  77652. */
  77653. registerAction(action: IAction): Nullable<IAction>;
  77654. /**
  77655. * Unregisters an action to this action manager
  77656. * @param action defines the action to be unregistered
  77657. * @return a boolean indicating whether the action has been unregistered
  77658. */
  77659. unregisterAction(action: IAction): Boolean;
  77660. /**
  77661. * Process a specific trigger
  77662. * @param trigger defines the trigger to process
  77663. * @param evt defines the event details to be processed
  77664. */
  77665. processTrigger(trigger: number, evt?: IActionEvent): void;
  77666. /** @hidden */
  77667. _getEffectiveTarget(target: any, propertyPath: string): any;
  77668. /** @hidden */
  77669. _getProperty(propertyPath: string): string;
  77670. /**
  77671. * Serialize this manager to a JSON object
  77672. * @param name defines the property name to store this manager
  77673. * @returns a JSON representation of this manager
  77674. */
  77675. serialize(name: string): any;
  77676. /**
  77677. * Creates a new ActionManager from a JSON data
  77678. * @param parsedActions defines the JSON data to read from
  77679. * @param object defines the hosting mesh
  77680. * @param scene defines the hosting scene
  77681. */
  77682. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77683. /**
  77684. * Get a trigger name by index
  77685. * @param trigger defines the trigger index
  77686. * @returns a trigger name
  77687. */
  77688. static GetTriggerName(trigger: number): string;
  77689. }
  77690. }
  77691. declare module BABYLON {
  77692. /**
  77693. * Class representing a ray with position and direction
  77694. */
  77695. export class Ray {
  77696. /** origin point */
  77697. origin: Vector3;
  77698. /** direction */
  77699. direction: Vector3;
  77700. /** length of the ray */
  77701. length: number;
  77702. private static readonly TmpVector3;
  77703. private _tmpRay;
  77704. /**
  77705. * Creates a new ray
  77706. * @param origin origin point
  77707. * @param direction direction
  77708. * @param length length of the ray
  77709. */
  77710. constructor(
  77711. /** origin point */
  77712. origin: Vector3,
  77713. /** direction */
  77714. direction: Vector3,
  77715. /** length of the ray */
  77716. length?: number);
  77717. /**
  77718. * Checks if the ray intersects a box
  77719. * @param minimum bound of the box
  77720. * @param maximum bound of the box
  77721. * @param intersectionTreshold extra extend to be added to the box in all direction
  77722. * @returns if the box was hit
  77723. */
  77724. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77725. /**
  77726. * Checks if the ray intersects a box
  77727. * @param box the bounding box to check
  77728. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77729. * @returns if the box was hit
  77730. */
  77731. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77732. /**
  77733. * If the ray hits a sphere
  77734. * @param sphere the bounding sphere to check
  77735. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77736. * @returns true if it hits the sphere
  77737. */
  77738. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77739. /**
  77740. * If the ray hits a triange
  77741. * @param vertex0 triangle vertex
  77742. * @param vertex1 triangle vertex
  77743. * @param vertex2 triangle vertex
  77744. * @returns intersection information if hit
  77745. */
  77746. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77747. /**
  77748. * Checks if ray intersects a plane
  77749. * @param plane the plane to check
  77750. * @returns the distance away it was hit
  77751. */
  77752. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77753. /**
  77754. * Calculate the intercept of a ray on a given axis
  77755. * @param axis to check 'x' | 'y' | 'z'
  77756. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77757. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77758. */
  77759. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77760. /**
  77761. * Checks if ray intersects a mesh
  77762. * @param mesh the mesh to check
  77763. * @param fastCheck if only the bounding box should checked
  77764. * @returns picking info of the intersecton
  77765. */
  77766. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77767. /**
  77768. * Checks if ray intersects a mesh
  77769. * @param meshes the meshes to check
  77770. * @param fastCheck if only the bounding box should checked
  77771. * @param results array to store result in
  77772. * @returns Array of picking infos
  77773. */
  77774. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77775. private _comparePickingInfo;
  77776. private static smallnum;
  77777. private static rayl;
  77778. /**
  77779. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77780. * @param sega the first point of the segment to test the intersection against
  77781. * @param segb the second point of the segment to test the intersection against
  77782. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77783. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77784. */
  77785. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77786. /**
  77787. * Update the ray from viewport position
  77788. * @param x position
  77789. * @param y y position
  77790. * @param viewportWidth viewport width
  77791. * @param viewportHeight viewport height
  77792. * @param world world matrix
  77793. * @param view view matrix
  77794. * @param projection projection matrix
  77795. * @returns this ray updated
  77796. */
  77797. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77798. /**
  77799. * Creates a ray with origin and direction of 0,0,0
  77800. * @returns the new ray
  77801. */
  77802. static Zero(): Ray;
  77803. /**
  77804. * Creates a new ray from screen space and viewport
  77805. * @param x position
  77806. * @param y y position
  77807. * @param viewportWidth viewport width
  77808. * @param viewportHeight viewport height
  77809. * @param world world matrix
  77810. * @param view view matrix
  77811. * @param projection projection matrix
  77812. * @returns new ray
  77813. */
  77814. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77815. /**
  77816. * 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
  77817. * transformed to the given world matrix.
  77818. * @param origin The origin point
  77819. * @param end The end point
  77820. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77821. * @returns the new ray
  77822. */
  77823. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77824. /**
  77825. * Transforms a ray by a matrix
  77826. * @param ray ray to transform
  77827. * @param matrix matrix to apply
  77828. * @returns the resulting new ray
  77829. */
  77830. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77831. /**
  77832. * Transforms a ray by a matrix
  77833. * @param ray ray to transform
  77834. * @param matrix matrix to apply
  77835. * @param result ray to store result in
  77836. */
  77837. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77838. /**
  77839. * Unproject a ray from screen space to object space
  77840. * @param sourceX defines the screen space x coordinate to use
  77841. * @param sourceY defines the screen space y coordinate to use
  77842. * @param viewportWidth defines the current width of the viewport
  77843. * @param viewportHeight defines the current height of the viewport
  77844. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77845. * @param view defines the view matrix to use
  77846. * @param projection defines the projection matrix to use
  77847. */
  77848. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77849. }
  77850. /**
  77851. * Type used to define predicate used to select faces when a mesh intersection is detected
  77852. */
  77853. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77854. interface Scene {
  77855. /** @hidden */
  77856. _tempPickingRay: Nullable<Ray>;
  77857. /** @hidden */
  77858. _cachedRayForTransform: Ray;
  77859. /** @hidden */
  77860. _pickWithRayInverseMatrix: Matrix;
  77861. /** @hidden */
  77862. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77863. /** @hidden */
  77864. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77865. }
  77866. }
  77867. declare module BABYLON {
  77868. /**
  77869. * Groups all the scene component constants in one place to ease maintenance.
  77870. * @hidden
  77871. */
  77872. export class SceneComponentConstants {
  77873. static readonly NAME_EFFECTLAYER: string;
  77874. static readonly NAME_LAYER: string;
  77875. static readonly NAME_LENSFLARESYSTEM: string;
  77876. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77877. static readonly NAME_PARTICLESYSTEM: string;
  77878. static readonly NAME_GAMEPAD: string;
  77879. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77880. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77881. static readonly NAME_DEPTHRENDERER: string;
  77882. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77883. static readonly NAME_SPRITE: string;
  77884. static readonly NAME_OUTLINERENDERER: string;
  77885. static readonly NAME_PROCEDURALTEXTURE: string;
  77886. static readonly NAME_SHADOWGENERATOR: string;
  77887. static readonly NAME_OCTREE: string;
  77888. static readonly NAME_PHYSICSENGINE: string;
  77889. static readonly NAME_AUDIO: string;
  77890. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77891. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77892. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77893. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77894. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77895. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77896. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77897. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77898. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77899. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77900. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77901. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77902. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77903. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77904. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77905. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77906. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77907. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77908. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77909. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77910. static readonly STEP_AFTERRENDER_AUDIO: number;
  77911. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77912. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77913. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77914. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77915. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77916. static readonly STEP_POINTERMOVE_SPRITE: number;
  77917. static readonly STEP_POINTERDOWN_SPRITE: number;
  77918. static readonly STEP_POINTERUP_SPRITE: number;
  77919. }
  77920. /**
  77921. * This represents a scene component.
  77922. *
  77923. * This is used to decouple the dependency the scene is having on the different workloads like
  77924. * layers, post processes...
  77925. */
  77926. export interface ISceneComponent {
  77927. /**
  77928. * The name of the component. Each component must have a unique name.
  77929. */
  77930. name: string;
  77931. /**
  77932. * The scene the component belongs to.
  77933. */
  77934. scene: Scene;
  77935. /**
  77936. * Register the component to one instance of a scene.
  77937. */
  77938. register(): void;
  77939. /**
  77940. * Rebuilds the elements related to this component in case of
  77941. * context lost for instance.
  77942. */
  77943. rebuild(): void;
  77944. /**
  77945. * Disposes the component and the associated ressources.
  77946. */
  77947. dispose(): void;
  77948. }
  77949. /**
  77950. * This represents a SERIALIZABLE scene component.
  77951. *
  77952. * This extends Scene Component to add Serialization methods on top.
  77953. */
  77954. export interface ISceneSerializableComponent extends ISceneComponent {
  77955. /**
  77956. * Adds all the elements from the container to the scene
  77957. * @param container the container holding the elements
  77958. */
  77959. addFromContainer(container: AbstractScene): void;
  77960. /**
  77961. * Removes all the elements in the container from the scene
  77962. * @param container contains the elements to remove
  77963. * @param dispose if the removed element should be disposed (default: false)
  77964. */
  77965. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77966. /**
  77967. * Serializes the component data to the specified json object
  77968. * @param serializationObject The object to serialize to
  77969. */
  77970. serialize(serializationObject: any): void;
  77971. }
  77972. /**
  77973. * Strong typing of a Mesh related stage step action
  77974. */
  77975. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77976. /**
  77977. * Strong typing of a Evaluate Sub Mesh related stage step action
  77978. */
  77979. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77980. /**
  77981. * Strong typing of a Active Mesh related stage step action
  77982. */
  77983. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77984. /**
  77985. * Strong typing of a Camera related stage step action
  77986. */
  77987. export type CameraStageAction = (camera: Camera) => void;
  77988. /**
  77989. * Strong typing of a Camera Frame buffer related stage step action
  77990. */
  77991. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77992. /**
  77993. * Strong typing of a Render Target related stage step action
  77994. */
  77995. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77996. /**
  77997. * Strong typing of a RenderingGroup related stage step action
  77998. */
  77999. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78000. /**
  78001. * Strong typing of a Mesh Render related stage step action
  78002. */
  78003. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78004. /**
  78005. * Strong typing of a simple stage step action
  78006. */
  78007. export type SimpleStageAction = () => void;
  78008. /**
  78009. * Strong typing of a render target action.
  78010. */
  78011. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78012. /**
  78013. * Strong typing of a pointer move action.
  78014. */
  78015. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78016. /**
  78017. * Strong typing of a pointer up/down action.
  78018. */
  78019. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78020. /**
  78021. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78022. * @hidden
  78023. */
  78024. export class Stage<T extends Function> extends Array<{
  78025. index: number;
  78026. component: ISceneComponent;
  78027. action: T;
  78028. }> {
  78029. /**
  78030. * Hide ctor from the rest of the world.
  78031. * @param items The items to add.
  78032. */
  78033. private constructor();
  78034. /**
  78035. * Creates a new Stage.
  78036. * @returns A new instance of a Stage
  78037. */
  78038. static Create<T extends Function>(): Stage<T>;
  78039. /**
  78040. * Registers a step in an ordered way in the targeted stage.
  78041. * @param index Defines the position to register the step in
  78042. * @param component Defines the component attached to the step
  78043. * @param action Defines the action to launch during the step
  78044. */
  78045. registerStep(index: number, component: ISceneComponent, action: T): void;
  78046. /**
  78047. * Clears all the steps from the stage.
  78048. */
  78049. clear(): void;
  78050. }
  78051. }
  78052. declare module BABYLON {
  78053. interface Scene {
  78054. /** @hidden */
  78055. _pointerOverSprite: Nullable<Sprite>;
  78056. /** @hidden */
  78057. _pickedDownSprite: Nullable<Sprite>;
  78058. /** @hidden */
  78059. _tempSpritePickingRay: Nullable<Ray>;
  78060. /**
  78061. * All of the sprite managers added to this scene
  78062. * @see http://doc.babylonjs.com/babylon101/sprites
  78063. */
  78064. spriteManagers: Array<ISpriteManager>;
  78065. /**
  78066. * An event triggered when sprites rendering is about to start
  78067. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78068. */
  78069. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78070. /**
  78071. * An event triggered when sprites rendering is done
  78072. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78073. */
  78074. onAfterSpritesRenderingObservable: Observable<Scene>;
  78075. /** @hidden */
  78076. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78077. /** Launch a ray to try to pick a sprite in the scene
  78078. * @param x position on screen
  78079. * @param y position on screen
  78080. * @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
  78081. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78082. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78083. * @returns a PickingInfo
  78084. */
  78085. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78086. /** Use the given ray to pick a sprite in the scene
  78087. * @param ray The ray (in world space) to use to pick meshes
  78088. * @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
  78089. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78090. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78091. * @returns a PickingInfo
  78092. */
  78093. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78094. /** @hidden */
  78095. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78096. /** Launch a ray to try to pick sprites in the scene
  78097. * @param x position on screen
  78098. * @param y position on screen
  78099. * @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
  78100. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78101. * @returns a PickingInfo array
  78102. */
  78103. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78104. /** Use the given ray to pick sprites in the scene
  78105. * @param ray The ray (in world space) to use to pick meshes
  78106. * @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
  78107. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78108. * @returns a PickingInfo array
  78109. */
  78110. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78111. /**
  78112. * Force the sprite under the pointer
  78113. * @param sprite defines the sprite to use
  78114. */
  78115. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78116. /**
  78117. * Gets the sprite under the pointer
  78118. * @returns a Sprite or null if no sprite is under the pointer
  78119. */
  78120. getPointerOverSprite(): Nullable<Sprite>;
  78121. }
  78122. /**
  78123. * Defines the sprite scene component responsible to manage sprites
  78124. * in a given scene.
  78125. */
  78126. export class SpriteSceneComponent implements ISceneComponent {
  78127. /**
  78128. * The component name helpfull to identify the component in the list of scene components.
  78129. */
  78130. readonly name: string;
  78131. /**
  78132. * The scene the component belongs to.
  78133. */
  78134. scene: Scene;
  78135. /** @hidden */
  78136. private _spritePredicate;
  78137. /**
  78138. * Creates a new instance of the component for the given scene
  78139. * @param scene Defines the scene to register the component in
  78140. */
  78141. constructor(scene: Scene);
  78142. /**
  78143. * Registers the component in a given scene
  78144. */
  78145. register(): void;
  78146. /**
  78147. * Rebuilds the elements related to this component in case of
  78148. * context lost for instance.
  78149. */
  78150. rebuild(): void;
  78151. /**
  78152. * Disposes the component and the associated ressources.
  78153. */
  78154. dispose(): void;
  78155. private _pickSpriteButKeepRay;
  78156. private _pointerMove;
  78157. private _pointerDown;
  78158. private _pointerUp;
  78159. }
  78160. }
  78161. declare module BABYLON {
  78162. /** @hidden */
  78163. export var fogFragmentDeclaration: {
  78164. name: string;
  78165. shader: string;
  78166. };
  78167. }
  78168. declare module BABYLON {
  78169. /** @hidden */
  78170. export var fogFragment: {
  78171. name: string;
  78172. shader: string;
  78173. };
  78174. }
  78175. declare module BABYLON {
  78176. /** @hidden */
  78177. export var spritesPixelShader: {
  78178. name: string;
  78179. shader: string;
  78180. };
  78181. }
  78182. declare module BABYLON {
  78183. /** @hidden */
  78184. export var fogVertexDeclaration: {
  78185. name: string;
  78186. shader: string;
  78187. };
  78188. }
  78189. declare module BABYLON {
  78190. /** @hidden */
  78191. export var spritesVertexShader: {
  78192. name: string;
  78193. shader: string;
  78194. };
  78195. }
  78196. declare module BABYLON {
  78197. /**
  78198. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78199. */
  78200. export interface ISpriteManager extends IDisposable {
  78201. /**
  78202. * Restricts the camera to viewing objects with the same layerMask.
  78203. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78204. */
  78205. layerMask: number;
  78206. /**
  78207. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78208. */
  78209. isPickable: boolean;
  78210. /**
  78211. * Specifies the rendering group id for this mesh (0 by default)
  78212. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78213. */
  78214. renderingGroupId: number;
  78215. /**
  78216. * Defines the list of sprites managed by the manager.
  78217. */
  78218. sprites: Array<Sprite>;
  78219. /**
  78220. * Tests the intersection of a sprite with a specific ray.
  78221. * @param ray The ray we are sending to test the collision
  78222. * @param camera The camera space we are sending rays in
  78223. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78224. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78225. * @returns picking info or null.
  78226. */
  78227. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78228. /**
  78229. * Intersects the sprites with a ray
  78230. * @param ray defines the ray to intersect with
  78231. * @param camera defines the current active camera
  78232. * @param predicate defines a predicate used to select candidate sprites
  78233. * @returns null if no hit or a PickingInfo array
  78234. */
  78235. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78236. /**
  78237. * Renders the list of sprites on screen.
  78238. */
  78239. render(): void;
  78240. }
  78241. /**
  78242. * Class used to manage multiple sprites on the same spritesheet
  78243. * @see http://doc.babylonjs.com/babylon101/sprites
  78244. */
  78245. export class SpriteManager implements ISpriteManager {
  78246. /** defines the manager's name */
  78247. name: string;
  78248. /** Gets the list of sprites */
  78249. sprites: Sprite[];
  78250. /** Gets or sets the rendering group id (0 by default) */
  78251. renderingGroupId: number;
  78252. /** Gets or sets camera layer mask */
  78253. layerMask: number;
  78254. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78255. fogEnabled: boolean;
  78256. /** Gets or sets a boolean indicating if the sprites are pickable */
  78257. isPickable: boolean;
  78258. /** Defines the default width of a cell in the spritesheet */
  78259. cellWidth: number;
  78260. /** Defines the default height of a cell in the spritesheet */
  78261. cellHeight: number;
  78262. /** Associative array from JSON sprite data file */
  78263. private _cellData;
  78264. /** Array of sprite names from JSON sprite data file */
  78265. private _spriteMap;
  78266. /** True when packed cell data from JSON file is ready*/
  78267. private _packedAndReady;
  78268. /**
  78269. * An event triggered when the manager is disposed.
  78270. */
  78271. onDisposeObservable: Observable<SpriteManager>;
  78272. private _onDisposeObserver;
  78273. /**
  78274. * Callback called when the manager is disposed
  78275. */
  78276. onDispose: () => void;
  78277. private _capacity;
  78278. private _fromPacked;
  78279. private _spriteTexture;
  78280. private _epsilon;
  78281. private _scene;
  78282. private _vertexData;
  78283. private _buffer;
  78284. private _vertexBuffers;
  78285. private _indexBuffer;
  78286. private _effectBase;
  78287. private _effectFog;
  78288. /**
  78289. * Gets or sets the spritesheet texture
  78290. */
  78291. texture: Texture;
  78292. /**
  78293. * Creates a new sprite manager
  78294. * @param name defines the manager's name
  78295. * @param imgUrl defines the sprite sheet url
  78296. * @param capacity defines the maximum allowed number of sprites
  78297. * @param cellSize defines the size of a sprite cell
  78298. * @param scene defines the hosting scene
  78299. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78300. * @param samplingMode defines the smapling mode to use with spritesheet
  78301. * @param fromPacked set to false; do not alter
  78302. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78303. */
  78304. constructor(
  78305. /** defines the manager's name */
  78306. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78307. private _makePacked;
  78308. private _appendSpriteVertex;
  78309. /**
  78310. * Intersects the sprites with a ray
  78311. * @param ray defines the ray to intersect with
  78312. * @param camera defines the current active camera
  78313. * @param predicate defines a predicate used to select candidate sprites
  78314. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78315. * @returns null if no hit or a PickingInfo
  78316. */
  78317. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78318. /**
  78319. * Intersects the sprites with a ray
  78320. * @param ray defines the ray to intersect with
  78321. * @param camera defines the current active camera
  78322. * @param predicate defines a predicate used to select candidate sprites
  78323. * @returns null if no hit or a PickingInfo array
  78324. */
  78325. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78326. /**
  78327. * Render all child sprites
  78328. */
  78329. render(): void;
  78330. /**
  78331. * Release associated resources
  78332. */
  78333. dispose(): void;
  78334. }
  78335. }
  78336. declare module BABYLON {
  78337. /**
  78338. * Class used to represent a sprite
  78339. * @see http://doc.babylonjs.com/babylon101/sprites
  78340. */
  78341. export class Sprite {
  78342. /** defines the name */
  78343. name: string;
  78344. /** Gets or sets the current world position */
  78345. position: Vector3;
  78346. /** Gets or sets the main color */
  78347. color: Color4;
  78348. /** Gets or sets the width */
  78349. width: number;
  78350. /** Gets or sets the height */
  78351. height: number;
  78352. /** Gets or sets rotation angle */
  78353. angle: number;
  78354. /** Gets or sets the cell index in the sprite sheet */
  78355. cellIndex: number;
  78356. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78357. cellRef: string;
  78358. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78359. invertU: number;
  78360. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78361. invertV: number;
  78362. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78363. disposeWhenFinishedAnimating: boolean;
  78364. /** Gets the list of attached animations */
  78365. animations: Animation[];
  78366. /** Gets or sets a boolean indicating if the sprite can be picked */
  78367. isPickable: boolean;
  78368. /**
  78369. * Gets or sets the associated action manager
  78370. */
  78371. actionManager: Nullable<ActionManager>;
  78372. private _animationStarted;
  78373. private _loopAnimation;
  78374. private _fromIndex;
  78375. private _toIndex;
  78376. private _delay;
  78377. private _direction;
  78378. private _manager;
  78379. private _time;
  78380. private _onAnimationEnd;
  78381. /**
  78382. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78383. */
  78384. isVisible: boolean;
  78385. /**
  78386. * Gets or sets the sprite size
  78387. */
  78388. size: number;
  78389. /**
  78390. * Creates a new Sprite
  78391. * @param name defines the name
  78392. * @param manager defines the manager
  78393. */
  78394. constructor(
  78395. /** defines the name */
  78396. name: string, manager: ISpriteManager);
  78397. /**
  78398. * Starts an animation
  78399. * @param from defines the initial key
  78400. * @param to defines the end key
  78401. * @param loop defines if the animation must loop
  78402. * @param delay defines the start delay (in ms)
  78403. * @param onAnimationEnd defines a callback to call when animation ends
  78404. */
  78405. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78406. /** Stops current animation (if any) */
  78407. stopAnimation(): void;
  78408. /** @hidden */
  78409. _animate(deltaTime: number): void;
  78410. /** Release associated resources */
  78411. dispose(): void;
  78412. }
  78413. }
  78414. declare module BABYLON {
  78415. /**
  78416. * Information about the result of picking within a scene
  78417. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78418. */
  78419. export class PickingInfo {
  78420. /** @hidden */
  78421. _pickingUnavailable: boolean;
  78422. /**
  78423. * If the pick collided with an object
  78424. */
  78425. hit: boolean;
  78426. /**
  78427. * Distance away where the pick collided
  78428. */
  78429. distance: number;
  78430. /**
  78431. * The location of pick collision
  78432. */
  78433. pickedPoint: Nullable<Vector3>;
  78434. /**
  78435. * The mesh corresponding the the pick collision
  78436. */
  78437. pickedMesh: Nullable<AbstractMesh>;
  78438. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78439. bu: number;
  78440. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78441. bv: number;
  78442. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78443. faceId: number;
  78444. /** Id of the the submesh that was picked */
  78445. subMeshId: number;
  78446. /** If a sprite was picked, this will be the sprite the pick collided with */
  78447. pickedSprite: Nullable<Sprite>;
  78448. /**
  78449. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78450. */
  78451. originMesh: Nullable<AbstractMesh>;
  78452. /**
  78453. * The ray that was used to perform the picking.
  78454. */
  78455. ray: Nullable<Ray>;
  78456. /**
  78457. * Gets the normal correspodning to the face the pick collided with
  78458. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78459. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78460. * @returns The normal correspodning to the face the pick collided with
  78461. */
  78462. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78463. /**
  78464. * Gets the texture coordinates of where the pick occured
  78465. * @returns the vector containing the coordnates of the texture
  78466. */
  78467. getTextureCoordinates(): Nullable<Vector2>;
  78468. }
  78469. }
  78470. declare module BABYLON {
  78471. /**
  78472. * Gather the list of pointer event types as constants.
  78473. */
  78474. export class PointerEventTypes {
  78475. /**
  78476. * 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.
  78477. */
  78478. static readonly POINTERDOWN: number;
  78479. /**
  78480. * The pointerup event is fired when a pointer is no longer active.
  78481. */
  78482. static readonly POINTERUP: number;
  78483. /**
  78484. * The pointermove event is fired when a pointer changes coordinates.
  78485. */
  78486. static readonly POINTERMOVE: number;
  78487. /**
  78488. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78489. */
  78490. static readonly POINTERWHEEL: number;
  78491. /**
  78492. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78493. */
  78494. static readonly POINTERPICK: number;
  78495. /**
  78496. * The pointertap event is fired when a the object has been touched and released without drag.
  78497. */
  78498. static readonly POINTERTAP: number;
  78499. /**
  78500. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78501. */
  78502. static readonly POINTERDOUBLETAP: number;
  78503. }
  78504. /**
  78505. * Base class of pointer info types.
  78506. */
  78507. export class PointerInfoBase {
  78508. /**
  78509. * Defines the type of event (PointerEventTypes)
  78510. */
  78511. type: number;
  78512. /**
  78513. * Defines the related dom event
  78514. */
  78515. event: PointerEvent | MouseWheelEvent;
  78516. /**
  78517. * Instantiates the base class of pointers info.
  78518. * @param type Defines the type of event (PointerEventTypes)
  78519. * @param event Defines the related dom event
  78520. */
  78521. constructor(
  78522. /**
  78523. * Defines the type of event (PointerEventTypes)
  78524. */
  78525. type: number,
  78526. /**
  78527. * Defines the related dom event
  78528. */
  78529. event: PointerEvent | MouseWheelEvent);
  78530. }
  78531. /**
  78532. * This class is used to store pointer related info for the onPrePointerObservable event.
  78533. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78534. */
  78535. export class PointerInfoPre extends PointerInfoBase {
  78536. /**
  78537. * Ray from a pointer if availible (eg. 6dof controller)
  78538. */
  78539. ray: Nullable<Ray>;
  78540. /**
  78541. * Defines the local position of the pointer on the canvas.
  78542. */
  78543. localPosition: Vector2;
  78544. /**
  78545. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78546. */
  78547. skipOnPointerObservable: boolean;
  78548. /**
  78549. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78550. * @param type Defines the type of event (PointerEventTypes)
  78551. * @param event Defines the related dom event
  78552. * @param localX Defines the local x coordinates of the pointer when the event occured
  78553. * @param localY Defines the local y coordinates of the pointer when the event occured
  78554. */
  78555. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78556. }
  78557. /**
  78558. * This type contains all the data related to a pointer event in Babylon.js.
  78559. * 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.
  78560. */
  78561. export class PointerInfo extends PointerInfoBase {
  78562. /**
  78563. * Defines the picking info associated to the info (if any)\
  78564. */
  78565. pickInfo: Nullable<PickingInfo>;
  78566. /**
  78567. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78568. * @param type Defines the type of event (PointerEventTypes)
  78569. * @param event Defines the related dom event
  78570. * @param pickInfo Defines the picking info associated to the info (if any)\
  78571. */
  78572. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78573. /**
  78574. * Defines the picking info associated to the info (if any)\
  78575. */
  78576. pickInfo: Nullable<PickingInfo>);
  78577. }
  78578. /**
  78579. * Data relating to a touch event on the screen.
  78580. */
  78581. export interface PointerTouch {
  78582. /**
  78583. * X coordinate of touch.
  78584. */
  78585. x: number;
  78586. /**
  78587. * Y coordinate of touch.
  78588. */
  78589. y: number;
  78590. /**
  78591. * Id of touch. Unique for each finger.
  78592. */
  78593. pointerId: number;
  78594. /**
  78595. * Event type passed from DOM.
  78596. */
  78597. type: any;
  78598. }
  78599. }
  78600. declare module BABYLON {
  78601. /**
  78602. * Manage the mouse inputs to control the movement of a free camera.
  78603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78604. */
  78605. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78606. /**
  78607. * Define if touch is enabled in the mouse input
  78608. */
  78609. touchEnabled: boolean;
  78610. /**
  78611. * Defines the camera the input is attached to.
  78612. */
  78613. camera: FreeCamera;
  78614. /**
  78615. * Defines the buttons associated with the input to handle camera move.
  78616. */
  78617. buttons: number[];
  78618. /**
  78619. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78620. */
  78621. angularSensibility: number;
  78622. private _pointerInput;
  78623. private _onMouseMove;
  78624. private _observer;
  78625. private previousPosition;
  78626. /**
  78627. * Observable for when a pointer move event occurs containing the move offset
  78628. */
  78629. onPointerMovedObservable: Observable<{
  78630. offsetX: number;
  78631. offsetY: number;
  78632. }>;
  78633. /**
  78634. * @hidden
  78635. * If the camera should be rotated automatically based on pointer movement
  78636. */
  78637. _allowCameraRotation: boolean;
  78638. /**
  78639. * Manage the mouse inputs to control the movement of a free camera.
  78640. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78641. * @param touchEnabled Defines if touch is enabled or not
  78642. */
  78643. constructor(
  78644. /**
  78645. * Define if touch is enabled in the mouse input
  78646. */
  78647. touchEnabled?: boolean);
  78648. /**
  78649. * Attach the input controls to a specific dom element to get the input from.
  78650. * @param element Defines the element the controls should be listened from
  78651. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78652. */
  78653. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78654. /**
  78655. * Called on JS contextmenu event.
  78656. * Override this method to provide functionality.
  78657. */
  78658. protected onContextMenu(evt: PointerEvent): void;
  78659. /**
  78660. * Detach the current controls from the specified dom element.
  78661. * @param element Defines the element to stop listening the inputs from
  78662. */
  78663. detachControl(element: Nullable<HTMLElement>): void;
  78664. /**
  78665. * Gets the class name of the current intput.
  78666. * @returns the class name
  78667. */
  78668. getClassName(): string;
  78669. /**
  78670. * Get the friendly name associated with the input class.
  78671. * @returns the input friendly name
  78672. */
  78673. getSimpleName(): string;
  78674. }
  78675. }
  78676. declare module BABYLON {
  78677. /**
  78678. * Manage the touch inputs to control the movement of a free camera.
  78679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78680. */
  78681. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78682. /**
  78683. * Defines the camera the input is attached to.
  78684. */
  78685. camera: FreeCamera;
  78686. /**
  78687. * Defines the touch sensibility for rotation.
  78688. * The higher the faster.
  78689. */
  78690. touchAngularSensibility: number;
  78691. /**
  78692. * Defines the touch sensibility for move.
  78693. * The higher the faster.
  78694. */
  78695. touchMoveSensibility: number;
  78696. private _offsetX;
  78697. private _offsetY;
  78698. private _pointerPressed;
  78699. private _pointerInput;
  78700. private _observer;
  78701. private _onLostFocus;
  78702. /**
  78703. * Attach the input controls to a specific dom element to get the input from.
  78704. * @param element Defines the element the controls should be listened from
  78705. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78706. */
  78707. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78708. /**
  78709. * Detach the current controls from the specified dom element.
  78710. * @param element Defines the element to stop listening the inputs from
  78711. */
  78712. detachControl(element: Nullable<HTMLElement>): void;
  78713. /**
  78714. * Update the current camera state depending on the inputs that have been used this frame.
  78715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78716. */
  78717. checkInputs(): void;
  78718. /**
  78719. * Gets the class name of the current intput.
  78720. * @returns the class name
  78721. */
  78722. getClassName(): string;
  78723. /**
  78724. * Get the friendly name associated with the input class.
  78725. * @returns the input friendly name
  78726. */
  78727. getSimpleName(): string;
  78728. }
  78729. }
  78730. declare module BABYLON {
  78731. /**
  78732. * Default Inputs manager for the FreeCamera.
  78733. * It groups all the default supported inputs for ease of use.
  78734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78735. */
  78736. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78737. /**
  78738. * @hidden
  78739. */
  78740. _mouseInput: Nullable<FreeCameraMouseInput>;
  78741. /**
  78742. * Instantiates a new FreeCameraInputsManager.
  78743. * @param camera Defines the camera the inputs belong to
  78744. */
  78745. constructor(camera: FreeCamera);
  78746. /**
  78747. * Add keyboard input support to the input manager.
  78748. * @returns the current input manager
  78749. */
  78750. addKeyboard(): FreeCameraInputsManager;
  78751. /**
  78752. * Add mouse input support to the input manager.
  78753. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78754. * @returns the current input manager
  78755. */
  78756. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78757. /**
  78758. * Removes the mouse input support from the manager
  78759. * @returns the current input manager
  78760. */
  78761. removeMouse(): FreeCameraInputsManager;
  78762. /**
  78763. * Add touch input support to the input manager.
  78764. * @returns the current input manager
  78765. */
  78766. addTouch(): FreeCameraInputsManager;
  78767. /**
  78768. * Remove all attached input methods from a camera
  78769. */
  78770. clear(): void;
  78771. }
  78772. }
  78773. declare module BABYLON {
  78774. /**
  78775. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78776. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78777. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78778. */
  78779. export class FreeCamera extends TargetCamera {
  78780. /**
  78781. * Define the collision ellipsoid of the camera.
  78782. * This is helpful to simulate a camera body like the player body around the camera
  78783. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78784. */
  78785. ellipsoid: Vector3;
  78786. /**
  78787. * Define an offset for the position of the ellipsoid around the camera.
  78788. * This can be helpful to determine the center of the body near the gravity center of the body
  78789. * instead of its head.
  78790. */
  78791. ellipsoidOffset: Vector3;
  78792. /**
  78793. * Enable or disable collisions of the camera with the rest of the scene objects.
  78794. */
  78795. checkCollisions: boolean;
  78796. /**
  78797. * Enable or disable gravity on the camera.
  78798. */
  78799. applyGravity: boolean;
  78800. /**
  78801. * Define the input manager associated to the camera.
  78802. */
  78803. inputs: FreeCameraInputsManager;
  78804. /**
  78805. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78806. * Higher values reduce sensitivity.
  78807. */
  78808. /**
  78809. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78810. * Higher values reduce sensitivity.
  78811. */
  78812. angularSensibility: number;
  78813. /**
  78814. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78815. */
  78816. keysUp: number[];
  78817. /**
  78818. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78819. */
  78820. keysDown: number[];
  78821. /**
  78822. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78823. */
  78824. keysLeft: number[];
  78825. /**
  78826. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78827. */
  78828. keysRight: number[];
  78829. /**
  78830. * Event raised when the camera collide with a mesh in the scene.
  78831. */
  78832. onCollide: (collidedMesh: AbstractMesh) => void;
  78833. private _collider;
  78834. private _needMoveForGravity;
  78835. private _oldPosition;
  78836. private _diffPosition;
  78837. private _newPosition;
  78838. /** @hidden */
  78839. _localDirection: Vector3;
  78840. /** @hidden */
  78841. _transformedDirection: Vector3;
  78842. /**
  78843. * Instantiates a Free Camera.
  78844. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78845. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78846. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78847. * @param name Define the name of the camera in the scene
  78848. * @param position Define the start position of the camera in the scene
  78849. * @param scene Define the scene the camera belongs to
  78850. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78851. */
  78852. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78853. /**
  78854. * Attached controls to the current camera.
  78855. * @param element Defines the element the controls should be listened from
  78856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78857. */
  78858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78859. /**
  78860. * Detach the current controls from the camera.
  78861. * The camera will stop reacting to inputs.
  78862. * @param element Defines the element to stop listening the inputs from
  78863. */
  78864. detachControl(element: HTMLElement): void;
  78865. private _collisionMask;
  78866. /**
  78867. * Define a collision mask to limit the list of object the camera can collide with
  78868. */
  78869. collisionMask: number;
  78870. /** @hidden */
  78871. _collideWithWorld(displacement: Vector3): void;
  78872. private _onCollisionPositionChange;
  78873. /** @hidden */
  78874. _checkInputs(): void;
  78875. /** @hidden */
  78876. _decideIfNeedsToMove(): boolean;
  78877. /** @hidden */
  78878. _updatePosition(): void;
  78879. /**
  78880. * Destroy the camera and release the current resources hold by it.
  78881. */
  78882. dispose(): void;
  78883. /**
  78884. * Gets the current object class name.
  78885. * @return the class name
  78886. */
  78887. getClassName(): string;
  78888. }
  78889. }
  78890. declare module BABYLON {
  78891. /**
  78892. * Represents a gamepad control stick position
  78893. */
  78894. export class StickValues {
  78895. /**
  78896. * The x component of the control stick
  78897. */
  78898. x: number;
  78899. /**
  78900. * The y component of the control stick
  78901. */
  78902. y: number;
  78903. /**
  78904. * Initializes the gamepad x and y control stick values
  78905. * @param x The x component of the gamepad control stick value
  78906. * @param y The y component of the gamepad control stick value
  78907. */
  78908. constructor(
  78909. /**
  78910. * The x component of the control stick
  78911. */
  78912. x: number,
  78913. /**
  78914. * The y component of the control stick
  78915. */
  78916. y: number);
  78917. }
  78918. /**
  78919. * An interface which manages callbacks for gamepad button changes
  78920. */
  78921. export interface GamepadButtonChanges {
  78922. /**
  78923. * Called when a gamepad has been changed
  78924. */
  78925. changed: boolean;
  78926. /**
  78927. * Called when a gamepad press event has been triggered
  78928. */
  78929. pressChanged: boolean;
  78930. /**
  78931. * Called when a touch event has been triggered
  78932. */
  78933. touchChanged: boolean;
  78934. /**
  78935. * Called when a value has changed
  78936. */
  78937. valueChanged: boolean;
  78938. }
  78939. /**
  78940. * Represents a gamepad
  78941. */
  78942. export class Gamepad {
  78943. /**
  78944. * The id of the gamepad
  78945. */
  78946. id: string;
  78947. /**
  78948. * The index of the gamepad
  78949. */
  78950. index: number;
  78951. /**
  78952. * The browser gamepad
  78953. */
  78954. browserGamepad: any;
  78955. /**
  78956. * Specifies what type of gamepad this represents
  78957. */
  78958. type: number;
  78959. private _leftStick;
  78960. private _rightStick;
  78961. /** @hidden */
  78962. _isConnected: boolean;
  78963. private _leftStickAxisX;
  78964. private _leftStickAxisY;
  78965. private _rightStickAxisX;
  78966. private _rightStickAxisY;
  78967. /**
  78968. * Triggered when the left control stick has been changed
  78969. */
  78970. private _onleftstickchanged;
  78971. /**
  78972. * Triggered when the right control stick has been changed
  78973. */
  78974. private _onrightstickchanged;
  78975. /**
  78976. * Represents a gamepad controller
  78977. */
  78978. static GAMEPAD: number;
  78979. /**
  78980. * Represents a generic controller
  78981. */
  78982. static GENERIC: number;
  78983. /**
  78984. * Represents an XBox controller
  78985. */
  78986. static XBOX: number;
  78987. /**
  78988. * Represents a pose-enabled controller
  78989. */
  78990. static POSE_ENABLED: number;
  78991. /**
  78992. * Represents an Dual Shock controller
  78993. */
  78994. static DUALSHOCK: number;
  78995. /**
  78996. * Specifies whether the left control stick should be Y-inverted
  78997. */
  78998. protected _invertLeftStickY: boolean;
  78999. /**
  79000. * Specifies if the gamepad has been connected
  79001. */
  79002. readonly isConnected: boolean;
  79003. /**
  79004. * Initializes the gamepad
  79005. * @param id The id of the gamepad
  79006. * @param index The index of the gamepad
  79007. * @param browserGamepad The browser gamepad
  79008. * @param leftStickX The x component of the left joystick
  79009. * @param leftStickY The y component of the left joystick
  79010. * @param rightStickX The x component of the right joystick
  79011. * @param rightStickY The y component of the right joystick
  79012. */
  79013. constructor(
  79014. /**
  79015. * The id of the gamepad
  79016. */
  79017. id: string,
  79018. /**
  79019. * The index of the gamepad
  79020. */
  79021. index: number,
  79022. /**
  79023. * The browser gamepad
  79024. */
  79025. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79026. /**
  79027. * Callback triggered when the left joystick has changed
  79028. * @param callback
  79029. */
  79030. onleftstickchanged(callback: (values: StickValues) => void): void;
  79031. /**
  79032. * Callback triggered when the right joystick has changed
  79033. * @param callback
  79034. */
  79035. onrightstickchanged(callback: (values: StickValues) => void): void;
  79036. /**
  79037. * Gets the left joystick
  79038. */
  79039. /**
  79040. * Sets the left joystick values
  79041. */
  79042. leftStick: StickValues;
  79043. /**
  79044. * Gets the right joystick
  79045. */
  79046. /**
  79047. * Sets the right joystick value
  79048. */
  79049. rightStick: StickValues;
  79050. /**
  79051. * Updates the gamepad joystick positions
  79052. */
  79053. update(): void;
  79054. /**
  79055. * Disposes the gamepad
  79056. */
  79057. dispose(): void;
  79058. }
  79059. /**
  79060. * Represents a generic gamepad
  79061. */
  79062. export class GenericPad extends Gamepad {
  79063. private _buttons;
  79064. private _onbuttondown;
  79065. private _onbuttonup;
  79066. /**
  79067. * Observable triggered when a button has been pressed
  79068. */
  79069. onButtonDownObservable: Observable<number>;
  79070. /**
  79071. * Observable triggered when a button has been released
  79072. */
  79073. onButtonUpObservable: Observable<number>;
  79074. /**
  79075. * Callback triggered when a button has been pressed
  79076. * @param callback Called when a button has been pressed
  79077. */
  79078. onbuttondown(callback: (buttonPressed: number) => void): void;
  79079. /**
  79080. * Callback triggered when a button has been released
  79081. * @param callback Called when a button has been released
  79082. */
  79083. onbuttonup(callback: (buttonReleased: number) => void): void;
  79084. /**
  79085. * Initializes the generic gamepad
  79086. * @param id The id of the generic gamepad
  79087. * @param index The index of the generic gamepad
  79088. * @param browserGamepad The browser gamepad
  79089. */
  79090. constructor(id: string, index: number, browserGamepad: any);
  79091. private _setButtonValue;
  79092. /**
  79093. * Updates the generic gamepad
  79094. */
  79095. update(): void;
  79096. /**
  79097. * Disposes the generic gamepad
  79098. */
  79099. dispose(): void;
  79100. }
  79101. }
  79102. declare module BABYLON {
  79103. interface Engine {
  79104. /**
  79105. * Creates a raw texture
  79106. * @param data defines the data to store in the texture
  79107. * @param width defines the width of the texture
  79108. * @param height defines the height of the texture
  79109. * @param format defines the format of the data
  79110. * @param generateMipMaps defines if the engine should generate the mip levels
  79111. * @param invertY defines if data must be stored with Y axis inverted
  79112. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79113. * @param compression defines the compression used (null by default)
  79114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79115. * @returns the raw texture inside an InternalTexture
  79116. */
  79117. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79118. /**
  79119. * Update a raw texture
  79120. * @param texture defines the texture to update
  79121. * @param data defines the data to store in the texture
  79122. * @param format defines the format of the data
  79123. * @param invertY defines if data must be stored with Y axis inverted
  79124. */
  79125. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79126. /**
  79127. * Update a raw texture
  79128. * @param texture defines the texture to update
  79129. * @param data defines the data to store in the texture
  79130. * @param format defines the format of the data
  79131. * @param invertY defines if data must be stored with Y axis inverted
  79132. * @param compression defines the compression used (null by default)
  79133. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79134. */
  79135. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79136. /**
  79137. * Creates a new raw cube texture
  79138. * @param data defines the array of data to use to create each face
  79139. * @param size defines the size of the textures
  79140. * @param format defines the format of the data
  79141. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79142. * @param generateMipMaps defines if the engine should generate the mip levels
  79143. * @param invertY defines if data must be stored with Y axis inverted
  79144. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79145. * @param compression defines the compression used (null by default)
  79146. * @returns the cube texture as an InternalTexture
  79147. */
  79148. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79149. /**
  79150. * Update a raw cube texture
  79151. * @param texture defines the texture to udpdate
  79152. * @param data defines the data to store
  79153. * @param format defines the data format
  79154. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79155. * @param invertY defines if data must be stored with Y axis inverted
  79156. */
  79157. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79158. /**
  79159. * Update a raw cube texture
  79160. * @param texture defines the texture to udpdate
  79161. * @param data defines the data to store
  79162. * @param format defines the data format
  79163. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79164. * @param invertY defines if data must be stored with Y axis inverted
  79165. * @param compression defines the compression used (null by default)
  79166. */
  79167. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79168. /**
  79169. * Update a raw cube texture
  79170. * @param texture defines the texture to udpdate
  79171. * @param data defines the data to store
  79172. * @param format defines the data format
  79173. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79174. * @param invertY defines if data must be stored with Y axis inverted
  79175. * @param compression defines the compression used (null by default)
  79176. * @param level defines which level of the texture to update
  79177. */
  79178. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79179. /**
  79180. * Creates a new raw cube texture from a specified url
  79181. * @param url defines the url where the data is located
  79182. * @param scene defines the current scene
  79183. * @param size defines the size of the textures
  79184. * @param format defines the format of the data
  79185. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79186. * @param noMipmap defines if the engine should avoid generating the mip levels
  79187. * @param callback defines a callback used to extract texture data from loaded data
  79188. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79189. * @param onLoad defines a callback called when texture is loaded
  79190. * @param onError defines a callback called if there is an error
  79191. * @returns the cube texture as an InternalTexture
  79192. */
  79193. 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;
  79194. /**
  79195. * Creates a new raw cube texture from a specified url
  79196. * @param url defines the url where the data is located
  79197. * @param scene defines the current scene
  79198. * @param size defines the size of the textures
  79199. * @param format defines the format of the data
  79200. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79201. * @param noMipmap defines if the engine should avoid generating the mip levels
  79202. * @param callback defines a callback used to extract texture data from loaded data
  79203. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79204. * @param onLoad defines a callback called when texture is loaded
  79205. * @param onError defines a callback called if there is an error
  79206. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79207. * @param invertY defines if data must be stored with Y axis inverted
  79208. * @returns the cube texture as an InternalTexture
  79209. */
  79210. 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;
  79211. /**
  79212. * Creates a new raw 3D texture
  79213. * @param data defines the data used to create the texture
  79214. * @param width defines the width of the texture
  79215. * @param height defines the height of the texture
  79216. * @param depth defines the depth of the texture
  79217. * @param format defines the format of the texture
  79218. * @param generateMipMaps defines if the engine must generate mip levels
  79219. * @param invertY defines if data must be stored with Y axis inverted
  79220. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79221. * @param compression defines the compressed used (can be null)
  79222. * @param textureType defines the compressed used (can be null)
  79223. * @returns a new raw 3D texture (stored in an InternalTexture)
  79224. */
  79225. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79226. /**
  79227. * Update a raw 3D texture
  79228. * @param texture defines the texture to update
  79229. * @param data defines the data to store
  79230. * @param format defines the data format
  79231. * @param invertY defines if data must be stored with Y axis inverted
  79232. */
  79233. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79234. /**
  79235. * Update a raw 3D texture
  79236. * @param texture defines the texture to update
  79237. * @param data defines the data to store
  79238. * @param format defines the data format
  79239. * @param invertY defines if data must be stored with Y axis inverted
  79240. * @param compression defines the used compression (can be null)
  79241. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79242. */
  79243. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79244. }
  79245. }
  79246. declare module BABYLON {
  79247. /**
  79248. * Raw texture can help creating a texture directly from an array of data.
  79249. * This can be super useful if you either get the data from an uncompressed source or
  79250. * if you wish to create your texture pixel by pixel.
  79251. */
  79252. export class RawTexture extends Texture {
  79253. /**
  79254. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79255. */
  79256. format: number;
  79257. private _engine;
  79258. /**
  79259. * Instantiates a new RawTexture.
  79260. * Raw texture can help creating a texture directly from an array of data.
  79261. * This can be super useful if you either get the data from an uncompressed source or
  79262. * if you wish to create your texture pixel by pixel.
  79263. * @param data define the array of data to use to create the texture
  79264. * @param width define the width of the texture
  79265. * @param height define the height of the texture
  79266. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79267. * @param scene define the scene the texture belongs to
  79268. * @param generateMipMaps define whether mip maps should be generated or not
  79269. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79270. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79271. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79272. */
  79273. constructor(data: ArrayBufferView, width: number, height: number,
  79274. /**
  79275. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79276. */
  79277. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79278. /**
  79279. * Updates the texture underlying data.
  79280. * @param data Define the new data of the texture
  79281. */
  79282. update(data: ArrayBufferView): void;
  79283. /**
  79284. * Creates a luminance texture from some data.
  79285. * @param data Define the texture data
  79286. * @param width Define the width of the texture
  79287. * @param height Define the height of the texture
  79288. * @param scene Define the scene the texture belongs to
  79289. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79290. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79291. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79292. * @returns the luminance texture
  79293. */
  79294. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79295. /**
  79296. * Creates a luminance alpha texture from some data.
  79297. * @param data Define the texture data
  79298. * @param width Define the width of the texture
  79299. * @param height Define the height of the texture
  79300. * @param scene Define the scene the texture belongs to
  79301. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79302. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79303. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79304. * @returns the luminance alpha texture
  79305. */
  79306. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79307. /**
  79308. * Creates an alpha texture from some data.
  79309. * @param data Define the texture data
  79310. * @param width Define the width of the texture
  79311. * @param height Define the height of the texture
  79312. * @param scene Define the scene the texture belongs to
  79313. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79314. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79315. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79316. * @returns the alpha texture
  79317. */
  79318. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79319. /**
  79320. * Creates a RGB texture from some data.
  79321. * @param data Define the texture data
  79322. * @param width Define the width of the texture
  79323. * @param height Define the height of the texture
  79324. * @param scene Define the scene the texture belongs to
  79325. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79326. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79327. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79328. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79329. * @returns the RGB alpha texture
  79330. */
  79331. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79332. /**
  79333. * Creates a RGBA texture from some data.
  79334. * @param data Define the texture data
  79335. * @param width Define the width of the texture
  79336. * @param height Define the height of the texture
  79337. * @param scene Define the scene the texture belongs to
  79338. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79339. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79340. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79341. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79342. * @returns the RGBA texture
  79343. */
  79344. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79345. /**
  79346. * Creates a R texture from some data.
  79347. * @param data Define the texture data
  79348. * @param width Define the width of the texture
  79349. * @param height Define the height of the texture
  79350. * @param scene Define the scene the texture belongs to
  79351. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79352. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79353. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79354. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79355. * @returns the R texture
  79356. */
  79357. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79358. }
  79359. }
  79360. declare module BABYLON {
  79361. /**
  79362. * Interface for the size containing width and height
  79363. */
  79364. export interface ISize {
  79365. /**
  79366. * Width
  79367. */
  79368. width: number;
  79369. /**
  79370. * Heighht
  79371. */
  79372. height: number;
  79373. }
  79374. /**
  79375. * Size containing widht and height
  79376. */
  79377. export class Size implements ISize {
  79378. /**
  79379. * Width
  79380. */
  79381. width: number;
  79382. /**
  79383. * Height
  79384. */
  79385. height: number;
  79386. /**
  79387. * Creates a Size object from the given width and height (floats).
  79388. * @param width width of the new size
  79389. * @param height height of the new size
  79390. */
  79391. constructor(width: number, height: number);
  79392. /**
  79393. * Returns a string with the Size width and height
  79394. * @returns a string with the Size width and height
  79395. */
  79396. toString(): string;
  79397. /**
  79398. * "Size"
  79399. * @returns the string "Size"
  79400. */
  79401. getClassName(): string;
  79402. /**
  79403. * Returns the Size hash code.
  79404. * @returns a hash code for a unique width and height
  79405. */
  79406. getHashCode(): number;
  79407. /**
  79408. * Updates the current size from the given one.
  79409. * @param src the given size
  79410. */
  79411. copyFrom(src: Size): void;
  79412. /**
  79413. * Updates in place the current Size from the given floats.
  79414. * @param width width of the new size
  79415. * @param height height of the new size
  79416. * @returns the updated Size.
  79417. */
  79418. copyFromFloats(width: number, height: number): Size;
  79419. /**
  79420. * Updates in place the current Size from the given floats.
  79421. * @param width width to set
  79422. * @param height height to set
  79423. * @returns the updated Size.
  79424. */
  79425. set(width: number, height: number): Size;
  79426. /**
  79427. * Multiplies the width and height by numbers
  79428. * @param w factor to multiple the width by
  79429. * @param h factor to multiple the height by
  79430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79431. */
  79432. multiplyByFloats(w: number, h: number): Size;
  79433. /**
  79434. * Clones the size
  79435. * @returns a new Size copied from the given one.
  79436. */
  79437. clone(): Size;
  79438. /**
  79439. * True if the current Size and the given one width and height are strictly equal.
  79440. * @param other the other size to compare against
  79441. * @returns True if the current Size and the given one width and height are strictly equal.
  79442. */
  79443. equals(other: Size): boolean;
  79444. /**
  79445. * The surface of the Size : width * height (float).
  79446. */
  79447. readonly surface: number;
  79448. /**
  79449. * Create a new size of zero
  79450. * @returns a new Size set to (0.0, 0.0)
  79451. */
  79452. static Zero(): Size;
  79453. /**
  79454. * Sums the width and height of two sizes
  79455. * @param otherSize size to add to this size
  79456. * @returns a new Size set as the addition result of the current Size and the given one.
  79457. */
  79458. add(otherSize: Size): Size;
  79459. /**
  79460. * Subtracts the width and height of two
  79461. * @param otherSize size to subtract to this size
  79462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79463. */
  79464. subtract(otherSize: Size): Size;
  79465. /**
  79466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79467. * @param start starting size to lerp between
  79468. * @param end end size to lerp between
  79469. * @param amount amount to lerp between the start and end values
  79470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79471. */
  79472. static Lerp(start: Size, end: Size, amount: number): Size;
  79473. }
  79474. }
  79475. declare module BABYLON {
  79476. /**
  79477. * Defines a runtime animation
  79478. */
  79479. export class RuntimeAnimation {
  79480. private _events;
  79481. /**
  79482. * The current frame of the runtime animation
  79483. */
  79484. private _currentFrame;
  79485. /**
  79486. * The animation used by the runtime animation
  79487. */
  79488. private _animation;
  79489. /**
  79490. * The target of the runtime animation
  79491. */
  79492. private _target;
  79493. /**
  79494. * The initiating animatable
  79495. */
  79496. private _host;
  79497. /**
  79498. * The original value of the runtime animation
  79499. */
  79500. private _originalValue;
  79501. /**
  79502. * The original blend value of the runtime animation
  79503. */
  79504. private _originalBlendValue;
  79505. /**
  79506. * The offsets cache of the runtime animation
  79507. */
  79508. private _offsetsCache;
  79509. /**
  79510. * The high limits cache of the runtime animation
  79511. */
  79512. private _highLimitsCache;
  79513. /**
  79514. * Specifies if the runtime animation has been stopped
  79515. */
  79516. private _stopped;
  79517. /**
  79518. * The blending factor of the runtime animation
  79519. */
  79520. private _blendingFactor;
  79521. /**
  79522. * The BabylonJS scene
  79523. */
  79524. private _scene;
  79525. /**
  79526. * The current value of the runtime animation
  79527. */
  79528. private _currentValue;
  79529. /** @hidden */
  79530. _animationState: _IAnimationState;
  79531. /**
  79532. * The active target of the runtime animation
  79533. */
  79534. private _activeTargets;
  79535. private _currentActiveTarget;
  79536. private _directTarget;
  79537. /**
  79538. * The target path of the runtime animation
  79539. */
  79540. private _targetPath;
  79541. /**
  79542. * The weight of the runtime animation
  79543. */
  79544. private _weight;
  79545. /**
  79546. * The ratio offset of the runtime animation
  79547. */
  79548. private _ratioOffset;
  79549. /**
  79550. * The previous delay of the runtime animation
  79551. */
  79552. private _previousDelay;
  79553. /**
  79554. * The previous ratio of the runtime animation
  79555. */
  79556. private _previousRatio;
  79557. private _enableBlending;
  79558. private _keys;
  79559. private _minFrame;
  79560. private _maxFrame;
  79561. private _minValue;
  79562. private _maxValue;
  79563. private _targetIsArray;
  79564. /**
  79565. * Gets the current frame of the runtime animation
  79566. */
  79567. readonly currentFrame: number;
  79568. /**
  79569. * Gets the weight of the runtime animation
  79570. */
  79571. readonly weight: number;
  79572. /**
  79573. * Gets the current value of the runtime animation
  79574. */
  79575. readonly currentValue: any;
  79576. /**
  79577. * Gets the target path of the runtime animation
  79578. */
  79579. readonly targetPath: string;
  79580. /**
  79581. * Gets the actual target of the runtime animation
  79582. */
  79583. readonly target: any;
  79584. /** @hidden */
  79585. _onLoop: () => void;
  79586. /**
  79587. * Create a new RuntimeAnimation object
  79588. * @param target defines the target of the animation
  79589. * @param animation defines the source animation object
  79590. * @param scene defines the hosting scene
  79591. * @param host defines the initiating Animatable
  79592. */
  79593. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79594. private _preparePath;
  79595. /**
  79596. * Gets the animation from the runtime animation
  79597. */
  79598. readonly animation: Animation;
  79599. /**
  79600. * Resets the runtime animation to the beginning
  79601. * @param restoreOriginal defines whether to restore the target property to the original value
  79602. */
  79603. reset(restoreOriginal?: boolean): void;
  79604. /**
  79605. * Specifies if the runtime animation is stopped
  79606. * @returns Boolean specifying if the runtime animation is stopped
  79607. */
  79608. isStopped(): boolean;
  79609. /**
  79610. * Disposes of the runtime animation
  79611. */
  79612. dispose(): void;
  79613. /**
  79614. * Apply the interpolated value to the target
  79615. * @param currentValue defines the value computed by the animation
  79616. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79617. */
  79618. setValue(currentValue: any, weight: number): void;
  79619. private _getOriginalValues;
  79620. private _setValue;
  79621. /**
  79622. * Gets the loop pmode of the runtime animation
  79623. * @returns Loop Mode
  79624. */
  79625. private _getCorrectLoopMode;
  79626. /**
  79627. * Move the current animation to a given frame
  79628. * @param frame defines the frame to move to
  79629. */
  79630. goToFrame(frame: number): void;
  79631. /**
  79632. * @hidden Internal use only
  79633. */
  79634. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79635. /**
  79636. * Execute the current animation
  79637. * @param delay defines the delay to add to the current frame
  79638. * @param from defines the lower bound of the animation range
  79639. * @param to defines the upper bound of the animation range
  79640. * @param loop defines if the current animation must loop
  79641. * @param speedRatio defines the current speed ratio
  79642. * @param weight defines the weight of the animation (default is -1 so no weight)
  79643. * @param onLoop optional callback called when animation loops
  79644. * @returns a boolean indicating if the animation is running
  79645. */
  79646. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79647. }
  79648. }
  79649. declare module BABYLON {
  79650. /**
  79651. * Class used to store an actual running animation
  79652. */
  79653. export class Animatable {
  79654. /** defines the target object */
  79655. target: any;
  79656. /** defines the starting frame number (default is 0) */
  79657. fromFrame: number;
  79658. /** defines the ending frame number (default is 100) */
  79659. toFrame: number;
  79660. /** defines if the animation must loop (default is false) */
  79661. loopAnimation: boolean;
  79662. /** defines a callback to call when animation ends if it is not looping */
  79663. onAnimationEnd?: (() => void) | null | undefined;
  79664. /** defines a callback to call when animation loops */
  79665. onAnimationLoop?: (() => void) | null | undefined;
  79666. private _localDelayOffset;
  79667. private _pausedDelay;
  79668. private _runtimeAnimations;
  79669. private _paused;
  79670. private _scene;
  79671. private _speedRatio;
  79672. private _weight;
  79673. private _syncRoot;
  79674. /**
  79675. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79676. * This will only apply for non looping animation (default is true)
  79677. */
  79678. disposeOnEnd: boolean;
  79679. /**
  79680. * Gets a boolean indicating if the animation has started
  79681. */
  79682. animationStarted: boolean;
  79683. /**
  79684. * Observer raised when the animation ends
  79685. */
  79686. onAnimationEndObservable: Observable<Animatable>;
  79687. /**
  79688. * Observer raised when the animation loops
  79689. */
  79690. onAnimationLoopObservable: Observable<Animatable>;
  79691. /**
  79692. * Gets the root Animatable used to synchronize and normalize animations
  79693. */
  79694. readonly syncRoot: Nullable<Animatable>;
  79695. /**
  79696. * Gets the current frame of the first RuntimeAnimation
  79697. * Used to synchronize Animatables
  79698. */
  79699. readonly masterFrame: number;
  79700. /**
  79701. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79702. */
  79703. weight: number;
  79704. /**
  79705. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79706. */
  79707. speedRatio: number;
  79708. /**
  79709. * Creates a new Animatable
  79710. * @param scene defines the hosting scene
  79711. * @param target defines the target object
  79712. * @param fromFrame defines the starting frame number (default is 0)
  79713. * @param toFrame defines the ending frame number (default is 100)
  79714. * @param loopAnimation defines if the animation must loop (default is false)
  79715. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79716. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79717. * @param animations defines a group of animation to add to the new Animatable
  79718. * @param onAnimationLoop defines a callback to call when animation loops
  79719. */
  79720. constructor(scene: Scene,
  79721. /** defines the target object */
  79722. target: any,
  79723. /** defines the starting frame number (default is 0) */
  79724. fromFrame?: number,
  79725. /** defines the ending frame number (default is 100) */
  79726. toFrame?: number,
  79727. /** defines if the animation must loop (default is false) */
  79728. loopAnimation?: boolean, speedRatio?: number,
  79729. /** defines a callback to call when animation ends if it is not looping */
  79730. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79731. /** defines a callback to call when animation loops */
  79732. onAnimationLoop?: (() => void) | null | undefined);
  79733. /**
  79734. * Synchronize and normalize current Animatable with a source Animatable
  79735. * This is useful when using animation weights and when animations are not of the same length
  79736. * @param root defines the root Animatable to synchronize with
  79737. * @returns the current Animatable
  79738. */
  79739. syncWith(root: Animatable): Animatable;
  79740. /**
  79741. * Gets the list of runtime animations
  79742. * @returns an array of RuntimeAnimation
  79743. */
  79744. getAnimations(): RuntimeAnimation[];
  79745. /**
  79746. * Adds more animations to the current animatable
  79747. * @param target defines the target of the animations
  79748. * @param animations defines the new animations to add
  79749. */
  79750. appendAnimations(target: any, animations: Animation[]): void;
  79751. /**
  79752. * Gets the source animation for a specific property
  79753. * @param property defines the propertyu to look for
  79754. * @returns null or the source animation for the given property
  79755. */
  79756. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79757. /**
  79758. * Gets the runtime animation for a specific property
  79759. * @param property defines the propertyu to look for
  79760. * @returns null or the runtime animation for the given property
  79761. */
  79762. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79763. /**
  79764. * Resets the animatable to its original state
  79765. */
  79766. reset(): void;
  79767. /**
  79768. * Allows the animatable to blend with current running animations
  79769. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79770. * @param blendingSpeed defines the blending speed to use
  79771. */
  79772. enableBlending(blendingSpeed: number): void;
  79773. /**
  79774. * Disable animation blending
  79775. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79776. */
  79777. disableBlending(): void;
  79778. /**
  79779. * Jump directly to a given frame
  79780. * @param frame defines the frame to jump to
  79781. */
  79782. goToFrame(frame: number): void;
  79783. /**
  79784. * Pause the animation
  79785. */
  79786. pause(): void;
  79787. /**
  79788. * Restart the animation
  79789. */
  79790. restart(): void;
  79791. private _raiseOnAnimationEnd;
  79792. /**
  79793. * Stop and delete the current animation
  79794. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79795. * @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)
  79796. */
  79797. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79798. /**
  79799. * Wait asynchronously for the animation to end
  79800. * @returns a promise which will be fullfilled when the animation ends
  79801. */
  79802. waitAsync(): Promise<Animatable>;
  79803. /** @hidden */
  79804. _animate(delay: number): boolean;
  79805. }
  79806. interface Scene {
  79807. /** @hidden */
  79808. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79809. /** @hidden */
  79810. _processLateAnimationBindingsForMatrices(holder: {
  79811. totalWeight: number;
  79812. animations: RuntimeAnimation[];
  79813. originalValue: Matrix;
  79814. }): any;
  79815. /** @hidden */
  79816. _processLateAnimationBindingsForQuaternions(holder: {
  79817. totalWeight: number;
  79818. animations: RuntimeAnimation[];
  79819. originalValue: Quaternion;
  79820. }, refQuaternion: Quaternion): Quaternion;
  79821. /** @hidden */
  79822. _processLateAnimationBindings(): void;
  79823. /**
  79824. * Will start the animation sequence of a given target
  79825. * @param target defines the target
  79826. * @param from defines from which frame should animation start
  79827. * @param to defines until which frame should animation run.
  79828. * @param weight defines the weight to apply to the animation (1.0 by default)
  79829. * @param loop defines if the animation loops
  79830. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79831. * @param onAnimationEnd defines the function to be executed when the animation ends
  79832. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79833. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79834. * @param onAnimationLoop defines the callback to call when an animation loops
  79835. * @returns the animatable object created for this animation
  79836. */
  79837. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79838. /**
  79839. * Will start the animation sequence of a given target
  79840. * @param target defines the target
  79841. * @param from defines from which frame should animation start
  79842. * @param to defines until which frame should animation run.
  79843. * @param loop defines if the animation loops
  79844. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79845. * @param onAnimationEnd defines the function to be executed when the animation ends
  79846. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79847. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79848. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79849. * @param onAnimationLoop defines the callback to call when an animation loops
  79850. * @returns the animatable object created for this animation
  79851. */
  79852. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79853. /**
  79854. * Will start the animation sequence of a given target and its hierarchy
  79855. * @param target defines the target
  79856. * @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.
  79857. * @param from defines from which frame should animation start
  79858. * @param to defines until which frame should animation run.
  79859. * @param loop defines if the animation loops
  79860. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79861. * @param onAnimationEnd defines the function to be executed when the animation ends
  79862. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79863. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79864. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79865. * @param onAnimationLoop defines the callback to call when an animation loops
  79866. * @returns the list of created animatables
  79867. */
  79868. 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[];
  79869. /**
  79870. * Begin a new animation on a given node
  79871. * @param target defines the target where the animation will take place
  79872. * @param animations defines the list of animations to start
  79873. * @param from defines the initial value
  79874. * @param to defines the final value
  79875. * @param loop defines if you want animation to loop (off by default)
  79876. * @param speedRatio defines the speed ratio to apply to all animations
  79877. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79878. * @param onAnimationLoop defines the callback to call when an animation loops
  79879. * @returns the list of created animatables
  79880. */
  79881. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79882. /**
  79883. * Begin a new animation on a given node and its hierarchy
  79884. * @param target defines the root node where the animation will take place
  79885. * @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.
  79886. * @param animations defines the list of animations to start
  79887. * @param from defines the initial value
  79888. * @param to defines the final value
  79889. * @param loop defines if you want animation to loop (off by default)
  79890. * @param speedRatio defines the speed ratio to apply to all animations
  79891. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79892. * @param onAnimationLoop defines the callback to call when an animation loops
  79893. * @returns the list of animatables created for all nodes
  79894. */
  79895. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79896. /**
  79897. * Gets the animatable associated with a specific target
  79898. * @param target defines the target of the animatable
  79899. * @returns the required animatable if found
  79900. */
  79901. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79902. /**
  79903. * Gets all animatables associated with a given target
  79904. * @param target defines the target to look animatables for
  79905. * @returns an array of Animatables
  79906. */
  79907. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79908. /**
  79909. * Stops and removes all animations that have been applied to the scene
  79910. */
  79911. stopAllAnimations(): void;
  79912. /**
  79913. * Gets the current delta time used by animation engine
  79914. */
  79915. deltaTime: number;
  79916. }
  79917. interface Bone {
  79918. /**
  79919. * Copy an animation range from another bone
  79920. * @param source defines the source bone
  79921. * @param rangeName defines the range name to copy
  79922. * @param frameOffset defines the frame offset
  79923. * @param rescaleAsRequired defines if rescaling must be applied if required
  79924. * @param skelDimensionsRatio defines the scaling ratio
  79925. * @returns true if operation was successful
  79926. */
  79927. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79928. }
  79929. }
  79930. declare module BABYLON {
  79931. /**
  79932. * Class used to override all child animations of a given target
  79933. */
  79934. export class AnimationPropertiesOverride {
  79935. /**
  79936. * Gets or sets a value indicating if animation blending must be used
  79937. */
  79938. enableBlending: boolean;
  79939. /**
  79940. * Gets or sets the blending speed to use when enableBlending is true
  79941. */
  79942. blendingSpeed: number;
  79943. /**
  79944. * Gets or sets the default loop mode to use
  79945. */
  79946. loopMode: number;
  79947. }
  79948. }
  79949. declare module BABYLON {
  79950. /**
  79951. * Class used to handle skinning animations
  79952. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79953. */
  79954. export class Skeleton implements IAnimatable {
  79955. /** defines the skeleton name */
  79956. name: string;
  79957. /** defines the skeleton Id */
  79958. id: string;
  79959. /**
  79960. * Defines the list of child bones
  79961. */
  79962. bones: Bone[];
  79963. /**
  79964. * Defines an estimate of the dimension of the skeleton at rest
  79965. */
  79966. dimensionsAtRest: Vector3;
  79967. /**
  79968. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79969. */
  79970. needInitialSkinMatrix: boolean;
  79971. /**
  79972. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79973. */
  79974. overrideMesh: Nullable<AbstractMesh>;
  79975. /**
  79976. * Gets the list of animations attached to this skeleton
  79977. */
  79978. animations: Array<Animation>;
  79979. private _scene;
  79980. private _isDirty;
  79981. private _transformMatrices;
  79982. private _transformMatrixTexture;
  79983. private _meshesWithPoseMatrix;
  79984. private _animatables;
  79985. private _identity;
  79986. private _synchronizedWithMesh;
  79987. private _ranges;
  79988. private _lastAbsoluteTransformsUpdateId;
  79989. private _canUseTextureForBones;
  79990. private _uniqueId;
  79991. /** @hidden */
  79992. _numBonesWithLinkedTransformNode: number;
  79993. /** @hidden */
  79994. _hasWaitingData: Nullable<boolean>;
  79995. /**
  79996. * Specifies if the skeleton should be serialized
  79997. */
  79998. doNotSerialize: boolean;
  79999. private _useTextureToStoreBoneMatrices;
  80000. /**
  80001. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80002. * Please note that this option is not available if the hardware does not support it
  80003. */
  80004. useTextureToStoreBoneMatrices: boolean;
  80005. private _animationPropertiesOverride;
  80006. /**
  80007. * Gets or sets the animation properties override
  80008. */
  80009. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80010. /**
  80011. * List of inspectable custom properties (used by the Inspector)
  80012. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80013. */
  80014. inspectableCustomProperties: IInspectable[];
  80015. /**
  80016. * An observable triggered before computing the skeleton's matrices
  80017. */
  80018. onBeforeComputeObservable: Observable<Skeleton>;
  80019. /**
  80020. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80021. */
  80022. readonly isUsingTextureForMatrices: boolean;
  80023. /**
  80024. * Gets the unique ID of this skeleton
  80025. */
  80026. readonly uniqueId: number;
  80027. /**
  80028. * Creates a new skeleton
  80029. * @param name defines the skeleton name
  80030. * @param id defines the skeleton Id
  80031. * @param scene defines the hosting scene
  80032. */
  80033. constructor(
  80034. /** defines the skeleton name */
  80035. name: string,
  80036. /** defines the skeleton Id */
  80037. id: string, scene: Scene);
  80038. /**
  80039. * Gets the current object class name.
  80040. * @return the class name
  80041. */
  80042. getClassName(): string;
  80043. /**
  80044. * Returns an array containing the root bones
  80045. * @returns an array containing the root bones
  80046. */
  80047. getChildren(): Array<Bone>;
  80048. /**
  80049. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80050. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80051. * @returns a Float32Array containing matrices data
  80052. */
  80053. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80054. /**
  80055. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80056. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80057. * @returns a raw texture containing the data
  80058. */
  80059. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80060. /**
  80061. * Gets the current hosting scene
  80062. * @returns a scene object
  80063. */
  80064. getScene(): Scene;
  80065. /**
  80066. * Gets a string representing the current skeleton data
  80067. * @param fullDetails defines a boolean indicating if we want a verbose version
  80068. * @returns a string representing the current skeleton data
  80069. */
  80070. toString(fullDetails?: boolean): string;
  80071. /**
  80072. * Get bone's index searching by name
  80073. * @param name defines bone's name to search for
  80074. * @return the indice of the bone. Returns -1 if not found
  80075. */
  80076. getBoneIndexByName(name: string): number;
  80077. /**
  80078. * Creater a new animation range
  80079. * @param name defines the name of the range
  80080. * @param from defines the start key
  80081. * @param to defines the end key
  80082. */
  80083. createAnimationRange(name: string, from: number, to: number): void;
  80084. /**
  80085. * Delete a specific animation range
  80086. * @param name defines the name of the range
  80087. * @param deleteFrames defines if frames must be removed as well
  80088. */
  80089. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80090. /**
  80091. * Gets a specific animation range
  80092. * @param name defines the name of the range to look for
  80093. * @returns the requested animation range or null if not found
  80094. */
  80095. getAnimationRange(name: string): Nullable<AnimationRange>;
  80096. /**
  80097. * Gets the list of all animation ranges defined on this skeleton
  80098. * @returns an array
  80099. */
  80100. getAnimationRanges(): Nullable<AnimationRange>[];
  80101. /**
  80102. * Copy animation range from a source skeleton.
  80103. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80104. * @param source defines the source skeleton
  80105. * @param name defines the name of the range to copy
  80106. * @param rescaleAsRequired defines if rescaling must be applied if required
  80107. * @returns true if operation was successful
  80108. */
  80109. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80110. /**
  80111. * Forces the skeleton to go to rest pose
  80112. */
  80113. returnToRest(): void;
  80114. private _getHighestAnimationFrame;
  80115. /**
  80116. * Begin a specific animation range
  80117. * @param name defines the name of the range to start
  80118. * @param loop defines if looping must be turned on (false by default)
  80119. * @param speedRatio defines the speed ratio to apply (1 by default)
  80120. * @param onAnimationEnd defines a callback which will be called when animation will end
  80121. * @returns a new animatable
  80122. */
  80123. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80124. /** @hidden */
  80125. _markAsDirty(): void;
  80126. /** @hidden */
  80127. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80128. /** @hidden */
  80129. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80130. private _computeTransformMatrices;
  80131. /**
  80132. * Build all resources required to render a skeleton
  80133. */
  80134. prepare(): void;
  80135. /**
  80136. * Gets the list of animatables currently running for this skeleton
  80137. * @returns an array of animatables
  80138. */
  80139. getAnimatables(): IAnimatable[];
  80140. /**
  80141. * Clone the current skeleton
  80142. * @param name defines the name of the new skeleton
  80143. * @param id defines the id of the new skeleton
  80144. * @returns the new skeleton
  80145. */
  80146. clone(name: string, id: string): Skeleton;
  80147. /**
  80148. * Enable animation blending for this skeleton
  80149. * @param blendingSpeed defines the blending speed to apply
  80150. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80151. */
  80152. enableBlending(blendingSpeed?: number): void;
  80153. /**
  80154. * Releases all resources associated with the current skeleton
  80155. */
  80156. dispose(): void;
  80157. /**
  80158. * Serialize the skeleton in a JSON object
  80159. * @returns a JSON object
  80160. */
  80161. serialize(): any;
  80162. /**
  80163. * Creates a new skeleton from serialized data
  80164. * @param parsedSkeleton defines the serialized data
  80165. * @param scene defines the hosting scene
  80166. * @returns a new skeleton
  80167. */
  80168. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80169. /**
  80170. * Compute all node absolute transforms
  80171. * @param forceUpdate defines if computation must be done even if cache is up to date
  80172. */
  80173. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80174. /**
  80175. * Gets the root pose matrix
  80176. * @returns a matrix
  80177. */
  80178. getPoseMatrix(): Nullable<Matrix>;
  80179. /**
  80180. * Sorts bones per internal index
  80181. */
  80182. sortBones(): void;
  80183. private _sortBones;
  80184. }
  80185. }
  80186. declare module BABYLON {
  80187. /**
  80188. * Class used to store bone information
  80189. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80190. */
  80191. export class Bone extends Node {
  80192. /**
  80193. * defines the bone name
  80194. */
  80195. name: string;
  80196. private static _tmpVecs;
  80197. private static _tmpQuat;
  80198. private static _tmpMats;
  80199. /**
  80200. * Gets the list of child bones
  80201. */
  80202. children: Bone[];
  80203. /** Gets the animations associated with this bone */
  80204. animations: Animation[];
  80205. /**
  80206. * Gets or sets bone length
  80207. */
  80208. length: number;
  80209. /**
  80210. * @hidden Internal only
  80211. * Set this value to map this bone to a different index in the transform matrices
  80212. * Set this value to -1 to exclude the bone from the transform matrices
  80213. */
  80214. _index: Nullable<number>;
  80215. private _skeleton;
  80216. private _localMatrix;
  80217. private _restPose;
  80218. private _baseMatrix;
  80219. private _absoluteTransform;
  80220. private _invertedAbsoluteTransform;
  80221. private _parent;
  80222. private _scalingDeterminant;
  80223. private _worldTransform;
  80224. private _localScaling;
  80225. private _localRotation;
  80226. private _localPosition;
  80227. private _needToDecompose;
  80228. private _needToCompose;
  80229. /** @hidden */
  80230. _linkedTransformNode: Nullable<TransformNode>;
  80231. /** @hidden */
  80232. _waitingTransformNodeId: Nullable<string>;
  80233. /** @hidden */
  80234. /** @hidden */
  80235. _matrix: Matrix;
  80236. /**
  80237. * Create a new bone
  80238. * @param name defines the bone name
  80239. * @param skeleton defines the parent skeleton
  80240. * @param parentBone defines the parent (can be null if the bone is the root)
  80241. * @param localMatrix defines the local matrix
  80242. * @param restPose defines the rest pose matrix
  80243. * @param baseMatrix defines the base matrix
  80244. * @param index defines index of the bone in the hiearchy
  80245. */
  80246. constructor(
  80247. /**
  80248. * defines the bone name
  80249. */
  80250. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80251. /**
  80252. * Gets the current object class name.
  80253. * @return the class name
  80254. */
  80255. getClassName(): string;
  80256. /**
  80257. * Gets the parent skeleton
  80258. * @returns a skeleton
  80259. */
  80260. getSkeleton(): Skeleton;
  80261. /**
  80262. * Gets parent bone
  80263. * @returns a bone or null if the bone is the root of the bone hierarchy
  80264. */
  80265. getParent(): Nullable<Bone>;
  80266. /**
  80267. * Returns an array containing the root bones
  80268. * @returns an array containing the root bones
  80269. */
  80270. getChildren(): Array<Bone>;
  80271. /**
  80272. * Sets the parent bone
  80273. * @param parent defines the parent (can be null if the bone is the root)
  80274. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80275. */
  80276. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80277. /**
  80278. * Gets the local matrix
  80279. * @returns a matrix
  80280. */
  80281. getLocalMatrix(): Matrix;
  80282. /**
  80283. * Gets the base matrix (initial matrix which remains unchanged)
  80284. * @returns a matrix
  80285. */
  80286. getBaseMatrix(): Matrix;
  80287. /**
  80288. * Gets the rest pose matrix
  80289. * @returns a matrix
  80290. */
  80291. getRestPose(): Matrix;
  80292. /**
  80293. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80294. */
  80295. getWorldMatrix(): Matrix;
  80296. /**
  80297. * Sets the local matrix to rest pose matrix
  80298. */
  80299. returnToRest(): void;
  80300. /**
  80301. * Gets the inverse of the absolute transform matrix.
  80302. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80303. * @returns a matrix
  80304. */
  80305. getInvertedAbsoluteTransform(): Matrix;
  80306. /**
  80307. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80308. * @returns a matrix
  80309. */
  80310. getAbsoluteTransform(): Matrix;
  80311. /**
  80312. * Links with the given transform node.
  80313. * The local matrix of this bone is copied from the transform node every frame.
  80314. * @param transformNode defines the transform node to link to
  80315. */
  80316. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80317. /**
  80318. * Gets the node used to drive the bone's transformation
  80319. * @returns a transform node or null
  80320. */
  80321. getTransformNode(): Nullable<TransformNode>;
  80322. /** Gets or sets current position (in local space) */
  80323. position: Vector3;
  80324. /** Gets or sets current rotation (in local space) */
  80325. rotation: Vector3;
  80326. /** Gets or sets current rotation quaternion (in local space) */
  80327. rotationQuaternion: Quaternion;
  80328. /** Gets or sets current scaling (in local space) */
  80329. scaling: Vector3;
  80330. /**
  80331. * Gets the animation properties override
  80332. */
  80333. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80334. private _decompose;
  80335. private _compose;
  80336. /**
  80337. * Update the base and local matrices
  80338. * @param matrix defines the new base or local matrix
  80339. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80340. * @param updateLocalMatrix defines if the local matrix should be updated
  80341. */
  80342. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80343. /** @hidden */
  80344. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80345. /**
  80346. * Flag the bone as dirty (Forcing it to update everything)
  80347. */
  80348. markAsDirty(): void;
  80349. /** @hidden */
  80350. _markAsDirtyAndCompose(): void;
  80351. private _markAsDirtyAndDecompose;
  80352. /**
  80353. * Translate the bone in local or world space
  80354. * @param vec The amount to translate the bone
  80355. * @param space The space that the translation is in
  80356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80357. */
  80358. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80359. /**
  80360. * Set the postion of the bone in local or world space
  80361. * @param position The position to set the bone
  80362. * @param space The space that the position is in
  80363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80364. */
  80365. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80366. /**
  80367. * Set the absolute position of the bone (world space)
  80368. * @param position The position to set the bone
  80369. * @param mesh The mesh that this bone is attached to
  80370. */
  80371. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80372. /**
  80373. * Scale the bone on the x, y and z axes (in local space)
  80374. * @param x The amount to scale the bone on the x axis
  80375. * @param y The amount to scale the bone on the y axis
  80376. * @param z The amount to scale the bone on the z axis
  80377. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80378. */
  80379. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80380. /**
  80381. * Set the bone scaling in local space
  80382. * @param scale defines the scaling vector
  80383. */
  80384. setScale(scale: Vector3): void;
  80385. /**
  80386. * Gets the current scaling in local space
  80387. * @returns the current scaling vector
  80388. */
  80389. getScale(): Vector3;
  80390. /**
  80391. * Gets the current scaling in local space and stores it in a target vector
  80392. * @param result defines the target vector
  80393. */
  80394. getScaleToRef(result: Vector3): void;
  80395. /**
  80396. * Set the yaw, pitch, and roll of the bone in local or world space
  80397. * @param yaw The rotation of the bone on the y axis
  80398. * @param pitch The rotation of the bone on the x axis
  80399. * @param roll The rotation of the bone on the z axis
  80400. * @param space The space that the axes of rotation are in
  80401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80402. */
  80403. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80404. /**
  80405. * Add a rotation to the bone on an axis in local or world space
  80406. * @param axis The axis to rotate the bone on
  80407. * @param amount The amount to rotate the bone
  80408. * @param space The space that the axis is in
  80409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80410. */
  80411. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80412. /**
  80413. * Set the rotation of the bone to a particular axis angle in local or world space
  80414. * @param axis The axis to rotate the bone on
  80415. * @param angle The angle that the bone should be rotated to
  80416. * @param space The space that the axis is in
  80417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80418. */
  80419. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80420. /**
  80421. * Set the euler rotation of the bone in local of world space
  80422. * @param rotation The euler rotation that the bone should be set to
  80423. * @param space The space that the rotation is in
  80424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80425. */
  80426. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80427. /**
  80428. * Set the quaternion rotation of the bone in local of world space
  80429. * @param quat The quaternion rotation that the bone should be set to
  80430. * @param space The space that the rotation is in
  80431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80432. */
  80433. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80434. /**
  80435. * Set the rotation matrix of the bone in local of world space
  80436. * @param rotMat The rotation matrix that the bone should be set to
  80437. * @param space The space that the rotation is in
  80438. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80439. */
  80440. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80441. private _rotateWithMatrix;
  80442. private _getNegativeRotationToRef;
  80443. /**
  80444. * Get the position of the bone in local or world space
  80445. * @param space The space that the returned position is in
  80446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80447. * @returns The position of the bone
  80448. */
  80449. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80450. /**
  80451. * Copy the position of the bone to a vector3 in local or world space
  80452. * @param space The space that the returned position is in
  80453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80454. * @param result The vector3 to copy the position to
  80455. */
  80456. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80457. /**
  80458. * Get the absolute position of the bone (world space)
  80459. * @param mesh The mesh that this bone is attached to
  80460. * @returns The absolute position of the bone
  80461. */
  80462. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80463. /**
  80464. * Copy the absolute position of the bone (world space) to the result param
  80465. * @param mesh The mesh that this bone is attached to
  80466. * @param result The vector3 to copy the absolute position to
  80467. */
  80468. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80469. /**
  80470. * Compute the absolute transforms of this bone and its children
  80471. */
  80472. computeAbsoluteTransforms(): void;
  80473. /**
  80474. * Get the world direction from an axis that is in the local space of the bone
  80475. * @param localAxis The local direction that is used to compute the world direction
  80476. * @param mesh The mesh that this bone is attached to
  80477. * @returns The world direction
  80478. */
  80479. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80480. /**
  80481. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80482. * @param localAxis The local direction that is used to compute the world direction
  80483. * @param mesh The mesh that this bone is attached to
  80484. * @param result The vector3 that the world direction will be copied to
  80485. */
  80486. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80487. /**
  80488. * Get the euler rotation of the bone in local or world space
  80489. * @param space The space that the rotation should be in
  80490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80491. * @returns The euler rotation
  80492. */
  80493. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80494. /**
  80495. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80496. * @param space The space that the rotation should be in
  80497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80498. * @param result The vector3 that the rotation should be copied to
  80499. */
  80500. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80501. /**
  80502. * Get the quaternion rotation of the bone in either local or world space
  80503. * @param space The space that the rotation should be in
  80504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80505. * @returns The quaternion rotation
  80506. */
  80507. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80508. /**
  80509. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80510. * @param space The space that the rotation should be in
  80511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80512. * @param result The quaternion that the rotation should be copied to
  80513. */
  80514. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80515. /**
  80516. * Get the rotation matrix of the bone in local or world space
  80517. * @param space The space that the rotation should be in
  80518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80519. * @returns The rotation matrix
  80520. */
  80521. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80522. /**
  80523. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80524. * @param space The space that the rotation should be in
  80525. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80526. * @param result The quaternion that the rotation should be copied to
  80527. */
  80528. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80529. /**
  80530. * Get the world position of a point that is in the local space of the bone
  80531. * @param position The local position
  80532. * @param mesh The mesh that this bone is attached to
  80533. * @returns The world position
  80534. */
  80535. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80536. /**
  80537. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80538. * @param position The local position
  80539. * @param mesh The mesh that this bone is attached to
  80540. * @param result The vector3 that the world position should be copied to
  80541. */
  80542. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80543. /**
  80544. * Get the local position of a point that is in world space
  80545. * @param position The world position
  80546. * @param mesh The mesh that this bone is attached to
  80547. * @returns The local position
  80548. */
  80549. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80550. /**
  80551. * Get the local position of a point that is in world space and copy it to the result param
  80552. * @param position The world position
  80553. * @param mesh The mesh that this bone is attached to
  80554. * @param result The vector3 that the local position should be copied to
  80555. */
  80556. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80557. }
  80558. }
  80559. declare module BABYLON {
  80560. /**
  80561. * 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.
  80562. * @see https://doc.babylonjs.com/how_to/transformnode
  80563. */
  80564. export class TransformNode extends Node {
  80565. /**
  80566. * Object will not rotate to face the camera
  80567. */
  80568. static BILLBOARDMODE_NONE: number;
  80569. /**
  80570. * Object will rotate to face the camera but only on the x axis
  80571. */
  80572. static BILLBOARDMODE_X: number;
  80573. /**
  80574. * Object will rotate to face the camera but only on the y axis
  80575. */
  80576. static BILLBOARDMODE_Y: number;
  80577. /**
  80578. * Object will rotate to face the camera but only on the z axis
  80579. */
  80580. static BILLBOARDMODE_Z: number;
  80581. /**
  80582. * Object will rotate to face the camera
  80583. */
  80584. static BILLBOARDMODE_ALL: number;
  80585. /**
  80586. * Object will rotate to face the camera's position instead of orientation
  80587. */
  80588. static BILLBOARDMODE_USE_POSITION: number;
  80589. private _forward;
  80590. private _forwardInverted;
  80591. private _up;
  80592. private _right;
  80593. private _rightInverted;
  80594. private _position;
  80595. private _rotation;
  80596. private _rotationQuaternion;
  80597. protected _scaling: Vector3;
  80598. protected _isDirty: boolean;
  80599. private _transformToBoneReferal;
  80600. private _isAbsoluteSynced;
  80601. private _billboardMode;
  80602. /**
  80603. * Gets or sets the billboard mode. Default is 0.
  80604. *
  80605. * | Value | Type | Description |
  80606. * | --- | --- | --- |
  80607. * | 0 | BILLBOARDMODE_NONE | |
  80608. * | 1 | BILLBOARDMODE_X | |
  80609. * | 2 | BILLBOARDMODE_Y | |
  80610. * | 4 | BILLBOARDMODE_Z | |
  80611. * | 7 | BILLBOARDMODE_ALL | |
  80612. *
  80613. */
  80614. billboardMode: number;
  80615. private _preserveParentRotationForBillboard;
  80616. /**
  80617. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80618. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80619. */
  80620. preserveParentRotationForBillboard: boolean;
  80621. /**
  80622. * 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
  80623. */
  80624. scalingDeterminant: number;
  80625. private _infiniteDistance;
  80626. /**
  80627. * Gets or sets the distance of the object to max, often used by skybox
  80628. */
  80629. infiniteDistance: boolean;
  80630. /**
  80631. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80632. * By default the system will update normals to compensate
  80633. */
  80634. ignoreNonUniformScaling: boolean;
  80635. /**
  80636. * 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
  80637. */
  80638. reIntegrateRotationIntoRotationQuaternion: boolean;
  80639. /** @hidden */
  80640. _poseMatrix: Nullable<Matrix>;
  80641. /** @hidden */
  80642. _localMatrix: Matrix;
  80643. private _usePivotMatrix;
  80644. private _absolutePosition;
  80645. private _absoluteScaling;
  80646. private _absoluteRotationQuaternion;
  80647. private _pivotMatrix;
  80648. private _pivotMatrixInverse;
  80649. protected _postMultiplyPivotMatrix: boolean;
  80650. protected _isWorldMatrixFrozen: boolean;
  80651. /** @hidden */
  80652. _indexInSceneTransformNodesArray: number;
  80653. /**
  80654. * An event triggered after the world matrix is updated
  80655. */
  80656. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80657. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80658. /**
  80659. * Gets a string identifying the name of the class
  80660. * @returns "TransformNode" string
  80661. */
  80662. getClassName(): string;
  80663. /**
  80664. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80665. */
  80666. position: Vector3;
  80667. /**
  80668. * 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)).
  80669. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80670. */
  80671. rotation: Vector3;
  80672. /**
  80673. * 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)).
  80674. */
  80675. scaling: Vector3;
  80676. /**
  80677. * 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).
  80678. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80679. */
  80680. rotationQuaternion: Nullable<Quaternion>;
  80681. /**
  80682. * The forward direction of that transform in world space.
  80683. */
  80684. readonly forward: Vector3;
  80685. /**
  80686. * The up direction of that transform in world space.
  80687. */
  80688. readonly up: Vector3;
  80689. /**
  80690. * The right direction of that transform in world space.
  80691. */
  80692. readonly right: Vector3;
  80693. /**
  80694. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80695. * @param matrix the matrix to copy the pose from
  80696. * @returns this TransformNode.
  80697. */
  80698. updatePoseMatrix(matrix: Matrix): TransformNode;
  80699. /**
  80700. * Returns the mesh Pose matrix.
  80701. * @returns the pose matrix
  80702. */
  80703. getPoseMatrix(): Matrix;
  80704. /** @hidden */
  80705. _isSynchronized(): boolean;
  80706. /** @hidden */
  80707. _initCache(): void;
  80708. /**
  80709. * Flag the transform node as dirty (Forcing it to update everything)
  80710. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80711. * @returns this transform node
  80712. */
  80713. markAsDirty(property: string): TransformNode;
  80714. /**
  80715. * Returns the current mesh absolute position.
  80716. * Returns a Vector3.
  80717. */
  80718. readonly absolutePosition: Vector3;
  80719. /**
  80720. * Returns the current mesh absolute scaling.
  80721. * Returns a Vector3.
  80722. */
  80723. readonly absoluteScaling: Vector3;
  80724. /**
  80725. * Returns the current mesh absolute rotation.
  80726. * Returns a Quaternion.
  80727. */
  80728. readonly absoluteRotationQuaternion: Quaternion;
  80729. /**
  80730. * Sets a new matrix to apply before all other transformation
  80731. * @param matrix defines the transform matrix
  80732. * @returns the current TransformNode
  80733. */
  80734. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80735. /**
  80736. * Sets a new pivot matrix to the current node
  80737. * @param matrix defines the new pivot matrix to use
  80738. * @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
  80739. * @returns the current TransformNode
  80740. */
  80741. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80742. /**
  80743. * Returns the mesh pivot matrix.
  80744. * Default : Identity.
  80745. * @returns the matrix
  80746. */
  80747. getPivotMatrix(): Matrix;
  80748. /**
  80749. * Instantiate (when possible) or clone that node with its hierarchy
  80750. * @param newParent defines the new parent to use for the instance (or clone)
  80751. * @returns an instance (or a clone) of the current node with its hiearchy
  80752. */
  80753. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80754. /**
  80755. * Prevents the World matrix to be computed any longer
  80756. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80757. * @returns the TransformNode.
  80758. */
  80759. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80760. /**
  80761. * Allows back the World matrix computation.
  80762. * @returns the TransformNode.
  80763. */
  80764. unfreezeWorldMatrix(): this;
  80765. /**
  80766. * True if the World matrix has been frozen.
  80767. */
  80768. readonly isWorldMatrixFrozen: boolean;
  80769. /**
  80770. * Retuns the mesh absolute position in the World.
  80771. * @returns a Vector3.
  80772. */
  80773. getAbsolutePosition(): Vector3;
  80774. /**
  80775. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80776. * @param absolutePosition the absolute position to set
  80777. * @returns the TransformNode.
  80778. */
  80779. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80780. /**
  80781. * Sets the mesh position in its local space.
  80782. * @param vector3 the position to set in localspace
  80783. * @returns the TransformNode.
  80784. */
  80785. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80786. /**
  80787. * Returns the mesh position in the local space from the current World matrix values.
  80788. * @returns a new Vector3.
  80789. */
  80790. getPositionExpressedInLocalSpace(): Vector3;
  80791. /**
  80792. * Translates the mesh along the passed Vector3 in its local space.
  80793. * @param vector3 the distance to translate in localspace
  80794. * @returns the TransformNode.
  80795. */
  80796. locallyTranslate(vector3: Vector3): TransformNode;
  80797. private static _lookAtVectorCache;
  80798. /**
  80799. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80800. * @param targetPoint the position (must be in same space as current mesh) to look at
  80801. * @param yawCor optional yaw (y-axis) correction in radians
  80802. * @param pitchCor optional pitch (x-axis) correction in radians
  80803. * @param rollCor optional roll (z-axis) correction in radians
  80804. * @param space the choosen space of the target
  80805. * @returns the TransformNode.
  80806. */
  80807. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80808. /**
  80809. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80810. * This Vector3 is expressed in the World space.
  80811. * @param localAxis axis to rotate
  80812. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80813. */
  80814. getDirection(localAxis: Vector3): Vector3;
  80815. /**
  80816. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80817. * localAxis is expressed in the mesh local space.
  80818. * result is computed in the Wordl space from the mesh World matrix.
  80819. * @param localAxis axis to rotate
  80820. * @param result the resulting transformnode
  80821. * @returns this TransformNode.
  80822. */
  80823. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80824. /**
  80825. * Sets this transform node rotation to the given local axis.
  80826. * @param localAxis the axis in local space
  80827. * @param yawCor optional yaw (y-axis) correction in radians
  80828. * @param pitchCor optional pitch (x-axis) correction in radians
  80829. * @param rollCor optional roll (z-axis) correction in radians
  80830. * @returns this TransformNode
  80831. */
  80832. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80833. /**
  80834. * Sets a new pivot point to the current node
  80835. * @param point defines the new pivot point to use
  80836. * @param space defines if the point is in world or local space (local by default)
  80837. * @returns the current TransformNode
  80838. */
  80839. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80840. /**
  80841. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80842. * @returns the pivot point
  80843. */
  80844. getPivotPoint(): Vector3;
  80845. /**
  80846. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80847. * @param result the vector3 to store the result
  80848. * @returns this TransformNode.
  80849. */
  80850. getPivotPointToRef(result: Vector3): TransformNode;
  80851. /**
  80852. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80853. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80854. */
  80855. getAbsolutePivotPoint(): Vector3;
  80856. /**
  80857. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80858. * @param result vector3 to store the result
  80859. * @returns this TransformNode.
  80860. */
  80861. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80862. /**
  80863. * Defines the passed node as the parent of the current node.
  80864. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80865. * @see https://doc.babylonjs.com/how_to/parenting
  80866. * @param node the node ot set as the parent
  80867. * @returns this TransformNode.
  80868. */
  80869. setParent(node: Nullable<Node>): TransformNode;
  80870. private _nonUniformScaling;
  80871. /**
  80872. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80873. */
  80874. readonly nonUniformScaling: boolean;
  80875. /** @hidden */
  80876. _updateNonUniformScalingState(value: boolean): boolean;
  80877. /**
  80878. * Attach the current TransformNode to another TransformNode associated with a bone
  80879. * @param bone Bone affecting the TransformNode
  80880. * @param affectedTransformNode TransformNode associated with the bone
  80881. * @returns this object
  80882. */
  80883. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80884. /**
  80885. * Detach the transform node if its associated with a bone
  80886. * @returns this object
  80887. */
  80888. detachFromBone(): TransformNode;
  80889. private static _rotationAxisCache;
  80890. /**
  80891. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80892. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80893. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80894. * The passed axis is also normalized.
  80895. * @param axis the axis to rotate around
  80896. * @param amount the amount to rotate in radians
  80897. * @param space Space to rotate in (Default: local)
  80898. * @returns the TransformNode.
  80899. */
  80900. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80901. /**
  80902. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80903. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80904. * The passed axis is also normalized. .
  80905. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80906. * @param point the point to rotate around
  80907. * @param axis the axis to rotate around
  80908. * @param amount the amount to rotate in radians
  80909. * @returns the TransformNode
  80910. */
  80911. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80912. /**
  80913. * Translates the mesh along the axis vector for the passed distance in the given space.
  80914. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80915. * @param axis the axis to translate in
  80916. * @param distance the distance to translate
  80917. * @param space Space to rotate in (Default: local)
  80918. * @returns the TransformNode.
  80919. */
  80920. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80921. /**
  80922. * Adds a rotation step to the mesh current rotation.
  80923. * x, y, z are Euler angles expressed in radians.
  80924. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80925. * This means this rotation is made in the mesh local space only.
  80926. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80927. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80928. * ```javascript
  80929. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80930. * ```
  80931. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80932. * 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.
  80933. * @param x Rotation to add
  80934. * @param y Rotation to add
  80935. * @param z Rotation to add
  80936. * @returns the TransformNode.
  80937. */
  80938. addRotation(x: number, y: number, z: number): TransformNode;
  80939. /**
  80940. * @hidden
  80941. */
  80942. protected _getEffectiveParent(): Nullable<Node>;
  80943. /**
  80944. * Computes the world matrix of the node
  80945. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80946. * @returns the world matrix
  80947. */
  80948. computeWorldMatrix(force?: boolean): Matrix;
  80949. protected _afterComputeWorldMatrix(): void;
  80950. /**
  80951. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80952. * @param func callback function to add
  80953. *
  80954. * @returns the TransformNode.
  80955. */
  80956. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80957. /**
  80958. * Removes a registered callback function.
  80959. * @param func callback function to remove
  80960. * @returns the TransformNode.
  80961. */
  80962. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80963. /**
  80964. * Gets the position of the current mesh in camera space
  80965. * @param camera defines the camera to use
  80966. * @returns a position
  80967. */
  80968. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80969. /**
  80970. * Returns the distance from the mesh to the active camera
  80971. * @param camera defines the camera to use
  80972. * @returns the distance
  80973. */
  80974. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80975. /**
  80976. * Clone the current transform node
  80977. * @param name Name of the new clone
  80978. * @param newParent New parent for the clone
  80979. * @param doNotCloneChildren Do not clone children hierarchy
  80980. * @returns the new transform node
  80981. */
  80982. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80983. /**
  80984. * Serializes the objects information.
  80985. * @param currentSerializationObject defines the object to serialize in
  80986. * @returns the serialized object
  80987. */
  80988. serialize(currentSerializationObject?: any): any;
  80989. /**
  80990. * Returns a new TransformNode object parsed from the source provided.
  80991. * @param parsedTransformNode is the source.
  80992. * @param scene the scne the object belongs to
  80993. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80994. * @returns a new TransformNode object parsed from the source provided.
  80995. */
  80996. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80997. /**
  80998. * Get all child-transformNodes of this node
  80999. * @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
  81000. * @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
  81001. * @returns an array of TransformNode
  81002. */
  81003. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81004. /**
  81005. * Releases resources associated with this transform node.
  81006. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81007. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81008. */
  81009. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81010. /**
  81011. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81012. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81013. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81014. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81015. * @returns the current mesh
  81016. */
  81017. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81018. private _syncAbsoluteScalingAndRotation;
  81019. }
  81020. }
  81021. declare module BABYLON {
  81022. /**
  81023. * Defines the types of pose enabled controllers that are supported
  81024. */
  81025. export enum PoseEnabledControllerType {
  81026. /**
  81027. * HTC Vive
  81028. */
  81029. VIVE = 0,
  81030. /**
  81031. * Oculus Rift
  81032. */
  81033. OCULUS = 1,
  81034. /**
  81035. * Windows mixed reality
  81036. */
  81037. WINDOWS = 2,
  81038. /**
  81039. * Samsung gear VR
  81040. */
  81041. GEAR_VR = 3,
  81042. /**
  81043. * Google Daydream
  81044. */
  81045. DAYDREAM = 4,
  81046. /**
  81047. * Generic
  81048. */
  81049. GENERIC = 5
  81050. }
  81051. /**
  81052. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81053. */
  81054. export interface MutableGamepadButton {
  81055. /**
  81056. * Value of the button/trigger
  81057. */
  81058. value: number;
  81059. /**
  81060. * If the button/trigger is currently touched
  81061. */
  81062. touched: boolean;
  81063. /**
  81064. * If the button/trigger is currently pressed
  81065. */
  81066. pressed: boolean;
  81067. }
  81068. /**
  81069. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81070. * @hidden
  81071. */
  81072. export interface ExtendedGamepadButton extends GamepadButton {
  81073. /**
  81074. * If the button/trigger is currently pressed
  81075. */
  81076. readonly pressed: boolean;
  81077. /**
  81078. * If the button/trigger is currently touched
  81079. */
  81080. readonly touched: boolean;
  81081. /**
  81082. * Value of the button/trigger
  81083. */
  81084. readonly value: number;
  81085. }
  81086. /** @hidden */
  81087. export interface _GamePadFactory {
  81088. /**
  81089. * Returns wether or not the current gamepad can be created for this type of controller.
  81090. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81091. * @returns true if it can be created, otherwise false
  81092. */
  81093. canCreate(gamepadInfo: any): boolean;
  81094. /**
  81095. * Creates a new instance of the Gamepad.
  81096. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81097. * @returns the new gamepad instance
  81098. */
  81099. create(gamepadInfo: any): Gamepad;
  81100. }
  81101. /**
  81102. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81103. */
  81104. export class PoseEnabledControllerHelper {
  81105. /** @hidden */
  81106. static _ControllerFactories: _GamePadFactory[];
  81107. /** @hidden */
  81108. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81109. /**
  81110. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81111. * @param vrGamepad the gamepad to initialized
  81112. * @returns a vr controller of the type the gamepad identified as
  81113. */
  81114. static InitiateController(vrGamepad: any): Gamepad;
  81115. }
  81116. /**
  81117. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81118. */
  81119. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81120. /**
  81121. * If the controller is used in a webXR session
  81122. */
  81123. isXR: boolean;
  81124. private _deviceRoomPosition;
  81125. private _deviceRoomRotationQuaternion;
  81126. /**
  81127. * The device position in babylon space
  81128. */
  81129. devicePosition: Vector3;
  81130. /**
  81131. * The device rotation in babylon space
  81132. */
  81133. deviceRotationQuaternion: Quaternion;
  81134. /**
  81135. * The scale factor of the device in babylon space
  81136. */
  81137. deviceScaleFactor: number;
  81138. /**
  81139. * (Likely devicePosition should be used instead) The device position in its room space
  81140. */
  81141. position: Vector3;
  81142. /**
  81143. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81144. */
  81145. rotationQuaternion: Quaternion;
  81146. /**
  81147. * The type of controller (Eg. Windows mixed reality)
  81148. */
  81149. controllerType: PoseEnabledControllerType;
  81150. protected _calculatedPosition: Vector3;
  81151. private _calculatedRotation;
  81152. /**
  81153. * The raw pose from the device
  81154. */
  81155. rawPose: DevicePose;
  81156. private _trackPosition;
  81157. private _maxRotationDistFromHeadset;
  81158. private _draggedRoomRotation;
  81159. /**
  81160. * @hidden
  81161. */
  81162. _disableTrackPosition(fixedPosition: Vector3): void;
  81163. /**
  81164. * Internal, the mesh attached to the controller
  81165. * @hidden
  81166. */
  81167. _mesh: Nullable<AbstractMesh>;
  81168. private _poseControlledCamera;
  81169. private _leftHandSystemQuaternion;
  81170. /**
  81171. * Internal, matrix used to convert room space to babylon space
  81172. * @hidden
  81173. */
  81174. _deviceToWorld: Matrix;
  81175. /**
  81176. * Node to be used when casting a ray from the controller
  81177. * @hidden
  81178. */
  81179. _pointingPoseNode: Nullable<TransformNode>;
  81180. /**
  81181. * Name of the child mesh that can be used to cast a ray from the controller
  81182. */
  81183. static readonly POINTING_POSE: string;
  81184. /**
  81185. * Creates a new PoseEnabledController from a gamepad
  81186. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81187. */
  81188. constructor(browserGamepad: any);
  81189. private _workingMatrix;
  81190. /**
  81191. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81192. */
  81193. update(): void;
  81194. /**
  81195. * Updates only the pose device and mesh without doing any button event checking
  81196. */
  81197. protected _updatePoseAndMesh(): void;
  81198. /**
  81199. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81200. * @param poseData raw pose fromthe device
  81201. */
  81202. updateFromDevice(poseData: DevicePose): void;
  81203. /**
  81204. * @hidden
  81205. */
  81206. _meshAttachedObservable: Observable<AbstractMesh>;
  81207. /**
  81208. * Attaches a mesh to the controller
  81209. * @param mesh the mesh to be attached
  81210. */
  81211. attachToMesh(mesh: AbstractMesh): void;
  81212. /**
  81213. * Attaches the controllers mesh to a camera
  81214. * @param camera the camera the mesh should be attached to
  81215. */
  81216. attachToPoseControlledCamera(camera: TargetCamera): void;
  81217. /**
  81218. * Disposes of the controller
  81219. */
  81220. dispose(): void;
  81221. /**
  81222. * The mesh that is attached to the controller
  81223. */
  81224. readonly mesh: Nullable<AbstractMesh>;
  81225. /**
  81226. * Gets the ray of the controller in the direction the controller is pointing
  81227. * @param length the length the resulting ray should be
  81228. * @returns a ray in the direction the controller is pointing
  81229. */
  81230. getForwardRay(length?: number): Ray;
  81231. }
  81232. }
  81233. declare module BABYLON {
  81234. /**
  81235. * Defines the WebVRController object that represents controllers tracked in 3D space
  81236. */
  81237. export abstract class WebVRController extends PoseEnabledController {
  81238. /**
  81239. * Internal, the default controller model for the controller
  81240. */
  81241. protected _defaultModel: Nullable<AbstractMesh>;
  81242. /**
  81243. * Fired when the trigger state has changed
  81244. */
  81245. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81246. /**
  81247. * Fired when the main button state has changed
  81248. */
  81249. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81250. /**
  81251. * Fired when the secondary button state has changed
  81252. */
  81253. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81254. /**
  81255. * Fired when the pad state has changed
  81256. */
  81257. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81258. /**
  81259. * Fired when controllers stick values have changed
  81260. */
  81261. onPadValuesChangedObservable: Observable<StickValues>;
  81262. /**
  81263. * Array of button availible on the controller
  81264. */
  81265. protected _buttons: Array<MutableGamepadButton>;
  81266. private _onButtonStateChange;
  81267. /**
  81268. * Fired when a controller button's state has changed
  81269. * @param callback the callback containing the button that was modified
  81270. */
  81271. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81272. /**
  81273. * X and Y axis corresponding to the controllers joystick
  81274. */
  81275. pad: StickValues;
  81276. /**
  81277. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81278. */
  81279. hand: string;
  81280. /**
  81281. * The default controller model for the controller
  81282. */
  81283. readonly defaultModel: Nullable<AbstractMesh>;
  81284. /**
  81285. * Creates a new WebVRController from a gamepad
  81286. * @param vrGamepad the gamepad that the WebVRController should be created from
  81287. */
  81288. constructor(vrGamepad: any);
  81289. /**
  81290. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81291. */
  81292. update(): void;
  81293. /**
  81294. * Function to be called when a button is modified
  81295. */
  81296. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81297. /**
  81298. * Loads a mesh and attaches it to the controller
  81299. * @param scene the scene the mesh should be added to
  81300. * @param meshLoaded callback for when the mesh has been loaded
  81301. */
  81302. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81303. private _setButtonValue;
  81304. private _changes;
  81305. private _checkChanges;
  81306. /**
  81307. * Disposes of th webVRCOntroller
  81308. */
  81309. dispose(): void;
  81310. }
  81311. }
  81312. declare module BABYLON {
  81313. /**
  81314. * The HemisphericLight simulates the ambient environment light,
  81315. * so the passed direction is the light reflection direction, not the incoming direction.
  81316. */
  81317. export class HemisphericLight extends Light {
  81318. /**
  81319. * The groundColor is the light in the opposite direction to the one specified during creation.
  81320. * 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.
  81321. */
  81322. groundColor: Color3;
  81323. /**
  81324. * The light reflection direction, not the incoming direction.
  81325. */
  81326. direction: Vector3;
  81327. /**
  81328. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81329. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81330. * The HemisphericLight can't cast shadows.
  81331. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81332. * @param name The friendly name of the light
  81333. * @param direction The direction of the light reflection
  81334. * @param scene The scene the light belongs to
  81335. */
  81336. constructor(name: string, direction: Vector3, scene: Scene);
  81337. protected _buildUniformLayout(): void;
  81338. /**
  81339. * Returns the string "HemisphericLight".
  81340. * @return The class name
  81341. */
  81342. getClassName(): string;
  81343. /**
  81344. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81345. * Returns the updated direction.
  81346. * @param target The target the direction should point to
  81347. * @return The computed direction
  81348. */
  81349. setDirectionToTarget(target: Vector3): Vector3;
  81350. /**
  81351. * Returns the shadow generator associated to the light.
  81352. * @returns Always null for hemispheric lights because it does not support shadows.
  81353. */
  81354. getShadowGenerator(): Nullable<IShadowGenerator>;
  81355. /**
  81356. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81357. * @param effect The effect to update
  81358. * @param lightIndex The index of the light in the effect to update
  81359. * @returns The hemispheric light
  81360. */
  81361. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81362. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81363. /**
  81364. * Computes the world matrix of the node
  81365. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81366. * @param useWasUpdatedFlag defines a reserved property
  81367. * @returns the world matrix
  81368. */
  81369. computeWorldMatrix(): Matrix;
  81370. /**
  81371. * Returns the integer 3.
  81372. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81373. */
  81374. getTypeID(): number;
  81375. /**
  81376. * Prepares the list of defines specific to the light type.
  81377. * @param defines the list of defines
  81378. * @param lightIndex defines the index of the light for the effect
  81379. */
  81380. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81381. }
  81382. }
  81383. declare module BABYLON {
  81384. /** @hidden */
  81385. export var vrMultiviewToSingleviewPixelShader: {
  81386. name: string;
  81387. shader: string;
  81388. };
  81389. }
  81390. declare module BABYLON {
  81391. /**
  81392. * Renders to multiple views with a single draw call
  81393. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81394. */
  81395. export class MultiviewRenderTarget extends RenderTargetTexture {
  81396. /**
  81397. * Creates a multiview render target
  81398. * @param scene scene used with the render target
  81399. * @param size the size of the render target (used for each view)
  81400. */
  81401. constructor(scene: Scene, size?: number | {
  81402. width: number;
  81403. height: number;
  81404. } | {
  81405. ratio: number;
  81406. });
  81407. /**
  81408. * @hidden
  81409. * @param faceIndex the face index, if its a cube texture
  81410. */
  81411. _bindFrameBuffer(faceIndex?: number): void;
  81412. /**
  81413. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81414. * @returns the view count
  81415. */
  81416. getViewCount(): number;
  81417. }
  81418. }
  81419. declare module BABYLON {
  81420. /**
  81421. * Represents a camera frustum
  81422. */
  81423. export class Frustum {
  81424. /**
  81425. * Gets the planes representing the frustum
  81426. * @param transform matrix to be applied to the returned planes
  81427. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81428. */
  81429. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81430. /**
  81431. * Gets the near frustum plane transformed by the transform matrix
  81432. * @param transform transformation matrix to be applied to the resulting frustum plane
  81433. * @param frustumPlane the resuling frustum plane
  81434. */
  81435. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81436. /**
  81437. * Gets the far frustum plane transformed by the transform matrix
  81438. * @param transform transformation matrix to be applied to the resulting frustum plane
  81439. * @param frustumPlane the resuling frustum plane
  81440. */
  81441. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81442. /**
  81443. * Gets the left frustum plane transformed by the transform matrix
  81444. * @param transform transformation matrix to be applied to the resulting frustum plane
  81445. * @param frustumPlane the resuling frustum plane
  81446. */
  81447. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81448. /**
  81449. * Gets the right frustum plane transformed by the transform matrix
  81450. * @param transform transformation matrix to be applied to the resulting frustum plane
  81451. * @param frustumPlane the resuling frustum plane
  81452. */
  81453. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81454. /**
  81455. * Gets the top frustum plane transformed by the transform matrix
  81456. * @param transform transformation matrix to be applied to the resulting frustum plane
  81457. * @param frustumPlane the resuling frustum plane
  81458. */
  81459. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81460. /**
  81461. * Gets the bottom frustum plane transformed by the transform matrix
  81462. * @param transform transformation matrix to be applied to the resulting frustum plane
  81463. * @param frustumPlane the resuling frustum plane
  81464. */
  81465. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81466. /**
  81467. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81468. * @param transform transformation matrix to be applied to the resulting frustum planes
  81469. * @param frustumPlanes the resuling frustum planes
  81470. */
  81471. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81472. }
  81473. }
  81474. declare module BABYLON {
  81475. interface Engine {
  81476. /**
  81477. * Creates a new multiview render target
  81478. * @param width defines the width of the texture
  81479. * @param height defines the height of the texture
  81480. * @returns the created multiview texture
  81481. */
  81482. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81483. /**
  81484. * Binds a multiview framebuffer to be drawn to
  81485. * @param multiviewTexture texture to bind
  81486. */
  81487. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81488. }
  81489. interface Camera {
  81490. /**
  81491. * @hidden
  81492. * 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)
  81493. */
  81494. _useMultiviewToSingleView: boolean;
  81495. /**
  81496. * @hidden
  81497. * 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)
  81498. */
  81499. _multiviewTexture: Nullable<RenderTargetTexture>;
  81500. /**
  81501. * @hidden
  81502. * ensures the multiview texture of the camera exists and has the specified width/height
  81503. * @param width height to set on the multiview texture
  81504. * @param height width to set on the multiview texture
  81505. */
  81506. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81507. }
  81508. interface Scene {
  81509. /** @hidden */
  81510. _transformMatrixR: Matrix;
  81511. /** @hidden */
  81512. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81513. /** @hidden */
  81514. _createMultiviewUbo(): void;
  81515. /** @hidden */
  81516. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81517. /** @hidden */
  81518. _renderMultiviewToSingleView(camera: Camera): void;
  81519. }
  81520. }
  81521. declare module BABYLON {
  81522. /**
  81523. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81524. * This will not be used for webXR as it supports displaying texture arrays directly
  81525. */
  81526. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81527. /**
  81528. * Initializes a VRMultiviewToSingleview
  81529. * @param name name of the post process
  81530. * @param camera camera to be applied to
  81531. * @param scaleFactor scaling factor to the size of the output texture
  81532. */
  81533. constructor(name: string, camera: Camera, scaleFactor: number);
  81534. }
  81535. }
  81536. declare module BABYLON {
  81537. interface Engine {
  81538. /** @hidden */
  81539. _vrDisplay: any;
  81540. /** @hidden */
  81541. _vrSupported: boolean;
  81542. /** @hidden */
  81543. _oldSize: Size;
  81544. /** @hidden */
  81545. _oldHardwareScaleFactor: number;
  81546. /** @hidden */
  81547. _vrExclusivePointerMode: boolean;
  81548. /** @hidden */
  81549. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81550. /** @hidden */
  81551. _onVRDisplayPointerRestricted: () => void;
  81552. /** @hidden */
  81553. _onVRDisplayPointerUnrestricted: () => void;
  81554. /** @hidden */
  81555. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81556. /** @hidden */
  81557. _onVrDisplayDisconnect: Nullable<() => void>;
  81558. /** @hidden */
  81559. _onVrDisplayPresentChange: Nullable<() => void>;
  81560. /**
  81561. * Observable signaled when VR display mode changes
  81562. */
  81563. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81564. /**
  81565. * Observable signaled when VR request present is complete
  81566. */
  81567. onVRRequestPresentComplete: Observable<boolean>;
  81568. /**
  81569. * Observable signaled when VR request present starts
  81570. */
  81571. onVRRequestPresentStart: Observable<Engine>;
  81572. /**
  81573. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81574. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81575. */
  81576. isInVRExclusivePointerMode: boolean;
  81577. /**
  81578. * Gets a boolean indicating if a webVR device was detected
  81579. * @returns true if a webVR device was detected
  81580. */
  81581. isVRDevicePresent(): boolean;
  81582. /**
  81583. * Gets the current webVR device
  81584. * @returns the current webVR device (or null)
  81585. */
  81586. getVRDevice(): any;
  81587. /**
  81588. * Initializes a webVR display and starts listening to display change events
  81589. * The onVRDisplayChangedObservable will be notified upon these changes
  81590. * @returns A promise containing a VRDisplay and if vr is supported
  81591. */
  81592. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81593. /** @hidden */
  81594. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81595. /**
  81596. * Call this function to switch to webVR mode
  81597. * Will do nothing if webVR is not supported or if there is no webVR device
  81598. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81599. */
  81600. enableVR(): void;
  81601. /** @hidden */
  81602. _onVRFullScreenTriggered(): void;
  81603. }
  81604. }
  81605. declare module BABYLON {
  81606. /**
  81607. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81608. * IMPORTANT!! The data is right-hand data.
  81609. * @export
  81610. * @interface DevicePose
  81611. */
  81612. export interface DevicePose {
  81613. /**
  81614. * The position of the device, values in array are [x,y,z].
  81615. */
  81616. readonly position: Nullable<Float32Array>;
  81617. /**
  81618. * The linearVelocity of the device, values in array are [x,y,z].
  81619. */
  81620. readonly linearVelocity: Nullable<Float32Array>;
  81621. /**
  81622. * The linearAcceleration of the device, values in array are [x,y,z].
  81623. */
  81624. readonly linearAcceleration: Nullable<Float32Array>;
  81625. /**
  81626. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81627. */
  81628. readonly orientation: Nullable<Float32Array>;
  81629. /**
  81630. * The angularVelocity of the device, values in array are [x,y,z].
  81631. */
  81632. readonly angularVelocity: Nullable<Float32Array>;
  81633. /**
  81634. * The angularAcceleration of the device, values in array are [x,y,z].
  81635. */
  81636. readonly angularAcceleration: Nullable<Float32Array>;
  81637. }
  81638. /**
  81639. * Interface representing a pose controlled object in Babylon.
  81640. * A pose controlled object has both regular pose values as well as pose values
  81641. * from an external device such as a VR head mounted display
  81642. */
  81643. export interface PoseControlled {
  81644. /**
  81645. * The position of the object in babylon space.
  81646. */
  81647. position: Vector3;
  81648. /**
  81649. * The rotation quaternion of the object in babylon space.
  81650. */
  81651. rotationQuaternion: Quaternion;
  81652. /**
  81653. * The position of the device in babylon space.
  81654. */
  81655. devicePosition?: Vector3;
  81656. /**
  81657. * The rotation quaternion of the device in babylon space.
  81658. */
  81659. deviceRotationQuaternion: Quaternion;
  81660. /**
  81661. * The raw pose coming from the device.
  81662. */
  81663. rawPose: Nullable<DevicePose>;
  81664. /**
  81665. * The scale of the device to be used when translating from device space to babylon space.
  81666. */
  81667. deviceScaleFactor: number;
  81668. /**
  81669. * Updates the poseControlled values based on the input device pose.
  81670. * @param poseData the pose data to update the object with
  81671. */
  81672. updateFromDevice(poseData: DevicePose): void;
  81673. }
  81674. /**
  81675. * Set of options to customize the webVRCamera
  81676. */
  81677. export interface WebVROptions {
  81678. /**
  81679. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81680. */
  81681. trackPosition?: boolean;
  81682. /**
  81683. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81684. */
  81685. positionScale?: number;
  81686. /**
  81687. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81688. */
  81689. displayName?: string;
  81690. /**
  81691. * Should the native controller meshes be initialized. (default: true)
  81692. */
  81693. controllerMeshes?: boolean;
  81694. /**
  81695. * Creating a default HemiLight only on controllers. (default: true)
  81696. */
  81697. defaultLightingOnControllers?: boolean;
  81698. /**
  81699. * If you don't want to use the default VR button of the helper. (default: false)
  81700. */
  81701. useCustomVRButton?: boolean;
  81702. /**
  81703. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81704. */
  81705. customVRButton?: HTMLButtonElement;
  81706. /**
  81707. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81708. */
  81709. rayLength?: number;
  81710. /**
  81711. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81712. */
  81713. defaultHeight?: number;
  81714. /**
  81715. * If multiview should be used if availible (default: false)
  81716. */
  81717. useMultiview?: boolean;
  81718. }
  81719. /**
  81720. * This represents a WebVR camera.
  81721. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81722. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81723. */
  81724. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81725. private webVROptions;
  81726. /**
  81727. * @hidden
  81728. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81729. */
  81730. _vrDevice: any;
  81731. /**
  81732. * The rawPose of the vrDevice.
  81733. */
  81734. rawPose: Nullable<DevicePose>;
  81735. private _onVREnabled;
  81736. private _specsVersion;
  81737. private _attached;
  81738. private _frameData;
  81739. protected _descendants: Array<Node>;
  81740. private _deviceRoomPosition;
  81741. /** @hidden */
  81742. _deviceRoomRotationQuaternion: Quaternion;
  81743. private _standingMatrix;
  81744. /**
  81745. * Represents device position in babylon space.
  81746. */
  81747. devicePosition: Vector3;
  81748. /**
  81749. * Represents device rotation in babylon space.
  81750. */
  81751. deviceRotationQuaternion: Quaternion;
  81752. /**
  81753. * The scale of the device to be used when translating from device space to babylon space.
  81754. */
  81755. deviceScaleFactor: number;
  81756. private _deviceToWorld;
  81757. private _worldToDevice;
  81758. /**
  81759. * References to the webVR controllers for the vrDevice.
  81760. */
  81761. controllers: Array<WebVRController>;
  81762. /**
  81763. * Emits an event when a controller is attached.
  81764. */
  81765. onControllersAttachedObservable: Observable<WebVRController[]>;
  81766. /**
  81767. * Emits an event when a controller's mesh has been loaded;
  81768. */
  81769. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81770. /**
  81771. * Emits an event when the HMD's pose has been updated.
  81772. */
  81773. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81774. private _poseSet;
  81775. /**
  81776. * If the rig cameras be used as parent instead of this camera.
  81777. */
  81778. rigParenting: boolean;
  81779. private _lightOnControllers;
  81780. private _defaultHeight?;
  81781. /**
  81782. * Instantiates a WebVRFreeCamera.
  81783. * @param name The name of the WebVRFreeCamera
  81784. * @param position The starting anchor position for the camera
  81785. * @param scene The scene the camera belongs to
  81786. * @param webVROptions a set of customizable options for the webVRCamera
  81787. */
  81788. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81789. /**
  81790. * Gets the device distance from the ground in meters.
  81791. * @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.
  81792. */
  81793. deviceDistanceToRoomGround(): number;
  81794. /**
  81795. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81796. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81797. */
  81798. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81799. /**
  81800. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81801. * @returns A promise with a boolean set to if the standing matrix is supported.
  81802. */
  81803. useStandingMatrixAsync(): Promise<boolean>;
  81804. /**
  81805. * Disposes the camera
  81806. */
  81807. dispose(): void;
  81808. /**
  81809. * Gets a vrController by name.
  81810. * @param name The name of the controller to retreive
  81811. * @returns the controller matching the name specified or null if not found
  81812. */
  81813. getControllerByName(name: string): Nullable<WebVRController>;
  81814. private _leftController;
  81815. /**
  81816. * The controller corresponding to the users left hand.
  81817. */
  81818. readonly leftController: Nullable<WebVRController>;
  81819. private _rightController;
  81820. /**
  81821. * The controller corresponding to the users right hand.
  81822. */
  81823. readonly rightController: Nullable<WebVRController>;
  81824. /**
  81825. * Casts a ray forward from the vrCamera's gaze.
  81826. * @param length Length of the ray (default: 100)
  81827. * @returns the ray corresponding to the gaze
  81828. */
  81829. getForwardRay(length?: number): Ray;
  81830. /**
  81831. * @hidden
  81832. * Updates the camera based on device's frame data
  81833. */
  81834. _checkInputs(): void;
  81835. /**
  81836. * Updates the poseControlled values based on the input device pose.
  81837. * @param poseData Pose coming from the device
  81838. */
  81839. updateFromDevice(poseData: DevicePose): void;
  81840. private _htmlElementAttached;
  81841. private _detachIfAttached;
  81842. /**
  81843. * WebVR's attach control will start broadcasting frames to the device.
  81844. * Note that in certain browsers (chrome for example) this function must be called
  81845. * within a user-interaction callback. Example:
  81846. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81847. *
  81848. * @param element html element to attach the vrDevice to
  81849. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81850. */
  81851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81852. /**
  81853. * Detaches the camera from the html element and disables VR
  81854. *
  81855. * @param element html element to detach from
  81856. */
  81857. detachControl(element: HTMLElement): void;
  81858. /**
  81859. * @returns the name of this class
  81860. */
  81861. getClassName(): string;
  81862. /**
  81863. * Calls resetPose on the vrDisplay
  81864. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81865. */
  81866. resetToCurrentRotation(): void;
  81867. /**
  81868. * @hidden
  81869. * Updates the rig cameras (left and right eye)
  81870. */
  81871. _updateRigCameras(): void;
  81872. private _workingVector;
  81873. private _oneVector;
  81874. private _workingMatrix;
  81875. private updateCacheCalled;
  81876. private _correctPositionIfNotTrackPosition;
  81877. /**
  81878. * @hidden
  81879. * Updates the cached values of the camera
  81880. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81881. */
  81882. _updateCache(ignoreParentClass?: boolean): void;
  81883. /**
  81884. * @hidden
  81885. * Get current device position in babylon world
  81886. */
  81887. _computeDevicePosition(): void;
  81888. /**
  81889. * Updates the current device position and rotation in the babylon world
  81890. */
  81891. update(): void;
  81892. /**
  81893. * @hidden
  81894. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81895. * @returns an identity matrix
  81896. */
  81897. _getViewMatrix(): Matrix;
  81898. private _tmpMatrix;
  81899. /**
  81900. * This function is called by the two RIG cameras.
  81901. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81902. * @hidden
  81903. */
  81904. _getWebVRViewMatrix(): Matrix;
  81905. /** @hidden */
  81906. _getWebVRProjectionMatrix(): Matrix;
  81907. private _onGamepadConnectedObserver;
  81908. private _onGamepadDisconnectedObserver;
  81909. private _updateCacheWhenTrackingDisabledObserver;
  81910. /**
  81911. * Initializes the controllers and their meshes
  81912. */
  81913. initControllers(): void;
  81914. }
  81915. }
  81916. declare module BABYLON {
  81917. /**
  81918. * Size options for a post process
  81919. */
  81920. export type PostProcessOptions = {
  81921. width: number;
  81922. height: number;
  81923. };
  81924. /**
  81925. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81926. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81927. */
  81928. export class PostProcess {
  81929. /** Name of the PostProcess. */
  81930. name: string;
  81931. /**
  81932. * Gets or sets the unique id of the post process
  81933. */
  81934. uniqueId: number;
  81935. /**
  81936. * Width of the texture to apply the post process on
  81937. */
  81938. width: number;
  81939. /**
  81940. * Height of the texture to apply the post process on
  81941. */
  81942. height: number;
  81943. /**
  81944. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81945. * @hidden
  81946. */
  81947. _outputTexture: Nullable<InternalTexture>;
  81948. /**
  81949. * Sampling mode used by the shader
  81950. * See https://doc.babylonjs.com/classes/3.1/texture
  81951. */
  81952. renderTargetSamplingMode: number;
  81953. /**
  81954. * Clear color to use when screen clearing
  81955. */
  81956. clearColor: Color4;
  81957. /**
  81958. * If the buffer needs to be cleared before applying the post process. (default: true)
  81959. * Should be set to false if shader will overwrite all previous pixels.
  81960. */
  81961. autoClear: boolean;
  81962. /**
  81963. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81964. */
  81965. alphaMode: number;
  81966. /**
  81967. * Sets the setAlphaBlendConstants of the babylon engine
  81968. */
  81969. alphaConstants: Color4;
  81970. /**
  81971. * Animations to be used for the post processing
  81972. */
  81973. animations: Animation[];
  81974. /**
  81975. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81976. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81977. */
  81978. enablePixelPerfectMode: boolean;
  81979. /**
  81980. * Force the postprocess to be applied without taking in account viewport
  81981. */
  81982. forceFullscreenViewport: boolean;
  81983. /**
  81984. * List of inspectable custom properties (used by the Inspector)
  81985. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81986. */
  81987. inspectableCustomProperties: IInspectable[];
  81988. /**
  81989. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81990. *
  81991. * | Value | Type | Description |
  81992. * | ----- | ----------------------------------- | ----------- |
  81993. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81994. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81995. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81996. *
  81997. */
  81998. scaleMode: number;
  81999. /**
  82000. * Force textures to be a power of two (default: false)
  82001. */
  82002. alwaysForcePOT: boolean;
  82003. private _samples;
  82004. /**
  82005. * Number of sample textures (default: 1)
  82006. */
  82007. samples: number;
  82008. /**
  82009. * Modify the scale of the post process to be the same as the viewport (default: false)
  82010. */
  82011. adaptScaleToCurrentViewport: boolean;
  82012. private _camera;
  82013. private _scene;
  82014. private _engine;
  82015. private _options;
  82016. private _reusable;
  82017. private _textureType;
  82018. /**
  82019. * Smart array of input and output textures for the post process.
  82020. * @hidden
  82021. */
  82022. _textures: SmartArray<InternalTexture>;
  82023. /**
  82024. * The index in _textures that corresponds to the output texture.
  82025. * @hidden
  82026. */
  82027. _currentRenderTextureInd: number;
  82028. private _effect;
  82029. private _samplers;
  82030. private _fragmentUrl;
  82031. private _vertexUrl;
  82032. private _parameters;
  82033. private _scaleRatio;
  82034. protected _indexParameters: any;
  82035. private _shareOutputWithPostProcess;
  82036. private _texelSize;
  82037. private _forcedOutputTexture;
  82038. /**
  82039. * Returns the fragment url or shader name used in the post process.
  82040. * @returns the fragment url or name in the shader store.
  82041. */
  82042. getEffectName(): string;
  82043. /**
  82044. * An event triggered when the postprocess is activated.
  82045. */
  82046. onActivateObservable: Observable<Camera>;
  82047. private _onActivateObserver;
  82048. /**
  82049. * A function that is added to the onActivateObservable
  82050. */
  82051. onActivate: Nullable<(camera: Camera) => void>;
  82052. /**
  82053. * An event triggered when the postprocess changes its size.
  82054. */
  82055. onSizeChangedObservable: Observable<PostProcess>;
  82056. private _onSizeChangedObserver;
  82057. /**
  82058. * A function that is added to the onSizeChangedObservable
  82059. */
  82060. onSizeChanged: (postProcess: PostProcess) => void;
  82061. /**
  82062. * An event triggered when the postprocess applies its effect.
  82063. */
  82064. onApplyObservable: Observable<Effect>;
  82065. private _onApplyObserver;
  82066. /**
  82067. * A function that is added to the onApplyObservable
  82068. */
  82069. onApply: (effect: Effect) => void;
  82070. /**
  82071. * An event triggered before rendering the postprocess
  82072. */
  82073. onBeforeRenderObservable: Observable<Effect>;
  82074. private _onBeforeRenderObserver;
  82075. /**
  82076. * A function that is added to the onBeforeRenderObservable
  82077. */
  82078. onBeforeRender: (effect: Effect) => void;
  82079. /**
  82080. * An event triggered after rendering the postprocess
  82081. */
  82082. onAfterRenderObservable: Observable<Effect>;
  82083. private _onAfterRenderObserver;
  82084. /**
  82085. * A function that is added to the onAfterRenderObservable
  82086. */
  82087. onAfterRender: (efect: Effect) => void;
  82088. /**
  82089. * 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
  82090. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82091. */
  82092. inputTexture: InternalTexture;
  82093. /**
  82094. * Gets the camera which post process is applied to.
  82095. * @returns The camera the post process is applied to.
  82096. */
  82097. getCamera(): Camera;
  82098. /**
  82099. * Gets the texel size of the postprocess.
  82100. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82101. */
  82102. readonly texelSize: Vector2;
  82103. /**
  82104. * Creates a new instance PostProcess
  82105. * @param name The name of the PostProcess.
  82106. * @param fragmentUrl The url of the fragment shader to be used.
  82107. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82108. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82109. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82110. * @param camera The camera to apply the render pass to.
  82111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82112. * @param engine The engine which the post process will be applied. (default: current engine)
  82113. * @param reusable If the post process can be reused on the same frame. (default: false)
  82114. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82115. * @param textureType Type of textures used when performing the post process. (default: 0)
  82116. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82117. * @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
  82118. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82119. */
  82120. constructor(
  82121. /** Name of the PostProcess. */
  82122. 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);
  82123. /**
  82124. * Gets a string idenfifying the name of the class
  82125. * @returns "PostProcess" string
  82126. */
  82127. getClassName(): string;
  82128. /**
  82129. * Gets the engine which this post process belongs to.
  82130. * @returns The engine the post process was enabled with.
  82131. */
  82132. getEngine(): Engine;
  82133. /**
  82134. * The effect that is created when initializing the post process.
  82135. * @returns The created effect corresponding the the postprocess.
  82136. */
  82137. getEffect(): Effect;
  82138. /**
  82139. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82140. * @param postProcess The post process to share the output with.
  82141. * @returns This post process.
  82142. */
  82143. shareOutputWith(postProcess: PostProcess): PostProcess;
  82144. /**
  82145. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82146. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82147. */
  82148. useOwnOutput(): void;
  82149. /**
  82150. * Updates the effect with the current post process compile time values and recompiles the shader.
  82151. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82152. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82153. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82154. * @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
  82155. * @param onCompiled Called when the shader has been compiled.
  82156. * @param onError Called if there is an error when compiling a shader.
  82157. */
  82158. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82159. /**
  82160. * The post process is reusable if it can be used multiple times within one frame.
  82161. * @returns If the post process is reusable
  82162. */
  82163. isReusable(): boolean;
  82164. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82165. markTextureDirty(): void;
  82166. /**
  82167. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82168. * 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.
  82169. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82170. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82171. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82172. * @returns The target texture that was bound to be written to.
  82173. */
  82174. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82175. /**
  82176. * If the post process is supported.
  82177. */
  82178. readonly isSupported: boolean;
  82179. /**
  82180. * The aspect ratio of the output texture.
  82181. */
  82182. readonly aspectRatio: number;
  82183. /**
  82184. * Get a value indicating if the post-process is ready to be used
  82185. * @returns true if the post-process is ready (shader is compiled)
  82186. */
  82187. isReady(): boolean;
  82188. /**
  82189. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82190. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82191. */
  82192. apply(): Nullable<Effect>;
  82193. private _disposeTextures;
  82194. /**
  82195. * Disposes the post process.
  82196. * @param camera The camera to dispose the post process on.
  82197. */
  82198. dispose(camera?: Camera): void;
  82199. }
  82200. }
  82201. declare module BABYLON {
  82202. /** @hidden */
  82203. export var kernelBlurVaryingDeclaration: {
  82204. name: string;
  82205. shader: string;
  82206. };
  82207. }
  82208. declare module BABYLON {
  82209. /** @hidden */
  82210. export var kernelBlurFragment: {
  82211. name: string;
  82212. shader: string;
  82213. };
  82214. }
  82215. declare module BABYLON {
  82216. /** @hidden */
  82217. export var kernelBlurFragment2: {
  82218. name: string;
  82219. shader: string;
  82220. };
  82221. }
  82222. declare module BABYLON {
  82223. /** @hidden */
  82224. export var kernelBlurPixelShader: {
  82225. name: string;
  82226. shader: string;
  82227. };
  82228. }
  82229. declare module BABYLON {
  82230. /** @hidden */
  82231. export var kernelBlurVertex: {
  82232. name: string;
  82233. shader: string;
  82234. };
  82235. }
  82236. declare module BABYLON {
  82237. /** @hidden */
  82238. export var kernelBlurVertexShader: {
  82239. name: string;
  82240. shader: string;
  82241. };
  82242. }
  82243. declare module BABYLON {
  82244. /**
  82245. * The Blur Post Process which blurs an image based on a kernel and direction.
  82246. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82247. */
  82248. export class BlurPostProcess extends PostProcess {
  82249. /** The direction in which to blur the image. */
  82250. direction: Vector2;
  82251. private blockCompilation;
  82252. protected _kernel: number;
  82253. protected _idealKernel: number;
  82254. protected _packedFloat: boolean;
  82255. private _staticDefines;
  82256. /**
  82257. * Sets the length in pixels of the blur sample region
  82258. */
  82259. /**
  82260. * Gets the length in pixels of the blur sample region
  82261. */
  82262. kernel: number;
  82263. /**
  82264. * Sets wether or not the blur needs to unpack/repack floats
  82265. */
  82266. /**
  82267. * Gets wether or not the blur is unpacking/repacking floats
  82268. */
  82269. packedFloat: boolean;
  82270. /**
  82271. * Creates a new instance BlurPostProcess
  82272. * @param name The name of the effect.
  82273. * @param direction The direction in which to blur the image.
  82274. * @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.
  82275. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82276. * @param camera The camera to apply the render pass to.
  82277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82278. * @param engine The engine which the post process will be applied. (default: current engine)
  82279. * @param reusable If the post process can be reused on the same frame. (default: false)
  82280. * @param textureType Type of textures used when performing the post process. (default: 0)
  82281. * @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)
  82282. */
  82283. constructor(name: string,
  82284. /** The direction in which to blur the image. */
  82285. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82286. /**
  82287. * Updates the effect with the current post process compile time values and recompiles the shader.
  82288. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82289. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82290. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82291. * @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
  82292. * @param onCompiled Called when the shader has been compiled.
  82293. * @param onError Called if there is an error when compiling a shader.
  82294. */
  82295. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82296. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82297. /**
  82298. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82299. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82300. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82301. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82302. * The gaps between physical kernels are compensated for in the weighting of the samples
  82303. * @param idealKernel Ideal blur kernel.
  82304. * @return Nearest best kernel.
  82305. */
  82306. protected _nearestBestKernel(idealKernel: number): number;
  82307. /**
  82308. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82309. * @param x The point on the Gaussian distribution to sample.
  82310. * @return the value of the Gaussian function at x.
  82311. */
  82312. protected _gaussianWeight(x: number): number;
  82313. /**
  82314. * Generates a string that can be used as a floating point number in GLSL.
  82315. * @param x Value to print.
  82316. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82317. * @return GLSL float string.
  82318. */
  82319. protected _glslFloat(x: number, decimalFigures?: number): string;
  82320. }
  82321. }
  82322. declare module BABYLON {
  82323. /**
  82324. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82325. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82326. * You can then easily use it as a reflectionTexture on a flat surface.
  82327. * In case the surface is not a plane, please consider relying on reflection probes.
  82328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82329. */
  82330. export class MirrorTexture extends RenderTargetTexture {
  82331. private scene;
  82332. /**
  82333. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82334. * 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.
  82335. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82336. */
  82337. mirrorPlane: Plane;
  82338. /**
  82339. * Define the blur ratio used to blur the reflection if needed.
  82340. */
  82341. blurRatio: number;
  82342. /**
  82343. * Define the adaptive blur kernel used to blur the reflection if needed.
  82344. * This will autocompute the closest best match for the `blurKernel`
  82345. */
  82346. adaptiveBlurKernel: number;
  82347. /**
  82348. * Define the blur kernel used to blur the reflection if needed.
  82349. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82350. */
  82351. blurKernel: number;
  82352. /**
  82353. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82354. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82355. */
  82356. blurKernelX: number;
  82357. /**
  82358. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82359. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82360. */
  82361. blurKernelY: number;
  82362. private _autoComputeBlurKernel;
  82363. protected _onRatioRescale(): void;
  82364. private _updateGammaSpace;
  82365. private _imageProcessingConfigChangeObserver;
  82366. private _transformMatrix;
  82367. private _mirrorMatrix;
  82368. private _savedViewMatrix;
  82369. private _blurX;
  82370. private _blurY;
  82371. private _adaptiveBlurKernel;
  82372. private _blurKernelX;
  82373. private _blurKernelY;
  82374. private _blurRatio;
  82375. /**
  82376. * Instantiates a Mirror Texture.
  82377. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82378. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82379. * You can then easily use it as a reflectionTexture on a flat surface.
  82380. * In case the surface is not a plane, please consider relying on reflection probes.
  82381. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82382. * @param name
  82383. * @param size
  82384. * @param scene
  82385. * @param generateMipMaps
  82386. * @param type
  82387. * @param samplingMode
  82388. * @param generateDepthBuffer
  82389. */
  82390. constructor(name: string, size: number | {
  82391. width: number;
  82392. height: number;
  82393. } | {
  82394. ratio: number;
  82395. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82396. private _preparePostProcesses;
  82397. /**
  82398. * Clone the mirror texture.
  82399. * @returns the cloned texture
  82400. */
  82401. clone(): MirrorTexture;
  82402. /**
  82403. * Serialize the texture to a JSON representation you could use in Parse later on
  82404. * @returns the serialized JSON representation
  82405. */
  82406. serialize(): any;
  82407. /**
  82408. * Dispose the texture and release its associated resources.
  82409. */
  82410. dispose(): void;
  82411. }
  82412. }
  82413. declare module BABYLON {
  82414. /**
  82415. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82416. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82417. */
  82418. export class Texture extends BaseTexture {
  82419. /**
  82420. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82421. */
  82422. static SerializeBuffers: boolean;
  82423. /** @hidden */
  82424. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82425. /** @hidden */
  82426. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82427. /** @hidden */
  82428. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82429. /** nearest is mag = nearest and min = nearest and mip = linear */
  82430. static readonly NEAREST_SAMPLINGMODE: number;
  82431. /** nearest is mag = nearest and min = nearest and mip = linear */
  82432. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82433. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82434. static readonly BILINEAR_SAMPLINGMODE: number;
  82435. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82436. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82437. /** Trilinear is mag = linear and min = linear and mip = linear */
  82438. static readonly TRILINEAR_SAMPLINGMODE: number;
  82439. /** Trilinear is mag = linear and min = linear and mip = linear */
  82440. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82441. /** mag = nearest and min = nearest and mip = nearest */
  82442. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82443. /** mag = nearest and min = linear and mip = nearest */
  82444. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82445. /** mag = nearest and min = linear and mip = linear */
  82446. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82447. /** mag = nearest and min = linear and mip = none */
  82448. static readonly NEAREST_LINEAR: number;
  82449. /** mag = nearest and min = nearest and mip = none */
  82450. static readonly NEAREST_NEAREST: number;
  82451. /** mag = linear and min = nearest and mip = nearest */
  82452. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82453. /** mag = linear and min = nearest and mip = linear */
  82454. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82455. /** mag = linear and min = linear and mip = none */
  82456. static readonly LINEAR_LINEAR: number;
  82457. /** mag = linear and min = nearest and mip = none */
  82458. static readonly LINEAR_NEAREST: number;
  82459. /** Explicit coordinates mode */
  82460. static readonly EXPLICIT_MODE: number;
  82461. /** Spherical coordinates mode */
  82462. static readonly SPHERICAL_MODE: number;
  82463. /** Planar coordinates mode */
  82464. static readonly PLANAR_MODE: number;
  82465. /** Cubic coordinates mode */
  82466. static readonly CUBIC_MODE: number;
  82467. /** Projection coordinates mode */
  82468. static readonly PROJECTION_MODE: number;
  82469. /** Inverse Cubic coordinates mode */
  82470. static readonly SKYBOX_MODE: number;
  82471. /** Inverse Cubic coordinates mode */
  82472. static readonly INVCUBIC_MODE: number;
  82473. /** Equirectangular coordinates mode */
  82474. static readonly EQUIRECTANGULAR_MODE: number;
  82475. /** Equirectangular Fixed coordinates mode */
  82476. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82477. /** Equirectangular Fixed Mirrored coordinates mode */
  82478. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82479. /** Texture is not repeating outside of 0..1 UVs */
  82480. static readonly CLAMP_ADDRESSMODE: number;
  82481. /** Texture is repeating outside of 0..1 UVs */
  82482. static readonly WRAP_ADDRESSMODE: number;
  82483. /** Texture is repeating and mirrored */
  82484. static readonly MIRROR_ADDRESSMODE: number;
  82485. /**
  82486. * 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
  82487. */
  82488. static UseSerializedUrlIfAny: boolean;
  82489. /**
  82490. * Define the url of the texture.
  82491. */
  82492. url: Nullable<string>;
  82493. /**
  82494. * Define an offset on the texture to offset the u coordinates of the UVs
  82495. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82496. */
  82497. uOffset: number;
  82498. /**
  82499. * Define an offset on the texture to offset the v coordinates of the UVs
  82500. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82501. */
  82502. vOffset: number;
  82503. /**
  82504. * Define an offset on the texture to scale the u coordinates of the UVs
  82505. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82506. */
  82507. uScale: number;
  82508. /**
  82509. * Define an offset on the texture to scale the v coordinates of the UVs
  82510. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82511. */
  82512. vScale: number;
  82513. /**
  82514. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82515. * @see http://doc.babylonjs.com/how_to/more_materials
  82516. */
  82517. uAng: number;
  82518. /**
  82519. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82520. * @see http://doc.babylonjs.com/how_to/more_materials
  82521. */
  82522. vAng: number;
  82523. /**
  82524. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82525. * @see http://doc.babylonjs.com/how_to/more_materials
  82526. */
  82527. wAng: number;
  82528. /**
  82529. * Defines the center of rotation (U)
  82530. */
  82531. uRotationCenter: number;
  82532. /**
  82533. * Defines the center of rotation (V)
  82534. */
  82535. vRotationCenter: number;
  82536. /**
  82537. * Defines the center of rotation (W)
  82538. */
  82539. wRotationCenter: number;
  82540. /**
  82541. * Are mip maps generated for this texture or not.
  82542. */
  82543. readonly noMipmap: boolean;
  82544. /**
  82545. * List of inspectable custom properties (used by the Inspector)
  82546. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82547. */
  82548. inspectableCustomProperties: Nullable<IInspectable[]>;
  82549. private _noMipmap;
  82550. /** @hidden */
  82551. _invertY: boolean;
  82552. private _rowGenerationMatrix;
  82553. private _cachedTextureMatrix;
  82554. private _projectionModeMatrix;
  82555. private _t0;
  82556. private _t1;
  82557. private _t2;
  82558. private _cachedUOffset;
  82559. private _cachedVOffset;
  82560. private _cachedUScale;
  82561. private _cachedVScale;
  82562. private _cachedUAng;
  82563. private _cachedVAng;
  82564. private _cachedWAng;
  82565. private _cachedProjectionMatrixId;
  82566. private _cachedCoordinatesMode;
  82567. /** @hidden */
  82568. protected _initialSamplingMode: number;
  82569. /** @hidden */
  82570. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82571. private _deleteBuffer;
  82572. protected _format: Nullable<number>;
  82573. private _delayedOnLoad;
  82574. private _delayedOnError;
  82575. /**
  82576. * Observable triggered once the texture has been loaded.
  82577. */
  82578. onLoadObservable: Observable<Texture>;
  82579. protected _isBlocking: boolean;
  82580. /**
  82581. * Is the texture preventing material to render while loading.
  82582. * If false, a default texture will be used instead of the loading one during the preparation step.
  82583. */
  82584. isBlocking: boolean;
  82585. /**
  82586. * Get the current sampling mode associated with the texture.
  82587. */
  82588. readonly samplingMode: number;
  82589. /**
  82590. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82591. */
  82592. readonly invertY: boolean;
  82593. /**
  82594. * Instantiates a new texture.
  82595. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82596. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82597. * @param url define the url of the picture to load as a texture
  82598. * @param scene define the scene or engine the texture will belong to
  82599. * @param noMipmap define if the texture will require mip maps or not
  82600. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82601. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82602. * @param onLoad define a callback triggered when the texture has been loaded
  82603. * @param onError define a callback triggered when an error occurred during the loading session
  82604. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82605. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82606. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82607. */
  82608. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  82609. /**
  82610. * Update the url (and optional buffer) of this texture if url was null during construction.
  82611. * @param url the url of the texture
  82612. * @param buffer the buffer of the texture (defaults to null)
  82613. * @param onLoad callback called when the texture is loaded (defaults to null)
  82614. */
  82615. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82616. /**
  82617. * Finish the loading sequence of a texture flagged as delayed load.
  82618. * @hidden
  82619. */
  82620. delayLoad(): void;
  82621. private _prepareRowForTextureGeneration;
  82622. /**
  82623. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82624. * @returns the transform matrix of the texture.
  82625. */
  82626. getTextureMatrix(): Matrix;
  82627. /**
  82628. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82629. * @returns The reflection texture transform
  82630. */
  82631. getReflectionTextureMatrix(): Matrix;
  82632. /**
  82633. * Clones the texture.
  82634. * @returns the cloned texture
  82635. */
  82636. clone(): Texture;
  82637. /**
  82638. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82639. * @returns The JSON representation of the texture
  82640. */
  82641. serialize(): any;
  82642. /**
  82643. * Get the current class name of the texture useful for serialization or dynamic coding.
  82644. * @returns "Texture"
  82645. */
  82646. getClassName(): string;
  82647. /**
  82648. * Dispose the texture and release its associated resources.
  82649. */
  82650. dispose(): void;
  82651. /**
  82652. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82653. * @param parsedTexture Define the JSON representation of the texture
  82654. * @param scene Define the scene the parsed texture should be instantiated in
  82655. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82656. * @returns The parsed texture if successful
  82657. */
  82658. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82659. /**
  82660. * Creates a texture from its base 64 representation.
  82661. * @param data Define the base64 payload without the data: prefix
  82662. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82663. * @param scene Define the scene the texture should belong to
  82664. * @param noMipmap Forces the texture to not create mip map information if true
  82665. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82666. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82667. * @param onLoad define a callback triggered when the texture has been loaded
  82668. * @param onError define a callback triggered when an error occurred during the loading session
  82669. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82670. * @returns the created texture
  82671. */
  82672. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82673. /**
  82674. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82675. * @param data Define the base64 payload without the data: prefix
  82676. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82677. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82678. * @param scene Define the scene the texture should belong to
  82679. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82680. * @param noMipmap Forces the texture to not create mip map information if true
  82681. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82682. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82683. * @param onLoad define a callback triggered when the texture has been loaded
  82684. * @param onError define a callback triggered when an error occurred during the loading session
  82685. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82686. * @returns the created texture
  82687. */
  82688. 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;
  82689. }
  82690. }
  82691. declare module BABYLON {
  82692. /**
  82693. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82694. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82695. */
  82696. export class PostProcessManager {
  82697. private _scene;
  82698. private _indexBuffer;
  82699. private _vertexBuffers;
  82700. /**
  82701. * Creates a new instance PostProcess
  82702. * @param scene The scene that the post process is associated with.
  82703. */
  82704. constructor(scene: Scene);
  82705. private _prepareBuffers;
  82706. private _buildIndexBuffer;
  82707. /**
  82708. * Rebuilds the vertex buffers of the manager.
  82709. * @hidden
  82710. */
  82711. _rebuild(): void;
  82712. /**
  82713. * Prepares a frame to be run through a post process.
  82714. * @param sourceTexture The input texture to the post procesess. (default: null)
  82715. * @param postProcesses An array of post processes to be run. (default: null)
  82716. * @returns True if the post processes were able to be run.
  82717. * @hidden
  82718. */
  82719. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82720. /**
  82721. * Manually render a set of post processes to a texture.
  82722. * @param postProcesses An array of post processes to be run.
  82723. * @param targetTexture The target texture to render to.
  82724. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82725. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82726. * @param lodLevel defines which lod of the texture to render to
  82727. */
  82728. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82729. /**
  82730. * Finalize the result of the output of the postprocesses.
  82731. * @param doNotPresent If true the result will not be displayed to the screen.
  82732. * @param targetTexture The target texture to render to.
  82733. * @param faceIndex The index of the face to bind the target texture to.
  82734. * @param postProcesses The array of post processes to render.
  82735. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82736. * @hidden
  82737. */
  82738. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82739. /**
  82740. * Disposes of the post process manager.
  82741. */
  82742. dispose(): void;
  82743. }
  82744. }
  82745. declare module BABYLON {
  82746. /** Interface used by value gradients (color, factor, ...) */
  82747. export interface IValueGradient {
  82748. /**
  82749. * Gets or sets the gradient value (between 0 and 1)
  82750. */
  82751. gradient: number;
  82752. }
  82753. /** Class used to store color4 gradient */
  82754. export class ColorGradient implements IValueGradient {
  82755. /**
  82756. * Gets or sets the gradient value (between 0 and 1)
  82757. */
  82758. gradient: number;
  82759. /**
  82760. * Gets or sets first associated color
  82761. */
  82762. color1: Color4;
  82763. /**
  82764. * Gets or sets second associated color
  82765. */
  82766. color2?: Color4;
  82767. /**
  82768. * Will get a color picked randomly between color1 and color2.
  82769. * If color2 is undefined then color1 will be used
  82770. * @param result defines the target Color4 to store the result in
  82771. */
  82772. getColorToRef(result: Color4): void;
  82773. }
  82774. /** Class used to store color 3 gradient */
  82775. export class Color3Gradient implements IValueGradient {
  82776. /**
  82777. * Gets or sets the gradient value (between 0 and 1)
  82778. */
  82779. gradient: number;
  82780. /**
  82781. * Gets or sets the associated color
  82782. */
  82783. color: Color3;
  82784. }
  82785. /** Class used to store factor gradient */
  82786. export class FactorGradient implements IValueGradient {
  82787. /**
  82788. * Gets or sets the gradient value (between 0 and 1)
  82789. */
  82790. gradient: number;
  82791. /**
  82792. * Gets or sets first associated factor
  82793. */
  82794. factor1: number;
  82795. /**
  82796. * Gets or sets second associated factor
  82797. */
  82798. factor2?: number;
  82799. /**
  82800. * Will get a number picked randomly between factor1 and factor2.
  82801. * If factor2 is undefined then factor1 will be used
  82802. * @returns the picked number
  82803. */
  82804. getFactor(): number;
  82805. }
  82806. /**
  82807. * Helper used to simplify some generic gradient tasks
  82808. */
  82809. export class GradientHelper {
  82810. /**
  82811. * Gets the current gradient from an array of IValueGradient
  82812. * @param ratio defines the current ratio to get
  82813. * @param gradients defines the array of IValueGradient
  82814. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82815. */
  82816. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82817. }
  82818. }
  82819. declare module BABYLON {
  82820. interface ThinEngine {
  82821. /**
  82822. * Creates a dynamic texture
  82823. * @param width defines the width of the texture
  82824. * @param height defines the height of the texture
  82825. * @param generateMipMaps defines if the engine should generate the mip levels
  82826. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82827. * @returns the dynamic texture inside an InternalTexture
  82828. */
  82829. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82830. /**
  82831. * Update the content of a dynamic texture
  82832. * @param texture defines the texture to update
  82833. * @param canvas defines the canvas containing the source
  82834. * @param invertY defines if data must be stored with Y axis inverted
  82835. * @param premulAlpha defines if alpha is stored as premultiplied
  82836. * @param format defines the format of the data
  82837. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82838. */
  82839. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82840. }
  82841. }
  82842. declare module BABYLON {
  82843. /**
  82844. * A class extending Texture allowing drawing on a texture
  82845. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82846. */
  82847. export class DynamicTexture extends Texture {
  82848. private _generateMipMaps;
  82849. private _canvas;
  82850. private _context;
  82851. private _engine;
  82852. /**
  82853. * Creates a DynamicTexture
  82854. * @param name defines the name of the texture
  82855. * @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
  82856. * @param scene defines the scene where you want the texture
  82857. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82858. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82859. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82860. */
  82861. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82862. /**
  82863. * Get the current class name of the texture useful for serialization or dynamic coding.
  82864. * @returns "DynamicTexture"
  82865. */
  82866. getClassName(): string;
  82867. /**
  82868. * Gets the current state of canRescale
  82869. */
  82870. readonly canRescale: boolean;
  82871. private _recreate;
  82872. /**
  82873. * Scales the texture
  82874. * @param ratio the scale factor to apply to both width and height
  82875. */
  82876. scale(ratio: number): void;
  82877. /**
  82878. * Resizes the texture
  82879. * @param width the new width
  82880. * @param height the new height
  82881. */
  82882. scaleTo(width: number, height: number): void;
  82883. /**
  82884. * Gets the context of the canvas used by the texture
  82885. * @returns the canvas context of the dynamic texture
  82886. */
  82887. getContext(): CanvasRenderingContext2D;
  82888. /**
  82889. * Clears the texture
  82890. */
  82891. clear(): void;
  82892. /**
  82893. * Updates the texture
  82894. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82895. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82896. */
  82897. update(invertY?: boolean, premulAlpha?: boolean): void;
  82898. /**
  82899. * Draws text onto the texture
  82900. * @param text defines the text to be drawn
  82901. * @param x defines the placement of the text from the left
  82902. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82903. * @param font defines the font to be used with font-style, font-size, font-name
  82904. * @param color defines the color used for the text
  82905. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82906. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82907. * @param update defines whether texture is immediately update (default is true)
  82908. */
  82909. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82910. /**
  82911. * Clones the texture
  82912. * @returns the clone of the texture.
  82913. */
  82914. clone(): DynamicTexture;
  82915. /**
  82916. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82917. * @returns a serialized dynamic texture object
  82918. */
  82919. serialize(): any;
  82920. /** @hidden */
  82921. _rebuild(): void;
  82922. }
  82923. }
  82924. declare module BABYLON {
  82925. interface AbstractScene {
  82926. /**
  82927. * The list of procedural textures added to the scene
  82928. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82929. */
  82930. proceduralTextures: Array<ProceduralTexture>;
  82931. }
  82932. /**
  82933. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82934. * in a given scene.
  82935. */
  82936. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82937. /**
  82938. * The component name helpfull to identify the component in the list of scene components.
  82939. */
  82940. readonly name: string;
  82941. /**
  82942. * The scene the component belongs to.
  82943. */
  82944. scene: Scene;
  82945. /**
  82946. * Creates a new instance of the component for the given scene
  82947. * @param scene Defines the scene to register the component in
  82948. */
  82949. constructor(scene: Scene);
  82950. /**
  82951. * Registers the component in a given scene
  82952. */
  82953. register(): void;
  82954. /**
  82955. * Rebuilds the elements related to this component in case of
  82956. * context lost for instance.
  82957. */
  82958. rebuild(): void;
  82959. /**
  82960. * Disposes the component and the associated ressources.
  82961. */
  82962. dispose(): void;
  82963. private _beforeClear;
  82964. }
  82965. }
  82966. declare module BABYLON {
  82967. interface ThinEngine {
  82968. /**
  82969. * Creates a new render target cube texture
  82970. * @param size defines the size of the texture
  82971. * @param options defines the options used to create the texture
  82972. * @returns a new render target cube texture stored in an InternalTexture
  82973. */
  82974. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82975. }
  82976. }
  82977. declare module BABYLON {
  82978. /** @hidden */
  82979. export var proceduralVertexShader: {
  82980. name: string;
  82981. shader: string;
  82982. };
  82983. }
  82984. declare module BABYLON {
  82985. /**
  82986. * 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.
  82987. * This is the base class of any Procedural texture and contains most of the shareable code.
  82988. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82989. */
  82990. export class ProceduralTexture extends Texture {
  82991. isCube: boolean;
  82992. /**
  82993. * Define if the texture is enabled or not (disabled texture will not render)
  82994. */
  82995. isEnabled: boolean;
  82996. /**
  82997. * Define if the texture must be cleared before rendering (default is true)
  82998. */
  82999. autoClear: boolean;
  83000. /**
  83001. * Callback called when the texture is generated
  83002. */
  83003. onGenerated: () => void;
  83004. /**
  83005. * Event raised when the texture is generated
  83006. */
  83007. onGeneratedObservable: Observable<ProceduralTexture>;
  83008. /** @hidden */
  83009. _generateMipMaps: boolean;
  83010. /** @hidden **/
  83011. _effect: Effect;
  83012. /** @hidden */
  83013. _textures: {
  83014. [key: string]: Texture;
  83015. };
  83016. private _size;
  83017. private _currentRefreshId;
  83018. private _refreshRate;
  83019. private _vertexBuffers;
  83020. private _indexBuffer;
  83021. private _uniforms;
  83022. private _samplers;
  83023. private _fragment;
  83024. private _floats;
  83025. private _ints;
  83026. private _floatsArrays;
  83027. private _colors3;
  83028. private _colors4;
  83029. private _vectors2;
  83030. private _vectors3;
  83031. private _matrices;
  83032. private _fallbackTexture;
  83033. private _fallbackTextureUsed;
  83034. private _engine;
  83035. private _cachedDefines;
  83036. private _contentUpdateId;
  83037. private _contentData;
  83038. /**
  83039. * Instantiates a new procedural texture.
  83040. * 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.
  83041. * This is the base class of any Procedural texture and contains most of the shareable code.
  83042. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83043. * @param name Define the name of the texture
  83044. * @param size Define the size of the texture to create
  83045. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83046. * @param scene Define the scene the texture belongs to
  83047. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83048. * @param generateMipMaps Define if the texture should creates mip maps or not
  83049. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83050. */
  83051. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83052. /**
  83053. * The effect that is created when initializing the post process.
  83054. * @returns The created effect corresponding the the postprocess.
  83055. */
  83056. getEffect(): Effect;
  83057. /**
  83058. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83059. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83060. */
  83061. getContent(): Nullable<ArrayBufferView>;
  83062. private _createIndexBuffer;
  83063. /** @hidden */
  83064. _rebuild(): void;
  83065. /**
  83066. * Resets the texture in order to recreate its associated resources.
  83067. * This can be called in case of context loss
  83068. */
  83069. reset(): void;
  83070. protected _getDefines(): string;
  83071. /**
  83072. * Is the texture ready to be used ? (rendered at least once)
  83073. * @returns true if ready, otherwise, false.
  83074. */
  83075. isReady(): boolean;
  83076. /**
  83077. * Resets the refresh counter of the texture and start bak from scratch.
  83078. * Could be useful to regenerate the texture if it is setup to render only once.
  83079. */
  83080. resetRefreshCounter(): void;
  83081. /**
  83082. * Set the fragment shader to use in order to render the texture.
  83083. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83084. */
  83085. setFragment(fragment: any): void;
  83086. /**
  83087. * Define the refresh rate of the texture or the rendering frequency.
  83088. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83089. */
  83090. refreshRate: number;
  83091. /** @hidden */
  83092. _shouldRender(): boolean;
  83093. /**
  83094. * Get the size the texture is rendering at.
  83095. * @returns the size (texture is always squared)
  83096. */
  83097. getRenderSize(): number;
  83098. /**
  83099. * Resize the texture to new value.
  83100. * @param size Define the new size the texture should have
  83101. * @param generateMipMaps Define whether the new texture should create mip maps
  83102. */
  83103. resize(size: number, generateMipMaps: boolean): void;
  83104. private _checkUniform;
  83105. /**
  83106. * Set a texture in the shader program used to render.
  83107. * @param name Define the name of the uniform samplers as defined in the shader
  83108. * @param texture Define the texture to bind to this sampler
  83109. * @return the texture itself allowing "fluent" like uniform updates
  83110. */
  83111. setTexture(name: string, texture: Texture): ProceduralTexture;
  83112. /**
  83113. * Set a float in the shader.
  83114. * @param name Define the name of the uniform as defined in the shader
  83115. * @param value Define the value to give to the uniform
  83116. * @return the texture itself allowing "fluent" like uniform updates
  83117. */
  83118. setFloat(name: string, value: number): ProceduralTexture;
  83119. /**
  83120. * Set a int in the shader.
  83121. * @param name Define the name of the uniform as defined in the shader
  83122. * @param value Define the value to give to the uniform
  83123. * @return the texture itself allowing "fluent" like uniform updates
  83124. */
  83125. setInt(name: string, value: number): ProceduralTexture;
  83126. /**
  83127. * Set an array of floats in the shader.
  83128. * @param name Define the name of the uniform as defined in the shader
  83129. * @param value Define the value to give to the uniform
  83130. * @return the texture itself allowing "fluent" like uniform updates
  83131. */
  83132. setFloats(name: string, value: number[]): ProceduralTexture;
  83133. /**
  83134. * Set a vec3 in the shader from a Color3.
  83135. * @param name Define the name of the uniform as defined in the shader
  83136. * @param value Define the value to give to the uniform
  83137. * @return the texture itself allowing "fluent" like uniform updates
  83138. */
  83139. setColor3(name: string, value: Color3): ProceduralTexture;
  83140. /**
  83141. * Set a vec4 in the shader from a Color4.
  83142. * @param name Define the name of the uniform as defined in the shader
  83143. * @param value Define the value to give to the uniform
  83144. * @return the texture itself allowing "fluent" like uniform updates
  83145. */
  83146. setColor4(name: string, value: Color4): ProceduralTexture;
  83147. /**
  83148. * Set a vec2 in the shader from a Vector2.
  83149. * @param name Define the name of the uniform as defined in the shader
  83150. * @param value Define the value to give to the uniform
  83151. * @return the texture itself allowing "fluent" like uniform updates
  83152. */
  83153. setVector2(name: string, value: Vector2): ProceduralTexture;
  83154. /**
  83155. * Set a vec3 in the shader from a Vector3.
  83156. * @param name Define the name of the uniform as defined in the shader
  83157. * @param value Define the value to give to the uniform
  83158. * @return the texture itself allowing "fluent" like uniform updates
  83159. */
  83160. setVector3(name: string, value: Vector3): ProceduralTexture;
  83161. /**
  83162. * Set a mat4 in the shader from a MAtrix.
  83163. * @param name Define the name of the uniform as defined in the shader
  83164. * @param value Define the value to give to the uniform
  83165. * @return the texture itself allowing "fluent" like uniform updates
  83166. */
  83167. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83168. /**
  83169. * Render the texture to its associated render target.
  83170. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83171. */
  83172. render(useCameraPostProcess?: boolean): void;
  83173. /**
  83174. * Clone the texture.
  83175. * @returns the cloned texture
  83176. */
  83177. clone(): ProceduralTexture;
  83178. /**
  83179. * Dispose the texture and release its asoociated resources.
  83180. */
  83181. dispose(): void;
  83182. }
  83183. }
  83184. declare module BABYLON {
  83185. /**
  83186. * This represents the base class for particle system in Babylon.
  83187. * 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.
  83188. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83189. * @example https://doc.babylonjs.com/babylon101/particles
  83190. */
  83191. export class BaseParticleSystem {
  83192. /**
  83193. * Source color is added to the destination color without alpha affecting the result
  83194. */
  83195. static BLENDMODE_ONEONE: number;
  83196. /**
  83197. * Blend current color and particle color using particle’s alpha
  83198. */
  83199. static BLENDMODE_STANDARD: number;
  83200. /**
  83201. * Add current color and particle color multiplied by particle’s alpha
  83202. */
  83203. static BLENDMODE_ADD: number;
  83204. /**
  83205. * Multiply current color with particle color
  83206. */
  83207. static BLENDMODE_MULTIPLY: number;
  83208. /**
  83209. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83210. */
  83211. static BLENDMODE_MULTIPLYADD: number;
  83212. /**
  83213. * List of animations used by the particle system.
  83214. */
  83215. animations: Animation[];
  83216. /**
  83217. * The id of the Particle system.
  83218. */
  83219. id: string;
  83220. /**
  83221. * The friendly name of the Particle system.
  83222. */
  83223. name: string;
  83224. /**
  83225. * The rendering group used by the Particle system to chose when to render.
  83226. */
  83227. renderingGroupId: number;
  83228. /**
  83229. * The emitter represents the Mesh or position we are attaching the particle system to.
  83230. */
  83231. emitter: Nullable<AbstractMesh | Vector3>;
  83232. /**
  83233. * The maximum number of particles to emit per frame
  83234. */
  83235. emitRate: number;
  83236. /**
  83237. * If you want to launch only a few particles at once, that can be done, as well.
  83238. */
  83239. manualEmitCount: number;
  83240. /**
  83241. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83242. */
  83243. updateSpeed: number;
  83244. /**
  83245. * The amount of time the particle system is running (depends of the overall update speed).
  83246. */
  83247. targetStopDuration: number;
  83248. /**
  83249. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83250. */
  83251. disposeOnStop: boolean;
  83252. /**
  83253. * Minimum power of emitting particles.
  83254. */
  83255. minEmitPower: number;
  83256. /**
  83257. * Maximum power of emitting particles.
  83258. */
  83259. maxEmitPower: number;
  83260. /**
  83261. * Minimum life time of emitting particles.
  83262. */
  83263. minLifeTime: number;
  83264. /**
  83265. * Maximum life time of emitting particles.
  83266. */
  83267. maxLifeTime: number;
  83268. /**
  83269. * Minimum Size of emitting particles.
  83270. */
  83271. minSize: number;
  83272. /**
  83273. * Maximum Size of emitting particles.
  83274. */
  83275. maxSize: number;
  83276. /**
  83277. * Minimum scale of emitting particles on X axis.
  83278. */
  83279. minScaleX: number;
  83280. /**
  83281. * Maximum scale of emitting particles on X axis.
  83282. */
  83283. maxScaleX: number;
  83284. /**
  83285. * Minimum scale of emitting particles on Y axis.
  83286. */
  83287. minScaleY: number;
  83288. /**
  83289. * Maximum scale of emitting particles on Y axis.
  83290. */
  83291. maxScaleY: number;
  83292. /**
  83293. * Gets or sets the minimal initial rotation in radians.
  83294. */
  83295. minInitialRotation: number;
  83296. /**
  83297. * Gets or sets the maximal initial rotation in radians.
  83298. */
  83299. maxInitialRotation: number;
  83300. /**
  83301. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83302. */
  83303. minAngularSpeed: number;
  83304. /**
  83305. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83306. */
  83307. maxAngularSpeed: number;
  83308. /**
  83309. * The texture used to render each particle. (this can be a spritesheet)
  83310. */
  83311. particleTexture: Nullable<Texture>;
  83312. /**
  83313. * The layer mask we are rendering the particles through.
  83314. */
  83315. layerMask: number;
  83316. /**
  83317. * This can help using your own shader to render the particle system.
  83318. * The according effect will be created
  83319. */
  83320. customShader: any;
  83321. /**
  83322. * By default particle system starts as soon as they are created. This prevents the
  83323. * automatic start to happen and let you decide when to start emitting particles.
  83324. */
  83325. preventAutoStart: boolean;
  83326. private _noiseTexture;
  83327. /**
  83328. * Gets or sets a texture used to add random noise to particle positions
  83329. */
  83330. noiseTexture: Nullable<ProceduralTexture>;
  83331. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83332. noiseStrength: Vector3;
  83333. /**
  83334. * Callback triggered when the particle animation is ending.
  83335. */
  83336. onAnimationEnd: Nullable<() => void>;
  83337. /**
  83338. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83339. */
  83340. blendMode: number;
  83341. /**
  83342. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83343. * to override the particles.
  83344. */
  83345. forceDepthWrite: boolean;
  83346. /** 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 */
  83347. preWarmCycles: number;
  83348. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83349. preWarmStepOffset: number;
  83350. /**
  83351. * 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)
  83352. */
  83353. spriteCellChangeSpeed: number;
  83354. /**
  83355. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83356. */
  83357. startSpriteCellID: number;
  83358. /**
  83359. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83360. */
  83361. endSpriteCellID: number;
  83362. /**
  83363. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83364. */
  83365. spriteCellWidth: number;
  83366. /**
  83367. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83368. */
  83369. spriteCellHeight: number;
  83370. /**
  83371. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83372. */
  83373. spriteRandomStartCell: boolean;
  83374. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83375. translationPivot: Vector2;
  83376. /** @hidden */
  83377. protected _isAnimationSheetEnabled: boolean;
  83378. /**
  83379. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83380. */
  83381. beginAnimationOnStart: boolean;
  83382. /**
  83383. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83384. */
  83385. beginAnimationFrom: number;
  83386. /**
  83387. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83388. */
  83389. beginAnimationTo: number;
  83390. /**
  83391. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83392. */
  83393. beginAnimationLoop: boolean;
  83394. /**
  83395. * Gets or sets a world offset applied to all particles
  83396. */
  83397. worldOffset: Vector3;
  83398. /**
  83399. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83400. */
  83401. isAnimationSheetEnabled: boolean;
  83402. /**
  83403. * Get hosting scene
  83404. * @returns the scene
  83405. */
  83406. getScene(): Scene;
  83407. /**
  83408. * You can use gravity if you want to give an orientation to your particles.
  83409. */
  83410. gravity: Vector3;
  83411. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83412. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83413. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83414. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83415. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83416. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83417. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83418. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83419. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83420. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83421. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83422. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83423. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83424. /**
  83425. * Defines the delay in milliseconds before starting the system (0 by default)
  83426. */
  83427. startDelay: number;
  83428. /**
  83429. * Gets the current list of drag gradients.
  83430. * You must use addDragGradient and removeDragGradient to udpate this list
  83431. * @returns the list of drag gradients
  83432. */
  83433. getDragGradients(): Nullable<Array<FactorGradient>>;
  83434. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83435. limitVelocityDamping: number;
  83436. /**
  83437. * Gets the current list of limit velocity gradients.
  83438. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83439. * @returns the list of limit velocity gradients
  83440. */
  83441. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83442. /**
  83443. * Gets the current list of color gradients.
  83444. * You must use addColorGradient and removeColorGradient to udpate this list
  83445. * @returns the list of color gradients
  83446. */
  83447. getColorGradients(): Nullable<Array<ColorGradient>>;
  83448. /**
  83449. * Gets the current list of size gradients.
  83450. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83451. * @returns the list of size gradients
  83452. */
  83453. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83454. /**
  83455. * Gets the current list of color remap gradients.
  83456. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83457. * @returns the list of color remap gradients
  83458. */
  83459. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83460. /**
  83461. * Gets the current list of alpha remap gradients.
  83462. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83463. * @returns the list of alpha remap gradients
  83464. */
  83465. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83466. /**
  83467. * Gets the current list of life time gradients.
  83468. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83469. * @returns the list of life time gradients
  83470. */
  83471. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83472. /**
  83473. * Gets the current list of angular speed gradients.
  83474. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83475. * @returns the list of angular speed gradients
  83476. */
  83477. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83478. /**
  83479. * Gets the current list of velocity gradients.
  83480. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83481. * @returns the list of velocity gradients
  83482. */
  83483. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83484. /**
  83485. * Gets the current list of start size gradients.
  83486. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83487. * @returns the list of start size gradients
  83488. */
  83489. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83490. /**
  83491. * Gets the current list of emit rate gradients.
  83492. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83493. * @returns the list of emit rate gradients
  83494. */
  83495. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83496. /**
  83497. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83498. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83499. */
  83500. direction1: Vector3;
  83501. /**
  83502. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83503. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83504. */
  83505. direction2: Vector3;
  83506. /**
  83507. * 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.
  83508. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83509. */
  83510. minEmitBox: Vector3;
  83511. /**
  83512. * 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.
  83513. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83514. */
  83515. maxEmitBox: Vector3;
  83516. /**
  83517. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83518. */
  83519. color1: Color4;
  83520. /**
  83521. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83522. */
  83523. color2: Color4;
  83524. /**
  83525. * Color the particle will have at the end of its lifetime
  83526. */
  83527. colorDead: Color4;
  83528. /**
  83529. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83530. */
  83531. textureMask: Color4;
  83532. /**
  83533. * The particle emitter type defines the emitter used by the particle system.
  83534. * It can be for example box, sphere, or cone...
  83535. */
  83536. particleEmitterType: IParticleEmitterType;
  83537. /** @hidden */
  83538. _isSubEmitter: boolean;
  83539. /**
  83540. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83541. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83542. */
  83543. billboardMode: number;
  83544. protected _isBillboardBased: boolean;
  83545. /**
  83546. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83547. */
  83548. isBillboardBased: boolean;
  83549. /**
  83550. * The scene the particle system belongs to.
  83551. */
  83552. protected _scene: Scene;
  83553. /**
  83554. * Local cache of defines for image processing.
  83555. */
  83556. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83557. /**
  83558. * Default configuration related to image processing available in the standard Material.
  83559. */
  83560. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83561. /**
  83562. * Gets the image processing configuration used either in this material.
  83563. */
  83564. /**
  83565. * Sets the Default image processing configuration used either in the this material.
  83566. *
  83567. * If sets to null, the scene one is in use.
  83568. */
  83569. imageProcessingConfiguration: ImageProcessingConfiguration;
  83570. /**
  83571. * Attaches a new image processing configuration to the Standard Material.
  83572. * @param configuration
  83573. */
  83574. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83575. /** @hidden */
  83576. protected _reset(): void;
  83577. /** @hidden */
  83578. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83579. /**
  83580. * Instantiates a particle system.
  83581. * 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.
  83582. * @param name The name of the particle system
  83583. */
  83584. constructor(name: string);
  83585. /**
  83586. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83587. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83588. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83589. * @returns the emitter
  83590. */
  83591. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83592. /**
  83593. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83594. * @param radius The radius of the hemisphere to emit from
  83595. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83596. * @returns the emitter
  83597. */
  83598. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83599. /**
  83600. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83601. * @param radius The radius of the sphere to emit from
  83602. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83603. * @returns the emitter
  83604. */
  83605. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83606. /**
  83607. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83608. * @param radius The radius of the sphere to emit from
  83609. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83610. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83611. * @returns the emitter
  83612. */
  83613. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83614. /**
  83615. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83616. * @param radius The radius of the emission cylinder
  83617. * @param height The height of the emission cylinder
  83618. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83619. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83620. * @returns the emitter
  83621. */
  83622. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83623. /**
  83624. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83625. * @param radius The radius of the cylinder to emit from
  83626. * @param height The height of the emission cylinder
  83627. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83630. * @returns the emitter
  83631. */
  83632. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83633. /**
  83634. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83635. * @param radius The radius of the cone to emit from
  83636. * @param angle The base angle of the cone
  83637. * @returns the emitter
  83638. */
  83639. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83640. /**
  83641. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83642. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83643. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83644. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83645. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83646. * @returns the emitter
  83647. */
  83648. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83649. }
  83650. }
  83651. declare module BABYLON {
  83652. /**
  83653. * Type of sub emitter
  83654. */
  83655. export enum SubEmitterType {
  83656. /**
  83657. * Attached to the particle over it's lifetime
  83658. */
  83659. ATTACHED = 0,
  83660. /**
  83661. * Created when the particle dies
  83662. */
  83663. END = 1
  83664. }
  83665. /**
  83666. * Sub emitter class used to emit particles from an existing particle
  83667. */
  83668. export class SubEmitter {
  83669. /**
  83670. * the particle system to be used by the sub emitter
  83671. */
  83672. particleSystem: ParticleSystem;
  83673. /**
  83674. * Type of the submitter (Default: END)
  83675. */
  83676. type: SubEmitterType;
  83677. /**
  83678. * 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)
  83679. * Note: This only is supported when using an emitter of type Mesh
  83680. */
  83681. inheritDirection: boolean;
  83682. /**
  83683. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83684. */
  83685. inheritedVelocityAmount: number;
  83686. /**
  83687. * Creates a sub emitter
  83688. * @param particleSystem the particle system to be used by the sub emitter
  83689. */
  83690. constructor(
  83691. /**
  83692. * the particle system to be used by the sub emitter
  83693. */
  83694. particleSystem: ParticleSystem);
  83695. /**
  83696. * Clones the sub emitter
  83697. * @returns the cloned sub emitter
  83698. */
  83699. clone(): SubEmitter;
  83700. /**
  83701. * Serialize current object to a JSON object
  83702. * @returns the serialized object
  83703. */
  83704. serialize(): any;
  83705. /** @hidden */
  83706. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83707. /**
  83708. * Creates a new SubEmitter from a serialized JSON version
  83709. * @param serializationObject defines the JSON object to read from
  83710. * @param scene defines the hosting scene
  83711. * @param rootUrl defines the rootUrl for data loading
  83712. * @returns a new SubEmitter
  83713. */
  83714. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83715. /** Release associated resources */
  83716. dispose(): void;
  83717. }
  83718. }
  83719. declare module BABYLON {
  83720. /** @hidden */
  83721. export var clipPlaneFragmentDeclaration: {
  83722. name: string;
  83723. shader: string;
  83724. };
  83725. }
  83726. declare module BABYLON {
  83727. /** @hidden */
  83728. export var imageProcessingDeclaration: {
  83729. name: string;
  83730. shader: string;
  83731. };
  83732. }
  83733. declare module BABYLON {
  83734. /** @hidden */
  83735. export var imageProcessingFunctions: {
  83736. name: string;
  83737. shader: string;
  83738. };
  83739. }
  83740. declare module BABYLON {
  83741. /** @hidden */
  83742. export var clipPlaneFragment: {
  83743. name: string;
  83744. shader: string;
  83745. };
  83746. }
  83747. declare module BABYLON {
  83748. /** @hidden */
  83749. export var particlesPixelShader: {
  83750. name: string;
  83751. shader: string;
  83752. };
  83753. }
  83754. declare module BABYLON {
  83755. /** @hidden */
  83756. export var clipPlaneVertexDeclaration: {
  83757. name: string;
  83758. shader: string;
  83759. };
  83760. }
  83761. declare module BABYLON {
  83762. /** @hidden */
  83763. export var clipPlaneVertex: {
  83764. name: string;
  83765. shader: string;
  83766. };
  83767. }
  83768. declare module BABYLON {
  83769. /** @hidden */
  83770. export var particlesVertexShader: {
  83771. name: string;
  83772. shader: string;
  83773. };
  83774. }
  83775. declare module BABYLON {
  83776. /**
  83777. * This represents a particle system in Babylon.
  83778. * 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.
  83779. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83780. * @example https://doc.babylonjs.com/babylon101/particles
  83781. */
  83782. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83783. /**
  83784. * Billboard mode will only apply to Y axis
  83785. */
  83786. static readonly BILLBOARDMODE_Y: number;
  83787. /**
  83788. * Billboard mode will apply to all axes
  83789. */
  83790. static readonly BILLBOARDMODE_ALL: number;
  83791. /**
  83792. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83793. */
  83794. static readonly BILLBOARDMODE_STRETCHED: number;
  83795. /**
  83796. * This function can be defined to provide custom update for active particles.
  83797. * This function will be called instead of regular update (age, position, color, etc.).
  83798. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83799. */
  83800. updateFunction: (particles: Particle[]) => void;
  83801. private _emitterWorldMatrix;
  83802. /**
  83803. * This function can be defined to specify initial direction for every new particle.
  83804. * It by default use the emitterType defined function
  83805. */
  83806. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83807. /**
  83808. * This function can be defined to specify initial position for every new particle.
  83809. * It by default use the emitterType defined function
  83810. */
  83811. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83812. /**
  83813. * @hidden
  83814. */
  83815. _inheritedVelocityOffset: Vector3;
  83816. /**
  83817. * An event triggered when the system is disposed
  83818. */
  83819. onDisposeObservable: Observable<ParticleSystem>;
  83820. private _onDisposeObserver;
  83821. /**
  83822. * Sets a callback that will be triggered when the system is disposed
  83823. */
  83824. onDispose: () => void;
  83825. private _particles;
  83826. private _epsilon;
  83827. private _capacity;
  83828. private _stockParticles;
  83829. private _newPartsExcess;
  83830. private _vertexData;
  83831. private _vertexBuffer;
  83832. private _vertexBuffers;
  83833. private _spriteBuffer;
  83834. private _indexBuffer;
  83835. private _effect;
  83836. private _customEffect;
  83837. private _cachedDefines;
  83838. private _scaledColorStep;
  83839. private _colorDiff;
  83840. private _scaledDirection;
  83841. private _scaledGravity;
  83842. private _currentRenderId;
  83843. private _alive;
  83844. private _useInstancing;
  83845. private _started;
  83846. private _stopped;
  83847. private _actualFrame;
  83848. private _scaledUpdateSpeed;
  83849. private _vertexBufferSize;
  83850. /** @hidden */
  83851. _currentEmitRateGradient: Nullable<FactorGradient>;
  83852. /** @hidden */
  83853. _currentEmitRate1: number;
  83854. /** @hidden */
  83855. _currentEmitRate2: number;
  83856. /** @hidden */
  83857. _currentStartSizeGradient: Nullable<FactorGradient>;
  83858. /** @hidden */
  83859. _currentStartSize1: number;
  83860. /** @hidden */
  83861. _currentStartSize2: number;
  83862. private readonly _rawTextureWidth;
  83863. private _rampGradientsTexture;
  83864. private _useRampGradients;
  83865. /** Gets or sets a boolean indicating that ramp gradients must be used
  83866. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83867. */
  83868. useRampGradients: boolean;
  83869. /**
  83870. * 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.
  83871. * 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: [])
  83872. */
  83873. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83874. private _subEmitters;
  83875. /**
  83876. * @hidden
  83877. * If the particle systems emitter should be disposed when the particle system is disposed
  83878. */
  83879. _disposeEmitterOnDispose: boolean;
  83880. /**
  83881. * The current active Sub-systems, this property is used by the root particle system only.
  83882. */
  83883. activeSubSystems: Array<ParticleSystem>;
  83884. private _rootParticleSystem;
  83885. /**
  83886. * Gets the current list of active particles
  83887. */
  83888. readonly particles: Particle[];
  83889. /**
  83890. * Returns the string "ParticleSystem"
  83891. * @returns a string containing the class name
  83892. */
  83893. getClassName(): string;
  83894. /**
  83895. * Instantiates a particle system.
  83896. * 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.
  83897. * @param name The name of the particle system
  83898. * @param capacity The max number of particles alive at the same time
  83899. * @param scene The scene the particle system belongs to
  83900. * @param customEffect a custom effect used to change the way particles are rendered by default
  83901. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83902. * @param epsilon Offset used to render the particles
  83903. */
  83904. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83905. private _addFactorGradient;
  83906. private _removeFactorGradient;
  83907. /**
  83908. * Adds a new life time gradient
  83909. * @param gradient defines the gradient to use (between 0 and 1)
  83910. * @param factor defines the life time factor to affect to the specified gradient
  83911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83912. * @returns the current particle system
  83913. */
  83914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83915. /**
  83916. * Remove a specific life time gradient
  83917. * @param gradient defines the gradient to remove
  83918. * @returns the current particle system
  83919. */
  83920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83921. /**
  83922. * Adds a new size gradient
  83923. * @param gradient defines the gradient to use (between 0 and 1)
  83924. * @param factor defines the size factor to affect to the specified gradient
  83925. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83926. * @returns the current particle system
  83927. */
  83928. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83929. /**
  83930. * Remove a specific size gradient
  83931. * @param gradient defines the gradient to remove
  83932. * @returns the current particle system
  83933. */
  83934. removeSizeGradient(gradient: number): IParticleSystem;
  83935. /**
  83936. * Adds a new color remap gradient
  83937. * @param gradient defines the gradient to use (between 0 and 1)
  83938. * @param min defines the color remap minimal range
  83939. * @param max defines the color remap maximal range
  83940. * @returns the current particle system
  83941. */
  83942. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83943. /**
  83944. * Remove a specific color remap gradient
  83945. * @param gradient defines the gradient to remove
  83946. * @returns the current particle system
  83947. */
  83948. removeColorRemapGradient(gradient: number): IParticleSystem;
  83949. /**
  83950. * Adds a new alpha remap gradient
  83951. * @param gradient defines the gradient to use (between 0 and 1)
  83952. * @param min defines the alpha remap minimal range
  83953. * @param max defines the alpha remap maximal range
  83954. * @returns the current particle system
  83955. */
  83956. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83957. /**
  83958. * Remove a specific alpha remap gradient
  83959. * @param gradient defines the gradient to remove
  83960. * @returns the current particle system
  83961. */
  83962. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83963. /**
  83964. * Adds a new angular speed gradient
  83965. * @param gradient defines the gradient to use (between 0 and 1)
  83966. * @param factor defines the angular speed to affect to the specified gradient
  83967. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83968. * @returns the current particle system
  83969. */
  83970. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83971. /**
  83972. * Remove a specific angular speed gradient
  83973. * @param gradient defines the gradient to remove
  83974. * @returns the current particle system
  83975. */
  83976. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83977. /**
  83978. * Adds a new velocity gradient
  83979. * @param gradient defines the gradient to use (between 0 and 1)
  83980. * @param factor defines the velocity to affect to the specified gradient
  83981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83982. * @returns the current particle system
  83983. */
  83984. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83985. /**
  83986. * Remove a specific velocity gradient
  83987. * @param gradient defines the gradient to remove
  83988. * @returns the current particle system
  83989. */
  83990. removeVelocityGradient(gradient: number): IParticleSystem;
  83991. /**
  83992. * Adds a new limit velocity gradient
  83993. * @param gradient defines the gradient to use (between 0 and 1)
  83994. * @param factor defines the limit velocity value to affect to the specified gradient
  83995. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83996. * @returns the current particle system
  83997. */
  83998. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83999. /**
  84000. * Remove a specific limit velocity gradient
  84001. * @param gradient defines the gradient to remove
  84002. * @returns the current particle system
  84003. */
  84004. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84005. /**
  84006. * Adds a new drag gradient
  84007. * @param gradient defines the gradient to use (between 0 and 1)
  84008. * @param factor defines the drag value to affect to the specified gradient
  84009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84010. * @returns the current particle system
  84011. */
  84012. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84013. /**
  84014. * Remove a specific drag gradient
  84015. * @param gradient defines the gradient to remove
  84016. * @returns the current particle system
  84017. */
  84018. removeDragGradient(gradient: number): IParticleSystem;
  84019. /**
  84020. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84021. * @param gradient defines the gradient to use (between 0 and 1)
  84022. * @param factor defines the emit rate value to affect to the specified gradient
  84023. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84024. * @returns the current particle system
  84025. */
  84026. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84027. /**
  84028. * Remove a specific emit rate gradient
  84029. * @param gradient defines the gradient to remove
  84030. * @returns the current particle system
  84031. */
  84032. removeEmitRateGradient(gradient: number): IParticleSystem;
  84033. /**
  84034. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84035. * @param gradient defines the gradient to use (between 0 and 1)
  84036. * @param factor defines the start size value to affect to the specified gradient
  84037. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84038. * @returns the current particle system
  84039. */
  84040. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84041. /**
  84042. * Remove a specific start size gradient
  84043. * @param gradient defines the gradient to remove
  84044. * @returns the current particle system
  84045. */
  84046. removeStartSizeGradient(gradient: number): IParticleSystem;
  84047. private _createRampGradientTexture;
  84048. /**
  84049. * Gets the current list of ramp gradients.
  84050. * You must use addRampGradient and removeRampGradient to udpate this list
  84051. * @returns the list of ramp gradients
  84052. */
  84053. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84054. /**
  84055. * Adds a new ramp gradient used to remap particle colors
  84056. * @param gradient defines the gradient to use (between 0 and 1)
  84057. * @param color defines the color to affect to the specified gradient
  84058. * @returns the current particle system
  84059. */
  84060. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84061. /**
  84062. * Remove a specific ramp gradient
  84063. * @param gradient defines the gradient to remove
  84064. * @returns the current particle system
  84065. */
  84066. removeRampGradient(gradient: number): ParticleSystem;
  84067. /**
  84068. * Adds a new color gradient
  84069. * @param gradient defines the gradient to use (between 0 and 1)
  84070. * @param color1 defines the color to affect to the specified gradient
  84071. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84072. * @returns this particle system
  84073. */
  84074. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84075. /**
  84076. * Remove a specific color gradient
  84077. * @param gradient defines the gradient to remove
  84078. * @returns this particle system
  84079. */
  84080. removeColorGradient(gradient: number): IParticleSystem;
  84081. private _fetchR;
  84082. protected _reset(): void;
  84083. private _resetEffect;
  84084. private _createVertexBuffers;
  84085. private _createIndexBuffer;
  84086. /**
  84087. * Gets the maximum number of particles active at the same time.
  84088. * @returns The max number of active particles.
  84089. */
  84090. getCapacity(): number;
  84091. /**
  84092. * Gets whether there are still active particles in the system.
  84093. * @returns True if it is alive, otherwise false.
  84094. */
  84095. isAlive(): boolean;
  84096. /**
  84097. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84098. * @returns True if it has been started, otherwise false.
  84099. */
  84100. isStarted(): boolean;
  84101. private _prepareSubEmitterInternalArray;
  84102. /**
  84103. * Starts the particle system and begins to emit
  84104. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84105. */
  84106. start(delay?: number): void;
  84107. /**
  84108. * Stops the particle system.
  84109. * @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.
  84110. */
  84111. stop(stopSubEmitters?: boolean): void;
  84112. /**
  84113. * Remove all active particles
  84114. */
  84115. reset(): void;
  84116. /**
  84117. * @hidden (for internal use only)
  84118. */
  84119. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84120. /**
  84121. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84122. * Its lifetime will start back at 0.
  84123. */
  84124. recycleParticle: (particle: Particle) => void;
  84125. private _stopSubEmitters;
  84126. private _createParticle;
  84127. private _removeFromRoot;
  84128. private _emitFromParticle;
  84129. private _update;
  84130. /** @hidden */
  84131. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84132. /** @hidden */
  84133. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84134. /** @hidden */
  84135. private _getEffect;
  84136. /**
  84137. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84138. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84139. */
  84140. animate(preWarmOnly?: boolean): void;
  84141. private _appendParticleVertices;
  84142. /**
  84143. * Rebuilds the particle system.
  84144. */
  84145. rebuild(): void;
  84146. /**
  84147. * Is this system ready to be used/rendered
  84148. * @return true if the system is ready
  84149. */
  84150. isReady(): boolean;
  84151. private _render;
  84152. /**
  84153. * Renders the particle system in its current state.
  84154. * @returns the current number of particles
  84155. */
  84156. render(): number;
  84157. /**
  84158. * Disposes the particle system and free the associated resources
  84159. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84160. */
  84161. dispose(disposeTexture?: boolean): void;
  84162. /**
  84163. * Clones the particle system.
  84164. * @param name The name of the cloned object
  84165. * @param newEmitter The new emitter to use
  84166. * @returns the cloned particle system
  84167. */
  84168. clone(name: string, newEmitter: any): ParticleSystem;
  84169. /**
  84170. * Serializes the particle system to a JSON object.
  84171. * @returns the JSON object
  84172. */
  84173. serialize(): any;
  84174. /** @hidden */
  84175. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84176. /** @hidden */
  84177. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84178. /**
  84179. * Parses a JSON object to create a particle system.
  84180. * @param parsedParticleSystem The JSON object to parse
  84181. * @param scene The scene to create the particle system in
  84182. * @param rootUrl The root url to use to load external dependencies like texture
  84183. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84184. * @returns the Parsed particle system
  84185. */
  84186. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84187. }
  84188. }
  84189. declare module BABYLON {
  84190. /**
  84191. * A particle represents one of the element emitted by a particle system.
  84192. * This is mainly define by its coordinates, direction, velocity and age.
  84193. */
  84194. export class Particle {
  84195. /**
  84196. * The particle system the particle belongs to.
  84197. */
  84198. particleSystem: ParticleSystem;
  84199. private static _Count;
  84200. /**
  84201. * Unique ID of the particle
  84202. */
  84203. id: number;
  84204. /**
  84205. * The world position of the particle in the scene.
  84206. */
  84207. position: Vector3;
  84208. /**
  84209. * The world direction of the particle in the scene.
  84210. */
  84211. direction: Vector3;
  84212. /**
  84213. * The color of the particle.
  84214. */
  84215. color: Color4;
  84216. /**
  84217. * The color change of the particle per step.
  84218. */
  84219. colorStep: Color4;
  84220. /**
  84221. * Defines how long will the life of the particle be.
  84222. */
  84223. lifeTime: number;
  84224. /**
  84225. * The current age of the particle.
  84226. */
  84227. age: number;
  84228. /**
  84229. * The current size of the particle.
  84230. */
  84231. size: number;
  84232. /**
  84233. * The current scale of the particle.
  84234. */
  84235. scale: Vector2;
  84236. /**
  84237. * The current angle of the particle.
  84238. */
  84239. angle: number;
  84240. /**
  84241. * Defines how fast is the angle changing.
  84242. */
  84243. angularSpeed: number;
  84244. /**
  84245. * Defines the cell index used by the particle to be rendered from a sprite.
  84246. */
  84247. cellIndex: number;
  84248. /**
  84249. * The information required to support color remapping
  84250. */
  84251. remapData: Vector4;
  84252. /** @hidden */
  84253. _randomCellOffset?: number;
  84254. /** @hidden */
  84255. _initialDirection: Nullable<Vector3>;
  84256. /** @hidden */
  84257. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84258. /** @hidden */
  84259. _initialStartSpriteCellID: number;
  84260. /** @hidden */
  84261. _initialEndSpriteCellID: number;
  84262. /** @hidden */
  84263. _currentColorGradient: Nullable<ColorGradient>;
  84264. /** @hidden */
  84265. _currentColor1: Color4;
  84266. /** @hidden */
  84267. _currentColor2: Color4;
  84268. /** @hidden */
  84269. _currentSizeGradient: Nullable<FactorGradient>;
  84270. /** @hidden */
  84271. _currentSize1: number;
  84272. /** @hidden */
  84273. _currentSize2: number;
  84274. /** @hidden */
  84275. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84276. /** @hidden */
  84277. _currentAngularSpeed1: number;
  84278. /** @hidden */
  84279. _currentAngularSpeed2: number;
  84280. /** @hidden */
  84281. _currentVelocityGradient: Nullable<FactorGradient>;
  84282. /** @hidden */
  84283. _currentVelocity1: number;
  84284. /** @hidden */
  84285. _currentVelocity2: number;
  84286. /** @hidden */
  84287. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84288. /** @hidden */
  84289. _currentLimitVelocity1: number;
  84290. /** @hidden */
  84291. _currentLimitVelocity2: number;
  84292. /** @hidden */
  84293. _currentDragGradient: Nullable<FactorGradient>;
  84294. /** @hidden */
  84295. _currentDrag1: number;
  84296. /** @hidden */
  84297. _currentDrag2: number;
  84298. /** @hidden */
  84299. _randomNoiseCoordinates1: Vector3;
  84300. /** @hidden */
  84301. _randomNoiseCoordinates2: Vector3;
  84302. /**
  84303. * Creates a new instance Particle
  84304. * @param particleSystem the particle system the particle belongs to
  84305. */
  84306. constructor(
  84307. /**
  84308. * The particle system the particle belongs to.
  84309. */
  84310. particleSystem: ParticleSystem);
  84311. private updateCellInfoFromSystem;
  84312. /**
  84313. * Defines how the sprite cell index is updated for the particle
  84314. */
  84315. updateCellIndex(): void;
  84316. /** @hidden */
  84317. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84318. /** @hidden */
  84319. _inheritParticleInfoToSubEmitters(): void;
  84320. /** @hidden */
  84321. _reset(): void;
  84322. /**
  84323. * Copy the properties of particle to another one.
  84324. * @param other the particle to copy the information to.
  84325. */
  84326. copyTo(other: Particle): void;
  84327. }
  84328. }
  84329. declare module BABYLON {
  84330. /**
  84331. * Particle emitter represents a volume emitting particles.
  84332. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84333. */
  84334. export interface IParticleEmitterType {
  84335. /**
  84336. * Called by the particle System when the direction is computed for the created particle.
  84337. * @param worldMatrix is the world matrix of the particle system
  84338. * @param directionToUpdate is the direction vector to update with the result
  84339. * @param particle is the particle we are computed the direction for
  84340. */
  84341. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84342. /**
  84343. * Called by the particle System when the position is computed for the created particle.
  84344. * @param worldMatrix is the world matrix of the particle system
  84345. * @param positionToUpdate is the position vector to update with the result
  84346. * @param particle is the particle we are computed the position for
  84347. */
  84348. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84349. /**
  84350. * Clones the current emitter and returns a copy of it
  84351. * @returns the new emitter
  84352. */
  84353. clone(): IParticleEmitterType;
  84354. /**
  84355. * Called by the GPUParticleSystem to setup the update shader
  84356. * @param effect defines the update shader
  84357. */
  84358. applyToShader(effect: Effect): void;
  84359. /**
  84360. * Returns a string to use to update the GPU particles update shader
  84361. * @returns the effect defines string
  84362. */
  84363. getEffectDefines(): string;
  84364. /**
  84365. * Returns a string representing the class name
  84366. * @returns a string containing the class name
  84367. */
  84368. getClassName(): string;
  84369. /**
  84370. * Serializes the particle system to a JSON object.
  84371. * @returns the JSON object
  84372. */
  84373. serialize(): any;
  84374. /**
  84375. * Parse properties from a JSON object
  84376. * @param serializationObject defines the JSON object
  84377. */
  84378. parse(serializationObject: any): void;
  84379. }
  84380. }
  84381. declare module BABYLON {
  84382. /**
  84383. * Particle emitter emitting particles from the inside of a box.
  84384. * It emits the particles randomly between 2 given directions.
  84385. */
  84386. export class BoxParticleEmitter implements IParticleEmitterType {
  84387. /**
  84388. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84389. */
  84390. direction1: Vector3;
  84391. /**
  84392. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84393. */
  84394. direction2: Vector3;
  84395. /**
  84396. * 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.
  84397. */
  84398. minEmitBox: Vector3;
  84399. /**
  84400. * 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.
  84401. */
  84402. maxEmitBox: Vector3;
  84403. /**
  84404. * Creates a new instance BoxParticleEmitter
  84405. */
  84406. constructor();
  84407. /**
  84408. * Called by the particle System when the direction is computed for the created particle.
  84409. * @param worldMatrix is the world matrix of the particle system
  84410. * @param directionToUpdate is the direction vector to update with the result
  84411. * @param particle is the particle we are computed the direction for
  84412. */
  84413. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84414. /**
  84415. * Called by the particle System when the position is computed for the created particle.
  84416. * @param worldMatrix is the world matrix of the particle system
  84417. * @param positionToUpdate is the position vector to update with the result
  84418. * @param particle is the particle we are computed the position for
  84419. */
  84420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84421. /**
  84422. * Clones the current emitter and returns a copy of it
  84423. * @returns the new emitter
  84424. */
  84425. clone(): BoxParticleEmitter;
  84426. /**
  84427. * Called by the GPUParticleSystem to setup the update shader
  84428. * @param effect defines the update shader
  84429. */
  84430. applyToShader(effect: Effect): void;
  84431. /**
  84432. * Returns a string to use to update the GPU particles update shader
  84433. * @returns a string containng the defines string
  84434. */
  84435. getEffectDefines(): string;
  84436. /**
  84437. * Returns the string "BoxParticleEmitter"
  84438. * @returns a string containing the class name
  84439. */
  84440. getClassName(): string;
  84441. /**
  84442. * Serializes the particle system to a JSON object.
  84443. * @returns the JSON object
  84444. */
  84445. serialize(): any;
  84446. /**
  84447. * Parse properties from a JSON object
  84448. * @param serializationObject defines the JSON object
  84449. */
  84450. parse(serializationObject: any): void;
  84451. }
  84452. }
  84453. declare module BABYLON {
  84454. /**
  84455. * Particle emitter emitting particles from the inside of a cone.
  84456. * It emits the particles alongside the cone volume from the base to the particle.
  84457. * The emission direction might be randomized.
  84458. */
  84459. export class ConeParticleEmitter implements IParticleEmitterType {
  84460. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84461. directionRandomizer: number;
  84462. private _radius;
  84463. private _angle;
  84464. private _height;
  84465. /**
  84466. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84467. */
  84468. radiusRange: number;
  84469. /**
  84470. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84471. */
  84472. heightRange: number;
  84473. /**
  84474. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84475. */
  84476. emitFromSpawnPointOnly: boolean;
  84477. /**
  84478. * Gets or sets the radius of the emission cone
  84479. */
  84480. radius: number;
  84481. /**
  84482. * Gets or sets the angle of the emission cone
  84483. */
  84484. angle: number;
  84485. private _buildHeight;
  84486. /**
  84487. * Creates a new instance ConeParticleEmitter
  84488. * @param radius the radius of the emission cone (1 by default)
  84489. * @param angle the cone base angle (PI by default)
  84490. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84491. */
  84492. constructor(radius?: number, angle?: number,
  84493. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84494. directionRandomizer?: number);
  84495. /**
  84496. * Called by the particle System when the direction is computed for the created particle.
  84497. * @param worldMatrix is the world matrix of the particle system
  84498. * @param directionToUpdate is the direction vector to update with the result
  84499. * @param particle is the particle we are computed the direction for
  84500. */
  84501. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84502. /**
  84503. * Called by the particle System when the position is computed for the created particle.
  84504. * @param worldMatrix is the world matrix of the particle system
  84505. * @param positionToUpdate is the position vector to update with the result
  84506. * @param particle is the particle we are computed the position for
  84507. */
  84508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84509. /**
  84510. * Clones the current emitter and returns a copy of it
  84511. * @returns the new emitter
  84512. */
  84513. clone(): ConeParticleEmitter;
  84514. /**
  84515. * Called by the GPUParticleSystem to setup the update shader
  84516. * @param effect defines the update shader
  84517. */
  84518. applyToShader(effect: Effect): void;
  84519. /**
  84520. * Returns a string to use to update the GPU particles update shader
  84521. * @returns a string containng the defines string
  84522. */
  84523. getEffectDefines(): string;
  84524. /**
  84525. * Returns the string "ConeParticleEmitter"
  84526. * @returns a string containing the class name
  84527. */
  84528. getClassName(): string;
  84529. /**
  84530. * Serializes the particle system to a JSON object.
  84531. * @returns the JSON object
  84532. */
  84533. serialize(): any;
  84534. /**
  84535. * Parse properties from a JSON object
  84536. * @param serializationObject defines the JSON object
  84537. */
  84538. parse(serializationObject: any): void;
  84539. }
  84540. }
  84541. declare module BABYLON {
  84542. /**
  84543. * Particle emitter emitting particles from the inside of a cylinder.
  84544. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84545. */
  84546. export class CylinderParticleEmitter implements IParticleEmitterType {
  84547. /**
  84548. * The radius of the emission cylinder.
  84549. */
  84550. radius: number;
  84551. /**
  84552. * The height of the emission cylinder.
  84553. */
  84554. height: number;
  84555. /**
  84556. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84557. */
  84558. radiusRange: number;
  84559. /**
  84560. * How much to randomize the particle direction [0-1].
  84561. */
  84562. directionRandomizer: number;
  84563. /**
  84564. * Creates a new instance CylinderParticleEmitter
  84565. * @param radius the radius of the emission cylinder (1 by default)
  84566. * @param height the height of the emission cylinder (1 by default)
  84567. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84568. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84569. */
  84570. constructor(
  84571. /**
  84572. * The radius of the emission cylinder.
  84573. */
  84574. radius?: number,
  84575. /**
  84576. * The height of the emission cylinder.
  84577. */
  84578. height?: number,
  84579. /**
  84580. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84581. */
  84582. radiusRange?: number,
  84583. /**
  84584. * How much to randomize the particle direction [0-1].
  84585. */
  84586. directionRandomizer?: number);
  84587. /**
  84588. * Called by the particle System when the direction is computed for the created particle.
  84589. * @param worldMatrix is the world matrix of the particle system
  84590. * @param directionToUpdate is the direction vector to update with the result
  84591. * @param particle is the particle we are computed the direction for
  84592. */
  84593. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84594. /**
  84595. * Called by the particle System when the position is computed for the created particle.
  84596. * @param worldMatrix is the world matrix of the particle system
  84597. * @param positionToUpdate is the position vector to update with the result
  84598. * @param particle is the particle we are computed the position for
  84599. */
  84600. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84601. /**
  84602. * Clones the current emitter and returns a copy of it
  84603. * @returns the new emitter
  84604. */
  84605. clone(): CylinderParticleEmitter;
  84606. /**
  84607. * Called by the GPUParticleSystem to setup the update shader
  84608. * @param effect defines the update shader
  84609. */
  84610. applyToShader(effect: Effect): void;
  84611. /**
  84612. * Returns a string to use to update the GPU particles update shader
  84613. * @returns a string containng the defines string
  84614. */
  84615. getEffectDefines(): string;
  84616. /**
  84617. * Returns the string "CylinderParticleEmitter"
  84618. * @returns a string containing the class name
  84619. */
  84620. getClassName(): string;
  84621. /**
  84622. * Serializes the particle system to a JSON object.
  84623. * @returns the JSON object
  84624. */
  84625. serialize(): any;
  84626. /**
  84627. * Parse properties from a JSON object
  84628. * @param serializationObject defines the JSON object
  84629. */
  84630. parse(serializationObject: any): void;
  84631. }
  84632. /**
  84633. * Particle emitter emitting particles from the inside of a cylinder.
  84634. * It emits the particles randomly between two vectors.
  84635. */
  84636. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84637. /**
  84638. * The min limit of the emission direction.
  84639. */
  84640. direction1: Vector3;
  84641. /**
  84642. * The max limit of the emission direction.
  84643. */
  84644. direction2: Vector3;
  84645. /**
  84646. * Creates a new instance CylinderDirectedParticleEmitter
  84647. * @param radius the radius of the emission cylinder (1 by default)
  84648. * @param height the height of the emission cylinder (1 by default)
  84649. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84650. * @param direction1 the min limit of the emission direction (up vector by default)
  84651. * @param direction2 the max limit of the emission direction (up vector by default)
  84652. */
  84653. constructor(radius?: number, height?: number, radiusRange?: number,
  84654. /**
  84655. * The min limit of the emission direction.
  84656. */
  84657. direction1?: Vector3,
  84658. /**
  84659. * The max limit of the emission direction.
  84660. */
  84661. direction2?: Vector3);
  84662. /**
  84663. * Called by the particle System when the direction is computed for the created particle.
  84664. * @param worldMatrix is the world matrix of the particle system
  84665. * @param directionToUpdate is the direction vector to update with the result
  84666. * @param particle is the particle we are computed the direction for
  84667. */
  84668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84669. /**
  84670. * Clones the current emitter and returns a copy of it
  84671. * @returns the new emitter
  84672. */
  84673. clone(): CylinderDirectedParticleEmitter;
  84674. /**
  84675. * Called by the GPUParticleSystem to setup the update shader
  84676. * @param effect defines the update shader
  84677. */
  84678. applyToShader(effect: Effect): void;
  84679. /**
  84680. * Returns a string to use to update the GPU particles update shader
  84681. * @returns a string containng the defines string
  84682. */
  84683. getEffectDefines(): string;
  84684. /**
  84685. * Returns the string "CylinderDirectedParticleEmitter"
  84686. * @returns a string containing the class name
  84687. */
  84688. getClassName(): string;
  84689. /**
  84690. * Serializes the particle system to a JSON object.
  84691. * @returns the JSON object
  84692. */
  84693. serialize(): any;
  84694. /**
  84695. * Parse properties from a JSON object
  84696. * @param serializationObject defines the JSON object
  84697. */
  84698. parse(serializationObject: any): void;
  84699. }
  84700. }
  84701. declare module BABYLON {
  84702. /**
  84703. * Particle emitter emitting particles from the inside of a hemisphere.
  84704. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84705. */
  84706. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84707. /**
  84708. * The radius of the emission hemisphere.
  84709. */
  84710. radius: number;
  84711. /**
  84712. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84713. */
  84714. radiusRange: number;
  84715. /**
  84716. * How much to randomize the particle direction [0-1].
  84717. */
  84718. directionRandomizer: number;
  84719. /**
  84720. * Creates a new instance HemisphericParticleEmitter
  84721. * @param radius the radius of the emission hemisphere (1 by default)
  84722. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84723. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84724. */
  84725. constructor(
  84726. /**
  84727. * The radius of the emission hemisphere.
  84728. */
  84729. radius?: number,
  84730. /**
  84731. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84732. */
  84733. radiusRange?: number,
  84734. /**
  84735. * How much to randomize the particle direction [0-1].
  84736. */
  84737. directionRandomizer?: number);
  84738. /**
  84739. * Called by the particle System when the direction is computed for the created particle.
  84740. * @param worldMatrix is the world matrix of the particle system
  84741. * @param directionToUpdate is the direction vector to update with the result
  84742. * @param particle is the particle we are computed the direction for
  84743. */
  84744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84745. /**
  84746. * Called by the particle System when the position is computed for the created particle.
  84747. * @param worldMatrix is the world matrix of the particle system
  84748. * @param positionToUpdate is the position vector to update with the result
  84749. * @param particle is the particle we are computed the position for
  84750. */
  84751. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84752. /**
  84753. * Clones the current emitter and returns a copy of it
  84754. * @returns the new emitter
  84755. */
  84756. clone(): HemisphericParticleEmitter;
  84757. /**
  84758. * Called by the GPUParticleSystem to setup the update shader
  84759. * @param effect defines the update shader
  84760. */
  84761. applyToShader(effect: Effect): void;
  84762. /**
  84763. * Returns a string to use to update the GPU particles update shader
  84764. * @returns a string containng the defines string
  84765. */
  84766. getEffectDefines(): string;
  84767. /**
  84768. * Returns the string "HemisphericParticleEmitter"
  84769. * @returns a string containing the class name
  84770. */
  84771. getClassName(): string;
  84772. /**
  84773. * Serializes the particle system to a JSON object.
  84774. * @returns the JSON object
  84775. */
  84776. serialize(): any;
  84777. /**
  84778. * Parse properties from a JSON object
  84779. * @param serializationObject defines the JSON object
  84780. */
  84781. parse(serializationObject: any): void;
  84782. }
  84783. }
  84784. declare module BABYLON {
  84785. /**
  84786. * Particle emitter emitting particles from a point.
  84787. * It emits the particles randomly between 2 given directions.
  84788. */
  84789. export class PointParticleEmitter implements IParticleEmitterType {
  84790. /**
  84791. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84792. */
  84793. direction1: Vector3;
  84794. /**
  84795. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84796. */
  84797. direction2: Vector3;
  84798. /**
  84799. * Creates a new instance PointParticleEmitter
  84800. */
  84801. constructor();
  84802. /**
  84803. * Called by the particle System when the direction is computed for the created particle.
  84804. * @param worldMatrix is the world matrix of the particle system
  84805. * @param directionToUpdate is the direction vector to update with the result
  84806. * @param particle is the particle we are computed the direction for
  84807. */
  84808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84809. /**
  84810. * Called by the particle System when the position is computed for the created particle.
  84811. * @param worldMatrix is the world matrix of the particle system
  84812. * @param positionToUpdate is the position vector to update with the result
  84813. * @param particle is the particle we are computed the position for
  84814. */
  84815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84816. /**
  84817. * Clones the current emitter and returns a copy of it
  84818. * @returns the new emitter
  84819. */
  84820. clone(): PointParticleEmitter;
  84821. /**
  84822. * Called by the GPUParticleSystem to setup the update shader
  84823. * @param effect defines the update shader
  84824. */
  84825. applyToShader(effect: Effect): void;
  84826. /**
  84827. * Returns a string to use to update the GPU particles update shader
  84828. * @returns a string containng the defines string
  84829. */
  84830. getEffectDefines(): string;
  84831. /**
  84832. * Returns the string "PointParticleEmitter"
  84833. * @returns a string containing the class name
  84834. */
  84835. getClassName(): string;
  84836. /**
  84837. * Serializes the particle system to a JSON object.
  84838. * @returns the JSON object
  84839. */
  84840. serialize(): any;
  84841. /**
  84842. * Parse properties from a JSON object
  84843. * @param serializationObject defines the JSON object
  84844. */
  84845. parse(serializationObject: any): void;
  84846. }
  84847. }
  84848. declare module BABYLON {
  84849. /**
  84850. * Particle emitter emitting particles from the inside of a sphere.
  84851. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84852. */
  84853. export class SphereParticleEmitter implements IParticleEmitterType {
  84854. /**
  84855. * The radius of the emission sphere.
  84856. */
  84857. radius: number;
  84858. /**
  84859. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84860. */
  84861. radiusRange: number;
  84862. /**
  84863. * How much to randomize the particle direction [0-1].
  84864. */
  84865. directionRandomizer: number;
  84866. /**
  84867. * Creates a new instance SphereParticleEmitter
  84868. * @param radius the radius of the emission sphere (1 by default)
  84869. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84870. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84871. */
  84872. constructor(
  84873. /**
  84874. * The radius of the emission sphere.
  84875. */
  84876. radius?: number,
  84877. /**
  84878. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84879. */
  84880. radiusRange?: number,
  84881. /**
  84882. * How much to randomize the particle direction [0-1].
  84883. */
  84884. directionRandomizer?: number);
  84885. /**
  84886. * Called by the particle System when the direction is computed for the created particle.
  84887. * @param worldMatrix is the world matrix of the particle system
  84888. * @param directionToUpdate is the direction vector to update with the result
  84889. * @param particle is the particle we are computed the direction for
  84890. */
  84891. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84892. /**
  84893. * Called by the particle System when the position is computed for the created particle.
  84894. * @param worldMatrix is the world matrix of the particle system
  84895. * @param positionToUpdate is the position vector to update with the result
  84896. * @param particle is the particle we are computed the position for
  84897. */
  84898. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84899. /**
  84900. * Clones the current emitter and returns a copy of it
  84901. * @returns the new emitter
  84902. */
  84903. clone(): SphereParticleEmitter;
  84904. /**
  84905. * Called by the GPUParticleSystem to setup the update shader
  84906. * @param effect defines the update shader
  84907. */
  84908. applyToShader(effect: Effect): void;
  84909. /**
  84910. * Returns a string to use to update the GPU particles update shader
  84911. * @returns a string containng the defines string
  84912. */
  84913. getEffectDefines(): string;
  84914. /**
  84915. * Returns the string "SphereParticleEmitter"
  84916. * @returns a string containing the class name
  84917. */
  84918. getClassName(): string;
  84919. /**
  84920. * Serializes the particle system to a JSON object.
  84921. * @returns the JSON object
  84922. */
  84923. serialize(): any;
  84924. /**
  84925. * Parse properties from a JSON object
  84926. * @param serializationObject defines the JSON object
  84927. */
  84928. parse(serializationObject: any): void;
  84929. }
  84930. /**
  84931. * Particle emitter emitting particles from the inside of a sphere.
  84932. * It emits the particles randomly between two vectors.
  84933. */
  84934. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84935. /**
  84936. * The min limit of the emission direction.
  84937. */
  84938. direction1: Vector3;
  84939. /**
  84940. * The max limit of the emission direction.
  84941. */
  84942. direction2: Vector3;
  84943. /**
  84944. * Creates a new instance SphereDirectedParticleEmitter
  84945. * @param radius the radius of the emission sphere (1 by default)
  84946. * @param direction1 the min limit of the emission direction (up vector by default)
  84947. * @param direction2 the max limit of the emission direction (up vector by default)
  84948. */
  84949. constructor(radius?: number,
  84950. /**
  84951. * The min limit of the emission direction.
  84952. */
  84953. direction1?: Vector3,
  84954. /**
  84955. * The max limit of the emission direction.
  84956. */
  84957. direction2?: Vector3);
  84958. /**
  84959. * Called by the particle System when the direction is computed for the created particle.
  84960. * @param worldMatrix is the world matrix of the particle system
  84961. * @param directionToUpdate is the direction vector to update with the result
  84962. * @param particle is the particle we are computed the direction for
  84963. */
  84964. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84965. /**
  84966. * Clones the current emitter and returns a copy of it
  84967. * @returns the new emitter
  84968. */
  84969. clone(): SphereDirectedParticleEmitter;
  84970. /**
  84971. * Called by the GPUParticleSystem to setup the update shader
  84972. * @param effect defines the update shader
  84973. */
  84974. applyToShader(effect: Effect): void;
  84975. /**
  84976. * Returns a string to use to update the GPU particles update shader
  84977. * @returns a string containng the defines string
  84978. */
  84979. getEffectDefines(): string;
  84980. /**
  84981. * Returns the string "SphereDirectedParticleEmitter"
  84982. * @returns a string containing the class name
  84983. */
  84984. getClassName(): string;
  84985. /**
  84986. * Serializes the particle system to a JSON object.
  84987. * @returns the JSON object
  84988. */
  84989. serialize(): any;
  84990. /**
  84991. * Parse properties from a JSON object
  84992. * @param serializationObject defines the JSON object
  84993. */
  84994. parse(serializationObject: any): void;
  84995. }
  84996. }
  84997. declare module BABYLON {
  84998. /**
  84999. * Interface representing a particle system in Babylon.js.
  85000. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85001. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85002. */
  85003. export interface IParticleSystem {
  85004. /**
  85005. * List of animations used by the particle system.
  85006. */
  85007. animations: Animation[];
  85008. /**
  85009. * The id of the Particle system.
  85010. */
  85011. id: string;
  85012. /**
  85013. * The name of the Particle system.
  85014. */
  85015. name: string;
  85016. /**
  85017. * The emitter represents the Mesh or position we are attaching the particle system to.
  85018. */
  85019. emitter: Nullable<AbstractMesh | Vector3>;
  85020. /**
  85021. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85022. */
  85023. isBillboardBased: boolean;
  85024. /**
  85025. * The rendering group used by the Particle system to chose when to render.
  85026. */
  85027. renderingGroupId: number;
  85028. /**
  85029. * The layer mask we are rendering the particles through.
  85030. */
  85031. layerMask: number;
  85032. /**
  85033. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85034. */
  85035. updateSpeed: number;
  85036. /**
  85037. * The amount of time the particle system is running (depends of the overall update speed).
  85038. */
  85039. targetStopDuration: number;
  85040. /**
  85041. * The texture used to render each particle. (this can be a spritesheet)
  85042. */
  85043. particleTexture: Nullable<Texture>;
  85044. /**
  85045. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85046. */
  85047. blendMode: number;
  85048. /**
  85049. * Minimum life time of emitting particles.
  85050. */
  85051. minLifeTime: number;
  85052. /**
  85053. * Maximum life time of emitting particles.
  85054. */
  85055. maxLifeTime: number;
  85056. /**
  85057. * Minimum Size of emitting particles.
  85058. */
  85059. minSize: number;
  85060. /**
  85061. * Maximum Size of emitting particles.
  85062. */
  85063. maxSize: number;
  85064. /**
  85065. * Minimum scale of emitting particles on X axis.
  85066. */
  85067. minScaleX: number;
  85068. /**
  85069. * Maximum scale of emitting particles on X axis.
  85070. */
  85071. maxScaleX: number;
  85072. /**
  85073. * Minimum scale of emitting particles on Y axis.
  85074. */
  85075. minScaleY: number;
  85076. /**
  85077. * Maximum scale of emitting particles on Y axis.
  85078. */
  85079. maxScaleY: number;
  85080. /**
  85081. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85082. */
  85083. color1: Color4;
  85084. /**
  85085. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85086. */
  85087. color2: Color4;
  85088. /**
  85089. * Color the particle will have at the end of its lifetime.
  85090. */
  85091. colorDead: Color4;
  85092. /**
  85093. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85094. */
  85095. emitRate: number;
  85096. /**
  85097. * You can use gravity if you want to give an orientation to your particles.
  85098. */
  85099. gravity: Vector3;
  85100. /**
  85101. * Minimum power of emitting particles.
  85102. */
  85103. minEmitPower: number;
  85104. /**
  85105. * Maximum power of emitting particles.
  85106. */
  85107. maxEmitPower: number;
  85108. /**
  85109. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85110. */
  85111. minAngularSpeed: number;
  85112. /**
  85113. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85114. */
  85115. maxAngularSpeed: number;
  85116. /**
  85117. * Gets or sets the minimal initial rotation in radians.
  85118. */
  85119. minInitialRotation: number;
  85120. /**
  85121. * Gets or sets the maximal initial rotation in radians.
  85122. */
  85123. maxInitialRotation: number;
  85124. /**
  85125. * The particle emitter type defines the emitter used by the particle system.
  85126. * It can be for example box, sphere, or cone...
  85127. */
  85128. particleEmitterType: Nullable<IParticleEmitterType>;
  85129. /**
  85130. * Defines the delay in milliseconds before starting the system (0 by default)
  85131. */
  85132. startDelay: number;
  85133. /**
  85134. * 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
  85135. */
  85136. preWarmCycles: number;
  85137. /**
  85138. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85139. */
  85140. preWarmStepOffset: number;
  85141. /**
  85142. * 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)
  85143. */
  85144. spriteCellChangeSpeed: number;
  85145. /**
  85146. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85147. */
  85148. startSpriteCellID: number;
  85149. /**
  85150. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85151. */
  85152. endSpriteCellID: number;
  85153. /**
  85154. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85155. */
  85156. spriteCellWidth: number;
  85157. /**
  85158. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85159. */
  85160. spriteCellHeight: number;
  85161. /**
  85162. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85163. */
  85164. spriteRandomStartCell: boolean;
  85165. /**
  85166. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85167. */
  85168. isAnimationSheetEnabled: boolean;
  85169. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85170. translationPivot: Vector2;
  85171. /**
  85172. * Gets or sets a texture used to add random noise to particle positions
  85173. */
  85174. noiseTexture: Nullable<BaseTexture>;
  85175. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85176. noiseStrength: Vector3;
  85177. /**
  85178. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85179. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85180. */
  85181. billboardMode: number;
  85182. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85183. limitVelocityDamping: number;
  85184. /**
  85185. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85186. */
  85187. beginAnimationOnStart: boolean;
  85188. /**
  85189. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85190. */
  85191. beginAnimationFrom: number;
  85192. /**
  85193. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85194. */
  85195. beginAnimationTo: number;
  85196. /**
  85197. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85198. */
  85199. beginAnimationLoop: boolean;
  85200. /**
  85201. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85202. */
  85203. disposeOnStop: boolean;
  85204. /**
  85205. * Gets the maximum number of particles active at the same time.
  85206. * @returns The max number of active particles.
  85207. */
  85208. getCapacity(): number;
  85209. /**
  85210. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85211. * @returns True if it has been started, otherwise false.
  85212. */
  85213. isStarted(): boolean;
  85214. /**
  85215. * Animates the particle system for this frame.
  85216. */
  85217. animate(): void;
  85218. /**
  85219. * Renders the particle system in its current state.
  85220. * @returns the current number of particles
  85221. */
  85222. render(): number;
  85223. /**
  85224. * Dispose the particle system and frees its associated resources.
  85225. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85226. */
  85227. dispose(disposeTexture?: boolean): void;
  85228. /**
  85229. * Clones the particle system.
  85230. * @param name The name of the cloned object
  85231. * @param newEmitter The new emitter to use
  85232. * @returns the cloned particle system
  85233. */
  85234. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85235. /**
  85236. * Serializes the particle system to a JSON object.
  85237. * @returns the JSON object
  85238. */
  85239. serialize(): any;
  85240. /**
  85241. * Rebuild the particle system
  85242. */
  85243. rebuild(): void;
  85244. /**
  85245. * Starts the particle system and begins to emit
  85246. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85247. */
  85248. start(delay?: number): void;
  85249. /**
  85250. * Stops the particle system.
  85251. */
  85252. stop(): void;
  85253. /**
  85254. * Remove all active particles
  85255. */
  85256. reset(): void;
  85257. /**
  85258. * Is this system ready to be used/rendered
  85259. * @return true if the system is ready
  85260. */
  85261. isReady(): boolean;
  85262. /**
  85263. * Adds a new color gradient
  85264. * @param gradient defines the gradient to use (between 0 and 1)
  85265. * @param color1 defines the color to affect to the specified gradient
  85266. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85267. * @returns the current particle system
  85268. */
  85269. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85270. /**
  85271. * Remove a specific color gradient
  85272. * @param gradient defines the gradient to remove
  85273. * @returns the current particle system
  85274. */
  85275. removeColorGradient(gradient: number): IParticleSystem;
  85276. /**
  85277. * Adds a new size gradient
  85278. * @param gradient defines the gradient to use (between 0 and 1)
  85279. * @param factor defines the size factor to affect to the specified gradient
  85280. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85281. * @returns the current particle system
  85282. */
  85283. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85284. /**
  85285. * Remove a specific size gradient
  85286. * @param gradient defines the gradient to remove
  85287. * @returns the current particle system
  85288. */
  85289. removeSizeGradient(gradient: number): IParticleSystem;
  85290. /**
  85291. * Gets the current list of color gradients.
  85292. * You must use addColorGradient and removeColorGradient to udpate this list
  85293. * @returns the list of color gradients
  85294. */
  85295. getColorGradients(): Nullable<Array<ColorGradient>>;
  85296. /**
  85297. * Gets the current list of size gradients.
  85298. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85299. * @returns the list of size gradients
  85300. */
  85301. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85302. /**
  85303. * Gets the current list of angular speed gradients.
  85304. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85305. * @returns the list of angular speed gradients
  85306. */
  85307. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85308. /**
  85309. * Adds a new angular speed gradient
  85310. * @param gradient defines the gradient to use (between 0 and 1)
  85311. * @param factor defines the angular speed to affect to the specified gradient
  85312. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85313. * @returns the current particle system
  85314. */
  85315. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85316. /**
  85317. * Remove a specific angular speed gradient
  85318. * @param gradient defines the gradient to remove
  85319. * @returns the current particle system
  85320. */
  85321. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85322. /**
  85323. * Gets the current list of velocity gradients.
  85324. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85325. * @returns the list of velocity gradients
  85326. */
  85327. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85328. /**
  85329. * Adds a new velocity gradient
  85330. * @param gradient defines the gradient to use (between 0 and 1)
  85331. * @param factor defines the velocity to affect to the specified gradient
  85332. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85333. * @returns the current particle system
  85334. */
  85335. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85336. /**
  85337. * Remove a specific velocity gradient
  85338. * @param gradient defines the gradient to remove
  85339. * @returns the current particle system
  85340. */
  85341. removeVelocityGradient(gradient: number): IParticleSystem;
  85342. /**
  85343. * Gets the current list of limit velocity gradients.
  85344. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85345. * @returns the list of limit velocity gradients
  85346. */
  85347. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85348. /**
  85349. * Adds a new limit velocity gradient
  85350. * @param gradient defines the gradient to use (between 0 and 1)
  85351. * @param factor defines the limit velocity to affect to the specified gradient
  85352. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85353. * @returns the current particle system
  85354. */
  85355. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85356. /**
  85357. * Remove a specific limit velocity gradient
  85358. * @param gradient defines the gradient to remove
  85359. * @returns the current particle system
  85360. */
  85361. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85362. /**
  85363. * Adds a new drag gradient
  85364. * @param gradient defines the gradient to use (between 0 and 1)
  85365. * @param factor defines the drag to affect to the specified gradient
  85366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85367. * @returns the current particle system
  85368. */
  85369. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85370. /**
  85371. * Remove a specific drag gradient
  85372. * @param gradient defines the gradient to remove
  85373. * @returns the current particle system
  85374. */
  85375. removeDragGradient(gradient: number): IParticleSystem;
  85376. /**
  85377. * Gets the current list of drag gradients.
  85378. * You must use addDragGradient and removeDragGradient to udpate this list
  85379. * @returns the list of drag gradients
  85380. */
  85381. getDragGradients(): Nullable<Array<FactorGradient>>;
  85382. /**
  85383. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85384. * @param gradient defines the gradient to use (between 0 and 1)
  85385. * @param factor defines the emit rate to affect to the specified gradient
  85386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85387. * @returns the current particle system
  85388. */
  85389. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85390. /**
  85391. * Remove a specific emit rate gradient
  85392. * @param gradient defines the gradient to remove
  85393. * @returns the current particle system
  85394. */
  85395. removeEmitRateGradient(gradient: number): IParticleSystem;
  85396. /**
  85397. * Gets the current list of emit rate gradients.
  85398. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85399. * @returns the list of emit rate gradients
  85400. */
  85401. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85402. /**
  85403. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85404. * @param gradient defines the gradient to use (between 0 and 1)
  85405. * @param factor defines the start size to affect to the specified gradient
  85406. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85407. * @returns the current particle system
  85408. */
  85409. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85410. /**
  85411. * Remove a specific start size gradient
  85412. * @param gradient defines the gradient to remove
  85413. * @returns the current particle system
  85414. */
  85415. removeStartSizeGradient(gradient: number): IParticleSystem;
  85416. /**
  85417. * Gets the current list of start size gradients.
  85418. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85419. * @returns the list of start size gradients
  85420. */
  85421. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85422. /**
  85423. * Adds a new life time gradient
  85424. * @param gradient defines the gradient to use (between 0 and 1)
  85425. * @param factor defines the life time factor to affect to the specified gradient
  85426. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85427. * @returns the current particle system
  85428. */
  85429. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85430. /**
  85431. * Remove a specific life time gradient
  85432. * @param gradient defines the gradient to remove
  85433. * @returns the current particle system
  85434. */
  85435. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85436. /**
  85437. * Gets the current list of life time gradients.
  85438. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85439. * @returns the list of life time gradients
  85440. */
  85441. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85442. /**
  85443. * Gets the current list of color gradients.
  85444. * You must use addColorGradient and removeColorGradient to udpate this list
  85445. * @returns the list of color gradients
  85446. */
  85447. getColorGradients(): Nullable<Array<ColorGradient>>;
  85448. /**
  85449. * Adds a new ramp gradient used to remap particle colors
  85450. * @param gradient defines the gradient to use (between 0 and 1)
  85451. * @param color defines the color to affect to the specified gradient
  85452. * @returns the current particle system
  85453. */
  85454. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85455. /**
  85456. * Gets the current list of ramp gradients.
  85457. * You must use addRampGradient and removeRampGradient to udpate this list
  85458. * @returns the list of ramp gradients
  85459. */
  85460. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85461. /** Gets or sets a boolean indicating that ramp gradients must be used
  85462. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85463. */
  85464. useRampGradients: boolean;
  85465. /**
  85466. * Adds a new color remap gradient
  85467. * @param gradient defines the gradient to use (between 0 and 1)
  85468. * @param min defines the color remap minimal range
  85469. * @param max defines the color remap maximal range
  85470. * @returns the current particle system
  85471. */
  85472. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85473. /**
  85474. * Gets the current list of color remap gradients.
  85475. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85476. * @returns the list of color remap gradients
  85477. */
  85478. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85479. /**
  85480. * Adds a new alpha remap gradient
  85481. * @param gradient defines the gradient to use (between 0 and 1)
  85482. * @param min defines the alpha remap minimal range
  85483. * @param max defines the alpha remap maximal range
  85484. * @returns the current particle system
  85485. */
  85486. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85487. /**
  85488. * Gets the current list of alpha remap gradients.
  85489. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85490. * @returns the list of alpha remap gradients
  85491. */
  85492. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85493. /**
  85494. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85497. * @returns the emitter
  85498. */
  85499. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85500. /**
  85501. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85502. * @param radius The radius of the hemisphere to emit from
  85503. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85504. * @returns the emitter
  85505. */
  85506. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85507. /**
  85508. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85509. * @param radius The radius of the sphere to emit from
  85510. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85511. * @returns the emitter
  85512. */
  85513. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85514. /**
  85515. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85516. * @param radius The radius of the sphere to emit from
  85517. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85518. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85519. * @returns the emitter
  85520. */
  85521. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85522. /**
  85523. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85524. * @param radius The radius of the emission cylinder
  85525. * @param height The height of the emission cylinder
  85526. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85527. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85528. * @returns the emitter
  85529. */
  85530. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85531. /**
  85532. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85533. * @param radius The radius of the cylinder to emit from
  85534. * @param height The height of the emission cylinder
  85535. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85536. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85537. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85538. * @returns the emitter
  85539. */
  85540. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85541. /**
  85542. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85543. * @param radius The radius of the cone to emit from
  85544. * @param angle The base angle of the cone
  85545. * @returns the emitter
  85546. */
  85547. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85548. /**
  85549. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85550. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85551. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85552. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85553. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85554. * @returns the emitter
  85555. */
  85556. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85557. /**
  85558. * Get hosting scene
  85559. * @returns the scene
  85560. */
  85561. getScene(): Scene;
  85562. }
  85563. }
  85564. declare module BABYLON {
  85565. /**
  85566. * Creates an instance based on a source mesh.
  85567. */
  85568. export class InstancedMesh extends AbstractMesh {
  85569. private _sourceMesh;
  85570. private _currentLOD;
  85571. /** @hidden */
  85572. _indexInSourceMeshInstanceArray: number;
  85573. constructor(name: string, source: Mesh);
  85574. /**
  85575. * Returns the string "InstancedMesh".
  85576. */
  85577. getClassName(): string;
  85578. /** Gets the list of lights affecting that mesh */
  85579. readonly lightSources: Light[];
  85580. _resyncLightSources(): void;
  85581. _resyncLighSource(light: Light): void;
  85582. _removeLightSource(light: Light, dispose: boolean): void;
  85583. /**
  85584. * If the source mesh receives shadows
  85585. */
  85586. readonly receiveShadows: boolean;
  85587. /**
  85588. * The material of the source mesh
  85589. */
  85590. readonly material: Nullable<Material>;
  85591. /**
  85592. * Visibility of the source mesh
  85593. */
  85594. readonly visibility: number;
  85595. /**
  85596. * Skeleton of the source mesh
  85597. */
  85598. readonly skeleton: Nullable<Skeleton>;
  85599. /**
  85600. * Rendering ground id of the source mesh
  85601. */
  85602. renderingGroupId: number;
  85603. /**
  85604. * Returns the total number of vertices (integer).
  85605. */
  85606. getTotalVertices(): number;
  85607. /**
  85608. * Returns a positive integer : the total number of indices in this mesh geometry.
  85609. * @returns the numner of indices or zero if the mesh has no geometry.
  85610. */
  85611. getTotalIndices(): number;
  85612. /**
  85613. * The source mesh of the instance
  85614. */
  85615. readonly sourceMesh: Mesh;
  85616. /**
  85617. * Is this node ready to be used/rendered
  85618. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85619. * @return {boolean} is it ready
  85620. */
  85621. isReady(completeCheck?: boolean): boolean;
  85622. /**
  85623. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85624. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85625. * @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.
  85626. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85627. */
  85628. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85629. /**
  85630. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85631. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85632. * The `data` are either a numeric array either a Float32Array.
  85633. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85634. * 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).
  85635. * Note that a new underlying VertexBuffer object is created each call.
  85636. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85637. *
  85638. * Possible `kind` values :
  85639. * - VertexBuffer.PositionKind
  85640. * - VertexBuffer.UVKind
  85641. * - VertexBuffer.UV2Kind
  85642. * - VertexBuffer.UV3Kind
  85643. * - VertexBuffer.UV4Kind
  85644. * - VertexBuffer.UV5Kind
  85645. * - VertexBuffer.UV6Kind
  85646. * - VertexBuffer.ColorKind
  85647. * - VertexBuffer.MatricesIndicesKind
  85648. * - VertexBuffer.MatricesIndicesExtraKind
  85649. * - VertexBuffer.MatricesWeightsKind
  85650. * - VertexBuffer.MatricesWeightsExtraKind
  85651. *
  85652. * Returns the Mesh.
  85653. */
  85654. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85655. /**
  85656. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85657. * If the mesh has no geometry, it is simply returned as it is.
  85658. * The `data` are either a numeric array either a Float32Array.
  85659. * No new underlying VertexBuffer object is created.
  85660. * 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.
  85661. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85662. *
  85663. * Possible `kind` values :
  85664. * - VertexBuffer.PositionKind
  85665. * - VertexBuffer.UVKind
  85666. * - VertexBuffer.UV2Kind
  85667. * - VertexBuffer.UV3Kind
  85668. * - VertexBuffer.UV4Kind
  85669. * - VertexBuffer.UV5Kind
  85670. * - VertexBuffer.UV6Kind
  85671. * - VertexBuffer.ColorKind
  85672. * - VertexBuffer.MatricesIndicesKind
  85673. * - VertexBuffer.MatricesIndicesExtraKind
  85674. * - VertexBuffer.MatricesWeightsKind
  85675. * - VertexBuffer.MatricesWeightsExtraKind
  85676. *
  85677. * Returns the Mesh.
  85678. */
  85679. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85680. /**
  85681. * Sets the mesh indices.
  85682. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85683. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85684. * This method creates a new index buffer each call.
  85685. * Returns the Mesh.
  85686. */
  85687. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85688. /**
  85689. * Boolean : True if the mesh owns the requested kind of data.
  85690. */
  85691. isVerticesDataPresent(kind: string): boolean;
  85692. /**
  85693. * Returns an array of indices (IndicesArray).
  85694. */
  85695. getIndices(): Nullable<IndicesArray>;
  85696. readonly _positions: Nullable<Vector3[]>;
  85697. /**
  85698. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85699. * This means the mesh underlying bounding box and sphere are recomputed.
  85700. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85701. * @returns the current mesh
  85702. */
  85703. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85704. /** @hidden */
  85705. _preActivate(): InstancedMesh;
  85706. /** @hidden */
  85707. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85708. /** @hidden */
  85709. _postActivate(): void;
  85710. getWorldMatrix(): Matrix;
  85711. readonly isAnInstance: boolean;
  85712. /**
  85713. * Returns the current associated LOD AbstractMesh.
  85714. */
  85715. getLOD(camera: Camera): AbstractMesh;
  85716. /** @hidden */
  85717. _syncSubMeshes(): InstancedMesh;
  85718. /** @hidden */
  85719. _generatePointsArray(): boolean;
  85720. /**
  85721. * Creates a new InstancedMesh from the current mesh.
  85722. * - name (string) : the cloned mesh name
  85723. * - newParent (optional Node) : the optional Node to parent the clone to.
  85724. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85725. *
  85726. * Returns the clone.
  85727. */
  85728. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85729. /**
  85730. * Disposes the InstancedMesh.
  85731. * Returns nothing.
  85732. */
  85733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85734. }
  85735. }
  85736. declare module BABYLON {
  85737. /**
  85738. * Defines the options associated with the creation of a shader material.
  85739. */
  85740. export interface IShaderMaterialOptions {
  85741. /**
  85742. * Does the material work in alpha blend mode
  85743. */
  85744. needAlphaBlending: boolean;
  85745. /**
  85746. * Does the material work in alpha test mode
  85747. */
  85748. needAlphaTesting: boolean;
  85749. /**
  85750. * The list of attribute names used in the shader
  85751. */
  85752. attributes: string[];
  85753. /**
  85754. * The list of unifrom names used in the shader
  85755. */
  85756. uniforms: string[];
  85757. /**
  85758. * The list of UBO names used in the shader
  85759. */
  85760. uniformBuffers: string[];
  85761. /**
  85762. * The list of sampler names used in the shader
  85763. */
  85764. samplers: string[];
  85765. /**
  85766. * The list of defines used in the shader
  85767. */
  85768. defines: string[];
  85769. }
  85770. /**
  85771. * 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.
  85772. *
  85773. * This returned material effects how the mesh will look based on the code in the shaders.
  85774. *
  85775. * @see http://doc.babylonjs.com/how_to/shader_material
  85776. */
  85777. export class ShaderMaterial extends Material {
  85778. private _shaderPath;
  85779. private _options;
  85780. private _textures;
  85781. private _textureArrays;
  85782. private _floats;
  85783. private _ints;
  85784. private _floatsArrays;
  85785. private _colors3;
  85786. private _colors3Arrays;
  85787. private _colors4;
  85788. private _colors4Arrays;
  85789. private _vectors2;
  85790. private _vectors3;
  85791. private _vectors4;
  85792. private _matrices;
  85793. private _matrices3x3;
  85794. private _matrices2x2;
  85795. private _vectors2Arrays;
  85796. private _vectors3Arrays;
  85797. private _vectors4Arrays;
  85798. private _cachedWorldViewMatrix;
  85799. private _cachedWorldViewProjectionMatrix;
  85800. private _renderId;
  85801. /**
  85802. * Instantiate a new shader material.
  85803. * 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.
  85804. * This returned material effects how the mesh will look based on the code in the shaders.
  85805. * @see http://doc.babylonjs.com/how_to/shader_material
  85806. * @param name Define the name of the material in the scene
  85807. * @param scene Define the scene the material belongs to
  85808. * @param shaderPath Defines the route to the shader code in one of three ways:
  85809. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85810. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85811. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85812. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85813. * @param options Define the options used to create the shader
  85814. */
  85815. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85816. /**
  85817. * Gets the options used to compile the shader.
  85818. * They can be modified to trigger a new compilation
  85819. */
  85820. readonly options: IShaderMaterialOptions;
  85821. /**
  85822. * Gets the current class name of the material e.g. "ShaderMaterial"
  85823. * Mainly use in serialization.
  85824. * @returns the class name
  85825. */
  85826. getClassName(): string;
  85827. /**
  85828. * Specifies if the material will require alpha blending
  85829. * @returns a boolean specifying if alpha blending is needed
  85830. */
  85831. needAlphaBlending(): boolean;
  85832. /**
  85833. * Specifies if this material should be rendered in alpha test mode
  85834. * @returns a boolean specifying if an alpha test is needed.
  85835. */
  85836. needAlphaTesting(): boolean;
  85837. private _checkUniform;
  85838. /**
  85839. * Set a texture in the shader.
  85840. * @param name Define the name of the uniform samplers as defined in the shader
  85841. * @param texture Define the texture to bind to this sampler
  85842. * @return the material itself allowing "fluent" like uniform updates
  85843. */
  85844. setTexture(name: string, texture: Texture): ShaderMaterial;
  85845. /**
  85846. * Set a texture array in the shader.
  85847. * @param name Define the name of the uniform sampler array as defined in the shader
  85848. * @param textures Define the list of textures to bind to this sampler
  85849. * @return the material itself allowing "fluent" like uniform updates
  85850. */
  85851. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85852. /**
  85853. * Set a float in the shader.
  85854. * @param name Define the name of the uniform as defined in the shader
  85855. * @param value Define the value to give to the uniform
  85856. * @return the material itself allowing "fluent" like uniform updates
  85857. */
  85858. setFloat(name: string, value: number): ShaderMaterial;
  85859. /**
  85860. * Set a int in the shader.
  85861. * @param name Define the name of the uniform as defined in the shader
  85862. * @param value Define the value to give to the uniform
  85863. * @return the material itself allowing "fluent" like uniform updates
  85864. */
  85865. setInt(name: string, value: number): ShaderMaterial;
  85866. /**
  85867. * Set an array of floats in the shader.
  85868. * @param name Define the name of the uniform as defined in the shader
  85869. * @param value Define the value to give to the uniform
  85870. * @return the material itself allowing "fluent" like uniform updates
  85871. */
  85872. setFloats(name: string, value: number[]): ShaderMaterial;
  85873. /**
  85874. * Set a vec3 in the shader from a Color3.
  85875. * @param name Define the name of the uniform as defined in the shader
  85876. * @param value Define the value to give to the uniform
  85877. * @return the material itself allowing "fluent" like uniform updates
  85878. */
  85879. setColor3(name: string, value: Color3): ShaderMaterial;
  85880. /**
  85881. * Set a vec3 array in the shader from a Color3 array.
  85882. * @param name Define the name of the uniform as defined in the shader
  85883. * @param value Define the value to give to the uniform
  85884. * @return the material itself allowing "fluent" like uniform updates
  85885. */
  85886. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85887. /**
  85888. * Set a vec4 in the shader from a Color4.
  85889. * @param name Define the name of the uniform as defined in the shader
  85890. * @param value Define the value to give to the uniform
  85891. * @return the material itself allowing "fluent" like uniform updates
  85892. */
  85893. setColor4(name: string, value: Color4): ShaderMaterial;
  85894. /**
  85895. * Set a vec4 array in the shader from a Color4 array.
  85896. * @param name Define the name of the uniform as defined in the shader
  85897. * @param value Define the value to give to the uniform
  85898. * @return the material itself allowing "fluent" like uniform updates
  85899. */
  85900. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85901. /**
  85902. * Set a vec2 in the shader from a Vector2.
  85903. * @param name Define the name of the uniform as defined in the shader
  85904. * @param value Define the value to give to the uniform
  85905. * @return the material itself allowing "fluent" like uniform updates
  85906. */
  85907. setVector2(name: string, value: Vector2): ShaderMaterial;
  85908. /**
  85909. * Set a vec3 in the shader from a Vector3.
  85910. * @param name Define the name of the uniform as defined in the shader
  85911. * @param value Define the value to give to the uniform
  85912. * @return the material itself allowing "fluent" like uniform updates
  85913. */
  85914. setVector3(name: string, value: Vector3): ShaderMaterial;
  85915. /**
  85916. * Set a vec4 in the shader from a Vector4.
  85917. * @param name Define the name of the uniform as defined in the shader
  85918. * @param value Define the value to give to the uniform
  85919. * @return the material itself allowing "fluent" like uniform updates
  85920. */
  85921. setVector4(name: string, value: Vector4): ShaderMaterial;
  85922. /**
  85923. * Set a mat4 in the shader from a Matrix.
  85924. * @param name Define the name of the uniform as defined in the shader
  85925. * @param value Define the value to give to the uniform
  85926. * @return the material itself allowing "fluent" like uniform updates
  85927. */
  85928. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85929. /**
  85930. * Set a mat3 in the shader from a Float32Array.
  85931. * @param name Define the name of the uniform as defined in the shader
  85932. * @param value Define the value to give to the uniform
  85933. * @return the material itself allowing "fluent" like uniform updates
  85934. */
  85935. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85936. /**
  85937. * Set a mat2 in the shader from a Float32Array.
  85938. * @param name Define the name of the uniform as defined in the shader
  85939. * @param value Define the value to give to the uniform
  85940. * @return the material itself allowing "fluent" like uniform updates
  85941. */
  85942. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85943. /**
  85944. * Set a vec2 array in the shader from a number array.
  85945. * @param name Define the name of the uniform as defined in the shader
  85946. * @param value Define the value to give to the uniform
  85947. * @return the material itself allowing "fluent" like uniform updates
  85948. */
  85949. setArray2(name: string, value: number[]): ShaderMaterial;
  85950. /**
  85951. * Set a vec3 array in the shader from a number array.
  85952. * @param name Define the name of the uniform as defined in the shader
  85953. * @param value Define the value to give to the uniform
  85954. * @return the material itself allowing "fluent" like uniform updates
  85955. */
  85956. setArray3(name: string, value: number[]): ShaderMaterial;
  85957. /**
  85958. * Set a vec4 array in the shader from a number array.
  85959. * @param name Define the name of the uniform as defined in the shader
  85960. * @param value Define the value to give to the uniform
  85961. * @return the material itself allowing "fluent" like uniform updates
  85962. */
  85963. setArray4(name: string, value: number[]): ShaderMaterial;
  85964. private _checkCache;
  85965. /**
  85966. * Specifies that the submesh is ready to be used
  85967. * @param mesh defines the mesh to check
  85968. * @param subMesh defines which submesh to check
  85969. * @param useInstances specifies that instances should be used
  85970. * @returns a boolean indicating that the submesh is ready or not
  85971. */
  85972. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85973. /**
  85974. * Checks if the material is ready to render the requested mesh
  85975. * @param mesh Define the mesh to render
  85976. * @param useInstances Define whether or not the material is used with instances
  85977. * @returns true if ready, otherwise false
  85978. */
  85979. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85980. /**
  85981. * Binds the world matrix to the material
  85982. * @param world defines the world transformation matrix
  85983. */
  85984. bindOnlyWorldMatrix(world: Matrix): void;
  85985. /**
  85986. * Binds the material to the mesh
  85987. * @param world defines the world transformation matrix
  85988. * @param mesh defines the mesh to bind the material to
  85989. */
  85990. bind(world: Matrix, mesh?: Mesh): void;
  85991. /**
  85992. * Gets the active textures from the material
  85993. * @returns an array of textures
  85994. */
  85995. getActiveTextures(): BaseTexture[];
  85996. /**
  85997. * Specifies if the material uses a texture
  85998. * @param texture defines the texture to check against the material
  85999. * @returns a boolean specifying if the material uses the texture
  86000. */
  86001. hasTexture(texture: BaseTexture): boolean;
  86002. /**
  86003. * Makes a duplicate of the material, and gives it a new name
  86004. * @param name defines the new name for the duplicated material
  86005. * @returns the cloned material
  86006. */
  86007. clone(name: string): ShaderMaterial;
  86008. /**
  86009. * Disposes the material
  86010. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86011. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86012. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86013. */
  86014. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86015. /**
  86016. * Serializes this material in a JSON representation
  86017. * @returns the serialized material object
  86018. */
  86019. serialize(): any;
  86020. /**
  86021. * Creates a shader material from parsed shader material data
  86022. * @param source defines the JSON represnetation of the material
  86023. * @param scene defines the hosting scene
  86024. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86025. * @returns a new material
  86026. */
  86027. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86028. }
  86029. }
  86030. declare module BABYLON {
  86031. /** @hidden */
  86032. export var colorPixelShader: {
  86033. name: string;
  86034. shader: string;
  86035. };
  86036. }
  86037. declare module BABYLON {
  86038. /** @hidden */
  86039. export var colorVertexShader: {
  86040. name: string;
  86041. shader: string;
  86042. };
  86043. }
  86044. declare module BABYLON {
  86045. /**
  86046. * Line mesh
  86047. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86048. */
  86049. export class LinesMesh extends Mesh {
  86050. /**
  86051. * If vertex color should be applied to the mesh
  86052. */
  86053. readonly useVertexColor?: boolean | undefined;
  86054. /**
  86055. * If vertex alpha should be applied to the mesh
  86056. */
  86057. readonly useVertexAlpha?: boolean | undefined;
  86058. /**
  86059. * Color of the line (Default: White)
  86060. */
  86061. color: Color3;
  86062. /**
  86063. * Alpha of the line (Default: 1)
  86064. */
  86065. alpha: number;
  86066. /**
  86067. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86068. * This margin is expressed in world space coordinates, so its value may vary.
  86069. * Default value is 0.1
  86070. */
  86071. intersectionThreshold: number;
  86072. private _colorShader;
  86073. private color4;
  86074. /**
  86075. * Creates a new LinesMesh
  86076. * @param name defines the name
  86077. * @param scene defines the hosting scene
  86078. * @param parent defines the parent mesh if any
  86079. * @param source defines the optional source LinesMesh used to clone data from
  86080. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86081. * When false, achieved by calling a clone(), also passing False.
  86082. * This will make creation of children, recursive.
  86083. * @param useVertexColor defines if this LinesMesh supports vertex color
  86084. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86085. */
  86086. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86087. /**
  86088. * If vertex color should be applied to the mesh
  86089. */
  86090. useVertexColor?: boolean | undefined,
  86091. /**
  86092. * If vertex alpha should be applied to the mesh
  86093. */
  86094. useVertexAlpha?: boolean | undefined);
  86095. private _addClipPlaneDefine;
  86096. private _removeClipPlaneDefine;
  86097. isReady(): boolean;
  86098. /**
  86099. * Returns the string "LineMesh"
  86100. */
  86101. getClassName(): string;
  86102. /**
  86103. * @hidden
  86104. */
  86105. /**
  86106. * @hidden
  86107. */
  86108. material: Material;
  86109. /**
  86110. * @hidden
  86111. */
  86112. readonly checkCollisions: boolean;
  86113. /** @hidden */
  86114. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86115. /** @hidden */
  86116. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86117. /**
  86118. * Disposes of the line mesh
  86119. * @param doNotRecurse If children should be disposed
  86120. */
  86121. dispose(doNotRecurse?: boolean): void;
  86122. /**
  86123. * Returns a new LineMesh object cloned from the current one.
  86124. */
  86125. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86126. /**
  86127. * Creates a new InstancedLinesMesh object from the mesh model.
  86128. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86129. * @param name defines the name of the new instance
  86130. * @returns a new InstancedLinesMesh
  86131. */
  86132. createInstance(name: string): InstancedLinesMesh;
  86133. }
  86134. /**
  86135. * Creates an instance based on a source LinesMesh
  86136. */
  86137. export class InstancedLinesMesh extends InstancedMesh {
  86138. /**
  86139. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86140. * This margin is expressed in world space coordinates, so its value may vary.
  86141. * Initilized with the intersectionThreshold value of the source LinesMesh
  86142. */
  86143. intersectionThreshold: number;
  86144. constructor(name: string, source: LinesMesh);
  86145. /**
  86146. * Returns the string "InstancedLinesMesh".
  86147. */
  86148. getClassName(): string;
  86149. }
  86150. }
  86151. declare module BABYLON {
  86152. /** @hidden */
  86153. export var linePixelShader: {
  86154. name: string;
  86155. shader: string;
  86156. };
  86157. }
  86158. declare module BABYLON {
  86159. /** @hidden */
  86160. export var lineVertexShader: {
  86161. name: string;
  86162. shader: string;
  86163. };
  86164. }
  86165. declare module BABYLON {
  86166. interface AbstractMesh {
  86167. /**
  86168. * Gets the edgesRenderer associated with the mesh
  86169. */
  86170. edgesRenderer: Nullable<EdgesRenderer>;
  86171. }
  86172. interface LinesMesh {
  86173. /**
  86174. * Enables the edge rendering mode on the mesh.
  86175. * This mode makes the mesh edges visible
  86176. * @param epsilon defines the maximal distance between two angles to detect a face
  86177. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86178. * @returns the currentAbstractMesh
  86179. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86180. */
  86181. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86182. }
  86183. interface InstancedLinesMesh {
  86184. /**
  86185. * Enables the edge rendering mode on the mesh.
  86186. * This mode makes the mesh edges visible
  86187. * @param epsilon defines the maximal distance between two angles to detect a face
  86188. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86189. * @returns the current InstancedLinesMesh
  86190. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86191. */
  86192. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86193. }
  86194. /**
  86195. * Defines the minimum contract an Edges renderer should follow.
  86196. */
  86197. export interface IEdgesRenderer extends IDisposable {
  86198. /**
  86199. * Gets or sets a boolean indicating if the edgesRenderer is active
  86200. */
  86201. isEnabled: boolean;
  86202. /**
  86203. * Renders the edges of the attached mesh,
  86204. */
  86205. render(): void;
  86206. /**
  86207. * Checks wether or not the edges renderer is ready to render.
  86208. * @return true if ready, otherwise false.
  86209. */
  86210. isReady(): boolean;
  86211. }
  86212. /**
  86213. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86214. */
  86215. export class EdgesRenderer implements IEdgesRenderer {
  86216. /**
  86217. * Define the size of the edges with an orthographic camera
  86218. */
  86219. edgesWidthScalerForOrthographic: number;
  86220. /**
  86221. * Define the size of the edges with a perspective camera
  86222. */
  86223. edgesWidthScalerForPerspective: number;
  86224. protected _source: AbstractMesh;
  86225. protected _linesPositions: number[];
  86226. protected _linesNormals: number[];
  86227. protected _linesIndices: number[];
  86228. protected _epsilon: number;
  86229. protected _indicesCount: number;
  86230. protected _lineShader: ShaderMaterial;
  86231. protected _ib: DataBuffer;
  86232. protected _buffers: {
  86233. [key: string]: Nullable<VertexBuffer>;
  86234. };
  86235. protected _checkVerticesInsteadOfIndices: boolean;
  86236. private _meshRebuildObserver;
  86237. private _meshDisposeObserver;
  86238. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86239. isEnabled: boolean;
  86240. /**
  86241. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86242. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86243. * @param source Mesh used to create edges
  86244. * @param epsilon sum of angles in adjacency to check for edge
  86245. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86246. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86247. */
  86248. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86249. protected _prepareRessources(): void;
  86250. /** @hidden */
  86251. _rebuild(): void;
  86252. /**
  86253. * Releases the required resources for the edges renderer
  86254. */
  86255. dispose(): void;
  86256. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86257. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86258. /**
  86259. * Checks if the pair of p0 and p1 is en edge
  86260. * @param faceIndex
  86261. * @param edge
  86262. * @param faceNormals
  86263. * @param p0
  86264. * @param p1
  86265. * @private
  86266. */
  86267. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86268. /**
  86269. * push line into the position, normal and index buffer
  86270. * @protected
  86271. */
  86272. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86273. /**
  86274. * Generates lines edges from adjacencjes
  86275. * @private
  86276. */
  86277. _generateEdgesLines(): void;
  86278. /**
  86279. * Checks wether or not the edges renderer is ready to render.
  86280. * @return true if ready, otherwise false.
  86281. */
  86282. isReady(): boolean;
  86283. /**
  86284. * Renders the edges of the attached mesh,
  86285. */
  86286. render(): void;
  86287. }
  86288. /**
  86289. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86290. */
  86291. export class LineEdgesRenderer extends EdgesRenderer {
  86292. /**
  86293. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86294. * @param source LineMesh used to generate edges
  86295. * @param epsilon not important (specified angle for edge detection)
  86296. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86297. */
  86298. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86299. /**
  86300. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86301. */
  86302. _generateEdgesLines(): void;
  86303. }
  86304. }
  86305. declare module BABYLON {
  86306. /**
  86307. * This represents the object necessary to create a rendering group.
  86308. * This is exclusively used and created by the rendering manager.
  86309. * To modify the behavior, you use the available helpers in your scene or meshes.
  86310. * @hidden
  86311. */
  86312. export class RenderingGroup {
  86313. index: number;
  86314. private static _zeroVector;
  86315. private _scene;
  86316. private _opaqueSubMeshes;
  86317. private _transparentSubMeshes;
  86318. private _alphaTestSubMeshes;
  86319. private _depthOnlySubMeshes;
  86320. private _particleSystems;
  86321. private _spriteManagers;
  86322. private _opaqueSortCompareFn;
  86323. private _alphaTestSortCompareFn;
  86324. private _transparentSortCompareFn;
  86325. private _renderOpaque;
  86326. private _renderAlphaTest;
  86327. private _renderTransparent;
  86328. /** @hidden */
  86329. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86330. onBeforeTransparentRendering: () => void;
  86331. /**
  86332. * Set the opaque sort comparison function.
  86333. * If null the sub meshes will be render in the order they were created
  86334. */
  86335. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86336. /**
  86337. * Set the alpha test sort comparison function.
  86338. * If null the sub meshes will be render in the order they were created
  86339. */
  86340. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86341. /**
  86342. * Set the transparent sort comparison function.
  86343. * If null the sub meshes will be render in the order they were created
  86344. */
  86345. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86346. /**
  86347. * Creates a new rendering group.
  86348. * @param index The rendering group index
  86349. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86350. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86351. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86352. */
  86353. 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>);
  86354. /**
  86355. * Render all the sub meshes contained in the group.
  86356. * @param customRenderFunction Used to override the default render behaviour of the group.
  86357. * @returns true if rendered some submeshes.
  86358. */
  86359. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86360. /**
  86361. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86362. * @param subMeshes The submeshes to render
  86363. */
  86364. private renderOpaqueSorted;
  86365. /**
  86366. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86367. * @param subMeshes The submeshes to render
  86368. */
  86369. private renderAlphaTestSorted;
  86370. /**
  86371. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86372. * @param subMeshes The submeshes to render
  86373. */
  86374. private renderTransparentSorted;
  86375. /**
  86376. * Renders the submeshes in a specified order.
  86377. * @param subMeshes The submeshes to sort before render
  86378. * @param sortCompareFn The comparison function use to sort
  86379. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86380. * @param transparent Specifies to activate blending if true
  86381. */
  86382. private static renderSorted;
  86383. /**
  86384. * Renders the submeshes in the order they were dispatched (no sort applied).
  86385. * @param subMeshes The submeshes to render
  86386. */
  86387. private static renderUnsorted;
  86388. /**
  86389. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86390. * are rendered back to front if in the same alpha index.
  86391. *
  86392. * @param a The first submesh
  86393. * @param b The second submesh
  86394. * @returns The result of the comparison
  86395. */
  86396. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86397. /**
  86398. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86399. * are rendered back to front.
  86400. *
  86401. * @param a The first submesh
  86402. * @param b The second submesh
  86403. * @returns The result of the comparison
  86404. */
  86405. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86406. /**
  86407. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86408. * are rendered front to back (prevent overdraw).
  86409. *
  86410. * @param a The first submesh
  86411. * @param b The second submesh
  86412. * @returns The result of the comparison
  86413. */
  86414. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86415. /**
  86416. * Resets the different lists of submeshes to prepare a new frame.
  86417. */
  86418. prepare(): void;
  86419. dispose(): void;
  86420. /**
  86421. * Inserts the submesh in its correct queue depending on its material.
  86422. * @param subMesh The submesh to dispatch
  86423. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86424. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86425. */
  86426. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86427. dispatchSprites(spriteManager: ISpriteManager): void;
  86428. dispatchParticles(particleSystem: IParticleSystem): void;
  86429. private _renderParticles;
  86430. private _renderSprites;
  86431. }
  86432. }
  86433. declare module BABYLON {
  86434. /**
  86435. * Interface describing the different options available in the rendering manager
  86436. * regarding Auto Clear between groups.
  86437. */
  86438. export interface IRenderingManagerAutoClearSetup {
  86439. /**
  86440. * Defines whether or not autoclear is enable.
  86441. */
  86442. autoClear: boolean;
  86443. /**
  86444. * Defines whether or not to autoclear the depth buffer.
  86445. */
  86446. depth: boolean;
  86447. /**
  86448. * Defines whether or not to autoclear the stencil buffer.
  86449. */
  86450. stencil: boolean;
  86451. }
  86452. /**
  86453. * This class is used by the onRenderingGroupObservable
  86454. */
  86455. export class RenderingGroupInfo {
  86456. /**
  86457. * The Scene that being rendered
  86458. */
  86459. scene: Scene;
  86460. /**
  86461. * The camera currently used for the rendering pass
  86462. */
  86463. camera: Nullable<Camera>;
  86464. /**
  86465. * The ID of the renderingGroup being processed
  86466. */
  86467. renderingGroupId: number;
  86468. }
  86469. /**
  86470. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86471. * It is enable to manage the different groups as well as the different necessary sort functions.
  86472. * This should not be used directly aside of the few static configurations
  86473. */
  86474. export class RenderingManager {
  86475. /**
  86476. * The max id used for rendering groups (not included)
  86477. */
  86478. static MAX_RENDERINGGROUPS: number;
  86479. /**
  86480. * The min id used for rendering groups (included)
  86481. */
  86482. static MIN_RENDERINGGROUPS: number;
  86483. /**
  86484. * Used to globally prevent autoclearing scenes.
  86485. */
  86486. static AUTOCLEAR: boolean;
  86487. /**
  86488. * @hidden
  86489. */
  86490. _useSceneAutoClearSetup: boolean;
  86491. private _scene;
  86492. private _renderingGroups;
  86493. private _depthStencilBufferAlreadyCleaned;
  86494. private _autoClearDepthStencil;
  86495. private _customOpaqueSortCompareFn;
  86496. private _customAlphaTestSortCompareFn;
  86497. private _customTransparentSortCompareFn;
  86498. private _renderingGroupInfo;
  86499. /**
  86500. * Instantiates a new rendering group for a particular scene
  86501. * @param scene Defines the scene the groups belongs to
  86502. */
  86503. constructor(scene: Scene);
  86504. private _clearDepthStencilBuffer;
  86505. /**
  86506. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86507. * @hidden
  86508. */
  86509. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86510. /**
  86511. * Resets the different information of the group to prepare a new frame
  86512. * @hidden
  86513. */
  86514. reset(): void;
  86515. /**
  86516. * Dispose and release the group and its associated resources.
  86517. * @hidden
  86518. */
  86519. dispose(): void;
  86520. /**
  86521. * Clear the info related to rendering groups preventing retention points during dispose.
  86522. */
  86523. freeRenderingGroups(): void;
  86524. private _prepareRenderingGroup;
  86525. /**
  86526. * Add a sprite manager to the rendering manager in order to render it this frame.
  86527. * @param spriteManager Define the sprite manager to render
  86528. */
  86529. dispatchSprites(spriteManager: ISpriteManager): void;
  86530. /**
  86531. * Add a particle system to the rendering manager in order to render it this frame.
  86532. * @param particleSystem Define the particle system to render
  86533. */
  86534. dispatchParticles(particleSystem: IParticleSystem): void;
  86535. /**
  86536. * Add a submesh to the manager in order to render it this frame
  86537. * @param subMesh The submesh to dispatch
  86538. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86539. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86540. */
  86541. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86542. /**
  86543. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86544. * This allowed control for front to back rendering or reversly depending of the special needs.
  86545. *
  86546. * @param renderingGroupId The rendering group id corresponding to its index
  86547. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86548. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86549. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86550. */
  86551. 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;
  86552. /**
  86553. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86554. *
  86555. * @param renderingGroupId The rendering group id corresponding to its index
  86556. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86557. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86558. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86559. */
  86560. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86561. /**
  86562. * Gets the current auto clear configuration for one rendering group of the rendering
  86563. * manager.
  86564. * @param index the rendering group index to get the information for
  86565. * @returns The auto clear setup for the requested rendering group
  86566. */
  86567. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86568. }
  86569. }
  86570. declare module BABYLON {
  86571. /**
  86572. * This Helps creating a texture that will be created from a camera in your scene.
  86573. * It is basically a dynamic texture that could be used to create special effects for instance.
  86574. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86575. */
  86576. export class RenderTargetTexture extends Texture {
  86577. isCube: boolean;
  86578. /**
  86579. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86580. */
  86581. static readonly REFRESHRATE_RENDER_ONCE: number;
  86582. /**
  86583. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86584. */
  86585. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86586. /**
  86587. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86588. * the central point of your effect and can save a lot of performances.
  86589. */
  86590. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86591. /**
  86592. * Use this predicate to dynamically define the list of mesh you want to render.
  86593. * If set, the renderList property will be overwritten.
  86594. */
  86595. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86596. private _renderList;
  86597. /**
  86598. * Use this list to define the list of mesh you want to render.
  86599. */
  86600. renderList: Nullable<Array<AbstractMesh>>;
  86601. private _hookArray;
  86602. /**
  86603. * Define if particles should be rendered in your texture.
  86604. */
  86605. renderParticles: boolean;
  86606. /**
  86607. * Define if sprites should be rendered in your texture.
  86608. */
  86609. renderSprites: boolean;
  86610. /**
  86611. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86612. */
  86613. coordinatesMode: number;
  86614. /**
  86615. * Define the camera used to render the texture.
  86616. */
  86617. activeCamera: Nullable<Camera>;
  86618. /**
  86619. * Override the render function of the texture with your own one.
  86620. */
  86621. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86622. /**
  86623. * Define if camera post processes should be use while rendering the texture.
  86624. */
  86625. useCameraPostProcesses: boolean;
  86626. /**
  86627. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86628. */
  86629. ignoreCameraViewport: boolean;
  86630. private _postProcessManager;
  86631. private _postProcesses;
  86632. private _resizeObserver;
  86633. /**
  86634. * An event triggered when the texture is unbind.
  86635. */
  86636. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86637. /**
  86638. * An event triggered when the texture is unbind.
  86639. */
  86640. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86641. private _onAfterUnbindObserver;
  86642. /**
  86643. * Set a after unbind callback in the texture.
  86644. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86645. */
  86646. onAfterUnbind: () => void;
  86647. /**
  86648. * An event triggered before rendering the texture
  86649. */
  86650. onBeforeRenderObservable: Observable<number>;
  86651. private _onBeforeRenderObserver;
  86652. /**
  86653. * Set a before render callback in the texture.
  86654. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86655. */
  86656. onBeforeRender: (faceIndex: number) => void;
  86657. /**
  86658. * An event triggered after rendering the texture
  86659. */
  86660. onAfterRenderObservable: Observable<number>;
  86661. private _onAfterRenderObserver;
  86662. /**
  86663. * Set a after render callback in the texture.
  86664. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86665. */
  86666. onAfterRender: (faceIndex: number) => void;
  86667. /**
  86668. * An event triggered after the texture clear
  86669. */
  86670. onClearObservable: Observable<Engine>;
  86671. private _onClearObserver;
  86672. /**
  86673. * Set a clear callback in the texture.
  86674. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86675. */
  86676. onClear: (Engine: Engine) => void;
  86677. /**
  86678. * An event triggered when the texture is resized.
  86679. */
  86680. onResizeObservable: Observable<RenderTargetTexture>;
  86681. /**
  86682. * Define the clear color of the Render Target if it should be different from the scene.
  86683. */
  86684. clearColor: Color4;
  86685. protected _size: number | {
  86686. width: number;
  86687. height: number;
  86688. };
  86689. protected _initialSizeParameter: number | {
  86690. width: number;
  86691. height: number;
  86692. } | {
  86693. ratio: number;
  86694. };
  86695. protected _sizeRatio: Nullable<number>;
  86696. /** @hidden */
  86697. _generateMipMaps: boolean;
  86698. protected _renderingManager: RenderingManager;
  86699. /** @hidden */
  86700. _waitingRenderList: string[];
  86701. protected _doNotChangeAspectRatio: boolean;
  86702. protected _currentRefreshId: number;
  86703. protected _refreshRate: number;
  86704. protected _textureMatrix: Matrix;
  86705. protected _samples: number;
  86706. protected _renderTargetOptions: RenderTargetCreationOptions;
  86707. /**
  86708. * Gets render target creation options that were used.
  86709. */
  86710. readonly renderTargetOptions: RenderTargetCreationOptions;
  86711. protected _engine: Engine;
  86712. protected _onRatioRescale(): void;
  86713. /**
  86714. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86715. * It must define where the camera used to render the texture is set
  86716. */
  86717. boundingBoxPosition: Vector3;
  86718. private _boundingBoxSize;
  86719. /**
  86720. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86721. * When defined, the cubemap will switch to local mode
  86722. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86723. * @example https://www.babylonjs-playground.com/#RNASML
  86724. */
  86725. boundingBoxSize: Vector3;
  86726. /**
  86727. * In case the RTT has been created with a depth texture, get the associated
  86728. * depth texture.
  86729. * Otherwise, return null.
  86730. */
  86731. depthStencilTexture: Nullable<InternalTexture>;
  86732. /**
  86733. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86734. * or used a shadow, depth texture...
  86735. * @param name The friendly name of the texture
  86736. * @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)
  86737. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86738. * @param generateMipMaps True if mip maps need to be generated after render.
  86739. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86740. * @param type The type of the buffer in the RTT (int, half float, float...)
  86741. * @param isCube True if a cube texture needs to be created
  86742. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86743. * @param generateDepthBuffer True to generate a depth buffer
  86744. * @param generateStencilBuffer True to generate a stencil buffer
  86745. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86746. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86747. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86748. */
  86749. constructor(name: string, size: number | {
  86750. width: number;
  86751. height: number;
  86752. } | {
  86753. ratio: number;
  86754. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86755. /**
  86756. * Creates a depth stencil texture.
  86757. * This is only available in WebGL 2 or with the depth texture extension available.
  86758. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86759. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86760. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86761. */
  86762. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86763. private _processSizeParameter;
  86764. /**
  86765. * Define the number of samples to use in case of MSAA.
  86766. * It defaults to one meaning no MSAA has been enabled.
  86767. */
  86768. samples: number;
  86769. /**
  86770. * Resets the refresh counter of the texture and start bak from scratch.
  86771. * Could be useful to regenerate the texture if it is setup to render only once.
  86772. */
  86773. resetRefreshCounter(): void;
  86774. /**
  86775. * Define the refresh rate of the texture or the rendering frequency.
  86776. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86777. */
  86778. refreshRate: number;
  86779. /**
  86780. * Adds a post process to the render target rendering passes.
  86781. * @param postProcess define the post process to add
  86782. */
  86783. addPostProcess(postProcess: PostProcess): void;
  86784. /**
  86785. * Clear all the post processes attached to the render target
  86786. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86787. */
  86788. clearPostProcesses(dispose?: boolean): void;
  86789. /**
  86790. * Remove one of the post process from the list of attached post processes to the texture
  86791. * @param postProcess define the post process to remove from the list
  86792. */
  86793. removePostProcess(postProcess: PostProcess): void;
  86794. /** @hidden */
  86795. _shouldRender(): boolean;
  86796. /**
  86797. * Gets the actual render size of the texture.
  86798. * @returns the width of the render size
  86799. */
  86800. getRenderSize(): number;
  86801. /**
  86802. * Gets the actual render width of the texture.
  86803. * @returns the width of the render size
  86804. */
  86805. getRenderWidth(): number;
  86806. /**
  86807. * Gets the actual render height of the texture.
  86808. * @returns the height of the render size
  86809. */
  86810. getRenderHeight(): number;
  86811. /**
  86812. * Get if the texture can be rescaled or not.
  86813. */
  86814. readonly canRescale: boolean;
  86815. /**
  86816. * Resize the texture using a ratio.
  86817. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86818. */
  86819. scale(ratio: number): void;
  86820. /**
  86821. * Get the texture reflection matrix used to rotate/transform the reflection.
  86822. * @returns the reflection matrix
  86823. */
  86824. getReflectionTextureMatrix(): Matrix;
  86825. /**
  86826. * Resize the texture to a new desired size.
  86827. * Be carrefull as it will recreate all the data in the new texture.
  86828. * @param size Define the new size. It can be:
  86829. * - a number for squared texture,
  86830. * - an object containing { width: number, height: number }
  86831. * - or an object containing a ratio { ratio: number }
  86832. */
  86833. resize(size: number | {
  86834. width: number;
  86835. height: number;
  86836. } | {
  86837. ratio: number;
  86838. }): void;
  86839. /**
  86840. * Renders all the objects from the render list into the texture.
  86841. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86842. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86843. */
  86844. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86845. private _bestReflectionRenderTargetDimension;
  86846. /**
  86847. * @hidden
  86848. * @param faceIndex face index to bind to if this is a cubetexture
  86849. */
  86850. _bindFrameBuffer(faceIndex?: number): void;
  86851. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86852. private renderToTarget;
  86853. /**
  86854. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86855. * This allowed control for front to back rendering or reversly depending of the special needs.
  86856. *
  86857. * @param renderingGroupId The rendering group id corresponding to its index
  86858. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86859. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86860. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86861. */
  86862. 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;
  86863. /**
  86864. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86865. *
  86866. * @param renderingGroupId The rendering group id corresponding to its index
  86867. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86868. */
  86869. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86870. /**
  86871. * Clones the texture.
  86872. * @returns the cloned texture
  86873. */
  86874. clone(): RenderTargetTexture;
  86875. /**
  86876. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86877. * @returns The JSON representation of the texture
  86878. */
  86879. serialize(): any;
  86880. /**
  86881. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86882. */
  86883. disposeFramebufferObjects(): void;
  86884. /**
  86885. * Dispose the texture and release its associated resources.
  86886. */
  86887. dispose(): void;
  86888. /** @hidden */
  86889. _rebuild(): void;
  86890. /**
  86891. * Clear the info related to rendering groups preventing retention point in material dispose.
  86892. */
  86893. freeRenderingGroups(): void;
  86894. /**
  86895. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86896. * @returns the view count
  86897. */
  86898. getViewCount(): number;
  86899. }
  86900. }
  86901. declare module BABYLON {
  86902. /**
  86903. * Base class for the main features of a material in Babylon.js
  86904. */
  86905. export class Material implements IAnimatable {
  86906. /**
  86907. * Returns the triangle fill mode
  86908. */
  86909. static readonly TriangleFillMode: number;
  86910. /**
  86911. * Returns the wireframe mode
  86912. */
  86913. static readonly WireFrameFillMode: number;
  86914. /**
  86915. * Returns the point fill mode
  86916. */
  86917. static readonly PointFillMode: number;
  86918. /**
  86919. * Returns the point list draw mode
  86920. */
  86921. static readonly PointListDrawMode: number;
  86922. /**
  86923. * Returns the line list draw mode
  86924. */
  86925. static readonly LineListDrawMode: number;
  86926. /**
  86927. * Returns the line loop draw mode
  86928. */
  86929. static readonly LineLoopDrawMode: number;
  86930. /**
  86931. * Returns the line strip draw mode
  86932. */
  86933. static readonly LineStripDrawMode: number;
  86934. /**
  86935. * Returns the triangle strip draw mode
  86936. */
  86937. static readonly TriangleStripDrawMode: number;
  86938. /**
  86939. * Returns the triangle fan draw mode
  86940. */
  86941. static readonly TriangleFanDrawMode: number;
  86942. /**
  86943. * Stores the clock-wise side orientation
  86944. */
  86945. static readonly ClockWiseSideOrientation: number;
  86946. /**
  86947. * Stores the counter clock-wise side orientation
  86948. */
  86949. static readonly CounterClockWiseSideOrientation: number;
  86950. /**
  86951. * The dirty texture flag value
  86952. */
  86953. static readonly TextureDirtyFlag: number;
  86954. /**
  86955. * The dirty light flag value
  86956. */
  86957. static readonly LightDirtyFlag: number;
  86958. /**
  86959. * The dirty fresnel flag value
  86960. */
  86961. static readonly FresnelDirtyFlag: number;
  86962. /**
  86963. * The dirty attribute flag value
  86964. */
  86965. static readonly AttributesDirtyFlag: number;
  86966. /**
  86967. * The dirty misc flag value
  86968. */
  86969. static readonly MiscDirtyFlag: number;
  86970. /**
  86971. * The all dirty flag value
  86972. */
  86973. static readonly AllDirtyFlag: number;
  86974. /**
  86975. * The ID of the material
  86976. */
  86977. id: string;
  86978. /**
  86979. * Gets or sets the unique id of the material
  86980. */
  86981. uniqueId: number;
  86982. /**
  86983. * The name of the material
  86984. */
  86985. name: string;
  86986. /**
  86987. * Gets or sets user defined metadata
  86988. */
  86989. metadata: any;
  86990. /**
  86991. * For internal use only. Please do not use.
  86992. */
  86993. reservedDataStore: any;
  86994. /**
  86995. * Specifies if the ready state should be checked on each call
  86996. */
  86997. checkReadyOnEveryCall: boolean;
  86998. /**
  86999. * Specifies if the ready state should be checked once
  87000. */
  87001. checkReadyOnlyOnce: boolean;
  87002. /**
  87003. * The state of the material
  87004. */
  87005. state: string;
  87006. /**
  87007. * The alpha value of the material
  87008. */
  87009. protected _alpha: number;
  87010. /**
  87011. * List of inspectable custom properties (used by the Inspector)
  87012. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87013. */
  87014. inspectableCustomProperties: IInspectable[];
  87015. /**
  87016. * Sets the alpha value of the material
  87017. */
  87018. /**
  87019. * Gets the alpha value of the material
  87020. */
  87021. alpha: number;
  87022. /**
  87023. * Specifies if back face culling is enabled
  87024. */
  87025. protected _backFaceCulling: boolean;
  87026. /**
  87027. * Sets the back-face culling state
  87028. */
  87029. /**
  87030. * Gets the back-face culling state
  87031. */
  87032. backFaceCulling: boolean;
  87033. /**
  87034. * Stores the value for side orientation
  87035. */
  87036. sideOrientation: number;
  87037. /**
  87038. * Callback triggered when the material is compiled
  87039. */
  87040. onCompiled: Nullable<(effect: Effect) => void>;
  87041. /**
  87042. * Callback triggered when an error occurs
  87043. */
  87044. onError: Nullable<(effect: Effect, errors: string) => void>;
  87045. /**
  87046. * Callback triggered to get the render target textures
  87047. */
  87048. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87049. /**
  87050. * Gets a boolean indicating that current material needs to register RTT
  87051. */
  87052. readonly hasRenderTargetTextures: boolean;
  87053. /**
  87054. * Specifies if the material should be serialized
  87055. */
  87056. doNotSerialize: boolean;
  87057. /**
  87058. * @hidden
  87059. */
  87060. _storeEffectOnSubMeshes: boolean;
  87061. /**
  87062. * Stores the animations for the material
  87063. */
  87064. animations: Nullable<Array<Animation>>;
  87065. /**
  87066. * An event triggered when the material is disposed
  87067. */
  87068. onDisposeObservable: Observable<Material>;
  87069. /**
  87070. * An observer which watches for dispose events
  87071. */
  87072. private _onDisposeObserver;
  87073. private _onUnBindObservable;
  87074. /**
  87075. * Called during a dispose event
  87076. */
  87077. onDispose: () => void;
  87078. private _onBindObservable;
  87079. /**
  87080. * An event triggered when the material is bound
  87081. */
  87082. readonly onBindObservable: Observable<AbstractMesh>;
  87083. /**
  87084. * An observer which watches for bind events
  87085. */
  87086. private _onBindObserver;
  87087. /**
  87088. * Called during a bind event
  87089. */
  87090. onBind: (Mesh: AbstractMesh) => void;
  87091. /**
  87092. * An event triggered when the material is unbound
  87093. */
  87094. readonly onUnBindObservable: Observable<Material>;
  87095. /**
  87096. * Stores the value of the alpha mode
  87097. */
  87098. private _alphaMode;
  87099. /**
  87100. * Sets the value of the alpha mode.
  87101. *
  87102. * | Value | Type | Description |
  87103. * | --- | --- | --- |
  87104. * | 0 | ALPHA_DISABLE | |
  87105. * | 1 | ALPHA_ADD | |
  87106. * | 2 | ALPHA_COMBINE | |
  87107. * | 3 | ALPHA_SUBTRACT | |
  87108. * | 4 | ALPHA_MULTIPLY | |
  87109. * | 5 | ALPHA_MAXIMIZED | |
  87110. * | 6 | ALPHA_ONEONE | |
  87111. * | 7 | ALPHA_PREMULTIPLIED | |
  87112. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87113. * | 9 | ALPHA_INTERPOLATE | |
  87114. * | 10 | ALPHA_SCREENMODE | |
  87115. *
  87116. */
  87117. /**
  87118. * Gets the value of the alpha mode
  87119. */
  87120. alphaMode: number;
  87121. /**
  87122. * Stores the state of the need depth pre-pass value
  87123. */
  87124. private _needDepthPrePass;
  87125. /**
  87126. * Sets the need depth pre-pass value
  87127. */
  87128. /**
  87129. * Gets the depth pre-pass value
  87130. */
  87131. needDepthPrePass: boolean;
  87132. /**
  87133. * Specifies if depth writing should be disabled
  87134. */
  87135. disableDepthWrite: boolean;
  87136. /**
  87137. * Specifies if depth writing should be forced
  87138. */
  87139. forceDepthWrite: boolean;
  87140. /**
  87141. * Specifies if there should be a separate pass for culling
  87142. */
  87143. separateCullingPass: boolean;
  87144. /**
  87145. * Stores the state specifing if fog should be enabled
  87146. */
  87147. private _fogEnabled;
  87148. /**
  87149. * Sets the state for enabling fog
  87150. */
  87151. /**
  87152. * Gets the value of the fog enabled state
  87153. */
  87154. fogEnabled: boolean;
  87155. /**
  87156. * Stores the size of points
  87157. */
  87158. pointSize: number;
  87159. /**
  87160. * Stores the z offset value
  87161. */
  87162. zOffset: number;
  87163. /**
  87164. * Gets a value specifying if wireframe mode is enabled
  87165. */
  87166. /**
  87167. * Sets the state of wireframe mode
  87168. */
  87169. wireframe: boolean;
  87170. /**
  87171. * Gets the value specifying if point clouds are enabled
  87172. */
  87173. /**
  87174. * Sets the state of point cloud mode
  87175. */
  87176. pointsCloud: boolean;
  87177. /**
  87178. * Gets the material fill mode
  87179. */
  87180. /**
  87181. * Sets the material fill mode
  87182. */
  87183. fillMode: number;
  87184. /**
  87185. * @hidden
  87186. * Stores the effects for the material
  87187. */
  87188. _effect: Nullable<Effect>;
  87189. /**
  87190. * @hidden
  87191. * Specifies if the material was previously ready
  87192. */
  87193. _wasPreviouslyReady: boolean;
  87194. /**
  87195. * Specifies if uniform buffers should be used
  87196. */
  87197. private _useUBO;
  87198. /**
  87199. * Stores a reference to the scene
  87200. */
  87201. private _scene;
  87202. /**
  87203. * Stores the fill mode state
  87204. */
  87205. private _fillMode;
  87206. /**
  87207. * Specifies if the depth write state should be cached
  87208. */
  87209. private _cachedDepthWriteState;
  87210. /**
  87211. * Stores the uniform buffer
  87212. */
  87213. protected _uniformBuffer: UniformBuffer;
  87214. /** @hidden */
  87215. _indexInSceneMaterialArray: number;
  87216. /** @hidden */
  87217. meshMap: Nullable<{
  87218. [id: string]: AbstractMesh | undefined;
  87219. }>;
  87220. /**
  87221. * Creates a material instance
  87222. * @param name defines the name of the material
  87223. * @param scene defines the scene to reference
  87224. * @param doNotAdd specifies if the material should be added to the scene
  87225. */
  87226. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87227. /**
  87228. * Returns a string representation of the current material
  87229. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87230. * @returns a string with material information
  87231. */
  87232. toString(fullDetails?: boolean): string;
  87233. /**
  87234. * Gets the class name of the material
  87235. * @returns a string with the class name of the material
  87236. */
  87237. getClassName(): string;
  87238. /**
  87239. * Specifies if updates for the material been locked
  87240. */
  87241. readonly isFrozen: boolean;
  87242. /**
  87243. * Locks updates for the material
  87244. */
  87245. freeze(): void;
  87246. /**
  87247. * Unlocks updates for the material
  87248. */
  87249. unfreeze(): void;
  87250. /**
  87251. * Specifies if the material is ready to be used
  87252. * @param mesh defines the mesh to check
  87253. * @param useInstances specifies if instances should be used
  87254. * @returns a boolean indicating if the material is ready to be used
  87255. */
  87256. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87257. /**
  87258. * Specifies that the submesh is ready to be used
  87259. * @param mesh defines the mesh to check
  87260. * @param subMesh defines which submesh to check
  87261. * @param useInstances specifies that instances should be used
  87262. * @returns a boolean indicating that the submesh is ready or not
  87263. */
  87264. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87265. /**
  87266. * Returns the material effect
  87267. * @returns the effect associated with the material
  87268. */
  87269. getEffect(): Nullable<Effect>;
  87270. /**
  87271. * Returns the current scene
  87272. * @returns a Scene
  87273. */
  87274. getScene(): Scene;
  87275. /**
  87276. * Specifies if the material will require alpha blending
  87277. * @returns a boolean specifying if alpha blending is needed
  87278. */
  87279. needAlphaBlending(): boolean;
  87280. /**
  87281. * Specifies if the mesh will require alpha blending
  87282. * @param mesh defines the mesh to check
  87283. * @returns a boolean specifying if alpha blending is needed for the mesh
  87284. */
  87285. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87286. /**
  87287. * Specifies if this material should be rendered in alpha test mode
  87288. * @returns a boolean specifying if an alpha test is needed.
  87289. */
  87290. needAlphaTesting(): boolean;
  87291. /**
  87292. * Gets the texture used for the alpha test
  87293. * @returns the texture to use for alpha testing
  87294. */
  87295. getAlphaTestTexture(): Nullable<BaseTexture>;
  87296. /**
  87297. * Marks the material to indicate that it needs to be re-calculated
  87298. */
  87299. markDirty(): void;
  87300. /** @hidden */
  87301. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87302. /**
  87303. * Binds the material to the mesh
  87304. * @param world defines the world transformation matrix
  87305. * @param mesh defines the mesh to bind the material to
  87306. */
  87307. bind(world: Matrix, mesh?: Mesh): void;
  87308. /**
  87309. * Binds the submesh to the material
  87310. * @param world defines the world transformation matrix
  87311. * @param mesh defines the mesh containing the submesh
  87312. * @param subMesh defines the submesh to bind the material to
  87313. */
  87314. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87315. /**
  87316. * Binds the world matrix to the material
  87317. * @param world defines the world transformation matrix
  87318. */
  87319. bindOnlyWorldMatrix(world: Matrix): void;
  87320. /**
  87321. * Binds the scene's uniform buffer to the effect.
  87322. * @param effect defines the effect to bind to the scene uniform buffer
  87323. * @param sceneUbo defines the uniform buffer storing scene data
  87324. */
  87325. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87326. /**
  87327. * Binds the view matrix to the effect
  87328. * @param effect defines the effect to bind the view matrix to
  87329. */
  87330. bindView(effect: Effect): void;
  87331. /**
  87332. * Binds the view projection matrix to the effect
  87333. * @param effect defines the effect to bind the view projection matrix to
  87334. */
  87335. bindViewProjection(effect: Effect): void;
  87336. /**
  87337. * Specifies if material alpha testing should be turned on for the mesh
  87338. * @param mesh defines the mesh to check
  87339. */
  87340. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87341. /**
  87342. * Processes to execute after binding the material to a mesh
  87343. * @param mesh defines the rendered mesh
  87344. */
  87345. protected _afterBind(mesh?: Mesh): void;
  87346. /**
  87347. * Unbinds the material from the mesh
  87348. */
  87349. unbind(): void;
  87350. /**
  87351. * Gets the active textures from the material
  87352. * @returns an array of textures
  87353. */
  87354. getActiveTextures(): BaseTexture[];
  87355. /**
  87356. * Specifies if the material uses a texture
  87357. * @param texture defines the texture to check against the material
  87358. * @returns a boolean specifying if the material uses the texture
  87359. */
  87360. hasTexture(texture: BaseTexture): boolean;
  87361. /**
  87362. * Makes a duplicate of the material, and gives it a new name
  87363. * @param name defines the new name for the duplicated material
  87364. * @returns the cloned material
  87365. */
  87366. clone(name: string): Nullable<Material>;
  87367. /**
  87368. * Gets the meshes bound to the material
  87369. * @returns an array of meshes bound to the material
  87370. */
  87371. getBindedMeshes(): AbstractMesh[];
  87372. /**
  87373. * Force shader compilation
  87374. * @param mesh defines the mesh associated with this material
  87375. * @param onCompiled defines a function to execute once the material is compiled
  87376. * @param options defines the options to configure the compilation
  87377. */
  87378. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87379. clipPlane: boolean;
  87380. }>): void;
  87381. /**
  87382. * Force shader compilation
  87383. * @param mesh defines the mesh that will use this material
  87384. * @param options defines additional options for compiling the shaders
  87385. * @returns a promise that resolves when the compilation completes
  87386. */
  87387. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87388. clipPlane: boolean;
  87389. }>): Promise<void>;
  87390. private static readonly _AllDirtyCallBack;
  87391. private static readonly _ImageProcessingDirtyCallBack;
  87392. private static readonly _TextureDirtyCallBack;
  87393. private static readonly _FresnelDirtyCallBack;
  87394. private static readonly _MiscDirtyCallBack;
  87395. private static readonly _LightsDirtyCallBack;
  87396. private static readonly _AttributeDirtyCallBack;
  87397. private static _FresnelAndMiscDirtyCallBack;
  87398. private static _TextureAndMiscDirtyCallBack;
  87399. private static readonly _DirtyCallbackArray;
  87400. private static readonly _RunDirtyCallBacks;
  87401. /**
  87402. * Marks a define in the material to indicate that it needs to be re-computed
  87403. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87404. */
  87405. markAsDirty(flag: number): void;
  87406. /**
  87407. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87408. * @param func defines a function which checks material defines against the submeshes
  87409. */
  87410. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87411. /**
  87412. * Indicates that we need to re-calculated for all submeshes
  87413. */
  87414. protected _markAllSubMeshesAsAllDirty(): void;
  87415. /**
  87416. * Indicates that image processing needs to be re-calculated for all submeshes
  87417. */
  87418. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87419. /**
  87420. * Indicates that textures need to be re-calculated for all submeshes
  87421. */
  87422. protected _markAllSubMeshesAsTexturesDirty(): void;
  87423. /**
  87424. * Indicates that fresnel needs to be re-calculated for all submeshes
  87425. */
  87426. protected _markAllSubMeshesAsFresnelDirty(): void;
  87427. /**
  87428. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87429. */
  87430. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87431. /**
  87432. * Indicates that lights need to be re-calculated for all submeshes
  87433. */
  87434. protected _markAllSubMeshesAsLightsDirty(): void;
  87435. /**
  87436. * Indicates that attributes need to be re-calculated for all submeshes
  87437. */
  87438. protected _markAllSubMeshesAsAttributesDirty(): void;
  87439. /**
  87440. * Indicates that misc needs to be re-calculated for all submeshes
  87441. */
  87442. protected _markAllSubMeshesAsMiscDirty(): void;
  87443. /**
  87444. * Indicates that textures and misc need to be re-calculated for all submeshes
  87445. */
  87446. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87447. /**
  87448. * Disposes the material
  87449. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87450. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87451. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87452. */
  87453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87454. /** @hidden */
  87455. private releaseVertexArrayObject;
  87456. /**
  87457. * Serializes this material
  87458. * @returns the serialized material object
  87459. */
  87460. serialize(): any;
  87461. /**
  87462. * Creates a material from parsed material data
  87463. * @param parsedMaterial defines parsed material data
  87464. * @param scene defines the hosting scene
  87465. * @param rootUrl defines the root URL to use to load textures
  87466. * @returns a new material
  87467. */
  87468. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87469. }
  87470. }
  87471. declare module BABYLON {
  87472. /**
  87473. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87474. * separate meshes. This can be use to improve performances.
  87475. * @see http://doc.babylonjs.com/how_to/multi_materials
  87476. */
  87477. export class MultiMaterial extends Material {
  87478. private _subMaterials;
  87479. /**
  87480. * Gets or Sets the list of Materials used within the multi material.
  87481. * They need to be ordered according to the submeshes order in the associated mesh
  87482. */
  87483. subMaterials: Nullable<Material>[];
  87484. /**
  87485. * Function used to align with Node.getChildren()
  87486. * @returns the list of Materials used within the multi material
  87487. */
  87488. getChildren(): Nullable<Material>[];
  87489. /**
  87490. * Instantiates a new Multi Material
  87491. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87492. * separate meshes. This can be use to improve performances.
  87493. * @see http://doc.babylonjs.com/how_to/multi_materials
  87494. * @param name Define the name in the scene
  87495. * @param scene Define the scene the material belongs to
  87496. */
  87497. constructor(name: string, scene: Scene);
  87498. private _hookArray;
  87499. /**
  87500. * Get one of the submaterial by its index in the submaterials array
  87501. * @param index The index to look the sub material at
  87502. * @returns The Material if the index has been defined
  87503. */
  87504. getSubMaterial(index: number): Nullable<Material>;
  87505. /**
  87506. * Get the list of active textures for the whole sub materials list.
  87507. * @returns All the textures that will be used during the rendering
  87508. */
  87509. getActiveTextures(): BaseTexture[];
  87510. /**
  87511. * Gets the current class name of the material e.g. "MultiMaterial"
  87512. * Mainly use in serialization.
  87513. * @returns the class name
  87514. */
  87515. getClassName(): string;
  87516. /**
  87517. * Checks if the material is ready to render the requested sub mesh
  87518. * @param mesh Define the mesh the submesh belongs to
  87519. * @param subMesh Define the sub mesh to look readyness for
  87520. * @param useInstances Define whether or not the material is used with instances
  87521. * @returns true if ready, otherwise false
  87522. */
  87523. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87524. /**
  87525. * Clones the current material and its related sub materials
  87526. * @param name Define the name of the newly cloned material
  87527. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87528. * @returns the cloned material
  87529. */
  87530. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87531. /**
  87532. * Serializes the materials into a JSON representation.
  87533. * @returns the JSON representation
  87534. */
  87535. serialize(): any;
  87536. /**
  87537. * Dispose the material and release its associated resources
  87538. * @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)
  87539. * @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)
  87540. * @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)
  87541. */
  87542. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87543. /**
  87544. * Creates a MultiMaterial from parsed MultiMaterial data.
  87545. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87546. * @param scene defines the hosting scene
  87547. * @returns a new MultiMaterial
  87548. */
  87549. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87550. }
  87551. }
  87552. declare module BABYLON {
  87553. /**
  87554. * Base class for submeshes
  87555. */
  87556. export class BaseSubMesh {
  87557. /** @hidden */
  87558. _materialDefines: Nullable<MaterialDefines>;
  87559. /** @hidden */
  87560. _materialEffect: Nullable<Effect>;
  87561. /**
  87562. * Gets associated effect
  87563. */
  87564. readonly effect: Nullable<Effect>;
  87565. /**
  87566. * Sets associated effect (effect used to render this submesh)
  87567. * @param effect defines the effect to associate with
  87568. * @param defines defines the set of defines used to compile this effect
  87569. */
  87570. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87571. }
  87572. /**
  87573. * Defines a subdivision inside a mesh
  87574. */
  87575. export class SubMesh extends BaseSubMesh implements ICullable {
  87576. /** the material index to use */
  87577. materialIndex: number;
  87578. /** vertex index start */
  87579. verticesStart: number;
  87580. /** vertices count */
  87581. verticesCount: number;
  87582. /** index start */
  87583. indexStart: number;
  87584. /** indices count */
  87585. indexCount: number;
  87586. /** @hidden */
  87587. _linesIndexCount: number;
  87588. private _mesh;
  87589. private _renderingMesh;
  87590. private _boundingInfo;
  87591. private _linesIndexBuffer;
  87592. /** @hidden */
  87593. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87594. /** @hidden */
  87595. _trianglePlanes: Plane[];
  87596. /** @hidden */
  87597. _lastColliderTransformMatrix: Nullable<Matrix>;
  87598. /** @hidden */
  87599. _renderId: number;
  87600. /** @hidden */
  87601. _alphaIndex: number;
  87602. /** @hidden */
  87603. _distanceToCamera: number;
  87604. /** @hidden */
  87605. _id: number;
  87606. private _currentMaterial;
  87607. /**
  87608. * Add a new submesh to a mesh
  87609. * @param materialIndex defines the material index to use
  87610. * @param verticesStart defines vertex index start
  87611. * @param verticesCount defines vertices count
  87612. * @param indexStart defines index start
  87613. * @param indexCount defines indices count
  87614. * @param mesh defines the parent mesh
  87615. * @param renderingMesh defines an optional rendering mesh
  87616. * @param createBoundingBox defines if bounding box should be created for this submesh
  87617. * @returns the new submesh
  87618. */
  87619. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87620. /**
  87621. * Creates a new submesh
  87622. * @param materialIndex defines the material index to use
  87623. * @param verticesStart defines vertex index start
  87624. * @param verticesCount defines vertices count
  87625. * @param indexStart defines index start
  87626. * @param indexCount defines indices count
  87627. * @param mesh defines the parent mesh
  87628. * @param renderingMesh defines an optional rendering mesh
  87629. * @param createBoundingBox defines if bounding box should be created for this submesh
  87630. */
  87631. constructor(
  87632. /** the material index to use */
  87633. materialIndex: number,
  87634. /** vertex index start */
  87635. verticesStart: number,
  87636. /** vertices count */
  87637. verticesCount: number,
  87638. /** index start */
  87639. indexStart: number,
  87640. /** indices count */
  87641. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87642. /**
  87643. * Returns true if this submesh covers the entire parent mesh
  87644. * @ignorenaming
  87645. */
  87646. readonly IsGlobal: boolean;
  87647. /**
  87648. * Returns the submesh BoudingInfo object
  87649. * @returns current bounding info (or mesh's one if the submesh is global)
  87650. */
  87651. getBoundingInfo(): BoundingInfo;
  87652. /**
  87653. * Sets the submesh BoundingInfo
  87654. * @param boundingInfo defines the new bounding info to use
  87655. * @returns the SubMesh
  87656. */
  87657. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87658. /**
  87659. * Returns the mesh of the current submesh
  87660. * @return the parent mesh
  87661. */
  87662. getMesh(): AbstractMesh;
  87663. /**
  87664. * Returns the rendering mesh of the submesh
  87665. * @returns the rendering mesh (could be different from parent mesh)
  87666. */
  87667. getRenderingMesh(): Mesh;
  87668. /**
  87669. * Returns the submesh material
  87670. * @returns null or the current material
  87671. */
  87672. getMaterial(): Nullable<Material>;
  87673. /**
  87674. * Sets a new updated BoundingInfo object to the submesh
  87675. * @param data defines an optional position array to use to determine the bounding info
  87676. * @returns the SubMesh
  87677. */
  87678. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87679. /** @hidden */
  87680. _checkCollision(collider: Collider): boolean;
  87681. /**
  87682. * Updates the submesh BoundingInfo
  87683. * @param world defines the world matrix to use to update the bounding info
  87684. * @returns the submesh
  87685. */
  87686. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87687. /**
  87688. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87689. * @param frustumPlanes defines the frustum planes
  87690. * @returns true if the submesh is intersecting with the frustum
  87691. */
  87692. isInFrustum(frustumPlanes: Plane[]): boolean;
  87693. /**
  87694. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87695. * @param frustumPlanes defines the frustum planes
  87696. * @returns true if the submesh is inside the frustum
  87697. */
  87698. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87699. /**
  87700. * Renders the submesh
  87701. * @param enableAlphaMode defines if alpha needs to be used
  87702. * @returns the submesh
  87703. */
  87704. render(enableAlphaMode: boolean): SubMesh;
  87705. /**
  87706. * @hidden
  87707. */
  87708. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87709. /**
  87710. * Checks if the submesh intersects with a ray
  87711. * @param ray defines the ray to test
  87712. * @returns true is the passed ray intersects the submesh bounding box
  87713. */
  87714. canIntersects(ray: Ray): boolean;
  87715. /**
  87716. * Intersects current submesh with a ray
  87717. * @param ray defines the ray to test
  87718. * @param positions defines mesh's positions array
  87719. * @param indices defines mesh's indices array
  87720. * @param fastCheck defines if only bounding info should be used
  87721. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87722. * @returns intersection info or null if no intersection
  87723. */
  87724. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87725. /** @hidden */
  87726. private _intersectLines;
  87727. /** @hidden */
  87728. private _intersectUnIndexedLines;
  87729. /** @hidden */
  87730. private _intersectTriangles;
  87731. /** @hidden */
  87732. private _intersectUnIndexedTriangles;
  87733. /** @hidden */
  87734. _rebuild(): void;
  87735. /**
  87736. * Creates a new submesh from the passed mesh
  87737. * @param newMesh defines the new hosting mesh
  87738. * @param newRenderingMesh defines an optional rendering mesh
  87739. * @returns the new submesh
  87740. */
  87741. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87742. /**
  87743. * Release associated resources
  87744. */
  87745. dispose(): void;
  87746. /**
  87747. * Gets the class name
  87748. * @returns the string "SubMesh".
  87749. */
  87750. getClassName(): string;
  87751. /**
  87752. * Creates a new submesh from indices data
  87753. * @param materialIndex the index of the main mesh material
  87754. * @param startIndex the index where to start the copy in the mesh indices array
  87755. * @param indexCount the number of indices to copy then from the startIndex
  87756. * @param mesh the main mesh to create the submesh from
  87757. * @param renderingMesh the optional rendering mesh
  87758. * @returns a new submesh
  87759. */
  87760. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87761. }
  87762. }
  87763. declare module BABYLON {
  87764. /**
  87765. * Class used to represent data loading progression
  87766. */
  87767. export class SceneLoaderFlags {
  87768. private static _ForceFullSceneLoadingForIncremental;
  87769. private static _ShowLoadingScreen;
  87770. private static _CleanBoneMatrixWeights;
  87771. private static _loggingLevel;
  87772. /**
  87773. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87774. */
  87775. static ForceFullSceneLoadingForIncremental: boolean;
  87776. /**
  87777. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87778. */
  87779. static ShowLoadingScreen: boolean;
  87780. /**
  87781. * Defines the current logging level (while loading the scene)
  87782. * @ignorenaming
  87783. */
  87784. static loggingLevel: number;
  87785. /**
  87786. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87787. */
  87788. static CleanBoneMatrixWeights: boolean;
  87789. }
  87790. }
  87791. declare module BABYLON {
  87792. /**
  87793. * Class used to store geometry data (vertex buffers + index buffer)
  87794. */
  87795. export class Geometry implements IGetSetVerticesData {
  87796. /**
  87797. * Gets or sets the ID of the geometry
  87798. */
  87799. id: string;
  87800. /**
  87801. * Gets or sets the unique ID of the geometry
  87802. */
  87803. uniqueId: number;
  87804. /**
  87805. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87806. */
  87807. delayLoadState: number;
  87808. /**
  87809. * Gets the file containing the data to load when running in delay load state
  87810. */
  87811. delayLoadingFile: Nullable<string>;
  87812. /**
  87813. * Callback called when the geometry is updated
  87814. */
  87815. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87816. private _scene;
  87817. private _engine;
  87818. private _meshes;
  87819. private _totalVertices;
  87820. /** @hidden */
  87821. _indices: IndicesArray;
  87822. /** @hidden */
  87823. _vertexBuffers: {
  87824. [key: string]: VertexBuffer;
  87825. };
  87826. private _isDisposed;
  87827. private _extend;
  87828. private _boundingBias;
  87829. /** @hidden */
  87830. _delayInfo: Array<string>;
  87831. private _indexBuffer;
  87832. private _indexBufferIsUpdatable;
  87833. /** @hidden */
  87834. _boundingInfo: Nullable<BoundingInfo>;
  87835. /** @hidden */
  87836. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87837. /** @hidden */
  87838. _softwareSkinningFrameId: number;
  87839. private _vertexArrayObjects;
  87840. private _updatable;
  87841. /** @hidden */
  87842. _positions: Nullable<Vector3[]>;
  87843. /**
  87844. * 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
  87845. */
  87846. /**
  87847. * 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
  87848. */
  87849. boundingBias: Vector2;
  87850. /**
  87851. * Static function used to attach a new empty geometry to a mesh
  87852. * @param mesh defines the mesh to attach the geometry to
  87853. * @returns the new Geometry
  87854. */
  87855. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87856. /**
  87857. * Creates a new geometry
  87858. * @param id defines the unique ID
  87859. * @param scene defines the hosting scene
  87860. * @param vertexData defines the VertexData used to get geometry data
  87861. * @param updatable defines if geometry must be updatable (false by default)
  87862. * @param mesh defines the mesh that will be associated with the geometry
  87863. */
  87864. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87865. /**
  87866. * Gets the current extend of the geometry
  87867. */
  87868. readonly extend: {
  87869. minimum: Vector3;
  87870. maximum: Vector3;
  87871. };
  87872. /**
  87873. * Gets the hosting scene
  87874. * @returns the hosting Scene
  87875. */
  87876. getScene(): Scene;
  87877. /**
  87878. * Gets the hosting engine
  87879. * @returns the hosting Engine
  87880. */
  87881. getEngine(): Engine;
  87882. /**
  87883. * Defines if the geometry is ready to use
  87884. * @returns true if the geometry is ready to be used
  87885. */
  87886. isReady(): boolean;
  87887. /**
  87888. * Gets a value indicating that the geometry should not be serialized
  87889. */
  87890. readonly doNotSerialize: boolean;
  87891. /** @hidden */
  87892. _rebuild(): void;
  87893. /**
  87894. * Affects all geometry data in one call
  87895. * @param vertexData defines the geometry data
  87896. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87897. */
  87898. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87899. /**
  87900. * Set specific vertex data
  87901. * @param kind defines the data kind (Position, normal, etc...)
  87902. * @param data defines the vertex data to use
  87903. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87904. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87905. */
  87906. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87907. /**
  87908. * Removes a specific vertex data
  87909. * @param kind defines the data kind (Position, normal, etc...)
  87910. */
  87911. removeVerticesData(kind: string): void;
  87912. /**
  87913. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87914. * @param buffer defines the vertex buffer to use
  87915. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87916. */
  87917. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87918. /**
  87919. * Update a specific vertex buffer
  87920. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87921. * It will do nothing if the buffer is not updatable
  87922. * @param kind defines the data kind (Position, normal, etc...)
  87923. * @param data defines the data to use
  87924. * @param offset defines the offset in the target buffer where to store the data
  87925. * @param useBytes set to true if the offset is in bytes
  87926. */
  87927. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87928. /**
  87929. * Update a specific vertex buffer
  87930. * This function will create a new buffer if the current one is not updatable
  87931. * @param kind defines the data kind (Position, normal, etc...)
  87932. * @param data defines the data to use
  87933. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87934. */
  87935. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87936. private _updateBoundingInfo;
  87937. /** @hidden */
  87938. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87939. /**
  87940. * Gets total number of vertices
  87941. * @returns the total number of vertices
  87942. */
  87943. getTotalVertices(): number;
  87944. /**
  87945. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87946. * @param kind defines the data kind (Position, normal, etc...)
  87947. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87948. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87949. * @returns a float array containing vertex data
  87950. */
  87951. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87952. /**
  87953. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87954. * @param kind defines the data kind (Position, normal, etc...)
  87955. * @returns true if the vertex buffer with the specified kind is updatable
  87956. */
  87957. isVertexBufferUpdatable(kind: string): boolean;
  87958. /**
  87959. * Gets a specific vertex buffer
  87960. * @param kind defines the data kind (Position, normal, etc...)
  87961. * @returns a VertexBuffer
  87962. */
  87963. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87964. /**
  87965. * Returns all vertex buffers
  87966. * @return an object holding all vertex buffers indexed by kind
  87967. */
  87968. getVertexBuffers(): Nullable<{
  87969. [key: string]: VertexBuffer;
  87970. }>;
  87971. /**
  87972. * Gets a boolean indicating if specific vertex buffer is present
  87973. * @param kind defines the data kind (Position, normal, etc...)
  87974. * @returns true if data is present
  87975. */
  87976. isVerticesDataPresent(kind: string): boolean;
  87977. /**
  87978. * Gets a list of all attached data kinds (Position, normal, etc...)
  87979. * @returns a list of string containing all kinds
  87980. */
  87981. getVerticesDataKinds(): string[];
  87982. /**
  87983. * Update index buffer
  87984. * @param indices defines the indices to store in the index buffer
  87985. * @param offset defines the offset in the target buffer where to store the data
  87986. * @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)
  87987. */
  87988. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87989. /**
  87990. * Creates a new index buffer
  87991. * @param indices defines the indices to store in the index buffer
  87992. * @param totalVertices defines the total number of vertices (could be null)
  87993. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87994. */
  87995. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87996. /**
  87997. * Return the total number of indices
  87998. * @returns the total number of indices
  87999. */
  88000. getTotalIndices(): number;
  88001. /**
  88002. * Gets the index buffer array
  88003. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88004. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88005. * @returns the index buffer array
  88006. */
  88007. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88008. /**
  88009. * Gets the index buffer
  88010. * @return the index buffer
  88011. */
  88012. getIndexBuffer(): Nullable<DataBuffer>;
  88013. /** @hidden */
  88014. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88015. /**
  88016. * Release the associated resources for a specific mesh
  88017. * @param mesh defines the source mesh
  88018. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88019. */
  88020. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88021. /**
  88022. * Apply current geometry to a given mesh
  88023. * @param mesh defines the mesh to apply geometry to
  88024. */
  88025. applyToMesh(mesh: Mesh): void;
  88026. private _updateExtend;
  88027. private _applyToMesh;
  88028. private notifyUpdate;
  88029. /**
  88030. * Load the geometry if it was flagged as delay loaded
  88031. * @param scene defines the hosting scene
  88032. * @param onLoaded defines a callback called when the geometry is loaded
  88033. */
  88034. load(scene: Scene, onLoaded?: () => void): void;
  88035. private _queueLoad;
  88036. /**
  88037. * Invert the geometry to move from a right handed system to a left handed one.
  88038. */
  88039. toLeftHanded(): void;
  88040. /** @hidden */
  88041. _resetPointsArrayCache(): void;
  88042. /** @hidden */
  88043. _generatePointsArray(): boolean;
  88044. /**
  88045. * Gets a value indicating if the geometry is disposed
  88046. * @returns true if the geometry was disposed
  88047. */
  88048. isDisposed(): boolean;
  88049. private _disposeVertexArrayObjects;
  88050. /**
  88051. * Free all associated resources
  88052. */
  88053. dispose(): void;
  88054. /**
  88055. * Clone the current geometry into a new geometry
  88056. * @param id defines the unique ID of the new geometry
  88057. * @returns a new geometry object
  88058. */
  88059. copy(id: string): Geometry;
  88060. /**
  88061. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88062. * @return a JSON representation of the current geometry data (without the vertices data)
  88063. */
  88064. serialize(): any;
  88065. private toNumberArray;
  88066. /**
  88067. * Serialize all vertices data into a JSON oject
  88068. * @returns a JSON representation of the current geometry data
  88069. */
  88070. serializeVerticeData(): any;
  88071. /**
  88072. * Extracts a clone of a mesh geometry
  88073. * @param mesh defines the source mesh
  88074. * @param id defines the unique ID of the new geometry object
  88075. * @returns the new geometry object
  88076. */
  88077. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88078. /**
  88079. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88080. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88081. * Be aware Math.random() could cause collisions, but:
  88082. * "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"
  88083. * @returns a string containing a new GUID
  88084. */
  88085. static RandomId(): string;
  88086. /** @hidden */
  88087. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88088. private static _CleanMatricesWeights;
  88089. /**
  88090. * Create a new geometry from persisted data (Using .babylon file format)
  88091. * @param parsedVertexData defines the persisted data
  88092. * @param scene defines the hosting scene
  88093. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88094. * @returns the new geometry object
  88095. */
  88096. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88097. }
  88098. }
  88099. declare module BABYLON {
  88100. /**
  88101. * Define an interface for all classes that will get and set the data on vertices
  88102. */
  88103. export interface IGetSetVerticesData {
  88104. /**
  88105. * Gets a boolean indicating if specific vertex data is present
  88106. * @param kind defines the vertex data kind to use
  88107. * @returns true is data kind is present
  88108. */
  88109. isVerticesDataPresent(kind: string): boolean;
  88110. /**
  88111. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88112. * @param kind defines the data kind (Position, normal, etc...)
  88113. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88114. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88115. * @returns a float array containing vertex data
  88116. */
  88117. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88118. /**
  88119. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88120. * @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.
  88121. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88122. * @returns the indices array or an empty array if the mesh has no geometry
  88123. */
  88124. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88125. /**
  88126. * Set specific vertex data
  88127. * @param kind defines the data kind (Position, normal, etc...)
  88128. * @param data defines the vertex data to use
  88129. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88130. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88131. */
  88132. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88133. /**
  88134. * Update a specific associated vertex buffer
  88135. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88136. * - VertexBuffer.PositionKind
  88137. * - VertexBuffer.UVKind
  88138. * - VertexBuffer.UV2Kind
  88139. * - VertexBuffer.UV3Kind
  88140. * - VertexBuffer.UV4Kind
  88141. * - VertexBuffer.UV5Kind
  88142. * - VertexBuffer.UV6Kind
  88143. * - VertexBuffer.ColorKind
  88144. * - VertexBuffer.MatricesIndicesKind
  88145. * - VertexBuffer.MatricesIndicesExtraKind
  88146. * - VertexBuffer.MatricesWeightsKind
  88147. * - VertexBuffer.MatricesWeightsExtraKind
  88148. * @param data defines the data source
  88149. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88150. * @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)
  88151. */
  88152. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88153. /**
  88154. * Creates a new index buffer
  88155. * @param indices defines the indices to store in the index buffer
  88156. * @param totalVertices defines the total number of vertices (could be null)
  88157. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88158. */
  88159. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88160. }
  88161. /**
  88162. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88163. */
  88164. export class VertexData {
  88165. /**
  88166. * Mesh side orientation : usually the external or front surface
  88167. */
  88168. static readonly FRONTSIDE: number;
  88169. /**
  88170. * Mesh side orientation : usually the internal or back surface
  88171. */
  88172. static readonly BACKSIDE: number;
  88173. /**
  88174. * Mesh side orientation : both internal and external or front and back surfaces
  88175. */
  88176. static readonly DOUBLESIDE: number;
  88177. /**
  88178. * Mesh side orientation : by default, `FRONTSIDE`
  88179. */
  88180. static readonly DEFAULTSIDE: number;
  88181. /**
  88182. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88183. */
  88184. positions: Nullable<FloatArray>;
  88185. /**
  88186. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88187. */
  88188. normals: Nullable<FloatArray>;
  88189. /**
  88190. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88191. */
  88192. tangents: Nullable<FloatArray>;
  88193. /**
  88194. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88195. */
  88196. uvs: Nullable<FloatArray>;
  88197. /**
  88198. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88199. */
  88200. uvs2: Nullable<FloatArray>;
  88201. /**
  88202. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88203. */
  88204. uvs3: Nullable<FloatArray>;
  88205. /**
  88206. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88207. */
  88208. uvs4: Nullable<FloatArray>;
  88209. /**
  88210. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88211. */
  88212. uvs5: Nullable<FloatArray>;
  88213. /**
  88214. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88215. */
  88216. uvs6: Nullable<FloatArray>;
  88217. /**
  88218. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88219. */
  88220. colors: Nullable<FloatArray>;
  88221. /**
  88222. * 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).
  88223. */
  88224. matricesIndices: Nullable<FloatArray>;
  88225. /**
  88226. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88227. */
  88228. matricesWeights: Nullable<FloatArray>;
  88229. /**
  88230. * An array extending the number of possible indices
  88231. */
  88232. matricesIndicesExtra: Nullable<FloatArray>;
  88233. /**
  88234. * An array extending the number of possible weights when the number of indices is extended
  88235. */
  88236. matricesWeightsExtra: Nullable<FloatArray>;
  88237. /**
  88238. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88239. */
  88240. indices: Nullable<IndicesArray>;
  88241. /**
  88242. * Uses the passed data array to set the set the values for the specified kind of data
  88243. * @param data a linear array of floating numbers
  88244. * @param kind the type of data that is being set, eg positions, colors etc
  88245. */
  88246. set(data: FloatArray, kind: string): void;
  88247. /**
  88248. * Associates the vertexData to the passed Mesh.
  88249. * Sets it as updatable or not (default `false`)
  88250. * @param mesh the mesh the vertexData is applied to
  88251. * @param updatable when used and having the value true allows new data to update the vertexData
  88252. * @returns the VertexData
  88253. */
  88254. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88255. /**
  88256. * Associates the vertexData to the passed Geometry.
  88257. * Sets it as updatable or not (default `false`)
  88258. * @param geometry the geometry the vertexData is applied to
  88259. * @param updatable when used and having the value true allows new data to update the vertexData
  88260. * @returns VertexData
  88261. */
  88262. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88263. /**
  88264. * Updates the associated mesh
  88265. * @param mesh the mesh to be updated
  88266. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88267. * @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
  88268. * @returns VertexData
  88269. */
  88270. updateMesh(mesh: Mesh): VertexData;
  88271. /**
  88272. * Updates the associated geometry
  88273. * @param geometry the geometry to be updated
  88274. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88275. * @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
  88276. * @returns VertexData.
  88277. */
  88278. updateGeometry(geometry: Geometry): VertexData;
  88279. private _applyTo;
  88280. private _update;
  88281. /**
  88282. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88283. * @param matrix the transforming matrix
  88284. * @returns the VertexData
  88285. */
  88286. transform(matrix: Matrix): VertexData;
  88287. /**
  88288. * Merges the passed VertexData into the current one
  88289. * @param other the VertexData to be merged into the current one
  88290. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88291. * @returns the modified VertexData
  88292. */
  88293. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88294. private _mergeElement;
  88295. private _validate;
  88296. /**
  88297. * Serializes the VertexData
  88298. * @returns a serialized object
  88299. */
  88300. serialize(): any;
  88301. /**
  88302. * Extracts the vertexData from a mesh
  88303. * @param mesh the mesh from which to extract the VertexData
  88304. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88305. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88306. * @returns the object VertexData associated to the passed mesh
  88307. */
  88308. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88309. /**
  88310. * Extracts the vertexData from the geometry
  88311. * @param geometry the geometry from which to extract the VertexData
  88312. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88313. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88314. * @returns the object VertexData associated to the passed mesh
  88315. */
  88316. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88317. private static _ExtractFrom;
  88318. /**
  88319. * Creates the VertexData for a Ribbon
  88320. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88321. * * pathArray array of paths, each of which an array of successive Vector3
  88322. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88323. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88324. * * 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
  88325. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88326. * * 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)
  88327. * * 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)
  88328. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88329. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88330. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88331. * @returns the VertexData of the ribbon
  88332. */
  88333. static CreateRibbon(options: {
  88334. pathArray: Vector3[][];
  88335. closeArray?: boolean;
  88336. closePath?: boolean;
  88337. offset?: number;
  88338. sideOrientation?: number;
  88339. frontUVs?: Vector4;
  88340. backUVs?: Vector4;
  88341. invertUV?: boolean;
  88342. uvs?: Vector2[];
  88343. colors?: Color4[];
  88344. }): VertexData;
  88345. /**
  88346. * Creates the VertexData for a box
  88347. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88348. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88349. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88350. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88351. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88352. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88353. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88354. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88355. * * 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)
  88356. * * 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)
  88357. * @returns the VertexData of the box
  88358. */
  88359. static CreateBox(options: {
  88360. size?: number;
  88361. width?: number;
  88362. height?: number;
  88363. depth?: number;
  88364. faceUV?: Vector4[];
  88365. faceColors?: Color4[];
  88366. sideOrientation?: number;
  88367. frontUVs?: Vector4;
  88368. backUVs?: Vector4;
  88369. }): VertexData;
  88370. /**
  88371. * Creates the VertexData for a tiled box
  88372. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88373. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88374. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88375. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88377. * @returns the VertexData of the box
  88378. */
  88379. static CreateTiledBox(options: {
  88380. pattern?: number;
  88381. width?: number;
  88382. height?: number;
  88383. depth?: number;
  88384. tileSize?: number;
  88385. tileWidth?: number;
  88386. tileHeight?: number;
  88387. alignHorizontal?: number;
  88388. alignVertical?: number;
  88389. faceUV?: Vector4[];
  88390. faceColors?: Color4[];
  88391. sideOrientation?: number;
  88392. }): VertexData;
  88393. /**
  88394. * Creates the VertexData for a tiled plane
  88395. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88396. * * pattern a limited pattern arrangement depending on the number
  88397. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88398. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88399. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88400. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88401. * * 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)
  88402. * * 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)
  88403. * @returns the VertexData of the tiled plane
  88404. */
  88405. static CreateTiledPlane(options: {
  88406. pattern?: number;
  88407. tileSize?: number;
  88408. tileWidth?: number;
  88409. tileHeight?: number;
  88410. size?: number;
  88411. width?: number;
  88412. height?: number;
  88413. alignHorizontal?: number;
  88414. alignVertical?: number;
  88415. sideOrientation?: number;
  88416. frontUVs?: Vector4;
  88417. backUVs?: Vector4;
  88418. }): VertexData;
  88419. /**
  88420. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88421. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88422. * * segments sets the number of horizontal strips optional, default 32
  88423. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88424. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88425. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88426. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88427. * * 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
  88428. * * 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
  88429. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88430. * * 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)
  88431. * * 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)
  88432. * @returns the VertexData of the ellipsoid
  88433. */
  88434. static CreateSphere(options: {
  88435. segments?: number;
  88436. diameter?: number;
  88437. diameterX?: number;
  88438. diameterY?: number;
  88439. diameterZ?: number;
  88440. arc?: number;
  88441. slice?: number;
  88442. sideOrientation?: number;
  88443. frontUVs?: Vector4;
  88444. backUVs?: Vector4;
  88445. }): VertexData;
  88446. /**
  88447. * Creates the VertexData for a cylinder, cone or prism
  88448. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88449. * * height sets the height (y direction) of the cylinder, optional, default 2
  88450. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88451. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88452. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88453. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88454. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88455. * * 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
  88456. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88457. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88458. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88459. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88461. * * 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)
  88462. * * 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)
  88463. * @returns the VertexData of the cylinder, cone or prism
  88464. */
  88465. static CreateCylinder(options: {
  88466. height?: number;
  88467. diameterTop?: number;
  88468. diameterBottom?: number;
  88469. diameter?: number;
  88470. tessellation?: number;
  88471. subdivisions?: number;
  88472. arc?: number;
  88473. faceColors?: Color4[];
  88474. faceUV?: Vector4[];
  88475. hasRings?: boolean;
  88476. enclose?: boolean;
  88477. sideOrientation?: number;
  88478. frontUVs?: Vector4;
  88479. backUVs?: Vector4;
  88480. }): VertexData;
  88481. /**
  88482. * Creates the VertexData for a torus
  88483. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88484. * * diameter the diameter of the torus, optional default 1
  88485. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88486. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88488. * * 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)
  88489. * * 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)
  88490. * @returns the VertexData of the torus
  88491. */
  88492. static CreateTorus(options: {
  88493. diameter?: number;
  88494. thickness?: number;
  88495. tessellation?: number;
  88496. sideOrientation?: number;
  88497. frontUVs?: Vector4;
  88498. backUVs?: Vector4;
  88499. }): VertexData;
  88500. /**
  88501. * Creates the VertexData of the LineSystem
  88502. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88503. * - lines an array of lines, each line being an array of successive Vector3
  88504. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88505. * @returns the VertexData of the LineSystem
  88506. */
  88507. static CreateLineSystem(options: {
  88508. lines: Vector3[][];
  88509. colors?: Nullable<Color4[][]>;
  88510. }): VertexData;
  88511. /**
  88512. * Create the VertexData for a DashedLines
  88513. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88514. * - points an array successive Vector3
  88515. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88516. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88517. * - dashNb the intended total number of dashes, optional, default 200
  88518. * @returns the VertexData for the DashedLines
  88519. */
  88520. static CreateDashedLines(options: {
  88521. points: Vector3[];
  88522. dashSize?: number;
  88523. gapSize?: number;
  88524. dashNb?: number;
  88525. }): VertexData;
  88526. /**
  88527. * Creates the VertexData for a Ground
  88528. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88529. * - width the width (x direction) of the ground, optional, default 1
  88530. * - height the height (z direction) of the ground, optional, default 1
  88531. * - subdivisions the number of subdivisions per side, optional, default 1
  88532. * @returns the VertexData of the Ground
  88533. */
  88534. static CreateGround(options: {
  88535. width?: number;
  88536. height?: number;
  88537. subdivisions?: number;
  88538. subdivisionsX?: number;
  88539. subdivisionsY?: number;
  88540. }): VertexData;
  88541. /**
  88542. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88543. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88544. * * xmin the ground minimum X coordinate, optional, default -1
  88545. * * zmin the ground minimum Z coordinate, optional, default -1
  88546. * * xmax the ground maximum X coordinate, optional, default 1
  88547. * * zmax the ground maximum Z coordinate, optional, default 1
  88548. * * 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}
  88549. * * 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}
  88550. * @returns the VertexData of the TiledGround
  88551. */
  88552. static CreateTiledGround(options: {
  88553. xmin: number;
  88554. zmin: number;
  88555. xmax: number;
  88556. zmax: number;
  88557. subdivisions?: {
  88558. w: number;
  88559. h: number;
  88560. };
  88561. precision?: {
  88562. w: number;
  88563. h: number;
  88564. };
  88565. }): VertexData;
  88566. /**
  88567. * Creates the VertexData of the Ground designed from a heightmap
  88568. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88569. * * width the width (x direction) of the ground
  88570. * * height the height (z direction) of the ground
  88571. * * subdivisions the number of subdivisions per side
  88572. * * minHeight the minimum altitude on the ground, optional, default 0
  88573. * * maxHeight the maximum altitude on the ground, optional default 1
  88574. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88575. * * buffer the array holding the image color data
  88576. * * bufferWidth the width of image
  88577. * * bufferHeight the height of image
  88578. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88579. * @returns the VertexData of the Ground designed from a heightmap
  88580. */
  88581. static CreateGroundFromHeightMap(options: {
  88582. width: number;
  88583. height: number;
  88584. subdivisions: number;
  88585. minHeight: number;
  88586. maxHeight: number;
  88587. colorFilter: Color3;
  88588. buffer: Uint8Array;
  88589. bufferWidth: number;
  88590. bufferHeight: number;
  88591. alphaFilter: number;
  88592. }): VertexData;
  88593. /**
  88594. * Creates the VertexData for a Plane
  88595. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88596. * * size sets the width and height of the plane to the value of size, optional default 1
  88597. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88598. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88599. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88600. * * 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)
  88601. * * 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)
  88602. * @returns the VertexData of the box
  88603. */
  88604. static CreatePlane(options: {
  88605. size?: number;
  88606. width?: number;
  88607. height?: number;
  88608. sideOrientation?: number;
  88609. frontUVs?: Vector4;
  88610. backUVs?: Vector4;
  88611. }): VertexData;
  88612. /**
  88613. * Creates the VertexData of the Disc or regular Polygon
  88614. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88615. * * radius the radius of the disc, optional default 0.5
  88616. * * tessellation the number of polygon sides, optional, default 64
  88617. * * 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
  88618. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88619. * * 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)
  88620. * * 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)
  88621. * @returns the VertexData of the box
  88622. */
  88623. static CreateDisc(options: {
  88624. radius?: number;
  88625. tessellation?: number;
  88626. arc?: number;
  88627. sideOrientation?: number;
  88628. frontUVs?: Vector4;
  88629. backUVs?: Vector4;
  88630. }): VertexData;
  88631. /**
  88632. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88633. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88634. * @param polygon a mesh built from polygonTriangulation.build()
  88635. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88636. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88637. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88638. * @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)
  88639. * @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)
  88640. * @returns the VertexData of the Polygon
  88641. */
  88642. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88643. /**
  88644. * Creates the VertexData of the IcoSphere
  88645. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88646. * * radius the radius of the IcoSphere, optional default 1
  88647. * * radiusX allows stretching in the x direction, optional, default radius
  88648. * * radiusY allows stretching in the y direction, optional, default radius
  88649. * * radiusZ allows stretching in the z direction, optional, default radius
  88650. * * flat when true creates a flat shaded mesh, optional, default true
  88651. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88652. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88653. * * 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)
  88654. * * 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)
  88655. * @returns the VertexData of the IcoSphere
  88656. */
  88657. static CreateIcoSphere(options: {
  88658. radius?: number;
  88659. radiusX?: number;
  88660. radiusY?: number;
  88661. radiusZ?: number;
  88662. flat?: boolean;
  88663. subdivisions?: number;
  88664. sideOrientation?: number;
  88665. frontUVs?: Vector4;
  88666. backUVs?: Vector4;
  88667. }): VertexData;
  88668. /**
  88669. * Creates the VertexData for a Polyhedron
  88670. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88671. * * type provided types are:
  88672. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88673. * * 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)
  88674. * * size the size of the IcoSphere, optional default 1
  88675. * * sizeX allows stretching in the x direction, optional, default size
  88676. * * sizeY allows stretching in the y direction, optional, default size
  88677. * * sizeZ allows stretching in the z direction, optional, default size
  88678. * * 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
  88679. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88680. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88681. * * flat when true creates a flat shaded mesh, optional, default true
  88682. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88683. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88684. * * 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)
  88685. * * 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)
  88686. * @returns the VertexData of the Polyhedron
  88687. */
  88688. static CreatePolyhedron(options: {
  88689. type?: number;
  88690. size?: number;
  88691. sizeX?: number;
  88692. sizeY?: number;
  88693. sizeZ?: number;
  88694. custom?: any;
  88695. faceUV?: Vector4[];
  88696. faceColors?: Color4[];
  88697. flat?: boolean;
  88698. sideOrientation?: number;
  88699. frontUVs?: Vector4;
  88700. backUVs?: Vector4;
  88701. }): VertexData;
  88702. /**
  88703. * Creates the VertexData for a TorusKnot
  88704. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88705. * * radius the radius of the torus knot, optional, default 2
  88706. * * tube the thickness of the tube, optional, default 0.5
  88707. * * radialSegments the number of sides on each tube segments, optional, default 32
  88708. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88709. * * p the number of windings around the z axis, optional, default 2
  88710. * * q the number of windings around the x axis, optional, default 3
  88711. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88712. * * 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)
  88713. * * 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)
  88714. * @returns the VertexData of the Torus Knot
  88715. */
  88716. static CreateTorusKnot(options: {
  88717. radius?: number;
  88718. tube?: number;
  88719. radialSegments?: number;
  88720. tubularSegments?: number;
  88721. p?: number;
  88722. q?: number;
  88723. sideOrientation?: number;
  88724. frontUVs?: Vector4;
  88725. backUVs?: Vector4;
  88726. }): VertexData;
  88727. /**
  88728. * Compute normals for given positions and indices
  88729. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88730. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88731. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88732. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88733. * * facetNormals : optional array of facet normals (vector3)
  88734. * * facetPositions : optional array of facet positions (vector3)
  88735. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88736. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88737. * * bInfo : optional bounding info, required for facetPartitioning computation
  88738. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88739. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88740. * * useRightHandedSystem: optional boolean to for right handed system computation
  88741. * * depthSort : optional boolean to enable the facet depth sort computation
  88742. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88743. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88744. */
  88745. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88746. facetNormals?: any;
  88747. facetPositions?: any;
  88748. facetPartitioning?: any;
  88749. ratio?: number;
  88750. bInfo?: any;
  88751. bbSize?: Vector3;
  88752. subDiv?: any;
  88753. useRightHandedSystem?: boolean;
  88754. depthSort?: boolean;
  88755. distanceTo?: Vector3;
  88756. depthSortedFacets?: any;
  88757. }): void;
  88758. /** @hidden */
  88759. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88760. /**
  88761. * Applies VertexData created from the imported parameters to the geometry
  88762. * @param parsedVertexData the parsed data from an imported file
  88763. * @param geometry the geometry to apply the VertexData to
  88764. */
  88765. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88766. }
  88767. }
  88768. declare module BABYLON {
  88769. /**
  88770. * Defines a target to use with MorphTargetManager
  88771. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88772. */
  88773. export class MorphTarget implements IAnimatable {
  88774. /** defines the name of the target */
  88775. name: string;
  88776. /**
  88777. * Gets or sets the list of animations
  88778. */
  88779. animations: Animation[];
  88780. private _scene;
  88781. private _positions;
  88782. private _normals;
  88783. private _tangents;
  88784. private _uvs;
  88785. private _influence;
  88786. /**
  88787. * Observable raised when the influence changes
  88788. */
  88789. onInfluenceChanged: Observable<boolean>;
  88790. /** @hidden */
  88791. _onDataLayoutChanged: Observable<void>;
  88792. /**
  88793. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88794. */
  88795. influence: number;
  88796. /**
  88797. * Gets or sets the id of the morph Target
  88798. */
  88799. id: string;
  88800. private _animationPropertiesOverride;
  88801. /**
  88802. * Gets or sets the animation properties override
  88803. */
  88804. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88805. /**
  88806. * Creates a new MorphTarget
  88807. * @param name defines the name of the target
  88808. * @param influence defines the influence to use
  88809. * @param scene defines the scene the morphtarget belongs to
  88810. */
  88811. constructor(
  88812. /** defines the name of the target */
  88813. name: string, influence?: number, scene?: Nullable<Scene>);
  88814. /**
  88815. * Gets a boolean defining if the target contains position data
  88816. */
  88817. readonly hasPositions: boolean;
  88818. /**
  88819. * Gets a boolean defining if the target contains normal data
  88820. */
  88821. readonly hasNormals: boolean;
  88822. /**
  88823. * Gets a boolean defining if the target contains tangent data
  88824. */
  88825. readonly hasTangents: boolean;
  88826. /**
  88827. * Gets a boolean defining if the target contains texture coordinates data
  88828. */
  88829. readonly hasUVs: boolean;
  88830. /**
  88831. * Affects position data to this target
  88832. * @param data defines the position data to use
  88833. */
  88834. setPositions(data: Nullable<FloatArray>): void;
  88835. /**
  88836. * Gets the position data stored in this target
  88837. * @returns a FloatArray containing the position data (or null if not present)
  88838. */
  88839. getPositions(): Nullable<FloatArray>;
  88840. /**
  88841. * Affects normal data to this target
  88842. * @param data defines the normal data to use
  88843. */
  88844. setNormals(data: Nullable<FloatArray>): void;
  88845. /**
  88846. * Gets the normal data stored in this target
  88847. * @returns a FloatArray containing the normal data (or null if not present)
  88848. */
  88849. getNormals(): Nullable<FloatArray>;
  88850. /**
  88851. * Affects tangent data to this target
  88852. * @param data defines the tangent data to use
  88853. */
  88854. setTangents(data: Nullable<FloatArray>): void;
  88855. /**
  88856. * Gets the tangent data stored in this target
  88857. * @returns a FloatArray containing the tangent data (or null if not present)
  88858. */
  88859. getTangents(): Nullable<FloatArray>;
  88860. /**
  88861. * Affects texture coordinates data to this target
  88862. * @param data defines the texture coordinates data to use
  88863. */
  88864. setUVs(data: Nullable<FloatArray>): void;
  88865. /**
  88866. * Gets the texture coordinates data stored in this target
  88867. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88868. */
  88869. getUVs(): Nullable<FloatArray>;
  88870. /**
  88871. * Serializes the current target into a Serialization object
  88872. * @returns the serialized object
  88873. */
  88874. serialize(): any;
  88875. /**
  88876. * Returns the string "MorphTarget"
  88877. * @returns "MorphTarget"
  88878. */
  88879. getClassName(): string;
  88880. /**
  88881. * Creates a new target from serialized data
  88882. * @param serializationObject defines the serialized data to use
  88883. * @returns a new MorphTarget
  88884. */
  88885. static Parse(serializationObject: any): MorphTarget;
  88886. /**
  88887. * Creates a MorphTarget from mesh data
  88888. * @param mesh defines the source mesh
  88889. * @param name defines the name to use for the new target
  88890. * @param influence defines the influence to attach to the target
  88891. * @returns a new MorphTarget
  88892. */
  88893. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88894. }
  88895. }
  88896. declare module BABYLON {
  88897. /**
  88898. * This class is used to deform meshes using morphing between different targets
  88899. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88900. */
  88901. export class MorphTargetManager {
  88902. private _targets;
  88903. private _targetInfluenceChangedObservers;
  88904. private _targetDataLayoutChangedObservers;
  88905. private _activeTargets;
  88906. private _scene;
  88907. private _influences;
  88908. private _supportsNormals;
  88909. private _supportsTangents;
  88910. private _supportsUVs;
  88911. private _vertexCount;
  88912. private _uniqueId;
  88913. private _tempInfluences;
  88914. /**
  88915. * Gets or sets a boolean indicating if normals must be morphed
  88916. */
  88917. enableNormalMorphing: boolean;
  88918. /**
  88919. * Gets or sets a boolean indicating if tangents must be morphed
  88920. */
  88921. enableTangentMorphing: boolean;
  88922. /**
  88923. * Gets or sets a boolean indicating if UV must be morphed
  88924. */
  88925. enableUVMorphing: boolean;
  88926. /**
  88927. * Creates a new MorphTargetManager
  88928. * @param scene defines the current scene
  88929. */
  88930. constructor(scene?: Nullable<Scene>);
  88931. /**
  88932. * Gets the unique ID of this manager
  88933. */
  88934. readonly uniqueId: number;
  88935. /**
  88936. * Gets the number of vertices handled by this manager
  88937. */
  88938. readonly vertexCount: number;
  88939. /**
  88940. * Gets a boolean indicating if this manager supports morphing of normals
  88941. */
  88942. readonly supportsNormals: boolean;
  88943. /**
  88944. * Gets a boolean indicating if this manager supports morphing of tangents
  88945. */
  88946. readonly supportsTangents: boolean;
  88947. /**
  88948. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88949. */
  88950. readonly supportsUVs: boolean;
  88951. /**
  88952. * Gets the number of targets stored in this manager
  88953. */
  88954. readonly numTargets: number;
  88955. /**
  88956. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88957. */
  88958. readonly numInfluencers: number;
  88959. /**
  88960. * Gets the list of influences (one per target)
  88961. */
  88962. readonly influences: Float32Array;
  88963. /**
  88964. * Gets the active target at specified index. An active target is a target with an influence > 0
  88965. * @param index defines the index to check
  88966. * @returns the requested target
  88967. */
  88968. getActiveTarget(index: number): MorphTarget;
  88969. /**
  88970. * Gets the target at specified index
  88971. * @param index defines the index to check
  88972. * @returns the requested target
  88973. */
  88974. getTarget(index: number): MorphTarget;
  88975. /**
  88976. * Add a new target to this manager
  88977. * @param target defines the target to add
  88978. */
  88979. addTarget(target: MorphTarget): void;
  88980. /**
  88981. * Removes a target from the manager
  88982. * @param target defines the target to remove
  88983. */
  88984. removeTarget(target: MorphTarget): void;
  88985. /**
  88986. * Serializes the current manager into a Serialization object
  88987. * @returns the serialized object
  88988. */
  88989. serialize(): any;
  88990. private _syncActiveTargets;
  88991. /**
  88992. * Syncrhonize the targets with all the meshes using this morph target manager
  88993. */
  88994. synchronize(): void;
  88995. /**
  88996. * Creates a new MorphTargetManager from serialized data
  88997. * @param serializationObject defines the serialized data
  88998. * @param scene defines the hosting scene
  88999. * @returns the new MorphTargetManager
  89000. */
  89001. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89002. }
  89003. }
  89004. declare module BABYLON {
  89005. /**
  89006. * Class used to represent a specific level of detail of a mesh
  89007. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89008. */
  89009. export class MeshLODLevel {
  89010. /** Defines the distance where this level should start being displayed */
  89011. distance: number;
  89012. /** Defines the mesh to use to render this level */
  89013. mesh: Nullable<Mesh>;
  89014. /**
  89015. * Creates a new LOD level
  89016. * @param distance defines the distance where this level should star being displayed
  89017. * @param mesh defines the mesh to use to render this level
  89018. */
  89019. constructor(
  89020. /** Defines the distance where this level should start being displayed */
  89021. distance: number,
  89022. /** Defines the mesh to use to render this level */
  89023. mesh: Nullable<Mesh>);
  89024. }
  89025. }
  89026. declare module BABYLON {
  89027. /**
  89028. * Mesh representing the gorund
  89029. */
  89030. export class GroundMesh extends Mesh {
  89031. /** If octree should be generated */
  89032. generateOctree: boolean;
  89033. private _heightQuads;
  89034. /** @hidden */
  89035. _subdivisionsX: number;
  89036. /** @hidden */
  89037. _subdivisionsY: number;
  89038. /** @hidden */
  89039. _width: number;
  89040. /** @hidden */
  89041. _height: number;
  89042. /** @hidden */
  89043. _minX: number;
  89044. /** @hidden */
  89045. _maxX: number;
  89046. /** @hidden */
  89047. _minZ: number;
  89048. /** @hidden */
  89049. _maxZ: number;
  89050. constructor(name: string, scene: Scene);
  89051. /**
  89052. * "GroundMesh"
  89053. * @returns "GroundMesh"
  89054. */
  89055. getClassName(): string;
  89056. /**
  89057. * The minimum of x and y subdivisions
  89058. */
  89059. readonly subdivisions: number;
  89060. /**
  89061. * X subdivisions
  89062. */
  89063. readonly subdivisionsX: number;
  89064. /**
  89065. * Y subdivisions
  89066. */
  89067. readonly subdivisionsY: number;
  89068. /**
  89069. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89070. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89071. * @param chunksCount the number of subdivisions for x and y
  89072. * @param octreeBlocksSize (Default: 32)
  89073. */
  89074. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89075. /**
  89076. * Returns a height (y) value in the Worl system :
  89077. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89078. * @param x x coordinate
  89079. * @param z z coordinate
  89080. * @returns the ground y position if (x, z) are outside the ground surface.
  89081. */
  89082. getHeightAtCoordinates(x: number, z: number): number;
  89083. /**
  89084. * Returns a normalized vector (Vector3) orthogonal to the ground
  89085. * at the ground coordinates (x, z) expressed in the World system.
  89086. * @param x x coordinate
  89087. * @param z z coordinate
  89088. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89089. */
  89090. getNormalAtCoordinates(x: number, z: number): Vector3;
  89091. /**
  89092. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89093. * at the ground coordinates (x, z) expressed in the World system.
  89094. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89095. * @param x x coordinate
  89096. * @param z z coordinate
  89097. * @param ref vector to store the result
  89098. * @returns the GroundMesh.
  89099. */
  89100. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89101. /**
  89102. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89103. * if the ground has been updated.
  89104. * This can be used in the render loop.
  89105. * @returns the GroundMesh.
  89106. */
  89107. updateCoordinateHeights(): GroundMesh;
  89108. private _getFacetAt;
  89109. private _initHeightQuads;
  89110. private _computeHeightQuads;
  89111. /**
  89112. * Serializes this ground mesh
  89113. * @param serializationObject object to write serialization to
  89114. */
  89115. serialize(serializationObject: any): void;
  89116. /**
  89117. * Parses a serialized ground mesh
  89118. * @param parsedMesh the serialized mesh
  89119. * @param scene the scene to create the ground mesh in
  89120. * @returns the created ground mesh
  89121. */
  89122. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89123. }
  89124. }
  89125. declare module BABYLON {
  89126. /**
  89127. * Interface for Physics-Joint data
  89128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89129. */
  89130. export interface PhysicsJointData {
  89131. /**
  89132. * The main pivot of the joint
  89133. */
  89134. mainPivot?: Vector3;
  89135. /**
  89136. * The connected pivot of the joint
  89137. */
  89138. connectedPivot?: Vector3;
  89139. /**
  89140. * The main axis of the joint
  89141. */
  89142. mainAxis?: Vector3;
  89143. /**
  89144. * The connected axis of the joint
  89145. */
  89146. connectedAxis?: Vector3;
  89147. /**
  89148. * The collision of the joint
  89149. */
  89150. collision?: boolean;
  89151. /**
  89152. * Native Oimo/Cannon/Energy data
  89153. */
  89154. nativeParams?: any;
  89155. }
  89156. /**
  89157. * This is a holder class for the physics joint created by the physics plugin
  89158. * It holds a set of functions to control the underlying joint
  89159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89160. */
  89161. export class PhysicsJoint {
  89162. /**
  89163. * The type of the physics joint
  89164. */
  89165. type: number;
  89166. /**
  89167. * The data for the physics joint
  89168. */
  89169. jointData: PhysicsJointData;
  89170. private _physicsJoint;
  89171. protected _physicsPlugin: IPhysicsEnginePlugin;
  89172. /**
  89173. * Initializes the physics joint
  89174. * @param type The type of the physics joint
  89175. * @param jointData The data for the physics joint
  89176. */
  89177. constructor(
  89178. /**
  89179. * The type of the physics joint
  89180. */
  89181. type: number,
  89182. /**
  89183. * The data for the physics joint
  89184. */
  89185. jointData: PhysicsJointData);
  89186. /**
  89187. * Gets the physics joint
  89188. */
  89189. /**
  89190. * Sets the physics joint
  89191. */
  89192. physicsJoint: any;
  89193. /**
  89194. * Sets the physics plugin
  89195. */
  89196. physicsPlugin: IPhysicsEnginePlugin;
  89197. /**
  89198. * Execute a function that is physics-plugin specific.
  89199. * @param {Function} func the function that will be executed.
  89200. * It accepts two parameters: the physics world and the physics joint
  89201. */
  89202. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89203. /**
  89204. * Distance-Joint type
  89205. */
  89206. static DistanceJoint: number;
  89207. /**
  89208. * Hinge-Joint type
  89209. */
  89210. static HingeJoint: number;
  89211. /**
  89212. * Ball-and-Socket joint type
  89213. */
  89214. static BallAndSocketJoint: number;
  89215. /**
  89216. * Wheel-Joint type
  89217. */
  89218. static WheelJoint: number;
  89219. /**
  89220. * Slider-Joint type
  89221. */
  89222. static SliderJoint: number;
  89223. /**
  89224. * Prismatic-Joint type
  89225. */
  89226. static PrismaticJoint: number;
  89227. /**
  89228. * Universal-Joint type
  89229. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89230. */
  89231. static UniversalJoint: number;
  89232. /**
  89233. * Hinge-Joint 2 type
  89234. */
  89235. static Hinge2Joint: number;
  89236. /**
  89237. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89238. */
  89239. static PointToPointJoint: number;
  89240. /**
  89241. * Spring-Joint type
  89242. */
  89243. static SpringJoint: number;
  89244. /**
  89245. * Lock-Joint type
  89246. */
  89247. static LockJoint: number;
  89248. }
  89249. /**
  89250. * A class representing a physics distance joint
  89251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89252. */
  89253. export class DistanceJoint extends PhysicsJoint {
  89254. /**
  89255. *
  89256. * @param jointData The data for the Distance-Joint
  89257. */
  89258. constructor(jointData: DistanceJointData);
  89259. /**
  89260. * Update the predefined distance.
  89261. * @param maxDistance The maximum preferred distance
  89262. * @param minDistance The minimum preferred distance
  89263. */
  89264. updateDistance(maxDistance: number, minDistance?: number): void;
  89265. }
  89266. /**
  89267. * Represents a Motor-Enabled Joint
  89268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89269. */
  89270. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89271. /**
  89272. * Initializes the Motor-Enabled Joint
  89273. * @param type The type of the joint
  89274. * @param jointData The physica joint data for the joint
  89275. */
  89276. constructor(type: number, jointData: PhysicsJointData);
  89277. /**
  89278. * Set the motor values.
  89279. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89280. * @param force the force to apply
  89281. * @param maxForce max force for this motor.
  89282. */
  89283. setMotor(force?: number, maxForce?: number): void;
  89284. /**
  89285. * Set the motor's limits.
  89286. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89287. * @param upperLimit The upper limit of the motor
  89288. * @param lowerLimit The lower limit of the motor
  89289. */
  89290. setLimit(upperLimit: number, lowerLimit?: number): void;
  89291. }
  89292. /**
  89293. * This class represents a single physics Hinge-Joint
  89294. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89295. */
  89296. export class HingeJoint extends MotorEnabledJoint {
  89297. /**
  89298. * Initializes the Hinge-Joint
  89299. * @param jointData The joint data for the Hinge-Joint
  89300. */
  89301. constructor(jointData: PhysicsJointData);
  89302. /**
  89303. * Set the motor values.
  89304. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89305. * @param {number} force the force to apply
  89306. * @param {number} maxForce max force for this motor.
  89307. */
  89308. setMotor(force?: number, maxForce?: number): void;
  89309. /**
  89310. * Set the motor's limits.
  89311. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89312. * @param upperLimit The upper limit of the motor
  89313. * @param lowerLimit The lower limit of the motor
  89314. */
  89315. setLimit(upperLimit: number, lowerLimit?: number): void;
  89316. }
  89317. /**
  89318. * This class represents a dual hinge physics joint (same as wheel joint)
  89319. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89320. */
  89321. export class Hinge2Joint extends MotorEnabledJoint {
  89322. /**
  89323. * Initializes the Hinge2-Joint
  89324. * @param jointData The joint data for the Hinge2-Joint
  89325. */
  89326. constructor(jointData: PhysicsJointData);
  89327. /**
  89328. * Set the motor values.
  89329. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89330. * @param {number} targetSpeed the speed the motor is to reach
  89331. * @param {number} maxForce max force for this motor.
  89332. * @param {motorIndex} the motor's index, 0 or 1.
  89333. */
  89334. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89335. /**
  89336. * Set the motor limits.
  89337. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89338. * @param {number} upperLimit the upper limit
  89339. * @param {number} lowerLimit lower limit
  89340. * @param {motorIndex} the motor's index, 0 or 1.
  89341. */
  89342. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89343. }
  89344. /**
  89345. * Interface for a motor enabled joint
  89346. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89347. */
  89348. export interface IMotorEnabledJoint {
  89349. /**
  89350. * Physics joint
  89351. */
  89352. physicsJoint: any;
  89353. /**
  89354. * Sets the motor of the motor-enabled joint
  89355. * @param force The force of the motor
  89356. * @param maxForce The maximum force of the motor
  89357. * @param motorIndex The index of the motor
  89358. */
  89359. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89360. /**
  89361. * Sets the limit of the motor
  89362. * @param upperLimit The upper limit of the motor
  89363. * @param lowerLimit The lower limit of the motor
  89364. * @param motorIndex The index of the motor
  89365. */
  89366. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89367. }
  89368. /**
  89369. * Joint data for a Distance-Joint
  89370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89371. */
  89372. export interface DistanceJointData extends PhysicsJointData {
  89373. /**
  89374. * Max distance the 2 joint objects can be apart
  89375. */
  89376. maxDistance: number;
  89377. }
  89378. /**
  89379. * Joint data from a spring joint
  89380. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89381. */
  89382. export interface SpringJointData extends PhysicsJointData {
  89383. /**
  89384. * Length of the spring
  89385. */
  89386. length: number;
  89387. /**
  89388. * Stiffness of the spring
  89389. */
  89390. stiffness: number;
  89391. /**
  89392. * Damping of the spring
  89393. */
  89394. damping: number;
  89395. /** this callback will be called when applying the force to the impostors. */
  89396. forceApplicationCallback: () => void;
  89397. }
  89398. }
  89399. declare module BABYLON {
  89400. /**
  89401. * Holds the data for the raycast result
  89402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89403. */
  89404. export class PhysicsRaycastResult {
  89405. private _hasHit;
  89406. private _hitDistance;
  89407. private _hitNormalWorld;
  89408. private _hitPointWorld;
  89409. private _rayFromWorld;
  89410. private _rayToWorld;
  89411. /**
  89412. * Gets if there was a hit
  89413. */
  89414. readonly hasHit: boolean;
  89415. /**
  89416. * Gets the distance from the hit
  89417. */
  89418. readonly hitDistance: number;
  89419. /**
  89420. * Gets the hit normal/direction in the world
  89421. */
  89422. readonly hitNormalWorld: Vector3;
  89423. /**
  89424. * Gets the hit point in the world
  89425. */
  89426. readonly hitPointWorld: Vector3;
  89427. /**
  89428. * Gets the ray "start point" of the ray in the world
  89429. */
  89430. readonly rayFromWorld: Vector3;
  89431. /**
  89432. * Gets the ray "end point" of the ray in the world
  89433. */
  89434. readonly rayToWorld: Vector3;
  89435. /**
  89436. * Sets the hit data (normal & point in world space)
  89437. * @param hitNormalWorld defines the normal in world space
  89438. * @param hitPointWorld defines the point in world space
  89439. */
  89440. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89441. /**
  89442. * Sets the distance from the start point to the hit point
  89443. * @param distance
  89444. */
  89445. setHitDistance(distance: number): void;
  89446. /**
  89447. * Calculates the distance manually
  89448. */
  89449. calculateHitDistance(): void;
  89450. /**
  89451. * Resets all the values to default
  89452. * @param from The from point on world space
  89453. * @param to The to point on world space
  89454. */
  89455. reset(from?: Vector3, to?: Vector3): void;
  89456. }
  89457. /**
  89458. * Interface for the size containing width and height
  89459. */
  89460. interface IXYZ {
  89461. /**
  89462. * X
  89463. */
  89464. x: number;
  89465. /**
  89466. * Y
  89467. */
  89468. y: number;
  89469. /**
  89470. * Z
  89471. */
  89472. z: number;
  89473. }
  89474. }
  89475. declare module BABYLON {
  89476. /**
  89477. * Interface used to describe a physics joint
  89478. */
  89479. export interface PhysicsImpostorJoint {
  89480. /** Defines the main impostor to which the joint is linked */
  89481. mainImpostor: PhysicsImpostor;
  89482. /** Defines the impostor that is connected to the main impostor using this joint */
  89483. connectedImpostor: PhysicsImpostor;
  89484. /** Defines the joint itself */
  89485. joint: PhysicsJoint;
  89486. }
  89487. /** @hidden */
  89488. export interface IPhysicsEnginePlugin {
  89489. world: any;
  89490. name: string;
  89491. setGravity(gravity: Vector3): void;
  89492. setTimeStep(timeStep: number): void;
  89493. getTimeStep(): number;
  89494. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89495. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89496. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89497. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89498. removePhysicsBody(impostor: PhysicsImpostor): void;
  89499. generateJoint(joint: PhysicsImpostorJoint): void;
  89500. removeJoint(joint: PhysicsImpostorJoint): void;
  89501. isSupported(): boolean;
  89502. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89503. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89504. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89505. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89506. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89507. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89508. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89509. getBodyMass(impostor: PhysicsImpostor): number;
  89510. getBodyFriction(impostor: PhysicsImpostor): number;
  89511. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89512. getBodyRestitution(impostor: PhysicsImpostor): number;
  89513. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89514. getBodyPressure?(impostor: PhysicsImpostor): number;
  89515. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89516. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89517. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89518. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89519. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89520. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89521. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89522. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89523. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89524. sleepBody(impostor: PhysicsImpostor): void;
  89525. wakeUpBody(impostor: PhysicsImpostor): void;
  89526. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89527. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89528. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89529. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89530. getRadius(impostor: PhysicsImpostor): number;
  89531. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89532. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89533. dispose(): void;
  89534. }
  89535. /**
  89536. * Interface used to define a physics engine
  89537. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89538. */
  89539. export interface IPhysicsEngine {
  89540. /**
  89541. * Gets the gravity vector used by the simulation
  89542. */
  89543. gravity: Vector3;
  89544. /**
  89545. * Sets the gravity vector used by the simulation
  89546. * @param gravity defines the gravity vector to use
  89547. */
  89548. setGravity(gravity: Vector3): void;
  89549. /**
  89550. * Set the time step of the physics engine.
  89551. * Default is 1/60.
  89552. * To slow it down, enter 1/600 for example.
  89553. * To speed it up, 1/30
  89554. * @param newTimeStep the new timestep to apply to this world.
  89555. */
  89556. setTimeStep(newTimeStep: number): void;
  89557. /**
  89558. * Get the time step of the physics engine.
  89559. * @returns the current time step
  89560. */
  89561. getTimeStep(): number;
  89562. /**
  89563. * Release all resources
  89564. */
  89565. dispose(): void;
  89566. /**
  89567. * Gets the name of the current physics plugin
  89568. * @returns the name of the plugin
  89569. */
  89570. getPhysicsPluginName(): string;
  89571. /**
  89572. * Adding a new impostor for the impostor tracking.
  89573. * This will be done by the impostor itself.
  89574. * @param impostor the impostor to add
  89575. */
  89576. addImpostor(impostor: PhysicsImpostor): void;
  89577. /**
  89578. * Remove an impostor from the engine.
  89579. * This impostor and its mesh will not longer be updated by the physics engine.
  89580. * @param impostor the impostor to remove
  89581. */
  89582. removeImpostor(impostor: PhysicsImpostor): void;
  89583. /**
  89584. * Add a joint to the physics engine
  89585. * @param mainImpostor defines the main impostor to which the joint is added.
  89586. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89587. * @param joint defines the joint that will connect both impostors.
  89588. */
  89589. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89590. /**
  89591. * Removes a joint from the simulation
  89592. * @param mainImpostor defines the impostor used with the joint
  89593. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89594. * @param joint defines the joint to remove
  89595. */
  89596. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89597. /**
  89598. * Gets the current plugin used to run the simulation
  89599. * @returns current plugin
  89600. */
  89601. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89602. /**
  89603. * Gets the list of physic impostors
  89604. * @returns an array of PhysicsImpostor
  89605. */
  89606. getImpostors(): Array<PhysicsImpostor>;
  89607. /**
  89608. * Gets the impostor for a physics enabled object
  89609. * @param object defines the object impersonated by the impostor
  89610. * @returns the PhysicsImpostor or null if not found
  89611. */
  89612. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89613. /**
  89614. * Gets the impostor for a physics body object
  89615. * @param body defines physics body used by the impostor
  89616. * @returns the PhysicsImpostor or null if not found
  89617. */
  89618. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89619. /**
  89620. * Does a raycast in the physics world
  89621. * @param from when should the ray start?
  89622. * @param to when should the ray end?
  89623. * @returns PhysicsRaycastResult
  89624. */
  89625. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89626. /**
  89627. * Called by the scene. No need to call it.
  89628. * @param delta defines the timespam between frames
  89629. */
  89630. _step(delta: number): void;
  89631. }
  89632. }
  89633. declare module BABYLON {
  89634. /**
  89635. * The interface for the physics imposter parameters
  89636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89637. */
  89638. export interface PhysicsImpostorParameters {
  89639. /**
  89640. * The mass of the physics imposter
  89641. */
  89642. mass: number;
  89643. /**
  89644. * The friction of the physics imposter
  89645. */
  89646. friction?: number;
  89647. /**
  89648. * The coefficient of restitution of the physics imposter
  89649. */
  89650. restitution?: number;
  89651. /**
  89652. * The native options of the physics imposter
  89653. */
  89654. nativeOptions?: any;
  89655. /**
  89656. * Specifies if the parent should be ignored
  89657. */
  89658. ignoreParent?: boolean;
  89659. /**
  89660. * Specifies if bi-directional transformations should be disabled
  89661. */
  89662. disableBidirectionalTransformation?: boolean;
  89663. /**
  89664. * The pressure inside the physics imposter, soft object only
  89665. */
  89666. pressure?: number;
  89667. /**
  89668. * The stiffness the physics imposter, soft object only
  89669. */
  89670. stiffness?: number;
  89671. /**
  89672. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89673. */
  89674. velocityIterations?: number;
  89675. /**
  89676. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89677. */
  89678. positionIterations?: number;
  89679. /**
  89680. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89681. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89682. * Add to fix multiple points
  89683. */
  89684. fixedPoints?: number;
  89685. /**
  89686. * The collision margin around a soft object
  89687. */
  89688. margin?: number;
  89689. /**
  89690. * The collision margin around a soft object
  89691. */
  89692. damping?: number;
  89693. /**
  89694. * The path for a rope based on an extrusion
  89695. */
  89696. path?: any;
  89697. /**
  89698. * The shape of an extrusion used for a rope based on an extrusion
  89699. */
  89700. shape?: any;
  89701. }
  89702. /**
  89703. * Interface for a physics-enabled object
  89704. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89705. */
  89706. export interface IPhysicsEnabledObject {
  89707. /**
  89708. * The position of the physics-enabled object
  89709. */
  89710. position: Vector3;
  89711. /**
  89712. * The rotation of the physics-enabled object
  89713. */
  89714. rotationQuaternion: Nullable<Quaternion>;
  89715. /**
  89716. * The scale of the physics-enabled object
  89717. */
  89718. scaling: Vector3;
  89719. /**
  89720. * The rotation of the physics-enabled object
  89721. */
  89722. rotation?: Vector3;
  89723. /**
  89724. * The parent of the physics-enabled object
  89725. */
  89726. parent?: any;
  89727. /**
  89728. * The bounding info of the physics-enabled object
  89729. * @returns The bounding info of the physics-enabled object
  89730. */
  89731. getBoundingInfo(): BoundingInfo;
  89732. /**
  89733. * Computes the world matrix
  89734. * @param force Specifies if the world matrix should be computed by force
  89735. * @returns A world matrix
  89736. */
  89737. computeWorldMatrix(force: boolean): Matrix;
  89738. /**
  89739. * Gets the world matrix
  89740. * @returns A world matrix
  89741. */
  89742. getWorldMatrix?(): Matrix;
  89743. /**
  89744. * Gets the child meshes
  89745. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89746. * @returns An array of abstract meshes
  89747. */
  89748. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89749. /**
  89750. * Gets the vertex data
  89751. * @param kind The type of vertex data
  89752. * @returns A nullable array of numbers, or a float32 array
  89753. */
  89754. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89755. /**
  89756. * Gets the indices from the mesh
  89757. * @returns A nullable array of index arrays
  89758. */
  89759. getIndices?(): Nullable<IndicesArray>;
  89760. /**
  89761. * Gets the scene from the mesh
  89762. * @returns the indices array or null
  89763. */
  89764. getScene?(): Scene;
  89765. /**
  89766. * Gets the absolute position from the mesh
  89767. * @returns the absolute position
  89768. */
  89769. getAbsolutePosition(): Vector3;
  89770. /**
  89771. * Gets the absolute pivot point from the mesh
  89772. * @returns the absolute pivot point
  89773. */
  89774. getAbsolutePivotPoint(): Vector3;
  89775. /**
  89776. * Rotates the mesh
  89777. * @param axis The axis of rotation
  89778. * @param amount The amount of rotation
  89779. * @param space The space of the rotation
  89780. * @returns The rotation transform node
  89781. */
  89782. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89783. /**
  89784. * Translates the mesh
  89785. * @param axis The axis of translation
  89786. * @param distance The distance of translation
  89787. * @param space The space of the translation
  89788. * @returns The transform node
  89789. */
  89790. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89791. /**
  89792. * Sets the absolute position of the mesh
  89793. * @param absolutePosition The absolute position of the mesh
  89794. * @returns The transform node
  89795. */
  89796. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89797. /**
  89798. * Gets the class name of the mesh
  89799. * @returns The class name
  89800. */
  89801. getClassName(): string;
  89802. }
  89803. /**
  89804. * Represents a physics imposter
  89805. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89806. */
  89807. export class PhysicsImpostor {
  89808. /**
  89809. * The physics-enabled object used as the physics imposter
  89810. */
  89811. object: IPhysicsEnabledObject;
  89812. /**
  89813. * The type of the physics imposter
  89814. */
  89815. type: number;
  89816. private _options;
  89817. private _scene?;
  89818. /**
  89819. * The default object size of the imposter
  89820. */
  89821. static DEFAULT_OBJECT_SIZE: Vector3;
  89822. /**
  89823. * The identity quaternion of the imposter
  89824. */
  89825. static IDENTITY_QUATERNION: Quaternion;
  89826. /** @hidden */
  89827. _pluginData: any;
  89828. private _physicsEngine;
  89829. private _physicsBody;
  89830. private _bodyUpdateRequired;
  89831. private _onBeforePhysicsStepCallbacks;
  89832. private _onAfterPhysicsStepCallbacks;
  89833. /** @hidden */
  89834. _onPhysicsCollideCallbacks: Array<{
  89835. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89836. otherImpostors: Array<PhysicsImpostor>;
  89837. }>;
  89838. private _deltaPosition;
  89839. private _deltaRotation;
  89840. private _deltaRotationConjugated;
  89841. /** @hidden */
  89842. _isFromLine: boolean;
  89843. private _parent;
  89844. private _isDisposed;
  89845. private static _tmpVecs;
  89846. private static _tmpQuat;
  89847. /**
  89848. * Specifies if the physics imposter is disposed
  89849. */
  89850. readonly isDisposed: boolean;
  89851. /**
  89852. * Gets the mass of the physics imposter
  89853. */
  89854. mass: number;
  89855. /**
  89856. * Gets the coefficient of friction
  89857. */
  89858. /**
  89859. * Sets the coefficient of friction
  89860. */
  89861. friction: number;
  89862. /**
  89863. * Gets the coefficient of restitution
  89864. */
  89865. /**
  89866. * Sets the coefficient of restitution
  89867. */
  89868. restitution: number;
  89869. /**
  89870. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89871. */
  89872. /**
  89873. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89874. */
  89875. pressure: number;
  89876. /**
  89877. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89878. */
  89879. /**
  89880. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89881. */
  89882. stiffness: number;
  89883. /**
  89884. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89885. */
  89886. /**
  89887. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89888. */
  89889. velocityIterations: number;
  89890. /**
  89891. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89892. */
  89893. /**
  89894. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89895. */
  89896. positionIterations: number;
  89897. /**
  89898. * The unique id of the physics imposter
  89899. * set by the physics engine when adding this impostor to the array
  89900. */
  89901. uniqueId: number;
  89902. /**
  89903. * @hidden
  89904. */
  89905. soft: boolean;
  89906. /**
  89907. * @hidden
  89908. */
  89909. segments: number;
  89910. private _joints;
  89911. /**
  89912. * Initializes the physics imposter
  89913. * @param object The physics-enabled object used as the physics imposter
  89914. * @param type The type of the physics imposter
  89915. * @param _options The options for the physics imposter
  89916. * @param _scene The Babylon scene
  89917. */
  89918. constructor(
  89919. /**
  89920. * The physics-enabled object used as the physics imposter
  89921. */
  89922. object: IPhysicsEnabledObject,
  89923. /**
  89924. * The type of the physics imposter
  89925. */
  89926. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89927. /**
  89928. * This function will completly initialize this impostor.
  89929. * It will create a new body - but only if this mesh has no parent.
  89930. * If it has, this impostor will not be used other than to define the impostor
  89931. * of the child mesh.
  89932. * @hidden
  89933. */
  89934. _init(): void;
  89935. private _getPhysicsParent;
  89936. /**
  89937. * Should a new body be generated.
  89938. * @returns boolean specifying if body initialization is required
  89939. */
  89940. isBodyInitRequired(): boolean;
  89941. /**
  89942. * Sets the updated scaling
  89943. * @param updated Specifies if the scaling is updated
  89944. */
  89945. setScalingUpdated(): void;
  89946. /**
  89947. * Force a regeneration of this or the parent's impostor's body.
  89948. * Use under cautious - This will remove all joints already implemented.
  89949. */
  89950. forceUpdate(): void;
  89951. /**
  89952. * Gets the body that holds this impostor. Either its own, or its parent.
  89953. */
  89954. /**
  89955. * Set the physics body. Used mainly by the physics engine/plugin
  89956. */
  89957. physicsBody: any;
  89958. /**
  89959. * Get the parent of the physics imposter
  89960. * @returns Physics imposter or null
  89961. */
  89962. /**
  89963. * Sets the parent of the physics imposter
  89964. */
  89965. parent: Nullable<PhysicsImpostor>;
  89966. /**
  89967. * Resets the update flags
  89968. */
  89969. resetUpdateFlags(): void;
  89970. /**
  89971. * Gets the object extend size
  89972. * @returns the object extend size
  89973. */
  89974. getObjectExtendSize(): Vector3;
  89975. /**
  89976. * Gets the object center
  89977. * @returns The object center
  89978. */
  89979. getObjectCenter(): Vector3;
  89980. /**
  89981. * Get a specific parametes from the options parameter
  89982. * @param paramName The object parameter name
  89983. * @returns The object parameter
  89984. */
  89985. getParam(paramName: string): any;
  89986. /**
  89987. * Sets a specific parameter in the options given to the physics plugin
  89988. * @param paramName The parameter name
  89989. * @param value The value of the parameter
  89990. */
  89991. setParam(paramName: string, value: number): void;
  89992. /**
  89993. * Specifically change the body's mass option. Won't recreate the physics body object
  89994. * @param mass The mass of the physics imposter
  89995. */
  89996. setMass(mass: number): void;
  89997. /**
  89998. * Gets the linear velocity
  89999. * @returns linear velocity or null
  90000. */
  90001. getLinearVelocity(): Nullable<Vector3>;
  90002. /**
  90003. * Sets the linear velocity
  90004. * @param velocity linear velocity or null
  90005. */
  90006. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90007. /**
  90008. * Gets the angular velocity
  90009. * @returns angular velocity or null
  90010. */
  90011. getAngularVelocity(): Nullable<Vector3>;
  90012. /**
  90013. * Sets the angular velocity
  90014. * @param velocity The velocity or null
  90015. */
  90016. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90017. /**
  90018. * Execute a function with the physics plugin native code
  90019. * Provide a function the will have two variables - the world object and the physics body object
  90020. * @param func The function to execute with the physics plugin native code
  90021. */
  90022. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90023. /**
  90024. * Register a function that will be executed before the physics world is stepping forward
  90025. * @param func The function to execute before the physics world is stepped forward
  90026. */
  90027. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90028. /**
  90029. * Unregister a function that will be executed before the physics world is stepping forward
  90030. * @param func The function to execute before the physics world is stepped forward
  90031. */
  90032. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90033. /**
  90034. * Register a function that will be executed after the physics step
  90035. * @param func The function to execute after physics step
  90036. */
  90037. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90038. /**
  90039. * Unregisters a function that will be executed after the physics step
  90040. * @param func The function to execute after physics step
  90041. */
  90042. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90043. /**
  90044. * register a function that will be executed when this impostor collides against a different body
  90045. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90046. * @param func Callback that is executed on collision
  90047. */
  90048. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90049. /**
  90050. * Unregisters the physics imposter on contact
  90051. * @param collideAgainst The physics object to collide against
  90052. * @param func Callback to execute on collision
  90053. */
  90054. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90055. private _tmpQuat;
  90056. private _tmpQuat2;
  90057. /**
  90058. * Get the parent rotation
  90059. * @returns The parent rotation
  90060. */
  90061. getParentsRotation(): Quaternion;
  90062. /**
  90063. * this function is executed by the physics engine.
  90064. */
  90065. beforeStep: () => void;
  90066. /**
  90067. * this function is executed by the physics engine
  90068. */
  90069. afterStep: () => void;
  90070. /**
  90071. * Legacy collision detection event support
  90072. */
  90073. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90074. /**
  90075. * event and body object due to cannon's event-based architecture.
  90076. */
  90077. onCollide: (e: {
  90078. body: any;
  90079. }) => void;
  90080. /**
  90081. * Apply a force
  90082. * @param force The force to apply
  90083. * @param contactPoint The contact point for the force
  90084. * @returns The physics imposter
  90085. */
  90086. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90087. /**
  90088. * Apply an impulse
  90089. * @param force The impulse force
  90090. * @param contactPoint The contact point for the impulse force
  90091. * @returns The physics imposter
  90092. */
  90093. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90094. /**
  90095. * A help function to create a joint
  90096. * @param otherImpostor A physics imposter used to create a joint
  90097. * @param jointType The type of joint
  90098. * @param jointData The data for the joint
  90099. * @returns The physics imposter
  90100. */
  90101. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90102. /**
  90103. * Add a joint to this impostor with a different impostor
  90104. * @param otherImpostor A physics imposter used to add a joint
  90105. * @param joint The joint to add
  90106. * @returns The physics imposter
  90107. */
  90108. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90109. /**
  90110. * Add an anchor to a cloth impostor
  90111. * @param otherImpostor rigid impostor to anchor to
  90112. * @param width ratio across width from 0 to 1
  90113. * @param height ratio up height from 0 to 1
  90114. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90115. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90116. * @returns impostor the soft imposter
  90117. */
  90118. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90119. /**
  90120. * Add a hook to a rope impostor
  90121. * @param otherImpostor rigid impostor to anchor to
  90122. * @param length ratio across rope from 0 to 1
  90123. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90124. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90125. * @returns impostor the rope imposter
  90126. */
  90127. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90128. /**
  90129. * Will keep this body still, in a sleep mode.
  90130. * @returns the physics imposter
  90131. */
  90132. sleep(): PhysicsImpostor;
  90133. /**
  90134. * Wake the body up.
  90135. * @returns The physics imposter
  90136. */
  90137. wakeUp(): PhysicsImpostor;
  90138. /**
  90139. * Clones the physics imposter
  90140. * @param newObject The physics imposter clones to this physics-enabled object
  90141. * @returns A nullable physics imposter
  90142. */
  90143. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90144. /**
  90145. * Disposes the physics imposter
  90146. */
  90147. dispose(): void;
  90148. /**
  90149. * Sets the delta position
  90150. * @param position The delta position amount
  90151. */
  90152. setDeltaPosition(position: Vector3): void;
  90153. /**
  90154. * Sets the delta rotation
  90155. * @param rotation The delta rotation amount
  90156. */
  90157. setDeltaRotation(rotation: Quaternion): void;
  90158. /**
  90159. * Gets the box size of the physics imposter and stores the result in the input parameter
  90160. * @param result Stores the box size
  90161. * @returns The physics imposter
  90162. */
  90163. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90164. /**
  90165. * Gets the radius of the physics imposter
  90166. * @returns Radius of the physics imposter
  90167. */
  90168. getRadius(): number;
  90169. /**
  90170. * Sync a bone with this impostor
  90171. * @param bone The bone to sync to the impostor.
  90172. * @param boneMesh The mesh that the bone is influencing.
  90173. * @param jointPivot The pivot of the joint / bone in local space.
  90174. * @param distToJoint Optional distance from the impostor to the joint.
  90175. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90176. */
  90177. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90178. /**
  90179. * Sync impostor to a bone
  90180. * @param bone The bone that the impostor will be synced to.
  90181. * @param boneMesh The mesh that the bone is influencing.
  90182. * @param jointPivot The pivot of the joint / bone in local space.
  90183. * @param distToJoint Optional distance from the impostor to the joint.
  90184. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90185. * @param boneAxis Optional vector3 axis the bone is aligned with
  90186. */
  90187. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90188. /**
  90189. * No-Imposter type
  90190. */
  90191. static NoImpostor: number;
  90192. /**
  90193. * Sphere-Imposter type
  90194. */
  90195. static SphereImpostor: number;
  90196. /**
  90197. * Box-Imposter type
  90198. */
  90199. static BoxImpostor: number;
  90200. /**
  90201. * Plane-Imposter type
  90202. */
  90203. static PlaneImpostor: number;
  90204. /**
  90205. * Mesh-imposter type
  90206. */
  90207. static MeshImpostor: number;
  90208. /**
  90209. * Capsule-Impostor type (Ammo.js plugin only)
  90210. */
  90211. static CapsuleImpostor: number;
  90212. /**
  90213. * Cylinder-Imposter type
  90214. */
  90215. static CylinderImpostor: number;
  90216. /**
  90217. * Particle-Imposter type
  90218. */
  90219. static ParticleImpostor: number;
  90220. /**
  90221. * Heightmap-Imposter type
  90222. */
  90223. static HeightmapImpostor: number;
  90224. /**
  90225. * ConvexHull-Impostor type (Ammo.js plugin only)
  90226. */
  90227. static ConvexHullImpostor: number;
  90228. /**
  90229. * Rope-Imposter type
  90230. */
  90231. static RopeImpostor: number;
  90232. /**
  90233. * Cloth-Imposter type
  90234. */
  90235. static ClothImpostor: number;
  90236. /**
  90237. * Softbody-Imposter type
  90238. */
  90239. static SoftbodyImpostor: number;
  90240. }
  90241. }
  90242. declare module BABYLON {
  90243. /**
  90244. * @hidden
  90245. **/
  90246. export class _CreationDataStorage {
  90247. closePath?: boolean;
  90248. closeArray?: boolean;
  90249. idx: number[];
  90250. dashSize: number;
  90251. gapSize: number;
  90252. path3D: Path3D;
  90253. pathArray: Vector3[][];
  90254. arc: number;
  90255. radius: number;
  90256. cap: number;
  90257. tessellation: number;
  90258. }
  90259. /**
  90260. * @hidden
  90261. **/
  90262. class _InstanceDataStorage {
  90263. visibleInstances: any;
  90264. batchCache: _InstancesBatch;
  90265. instancesBufferSize: number;
  90266. instancesBuffer: Nullable<Buffer>;
  90267. instancesData: Float32Array;
  90268. overridenInstanceCount: number;
  90269. isFrozen: boolean;
  90270. previousBatch: Nullable<_InstancesBatch>;
  90271. hardwareInstancedRendering: boolean;
  90272. sideOrientation: number;
  90273. }
  90274. /**
  90275. * @hidden
  90276. **/
  90277. export class _InstancesBatch {
  90278. mustReturn: boolean;
  90279. visibleInstances: Nullable<InstancedMesh[]>[];
  90280. renderSelf: boolean[];
  90281. hardwareInstancedRendering: boolean[];
  90282. }
  90283. /**
  90284. * Class used to represent renderable models
  90285. */
  90286. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90287. /**
  90288. * Mesh side orientation : usually the external or front surface
  90289. */
  90290. static readonly FRONTSIDE: number;
  90291. /**
  90292. * Mesh side orientation : usually the internal or back surface
  90293. */
  90294. static readonly BACKSIDE: number;
  90295. /**
  90296. * Mesh side orientation : both internal and external or front and back surfaces
  90297. */
  90298. static readonly DOUBLESIDE: number;
  90299. /**
  90300. * Mesh side orientation : by default, `FRONTSIDE`
  90301. */
  90302. static readonly DEFAULTSIDE: number;
  90303. /**
  90304. * Mesh cap setting : no cap
  90305. */
  90306. static readonly NO_CAP: number;
  90307. /**
  90308. * Mesh cap setting : one cap at the beginning of the mesh
  90309. */
  90310. static readonly CAP_START: number;
  90311. /**
  90312. * Mesh cap setting : one cap at the end of the mesh
  90313. */
  90314. static readonly CAP_END: number;
  90315. /**
  90316. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90317. */
  90318. static readonly CAP_ALL: number;
  90319. /**
  90320. * Mesh pattern setting : no flip or rotate
  90321. */
  90322. static readonly NO_FLIP: number;
  90323. /**
  90324. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90325. */
  90326. static readonly FLIP_TILE: number;
  90327. /**
  90328. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90329. */
  90330. static readonly ROTATE_TILE: number;
  90331. /**
  90332. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90333. */
  90334. static readonly FLIP_ROW: number;
  90335. /**
  90336. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90337. */
  90338. static readonly ROTATE_ROW: number;
  90339. /**
  90340. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90341. */
  90342. static readonly FLIP_N_ROTATE_TILE: number;
  90343. /**
  90344. * Mesh pattern setting : rotate pattern and rotate
  90345. */
  90346. static readonly FLIP_N_ROTATE_ROW: number;
  90347. /**
  90348. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90349. */
  90350. static readonly CENTER: number;
  90351. /**
  90352. * Mesh tile positioning : part tiles on left
  90353. */
  90354. static readonly LEFT: number;
  90355. /**
  90356. * Mesh tile positioning : part tiles on right
  90357. */
  90358. static readonly RIGHT: number;
  90359. /**
  90360. * Mesh tile positioning : part tiles on top
  90361. */
  90362. static readonly TOP: number;
  90363. /**
  90364. * Mesh tile positioning : part tiles on bottom
  90365. */
  90366. static readonly BOTTOM: number;
  90367. /**
  90368. * Gets the default side orientation.
  90369. * @param orientation the orientation to value to attempt to get
  90370. * @returns the default orientation
  90371. * @hidden
  90372. */
  90373. static _GetDefaultSideOrientation(orientation?: number): number;
  90374. private _internalMeshDataInfo;
  90375. /**
  90376. * An event triggered before rendering the mesh
  90377. */
  90378. readonly onBeforeRenderObservable: Observable<Mesh>;
  90379. /**
  90380. * An event triggered before binding the mesh
  90381. */
  90382. readonly onBeforeBindObservable: Observable<Mesh>;
  90383. /**
  90384. * An event triggered after rendering the mesh
  90385. */
  90386. readonly onAfterRenderObservable: Observable<Mesh>;
  90387. /**
  90388. * An event triggered before drawing the mesh
  90389. */
  90390. readonly onBeforeDrawObservable: Observable<Mesh>;
  90391. private _onBeforeDrawObserver;
  90392. /**
  90393. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90394. */
  90395. onBeforeDraw: () => void;
  90396. readonly hasInstances: boolean;
  90397. /**
  90398. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90399. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90400. */
  90401. delayLoadState: number;
  90402. /**
  90403. * Gets the list of instances created from this mesh
  90404. * it is not supposed to be modified manually.
  90405. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90406. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90407. */
  90408. instances: InstancedMesh[];
  90409. /**
  90410. * Gets the file containing delay loading data for this mesh
  90411. */
  90412. delayLoadingFile: string;
  90413. /** @hidden */
  90414. _binaryInfo: any;
  90415. /**
  90416. * User defined function used to change how LOD level selection is done
  90417. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90418. */
  90419. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90420. /**
  90421. * Gets or sets the morph target manager
  90422. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90423. */
  90424. morphTargetManager: Nullable<MorphTargetManager>;
  90425. /** @hidden */
  90426. _creationDataStorage: Nullable<_CreationDataStorage>;
  90427. /** @hidden */
  90428. _geometry: Nullable<Geometry>;
  90429. /** @hidden */
  90430. _delayInfo: Array<string>;
  90431. /** @hidden */
  90432. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90433. /** @hidden */
  90434. _instanceDataStorage: _InstanceDataStorage;
  90435. private _effectiveMaterial;
  90436. /** @hidden */
  90437. _shouldGenerateFlatShading: boolean;
  90438. /** @hidden */
  90439. _originalBuilderSideOrientation: number;
  90440. /**
  90441. * Use this property to change the original side orientation defined at construction time
  90442. */
  90443. overrideMaterialSideOrientation: Nullable<number>;
  90444. /**
  90445. * Gets the source mesh (the one used to clone this one from)
  90446. */
  90447. readonly source: Nullable<Mesh>;
  90448. /**
  90449. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90450. */
  90451. isUnIndexed: boolean;
  90452. /**
  90453. * @constructor
  90454. * @param name The value used by scene.getMeshByName() to do a lookup.
  90455. * @param scene The scene to add this mesh to.
  90456. * @param parent The parent of this mesh, if it has one
  90457. * @param source An optional Mesh from which geometry is shared, cloned.
  90458. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90459. * When false, achieved by calling a clone(), also passing False.
  90460. * This will make creation of children, recursive.
  90461. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90462. */
  90463. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90464. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90465. /**
  90466. * Gets the class name
  90467. * @returns the string "Mesh".
  90468. */
  90469. getClassName(): string;
  90470. /** @hidden */
  90471. readonly _isMesh: boolean;
  90472. /**
  90473. * Returns a description of this mesh
  90474. * @param fullDetails define if full details about this mesh must be used
  90475. * @returns a descriptive string representing this mesh
  90476. */
  90477. toString(fullDetails?: boolean): string;
  90478. /** @hidden */
  90479. _unBindEffect(): void;
  90480. /**
  90481. * Gets a boolean indicating if this mesh has LOD
  90482. */
  90483. readonly hasLODLevels: boolean;
  90484. /**
  90485. * Gets the list of MeshLODLevel associated with the current mesh
  90486. * @returns an array of MeshLODLevel
  90487. */
  90488. getLODLevels(): MeshLODLevel[];
  90489. private _sortLODLevels;
  90490. /**
  90491. * Add a mesh as LOD level triggered at the given distance.
  90492. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90493. * @param distance The distance from the center of the object to show this level
  90494. * @param mesh The mesh to be added as LOD level (can be null)
  90495. * @return This mesh (for chaining)
  90496. */
  90497. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90498. /**
  90499. * Returns the LOD level mesh at the passed distance or null if not found.
  90500. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90501. * @param distance The distance from the center of the object to show this level
  90502. * @returns a Mesh or `null`
  90503. */
  90504. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90505. /**
  90506. * Remove a mesh from the LOD array
  90507. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90508. * @param mesh defines the mesh to be removed
  90509. * @return This mesh (for chaining)
  90510. */
  90511. removeLODLevel(mesh: Mesh): Mesh;
  90512. /**
  90513. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90514. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90515. * @param camera defines the camera to use to compute distance
  90516. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90517. * @return This mesh (for chaining)
  90518. */
  90519. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90520. /**
  90521. * Gets the mesh internal Geometry object
  90522. */
  90523. readonly geometry: Nullable<Geometry>;
  90524. /**
  90525. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90526. * @returns the total number of vertices
  90527. */
  90528. getTotalVertices(): number;
  90529. /**
  90530. * Returns the content of an associated vertex buffer
  90531. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90532. * - VertexBuffer.PositionKind
  90533. * - VertexBuffer.UVKind
  90534. * - VertexBuffer.UV2Kind
  90535. * - VertexBuffer.UV3Kind
  90536. * - VertexBuffer.UV4Kind
  90537. * - VertexBuffer.UV5Kind
  90538. * - VertexBuffer.UV6Kind
  90539. * - VertexBuffer.ColorKind
  90540. * - VertexBuffer.MatricesIndicesKind
  90541. * - VertexBuffer.MatricesIndicesExtraKind
  90542. * - VertexBuffer.MatricesWeightsKind
  90543. * - VertexBuffer.MatricesWeightsExtraKind
  90544. * @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
  90545. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90546. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90547. */
  90548. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90549. /**
  90550. * Returns the mesh VertexBuffer object from the requested `kind`
  90551. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90552. * - VertexBuffer.PositionKind
  90553. * - VertexBuffer.NormalKind
  90554. * - VertexBuffer.UVKind
  90555. * - VertexBuffer.UV2Kind
  90556. * - VertexBuffer.UV3Kind
  90557. * - VertexBuffer.UV4Kind
  90558. * - VertexBuffer.UV5Kind
  90559. * - VertexBuffer.UV6Kind
  90560. * - VertexBuffer.ColorKind
  90561. * - VertexBuffer.MatricesIndicesKind
  90562. * - VertexBuffer.MatricesIndicesExtraKind
  90563. * - VertexBuffer.MatricesWeightsKind
  90564. * - VertexBuffer.MatricesWeightsExtraKind
  90565. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90566. */
  90567. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90568. /**
  90569. * Tests if a specific vertex buffer is associated with this mesh
  90570. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90571. * - VertexBuffer.PositionKind
  90572. * - VertexBuffer.NormalKind
  90573. * - VertexBuffer.UVKind
  90574. * - VertexBuffer.UV2Kind
  90575. * - VertexBuffer.UV3Kind
  90576. * - VertexBuffer.UV4Kind
  90577. * - VertexBuffer.UV5Kind
  90578. * - VertexBuffer.UV6Kind
  90579. * - VertexBuffer.ColorKind
  90580. * - VertexBuffer.MatricesIndicesKind
  90581. * - VertexBuffer.MatricesIndicesExtraKind
  90582. * - VertexBuffer.MatricesWeightsKind
  90583. * - VertexBuffer.MatricesWeightsExtraKind
  90584. * @returns a boolean
  90585. */
  90586. isVerticesDataPresent(kind: string): boolean;
  90587. /**
  90588. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90589. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90590. * - VertexBuffer.PositionKind
  90591. * - VertexBuffer.UVKind
  90592. * - VertexBuffer.UV2Kind
  90593. * - VertexBuffer.UV3Kind
  90594. * - VertexBuffer.UV4Kind
  90595. * - VertexBuffer.UV5Kind
  90596. * - VertexBuffer.UV6Kind
  90597. * - VertexBuffer.ColorKind
  90598. * - VertexBuffer.MatricesIndicesKind
  90599. * - VertexBuffer.MatricesIndicesExtraKind
  90600. * - VertexBuffer.MatricesWeightsKind
  90601. * - VertexBuffer.MatricesWeightsExtraKind
  90602. * @returns a boolean
  90603. */
  90604. isVertexBufferUpdatable(kind: string): boolean;
  90605. /**
  90606. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90607. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90608. * - VertexBuffer.PositionKind
  90609. * - VertexBuffer.NormalKind
  90610. * - VertexBuffer.UVKind
  90611. * - VertexBuffer.UV2Kind
  90612. * - VertexBuffer.UV3Kind
  90613. * - VertexBuffer.UV4Kind
  90614. * - VertexBuffer.UV5Kind
  90615. * - VertexBuffer.UV6Kind
  90616. * - VertexBuffer.ColorKind
  90617. * - VertexBuffer.MatricesIndicesKind
  90618. * - VertexBuffer.MatricesIndicesExtraKind
  90619. * - VertexBuffer.MatricesWeightsKind
  90620. * - VertexBuffer.MatricesWeightsExtraKind
  90621. * @returns an array of strings
  90622. */
  90623. getVerticesDataKinds(): string[];
  90624. /**
  90625. * Returns a positive integer : the total number of indices in this mesh geometry.
  90626. * @returns the numner of indices or zero if the mesh has no geometry.
  90627. */
  90628. getTotalIndices(): number;
  90629. /**
  90630. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90631. * @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.
  90632. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90633. * @returns the indices array or an empty array if the mesh has no geometry
  90634. */
  90635. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90636. readonly isBlocked: boolean;
  90637. /**
  90638. * Determine if the current mesh is ready to be rendered
  90639. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90640. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90641. * @returns true if all associated assets are ready (material, textures, shaders)
  90642. */
  90643. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90644. /**
  90645. * 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.
  90646. */
  90647. readonly areNormalsFrozen: boolean;
  90648. /**
  90649. * 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.
  90650. * @returns the current mesh
  90651. */
  90652. freezeNormals(): Mesh;
  90653. /**
  90654. * 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
  90655. * @returns the current mesh
  90656. */
  90657. unfreezeNormals(): Mesh;
  90658. /**
  90659. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90660. */
  90661. overridenInstanceCount: number;
  90662. /** @hidden */
  90663. _preActivate(): Mesh;
  90664. /** @hidden */
  90665. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90666. /** @hidden */
  90667. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90668. /**
  90669. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90670. * This means the mesh underlying bounding box and sphere are recomputed.
  90671. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90672. * @returns the current mesh
  90673. */
  90674. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90675. /** @hidden */
  90676. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90677. /**
  90678. * This function will subdivide the mesh into multiple submeshes
  90679. * @param count defines the expected number of submeshes
  90680. */
  90681. subdivide(count: number): void;
  90682. /**
  90683. * Copy a FloatArray into a specific associated vertex buffer
  90684. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90685. * - VertexBuffer.PositionKind
  90686. * - VertexBuffer.UVKind
  90687. * - VertexBuffer.UV2Kind
  90688. * - VertexBuffer.UV3Kind
  90689. * - VertexBuffer.UV4Kind
  90690. * - VertexBuffer.UV5Kind
  90691. * - VertexBuffer.UV6Kind
  90692. * - VertexBuffer.ColorKind
  90693. * - VertexBuffer.MatricesIndicesKind
  90694. * - VertexBuffer.MatricesIndicesExtraKind
  90695. * - VertexBuffer.MatricesWeightsKind
  90696. * - VertexBuffer.MatricesWeightsExtraKind
  90697. * @param data defines the data source
  90698. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90699. * @param stride defines the data stride size (can be null)
  90700. * @returns the current mesh
  90701. */
  90702. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90703. /**
  90704. * Flags an associated vertex buffer as updatable
  90705. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90706. * - VertexBuffer.PositionKind
  90707. * - VertexBuffer.UVKind
  90708. * - VertexBuffer.UV2Kind
  90709. * - VertexBuffer.UV3Kind
  90710. * - VertexBuffer.UV4Kind
  90711. * - VertexBuffer.UV5Kind
  90712. * - VertexBuffer.UV6Kind
  90713. * - VertexBuffer.ColorKind
  90714. * - VertexBuffer.MatricesIndicesKind
  90715. * - VertexBuffer.MatricesIndicesExtraKind
  90716. * - VertexBuffer.MatricesWeightsKind
  90717. * - VertexBuffer.MatricesWeightsExtraKind
  90718. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90719. */
  90720. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90721. /**
  90722. * Sets the mesh global Vertex Buffer
  90723. * @param buffer defines the buffer to use
  90724. * @returns the current mesh
  90725. */
  90726. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90727. /**
  90728. * Update a specific associated vertex buffer
  90729. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90730. * - VertexBuffer.PositionKind
  90731. * - VertexBuffer.UVKind
  90732. * - VertexBuffer.UV2Kind
  90733. * - VertexBuffer.UV3Kind
  90734. * - VertexBuffer.UV4Kind
  90735. * - VertexBuffer.UV5Kind
  90736. * - VertexBuffer.UV6Kind
  90737. * - VertexBuffer.ColorKind
  90738. * - VertexBuffer.MatricesIndicesKind
  90739. * - VertexBuffer.MatricesIndicesExtraKind
  90740. * - VertexBuffer.MatricesWeightsKind
  90741. * - VertexBuffer.MatricesWeightsExtraKind
  90742. * @param data defines the data source
  90743. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90744. * @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)
  90745. * @returns the current mesh
  90746. */
  90747. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90748. /**
  90749. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90750. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90751. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90752. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90753. * @returns the current mesh
  90754. */
  90755. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90756. /**
  90757. * Creates a un-shared specific occurence of the geometry for the mesh.
  90758. * @returns the current mesh
  90759. */
  90760. makeGeometryUnique(): Mesh;
  90761. /**
  90762. * Set the index buffer of this mesh
  90763. * @param indices defines the source data
  90764. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90765. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90766. * @returns the current mesh
  90767. */
  90768. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90769. /**
  90770. * Update the current index buffer
  90771. * @param indices defines the source data
  90772. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90773. * @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)
  90774. * @returns the current mesh
  90775. */
  90776. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90777. /**
  90778. * Invert the geometry to move from a right handed system to a left handed one.
  90779. * @returns the current mesh
  90780. */
  90781. toLeftHanded(): Mesh;
  90782. /** @hidden */
  90783. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90784. /** @hidden */
  90785. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90786. /**
  90787. * Registers for this mesh a javascript function called just before the rendering process
  90788. * @param func defines the function to call before rendering this mesh
  90789. * @returns the current mesh
  90790. */
  90791. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90792. /**
  90793. * Disposes a previously registered javascript function called before the rendering
  90794. * @param func defines the function to remove
  90795. * @returns the current mesh
  90796. */
  90797. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90798. /**
  90799. * Registers for this mesh a javascript function called just after the rendering is complete
  90800. * @param func defines the function to call after rendering this mesh
  90801. * @returns the current mesh
  90802. */
  90803. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90804. /**
  90805. * Disposes a previously registered javascript function called after the rendering.
  90806. * @param func defines the function to remove
  90807. * @returns the current mesh
  90808. */
  90809. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90810. /** @hidden */
  90811. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90812. /** @hidden */
  90813. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90814. /** @hidden */
  90815. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90816. /** @hidden */
  90817. _rebuild(): void;
  90818. /** @hidden */
  90819. _freeze(): void;
  90820. /** @hidden */
  90821. _unFreeze(): void;
  90822. /**
  90823. * 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
  90824. * @param subMesh defines the subMesh to render
  90825. * @param enableAlphaMode defines if alpha mode can be changed
  90826. * @returns the current mesh
  90827. */
  90828. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90829. private _onBeforeDraw;
  90830. /**
  90831. * Renormalize the mesh and patch it up if there are no weights
  90832. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90833. * However in the case of zero weights then we set just a single influence to 1.
  90834. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90835. */
  90836. cleanMatrixWeights(): void;
  90837. private normalizeSkinFourWeights;
  90838. private normalizeSkinWeightsAndExtra;
  90839. /**
  90840. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90841. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90842. * the user know there was an issue with importing the mesh
  90843. * @returns a validation object with skinned, valid and report string
  90844. */
  90845. validateSkinning(): {
  90846. skinned: boolean;
  90847. valid: boolean;
  90848. report: string;
  90849. };
  90850. /** @hidden */
  90851. _checkDelayState(): Mesh;
  90852. private _queueLoad;
  90853. /**
  90854. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90855. * A mesh is in the frustum if its bounding box intersects the frustum
  90856. * @param frustumPlanes defines the frustum to test
  90857. * @returns true if the mesh is in the frustum planes
  90858. */
  90859. isInFrustum(frustumPlanes: Plane[]): boolean;
  90860. /**
  90861. * Sets the mesh material by the material or multiMaterial `id` property
  90862. * @param id is a string identifying the material or the multiMaterial
  90863. * @returns the current mesh
  90864. */
  90865. setMaterialByID(id: string): Mesh;
  90866. /**
  90867. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90868. * @returns an array of IAnimatable
  90869. */
  90870. getAnimatables(): IAnimatable[];
  90871. /**
  90872. * Modifies the mesh geometry according to the passed transformation matrix.
  90873. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90874. * The mesh normals are modified using the same transformation.
  90875. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90876. * @param transform defines the transform matrix to use
  90877. * @see http://doc.babylonjs.com/resources/baking_transformations
  90878. * @returns the current mesh
  90879. */
  90880. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90881. /**
  90882. * Modifies the mesh geometry according to its own current World Matrix.
  90883. * The mesh World Matrix is then reset.
  90884. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90885. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90886. * @see http://doc.babylonjs.com/resources/baking_transformations
  90887. * @returns the current mesh
  90888. */
  90889. bakeCurrentTransformIntoVertices(): Mesh;
  90890. /** @hidden */
  90891. readonly _positions: Nullable<Vector3[]>;
  90892. /** @hidden */
  90893. _resetPointsArrayCache(): Mesh;
  90894. /** @hidden */
  90895. _generatePointsArray(): boolean;
  90896. /**
  90897. * Returns a new Mesh object generated from the current mesh properties.
  90898. * This method must not get confused with createInstance()
  90899. * @param name is a string, the name given to the new mesh
  90900. * @param newParent can be any Node object (default `null`)
  90901. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90902. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90903. * @returns a new mesh
  90904. */
  90905. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90906. /**
  90907. * Releases resources associated with this mesh.
  90908. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90909. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90910. */
  90911. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90912. /**
  90913. * Modifies the mesh geometry according to a displacement map.
  90914. * 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.
  90915. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90916. * @param url is a string, the URL from the image file is to be downloaded.
  90917. * @param minHeight is the lower limit of the displacement.
  90918. * @param maxHeight is the upper limit of the displacement.
  90919. * @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.
  90920. * @param uvOffset is an optional vector2 used to offset UV.
  90921. * @param uvScale is an optional vector2 used to scale UV.
  90922. * @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.
  90923. * @returns the Mesh.
  90924. */
  90925. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90926. /**
  90927. * Modifies the mesh geometry according to a displacementMap buffer.
  90928. * 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.
  90929. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90930. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90931. * @param heightMapWidth is the width of the buffer image.
  90932. * @param heightMapHeight is the height of the buffer image.
  90933. * @param minHeight is the lower limit of the displacement.
  90934. * @param maxHeight is the upper limit of the displacement.
  90935. * @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.
  90936. * @param uvOffset is an optional vector2 used to offset UV.
  90937. * @param uvScale is an optional vector2 used to scale UV.
  90938. * @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.
  90939. * @returns the Mesh.
  90940. */
  90941. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90942. /**
  90943. * Modify the mesh to get a flat shading rendering.
  90944. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90945. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90946. * @returns current mesh
  90947. */
  90948. convertToFlatShadedMesh(): Mesh;
  90949. /**
  90950. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90951. * In other words, more vertices, no more indices and a single bigger VBO.
  90952. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90953. * @returns current mesh
  90954. */
  90955. convertToUnIndexedMesh(): Mesh;
  90956. /**
  90957. * Inverses facet orientations.
  90958. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90959. * @param flipNormals will also inverts the normals
  90960. * @returns current mesh
  90961. */
  90962. flipFaces(flipNormals?: boolean): Mesh;
  90963. /**
  90964. * Increase the number of facets and hence vertices in a mesh
  90965. * Vertex normals are interpolated from existing vertex normals
  90966. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90967. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90968. */
  90969. increaseVertices(numberPerEdge: number): void;
  90970. /**
  90971. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90972. * This will undo any application of covertToFlatShadedMesh
  90973. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90974. */
  90975. forceSharedVertices(): void;
  90976. /** @hidden */
  90977. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90978. /** @hidden */
  90979. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90980. /**
  90981. * Creates a new InstancedMesh object from the mesh model.
  90982. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90983. * @param name defines the name of the new instance
  90984. * @returns a new InstancedMesh
  90985. */
  90986. createInstance(name: string): InstancedMesh;
  90987. /**
  90988. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90989. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90990. * @returns the current mesh
  90991. */
  90992. synchronizeInstances(): Mesh;
  90993. /**
  90994. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90995. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90996. * This should be used together with the simplification to avoid disappearing triangles.
  90997. * @param successCallback an optional success callback to be called after the optimization finished.
  90998. * @returns the current mesh
  90999. */
  91000. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91001. /**
  91002. * Serialize current mesh
  91003. * @param serializationObject defines the object which will receive the serialization data
  91004. */
  91005. serialize(serializationObject: any): void;
  91006. /** @hidden */
  91007. _syncGeometryWithMorphTargetManager(): void;
  91008. /** @hidden */
  91009. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91010. /**
  91011. * Returns a new Mesh object parsed from the source provided.
  91012. * @param parsedMesh is the source
  91013. * @param scene defines the hosting scene
  91014. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91015. * @returns a new Mesh
  91016. */
  91017. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91018. /**
  91019. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91020. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91021. * @param name defines the name of the mesh to create
  91022. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91023. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91024. * @param closePath creates a seam between the first and the last points of each path of the path array
  91025. * @param offset is taken in account only if the `pathArray` is containing a single path
  91026. * @param scene defines the hosting scene
  91027. * @param updatable defines if the mesh must be flagged as updatable
  91028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91029. * @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)
  91030. * @returns a new Mesh
  91031. */
  91032. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91033. /**
  91034. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91035. * @param name defines the name of the mesh to create
  91036. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91037. * @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
  91038. * @param scene defines the hosting scene
  91039. * @param updatable defines if the mesh must be flagged as updatable
  91040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91041. * @returns a new Mesh
  91042. */
  91043. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91044. /**
  91045. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91046. * @param name defines the name of the mesh to create
  91047. * @param size sets the size (float) of each box side (default 1)
  91048. * @param scene defines the hosting scene
  91049. * @param updatable defines if the mesh must be flagged as updatable
  91050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91051. * @returns a new Mesh
  91052. */
  91053. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91054. /**
  91055. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91056. * @param name defines the name of the mesh to create
  91057. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91058. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91059. * @param scene defines the hosting scene
  91060. * @param updatable defines if the mesh must be flagged as updatable
  91061. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91062. * @returns a new Mesh
  91063. */
  91064. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91065. /**
  91066. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91067. * @param name defines the name of the mesh to create
  91068. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91069. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91070. * @param scene defines the hosting scene
  91071. * @returns a new Mesh
  91072. */
  91073. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91074. /**
  91075. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91076. * @param name defines the name of the mesh to create
  91077. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91078. * @param diameterTop set the top cap diameter (floats, default 1)
  91079. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91080. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91081. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91082. * @param scene defines the hosting scene
  91083. * @param updatable defines if the mesh must be flagged as updatable
  91084. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91085. * @returns a new Mesh
  91086. */
  91087. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91088. /**
  91089. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91090. * @param name defines the name of the mesh to create
  91091. * @param diameter sets the diameter size (float) of the torus (default 1)
  91092. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91093. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91094. * @param scene defines the hosting scene
  91095. * @param updatable defines if the mesh must be flagged as updatable
  91096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91097. * @returns a new Mesh
  91098. */
  91099. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91100. /**
  91101. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91102. * @param name defines the name of the mesh to create
  91103. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91104. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91105. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91106. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91107. * @param p the number of windings on X axis (positive integers, default 2)
  91108. * @param q the number of windings on Y axis (positive integers, default 3)
  91109. * @param scene defines the hosting scene
  91110. * @param updatable defines if the mesh must be flagged as updatable
  91111. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91112. * @returns a new Mesh
  91113. */
  91114. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91115. /**
  91116. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91117. * @param name defines the name of the mesh to create
  91118. * @param points is an array successive Vector3
  91119. * @param scene defines the hosting scene
  91120. * @param updatable defines if the mesh must be flagged as updatable
  91121. * @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).
  91122. * @returns a new Mesh
  91123. */
  91124. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91125. /**
  91126. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91127. * @param name defines the name of the mesh to create
  91128. * @param points is an array successive Vector3
  91129. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91130. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91131. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91132. * @param scene defines the hosting scene
  91133. * @param updatable defines if the mesh must be flagged as updatable
  91134. * @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)
  91135. * @returns a new Mesh
  91136. */
  91137. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91138. /**
  91139. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91140. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91141. * 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.
  91142. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91143. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91144. * Remember you can only change the shape positions, not their number when updating a polygon.
  91145. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91146. * @param name defines the name of the mesh to create
  91147. * @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
  91148. * @param scene defines the hosting scene
  91149. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91150. * @param updatable defines if the mesh must be flagged as updatable
  91151. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91152. * @param earcutInjection can be used to inject your own earcut reference
  91153. * @returns a new Mesh
  91154. */
  91155. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91156. /**
  91157. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91158. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91159. * @param name defines the name of the mesh to create
  91160. * @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
  91161. * @param depth defines the height of extrusion
  91162. * @param scene defines the hosting scene
  91163. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91164. * @param updatable defines if the mesh must be flagged as updatable
  91165. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91166. * @param earcutInjection can be used to inject your own earcut reference
  91167. * @returns a new Mesh
  91168. */
  91169. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91170. /**
  91171. * Creates an extruded shape mesh.
  91172. * 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
  91173. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91174. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91175. * @param name defines the name of the mesh to create
  91176. * @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
  91177. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91178. * @param scale is the value to scale the shape
  91179. * @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
  91180. * @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
  91181. * @param scene defines the hosting scene
  91182. * @param updatable defines if the mesh must be flagged as updatable
  91183. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91184. * @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)
  91185. * @returns a new Mesh
  91186. */
  91187. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91188. /**
  91189. * Creates an custom extruded shape mesh.
  91190. * The custom extrusion is a parametric shape.
  91191. * It has no predefined shape. Its final shape will depend on the input parameters.
  91192. * Please consider using the same method from the MeshBuilder class instead
  91193. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91194. * @param name defines the name of the mesh to create
  91195. * @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
  91196. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91197. * @param scaleFunction is a custom Javascript function called on each path point
  91198. * @param rotationFunction is a custom Javascript function called on each path point
  91199. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91200. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91201. * @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
  91202. * @param scene defines the hosting scene
  91203. * @param updatable defines if the mesh must be flagged as updatable
  91204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91205. * @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)
  91206. * @returns a new Mesh
  91207. */
  91208. 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;
  91209. /**
  91210. * Creates lathe mesh.
  91211. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91212. * Please consider using the same method from the MeshBuilder class instead
  91213. * @param name defines the name of the mesh to create
  91214. * @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
  91215. * @param radius is the radius value of the lathe
  91216. * @param tessellation is the side number of the lathe.
  91217. * @param scene defines the hosting scene
  91218. * @param updatable defines if the mesh must be flagged as updatable
  91219. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91220. * @returns a new Mesh
  91221. */
  91222. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91223. /**
  91224. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91225. * @param name defines the name of the mesh to create
  91226. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91227. * @param scene defines the hosting scene
  91228. * @param updatable defines if the mesh must be flagged as updatable
  91229. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91230. * @returns a new Mesh
  91231. */
  91232. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91233. /**
  91234. * Creates a ground mesh.
  91235. * Please consider using the same method from the MeshBuilder class instead
  91236. * @param name defines the name of the mesh to create
  91237. * @param width set the width of the ground
  91238. * @param height set the height of the ground
  91239. * @param subdivisions sets the number of subdivisions per side
  91240. * @param scene defines the hosting scene
  91241. * @param updatable defines if the mesh must be flagged as updatable
  91242. * @returns a new Mesh
  91243. */
  91244. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91245. /**
  91246. * Creates a tiled ground mesh.
  91247. * Please consider using the same method from the MeshBuilder class instead
  91248. * @param name defines the name of the mesh to create
  91249. * @param xmin set the ground minimum X coordinate
  91250. * @param zmin set the ground minimum Y coordinate
  91251. * @param xmax set the ground maximum X coordinate
  91252. * @param zmax set the ground maximum Z coordinate
  91253. * @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
  91254. * @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
  91255. * @param scene defines the hosting scene
  91256. * @param updatable defines if the mesh must be flagged as updatable
  91257. * @returns a new Mesh
  91258. */
  91259. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91260. w: number;
  91261. h: number;
  91262. }, precision: {
  91263. w: number;
  91264. h: number;
  91265. }, scene: Scene, updatable?: boolean): Mesh;
  91266. /**
  91267. * Creates a ground mesh from a height map.
  91268. * Please consider using the same method from the MeshBuilder class instead
  91269. * @see http://doc.babylonjs.com/babylon101/height_map
  91270. * @param name defines the name of the mesh to create
  91271. * @param url sets the URL of the height map image resource
  91272. * @param width set the ground width size
  91273. * @param height set the ground height size
  91274. * @param subdivisions sets the number of subdivision per side
  91275. * @param minHeight is the minimum altitude on the ground
  91276. * @param maxHeight is the maximum altitude on the ground
  91277. * @param scene defines the hosting scene
  91278. * @param updatable defines if the mesh must be flagged as updatable
  91279. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91280. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91281. * @returns a new Mesh
  91282. */
  91283. 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;
  91284. /**
  91285. * Creates a tube mesh.
  91286. * The tube is a parametric shape.
  91287. * It has no predefined shape. Its final shape will depend on the input parameters.
  91288. * Please consider using the same method from the MeshBuilder class instead
  91289. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91290. * @param name defines the name of the mesh to create
  91291. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91292. * @param radius sets the tube radius size
  91293. * @param tessellation is the number of sides on the tubular surface
  91294. * @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
  91295. * @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
  91296. * @param scene defines the hosting scene
  91297. * @param updatable defines if the mesh must be flagged as updatable
  91298. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91299. * @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)
  91300. * @returns a new Mesh
  91301. */
  91302. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91303. (i: number, distance: number): number;
  91304. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91305. /**
  91306. * Creates a polyhedron mesh.
  91307. * Please consider using the same method from the MeshBuilder class instead.
  91308. * * 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
  91309. * * The parameter `size` (positive float, default 1) sets the polygon size
  91310. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91311. * * 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`
  91312. * * 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
  91313. * * 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)`)
  91314. * * 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
  91315. * * 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
  91316. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91317. * * If you create a double-sided mesh, you can choose what parts of 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
  91318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91319. * @param name defines the name of the mesh to create
  91320. * @param options defines the options used to create the mesh
  91321. * @param scene defines the hosting scene
  91322. * @returns a new Mesh
  91323. */
  91324. static CreatePolyhedron(name: string, options: {
  91325. type?: number;
  91326. size?: number;
  91327. sizeX?: number;
  91328. sizeY?: number;
  91329. sizeZ?: number;
  91330. custom?: any;
  91331. faceUV?: Vector4[];
  91332. faceColors?: Color4[];
  91333. updatable?: boolean;
  91334. sideOrientation?: number;
  91335. }, scene: Scene): Mesh;
  91336. /**
  91337. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91338. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91339. * * 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`)
  91340. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91341. * * 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
  91342. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91343. * * If you create a double-sided mesh, you can choose what parts of 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
  91344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91345. * @param name defines the name of the mesh
  91346. * @param options defines the options used to create the mesh
  91347. * @param scene defines the hosting scene
  91348. * @returns a new Mesh
  91349. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91350. */
  91351. static CreateIcoSphere(name: string, options: {
  91352. radius?: number;
  91353. flat?: boolean;
  91354. subdivisions?: number;
  91355. sideOrientation?: number;
  91356. updatable?: boolean;
  91357. }, scene: Scene): Mesh;
  91358. /**
  91359. * Creates a decal mesh.
  91360. * Please consider using the same method from the MeshBuilder class instead.
  91361. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91362. * @param name defines the name of the mesh
  91363. * @param sourceMesh defines the mesh receiving the decal
  91364. * @param position sets the position of the decal in world coordinates
  91365. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91366. * @param size sets the decal scaling
  91367. * @param angle sets the angle to rotate the decal
  91368. * @returns a new Mesh
  91369. */
  91370. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91371. /**
  91372. * Prepare internal position array for software CPU skinning
  91373. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91374. */
  91375. setPositionsForCPUSkinning(): Float32Array;
  91376. /**
  91377. * Prepare internal normal array for software CPU skinning
  91378. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91379. */
  91380. setNormalsForCPUSkinning(): Float32Array;
  91381. /**
  91382. * Updates the vertex buffer by applying transformation from the bones
  91383. * @param skeleton defines the skeleton to apply to current mesh
  91384. * @returns the current mesh
  91385. */
  91386. applySkeleton(skeleton: Skeleton): Mesh;
  91387. /**
  91388. * 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
  91389. * @param meshes defines the list of meshes to scan
  91390. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91391. */
  91392. static MinMax(meshes: AbstractMesh[]): {
  91393. min: Vector3;
  91394. max: Vector3;
  91395. };
  91396. /**
  91397. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91398. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91399. * @returns a vector3
  91400. */
  91401. static Center(meshesOrMinMaxVector: {
  91402. min: Vector3;
  91403. max: Vector3;
  91404. } | AbstractMesh[]): Vector3;
  91405. /**
  91406. * Merge the array of meshes into a single mesh for performance reasons.
  91407. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91408. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91409. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91410. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91411. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91412. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91413. * @returns a new mesh
  91414. */
  91415. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91416. /** @hidden */
  91417. addInstance(instance: InstancedMesh): void;
  91418. /** @hidden */
  91419. removeInstance(instance: InstancedMesh): void;
  91420. }
  91421. }
  91422. declare module BABYLON {
  91423. /**
  91424. * This is the base class of all the camera used in the application.
  91425. * @see http://doc.babylonjs.com/features/cameras
  91426. */
  91427. export class Camera extends Node {
  91428. /** @hidden */
  91429. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91430. /**
  91431. * This is the default projection mode used by the cameras.
  91432. * It helps recreating a feeling of perspective and better appreciate depth.
  91433. * This is the best way to simulate real life cameras.
  91434. */
  91435. static readonly PERSPECTIVE_CAMERA: number;
  91436. /**
  91437. * This helps creating camera with an orthographic mode.
  91438. * 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.
  91439. */
  91440. static readonly ORTHOGRAPHIC_CAMERA: number;
  91441. /**
  91442. * This is the default FOV mode for perspective cameras.
  91443. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91444. */
  91445. static readonly FOVMODE_VERTICAL_FIXED: number;
  91446. /**
  91447. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91448. */
  91449. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91450. /**
  91451. * This specifies ther is no need for a camera rig.
  91452. * Basically only one eye is rendered corresponding to the camera.
  91453. */
  91454. static readonly RIG_MODE_NONE: number;
  91455. /**
  91456. * Simulates a camera Rig with one blue eye and one red eye.
  91457. * This can be use with 3d blue and red glasses.
  91458. */
  91459. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91460. /**
  91461. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91462. */
  91463. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91464. /**
  91465. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91466. */
  91467. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91468. /**
  91469. * Defines that both eyes of the camera will be rendered over under each other.
  91470. */
  91471. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91472. /**
  91473. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91474. */
  91475. static readonly RIG_MODE_VR: number;
  91476. /**
  91477. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91478. */
  91479. static readonly RIG_MODE_WEBVR: number;
  91480. /**
  91481. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91482. */
  91483. static readonly RIG_MODE_CUSTOM: number;
  91484. /**
  91485. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91486. */
  91487. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91488. /**
  91489. * Define the input manager associated with the camera.
  91490. */
  91491. inputs: CameraInputsManager<Camera>;
  91492. /** @hidden */
  91493. _position: Vector3;
  91494. /**
  91495. * Define the current local position of the camera in the scene
  91496. */
  91497. position: Vector3;
  91498. /**
  91499. * The vector the camera should consider as up.
  91500. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91501. */
  91502. upVector: Vector3;
  91503. /**
  91504. * Define the current limit on the left side for an orthographic camera
  91505. * In scene unit
  91506. */
  91507. orthoLeft: Nullable<number>;
  91508. /**
  91509. * Define the current limit on the right side for an orthographic camera
  91510. * In scene unit
  91511. */
  91512. orthoRight: Nullable<number>;
  91513. /**
  91514. * Define the current limit on the bottom side for an orthographic camera
  91515. * In scene unit
  91516. */
  91517. orthoBottom: Nullable<number>;
  91518. /**
  91519. * Define the current limit on the top side for an orthographic camera
  91520. * In scene unit
  91521. */
  91522. orthoTop: Nullable<number>;
  91523. /**
  91524. * Field Of View is set in Radians. (default is 0.8)
  91525. */
  91526. fov: number;
  91527. /**
  91528. * Define the minimum distance the camera can see from.
  91529. * This is important to note that the depth buffer are not infinite and the closer it starts
  91530. * the more your scene might encounter depth fighting issue.
  91531. */
  91532. minZ: number;
  91533. /**
  91534. * Define the maximum distance the camera can see to.
  91535. * This is important to note that the depth buffer are not infinite and the further it end
  91536. * the more your scene might encounter depth fighting issue.
  91537. */
  91538. maxZ: number;
  91539. /**
  91540. * Define the default inertia of the camera.
  91541. * This helps giving a smooth feeling to the camera movement.
  91542. */
  91543. inertia: number;
  91544. /**
  91545. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91546. */
  91547. mode: number;
  91548. /**
  91549. * Define wether the camera is intermediate.
  91550. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91551. */
  91552. isIntermediate: boolean;
  91553. /**
  91554. * Define the viewport of the camera.
  91555. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91556. */
  91557. viewport: Viewport;
  91558. /**
  91559. * Restricts the camera to viewing objects with the same layerMask.
  91560. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91561. */
  91562. layerMask: number;
  91563. /**
  91564. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91565. */
  91566. fovMode: number;
  91567. /**
  91568. * Rig mode of the camera.
  91569. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91570. * This is normally controlled byt the camera themselves as internal use.
  91571. */
  91572. cameraRigMode: number;
  91573. /**
  91574. * Defines the distance between both "eyes" in case of a RIG
  91575. */
  91576. interaxialDistance: number;
  91577. /**
  91578. * Defines if stereoscopic rendering is done side by side or over under.
  91579. */
  91580. isStereoscopicSideBySide: boolean;
  91581. /**
  91582. * 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
  91583. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91584. * else in the scene. (Eg. security camera)
  91585. *
  91586. * 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)
  91587. */
  91588. customRenderTargets: RenderTargetTexture[];
  91589. /**
  91590. * When set, the camera will render to this render target instead of the default canvas
  91591. *
  91592. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91593. */
  91594. outputRenderTarget: Nullable<RenderTargetTexture>;
  91595. /**
  91596. * Observable triggered when the camera view matrix has changed.
  91597. */
  91598. onViewMatrixChangedObservable: Observable<Camera>;
  91599. /**
  91600. * Observable triggered when the camera Projection matrix has changed.
  91601. */
  91602. onProjectionMatrixChangedObservable: Observable<Camera>;
  91603. /**
  91604. * Observable triggered when the inputs have been processed.
  91605. */
  91606. onAfterCheckInputsObservable: Observable<Camera>;
  91607. /**
  91608. * Observable triggered when reset has been called and applied to the camera.
  91609. */
  91610. onRestoreStateObservable: Observable<Camera>;
  91611. /** @hidden */
  91612. _cameraRigParams: any;
  91613. /** @hidden */
  91614. _rigCameras: Camera[];
  91615. /** @hidden */
  91616. _rigPostProcess: Nullable<PostProcess>;
  91617. protected _webvrViewMatrix: Matrix;
  91618. /** @hidden */
  91619. _skipRendering: boolean;
  91620. /** @hidden */
  91621. _projectionMatrix: Matrix;
  91622. /** @hidden */
  91623. _postProcesses: Nullable<PostProcess>[];
  91624. /** @hidden */
  91625. _activeMeshes: SmartArray<AbstractMesh>;
  91626. protected _globalPosition: Vector3;
  91627. /** @hidden */
  91628. _computedViewMatrix: Matrix;
  91629. private _doNotComputeProjectionMatrix;
  91630. private _transformMatrix;
  91631. private _frustumPlanes;
  91632. private _refreshFrustumPlanes;
  91633. private _storedFov;
  91634. private _stateStored;
  91635. /**
  91636. * Instantiates a new camera object.
  91637. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91638. * @see http://doc.babylonjs.com/features/cameras
  91639. * @param name Defines the name of the camera in the scene
  91640. * @param position Defines the position of the camera
  91641. * @param scene Defines the scene the camera belongs too
  91642. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91643. */
  91644. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91645. /**
  91646. * Store current camera state (fov, position, etc..)
  91647. * @returns the camera
  91648. */
  91649. storeState(): Camera;
  91650. /**
  91651. * Restores the camera state values if it has been stored. You must call storeState() first
  91652. */
  91653. protected _restoreStateValues(): boolean;
  91654. /**
  91655. * Restored camera state. You must call storeState() first.
  91656. * @returns true if restored and false otherwise
  91657. */
  91658. restoreState(): boolean;
  91659. /**
  91660. * Gets the class name of the camera.
  91661. * @returns the class name
  91662. */
  91663. getClassName(): string;
  91664. /** @hidden */
  91665. readonly _isCamera: boolean;
  91666. /**
  91667. * Gets a string representation of the camera useful for debug purpose.
  91668. * @param fullDetails Defines that a more verboe level of logging is required
  91669. * @returns the string representation
  91670. */
  91671. toString(fullDetails?: boolean): string;
  91672. /**
  91673. * Gets the current world space position of the camera.
  91674. */
  91675. readonly globalPosition: Vector3;
  91676. /**
  91677. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91678. * @returns the active meshe list
  91679. */
  91680. getActiveMeshes(): SmartArray<AbstractMesh>;
  91681. /**
  91682. * Check wether a mesh is part of the current active mesh list of the camera
  91683. * @param mesh Defines the mesh to check
  91684. * @returns true if active, false otherwise
  91685. */
  91686. isActiveMesh(mesh: Mesh): boolean;
  91687. /**
  91688. * Is this camera ready to be used/rendered
  91689. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91690. * @return true if the camera is ready
  91691. */
  91692. isReady(completeCheck?: boolean): boolean;
  91693. /** @hidden */
  91694. _initCache(): void;
  91695. /** @hidden */
  91696. _updateCache(ignoreParentClass?: boolean): void;
  91697. /** @hidden */
  91698. _isSynchronized(): boolean;
  91699. /** @hidden */
  91700. _isSynchronizedViewMatrix(): boolean;
  91701. /** @hidden */
  91702. _isSynchronizedProjectionMatrix(): boolean;
  91703. /**
  91704. * Attach the input controls to a specific dom element to get the input from.
  91705. * @param element Defines the element the controls should be listened from
  91706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91707. */
  91708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91709. /**
  91710. * Detach the current controls from the specified dom element.
  91711. * @param element Defines the element to stop listening the inputs from
  91712. */
  91713. detachControl(element: HTMLElement): void;
  91714. /**
  91715. * Update the camera state according to the different inputs gathered during the frame.
  91716. */
  91717. update(): void;
  91718. /** @hidden */
  91719. _checkInputs(): void;
  91720. /** @hidden */
  91721. readonly rigCameras: Camera[];
  91722. /**
  91723. * Gets the post process used by the rig cameras
  91724. */
  91725. readonly rigPostProcess: Nullable<PostProcess>;
  91726. /**
  91727. * Internal, gets the first post proces.
  91728. * @returns the first post process to be run on this camera.
  91729. */
  91730. _getFirstPostProcess(): Nullable<PostProcess>;
  91731. private _cascadePostProcessesToRigCams;
  91732. /**
  91733. * Attach a post process to the camera.
  91734. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91735. * @param postProcess The post process to attach to the camera
  91736. * @param insertAt The position of the post process in case several of them are in use in the scene
  91737. * @returns the position the post process has been inserted at
  91738. */
  91739. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91740. /**
  91741. * Detach a post process to the camera.
  91742. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91743. * @param postProcess The post process to detach from the camera
  91744. */
  91745. detachPostProcess(postProcess: PostProcess): void;
  91746. /**
  91747. * Gets the current world matrix of the camera
  91748. */
  91749. getWorldMatrix(): Matrix;
  91750. /** @hidden */
  91751. _getViewMatrix(): Matrix;
  91752. /**
  91753. * Gets the current view matrix of the camera.
  91754. * @param force forces the camera to recompute the matrix without looking at the cached state
  91755. * @returns the view matrix
  91756. */
  91757. getViewMatrix(force?: boolean): Matrix;
  91758. /**
  91759. * Freeze the projection matrix.
  91760. * It will prevent the cache check of the camera projection compute and can speed up perf
  91761. * if no parameter of the camera are meant to change
  91762. * @param projection Defines manually a projection if necessary
  91763. */
  91764. freezeProjectionMatrix(projection?: Matrix): void;
  91765. /**
  91766. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91767. */
  91768. unfreezeProjectionMatrix(): void;
  91769. /**
  91770. * Gets the current projection matrix of the camera.
  91771. * @param force forces the camera to recompute the matrix without looking at the cached state
  91772. * @returns the projection matrix
  91773. */
  91774. getProjectionMatrix(force?: boolean): Matrix;
  91775. /**
  91776. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91777. * @returns a Matrix
  91778. */
  91779. getTransformationMatrix(): Matrix;
  91780. private _updateFrustumPlanes;
  91781. /**
  91782. * Checks if a cullable object (mesh...) is in the camera frustum
  91783. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91784. * @param target The object to check
  91785. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91786. * @returns true if the object is in frustum otherwise false
  91787. */
  91788. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91789. /**
  91790. * Checks if a cullable object (mesh...) is in the camera frustum
  91791. * Unlike isInFrustum this cheks the full bounding box
  91792. * @param target The object to check
  91793. * @returns true if the object is in frustum otherwise false
  91794. */
  91795. isCompletelyInFrustum(target: ICullable): boolean;
  91796. /**
  91797. * Gets a ray in the forward direction from the camera.
  91798. * @param length Defines the length of the ray to create
  91799. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91800. * @param origin Defines the start point of the ray which defaults to the camera position
  91801. * @returns the forward ray
  91802. */
  91803. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91804. /**
  91805. * Releases resources associated with this node.
  91806. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91807. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91808. */
  91809. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91810. /** @hidden */
  91811. _isLeftCamera: boolean;
  91812. /**
  91813. * Gets the left camera of a rig setup in case of Rigged Camera
  91814. */
  91815. readonly isLeftCamera: boolean;
  91816. /** @hidden */
  91817. _isRightCamera: boolean;
  91818. /**
  91819. * Gets the right camera of a rig setup in case of Rigged Camera
  91820. */
  91821. readonly isRightCamera: boolean;
  91822. /**
  91823. * Gets the left camera of a rig setup in case of Rigged Camera
  91824. */
  91825. readonly leftCamera: Nullable<FreeCamera>;
  91826. /**
  91827. * Gets the right camera of a rig setup in case of Rigged Camera
  91828. */
  91829. readonly rightCamera: Nullable<FreeCamera>;
  91830. /**
  91831. * Gets the left camera target of a rig setup in case of Rigged Camera
  91832. * @returns the target position
  91833. */
  91834. getLeftTarget(): Nullable<Vector3>;
  91835. /**
  91836. * Gets the right camera target of a rig setup in case of Rigged Camera
  91837. * @returns the target position
  91838. */
  91839. getRightTarget(): Nullable<Vector3>;
  91840. /**
  91841. * @hidden
  91842. */
  91843. setCameraRigMode(mode: number, rigParams: any): void;
  91844. /** @hidden */
  91845. static _setStereoscopicRigMode(camera: Camera): void;
  91846. /** @hidden */
  91847. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91848. /** @hidden */
  91849. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91850. /** @hidden */
  91851. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91852. /** @hidden */
  91853. _getVRProjectionMatrix(): Matrix;
  91854. protected _updateCameraRotationMatrix(): void;
  91855. protected _updateWebVRCameraRotationMatrix(): void;
  91856. /**
  91857. * This function MUST be overwritten by the different WebVR cameras available.
  91858. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91859. * @hidden
  91860. */
  91861. _getWebVRProjectionMatrix(): Matrix;
  91862. /**
  91863. * This function MUST be overwritten by the different WebVR cameras available.
  91864. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91865. * @hidden
  91866. */
  91867. _getWebVRViewMatrix(): Matrix;
  91868. /** @hidden */
  91869. setCameraRigParameter(name: string, value: any): void;
  91870. /**
  91871. * needs to be overridden by children so sub has required properties to be copied
  91872. * @hidden
  91873. */
  91874. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91875. /**
  91876. * May need to be overridden by children
  91877. * @hidden
  91878. */
  91879. _updateRigCameras(): void;
  91880. /** @hidden */
  91881. _setupInputs(): void;
  91882. /**
  91883. * Serialiaze the camera setup to a json represention
  91884. * @returns the JSON representation
  91885. */
  91886. serialize(): any;
  91887. /**
  91888. * Clones the current camera.
  91889. * @param name The cloned camera name
  91890. * @returns the cloned camera
  91891. */
  91892. clone(name: string): Camera;
  91893. /**
  91894. * Gets the direction of the camera relative to a given local axis.
  91895. * @param localAxis Defines the reference axis to provide a relative direction.
  91896. * @return the direction
  91897. */
  91898. getDirection(localAxis: Vector3): Vector3;
  91899. /**
  91900. * Returns the current camera absolute rotation
  91901. */
  91902. readonly absoluteRotation: Quaternion;
  91903. /**
  91904. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91905. * @param localAxis Defines the reference axis to provide a relative direction.
  91906. * @param result Defines the vector to store the result in
  91907. */
  91908. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91909. /**
  91910. * Gets a camera constructor for a given camera type
  91911. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91912. * @param name The name of the camera the result will be able to instantiate
  91913. * @param scene The scene the result will construct the camera in
  91914. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91915. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91916. * @returns a factory method to construc the camera
  91917. */
  91918. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91919. /**
  91920. * Compute the world matrix of the camera.
  91921. * @returns the camera workd matrix
  91922. */
  91923. computeWorldMatrix(): Matrix;
  91924. /**
  91925. * Parse a JSON and creates the camera from the parsed information
  91926. * @param parsedCamera The JSON to parse
  91927. * @param scene The scene to instantiate the camera in
  91928. * @returns the newly constructed camera
  91929. */
  91930. static Parse(parsedCamera: any, scene: Scene): Camera;
  91931. }
  91932. }
  91933. declare module BABYLON {
  91934. /**
  91935. * Class containing static functions to help procedurally build meshes
  91936. */
  91937. export class DiscBuilder {
  91938. /**
  91939. * Creates a plane polygonal mesh. By default, this is a disc
  91940. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91941. * * 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
  91942. * * 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
  91943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91946. * @param name defines the name of the mesh
  91947. * @param options defines the options used to create the mesh
  91948. * @param scene defines the hosting scene
  91949. * @returns the plane polygonal mesh
  91950. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91951. */
  91952. static CreateDisc(name: string, options: {
  91953. radius?: number;
  91954. tessellation?: number;
  91955. arc?: number;
  91956. updatable?: boolean;
  91957. sideOrientation?: number;
  91958. frontUVs?: Vector4;
  91959. backUVs?: Vector4;
  91960. }, scene?: Nullable<Scene>): Mesh;
  91961. }
  91962. }
  91963. declare module BABYLON {
  91964. /**
  91965. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91966. *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.
  91967. * The SPS is also a particle system. It provides some methods to manage the particles.
  91968. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91969. *
  91970. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91971. */
  91972. export class SolidParticleSystem implements IDisposable {
  91973. /**
  91974. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91975. * Example : var p = SPS.particles[i];
  91976. */
  91977. particles: SolidParticle[];
  91978. /**
  91979. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91980. */
  91981. nbParticles: number;
  91982. /**
  91983. * If the particles must ever face the camera (default false). Useful for planar particles.
  91984. */
  91985. billboard: boolean;
  91986. /**
  91987. * Recompute normals when adding a shape
  91988. */
  91989. recomputeNormals: boolean;
  91990. /**
  91991. * This a counter ofr your own usage. It's not set by any SPS functions.
  91992. */
  91993. counter: number;
  91994. /**
  91995. * The SPS name. This name is also given to the underlying mesh.
  91996. */
  91997. name: string;
  91998. /**
  91999. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92000. */
  92001. mesh: Mesh;
  92002. /**
  92003. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92004. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92005. */
  92006. vars: any;
  92007. /**
  92008. * This array is populated when the SPS is set as 'pickable'.
  92009. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92010. * Each element of this array is an object `{idx: int, faceId: int}`.
  92011. * `idx` is the picked particle index in the `SPS.particles` array
  92012. * `faceId` is the picked face index counted within this particle.
  92013. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92014. */
  92015. pickedParticles: {
  92016. idx: number;
  92017. faceId: number;
  92018. }[];
  92019. /**
  92020. * This array is populated when `enableDepthSort` is set to true.
  92021. * Each element of this array is an instance of the class DepthSortedParticle.
  92022. */
  92023. depthSortedParticles: DepthSortedParticle[];
  92024. /**
  92025. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92026. * @hidden
  92027. */
  92028. _bSphereOnly: boolean;
  92029. /**
  92030. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92031. * @hidden
  92032. */
  92033. _bSphereRadiusFactor: number;
  92034. private _scene;
  92035. private _positions;
  92036. private _indices;
  92037. private _normals;
  92038. private _colors;
  92039. private _uvs;
  92040. private _indices32;
  92041. private _positions32;
  92042. private _normals32;
  92043. private _fixedNormal32;
  92044. private _colors32;
  92045. private _uvs32;
  92046. private _index;
  92047. private _updatable;
  92048. private _pickable;
  92049. private _isVisibilityBoxLocked;
  92050. private _alwaysVisible;
  92051. private _depthSort;
  92052. private _shapeCounter;
  92053. private _copy;
  92054. private _color;
  92055. private _computeParticleColor;
  92056. private _computeParticleTexture;
  92057. private _computeParticleRotation;
  92058. private _computeParticleVertex;
  92059. private _computeBoundingBox;
  92060. private _depthSortParticles;
  92061. private _camera;
  92062. private _mustUnrotateFixedNormals;
  92063. private _particlesIntersect;
  92064. private _needs32Bits;
  92065. /**
  92066. * Creates a SPS (Solid Particle System) object.
  92067. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92068. * @param scene (Scene) is the scene in which the SPS is added.
  92069. * @param options defines the options of the sps e.g.
  92070. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92071. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92072. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92073. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92074. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92075. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92076. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92077. */
  92078. constructor(name: string, scene: Scene, options?: {
  92079. updatable?: boolean;
  92080. isPickable?: boolean;
  92081. enableDepthSort?: boolean;
  92082. particleIntersection?: boolean;
  92083. boundingSphereOnly?: boolean;
  92084. bSphereRadiusFactor?: number;
  92085. });
  92086. /**
  92087. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92088. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92089. * @returns the created mesh
  92090. */
  92091. buildMesh(): Mesh;
  92092. /**
  92093. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92094. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92095. * Thus the particles generated from `digest()` have their property `position` set yet.
  92096. * @param mesh ( Mesh ) is the mesh to be digested
  92097. * @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
  92098. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92099. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92100. * @returns the current SPS
  92101. */
  92102. digest(mesh: Mesh, options?: {
  92103. facetNb?: number;
  92104. number?: number;
  92105. delta?: number;
  92106. }): SolidParticleSystem;
  92107. private _unrotateFixedNormals;
  92108. private _resetCopy;
  92109. private _meshBuilder;
  92110. private _posToShape;
  92111. private _uvsToShapeUV;
  92112. private _addParticle;
  92113. /**
  92114. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92115. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92116. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92117. * @param nb (positive integer) the number of particles to be created from this model
  92118. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92119. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92120. * @returns the number of shapes in the system
  92121. */
  92122. addShape(mesh: Mesh, nb: number, options?: {
  92123. positionFunction?: any;
  92124. vertexFunction?: any;
  92125. }): number;
  92126. private _rebuildParticle;
  92127. /**
  92128. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92129. * @returns the SPS.
  92130. */
  92131. rebuildMesh(): SolidParticleSystem;
  92132. /**
  92133. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92134. * This method calls `updateParticle()` for each particle of the SPS.
  92135. * For an animated SPS, it is usually called within the render loop.
  92136. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92137. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92138. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92139. * @returns the SPS.
  92140. */
  92141. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92142. /**
  92143. * Disposes the SPS.
  92144. */
  92145. dispose(): void;
  92146. /**
  92147. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92148. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92149. * @returns the SPS.
  92150. */
  92151. refreshVisibleSize(): SolidParticleSystem;
  92152. /**
  92153. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92154. * @param size the size (float) of the visibility box
  92155. * note : this doesn't lock the SPS mesh bounding box.
  92156. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92157. */
  92158. setVisibilityBox(size: number): void;
  92159. /**
  92160. * Gets whether the SPS as always visible or not
  92161. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92162. */
  92163. /**
  92164. * Sets the SPS as always visible or not
  92165. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92166. */
  92167. isAlwaysVisible: boolean;
  92168. /**
  92169. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92170. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92171. */
  92172. /**
  92173. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92174. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92175. */
  92176. isVisibilityBoxLocked: boolean;
  92177. /**
  92178. * Tells to `setParticles()` to compute the particle rotations or not.
  92179. * Default value : true. The SPS is faster when it's set to false.
  92180. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92181. */
  92182. /**
  92183. * Gets if `setParticles()` computes the particle rotations or not.
  92184. * Default value : true. The SPS is faster when it's set to false.
  92185. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92186. */
  92187. computeParticleRotation: boolean;
  92188. /**
  92189. * Tells to `setParticles()` to compute the particle colors or not.
  92190. * Default value : true. The SPS is faster when it's set to false.
  92191. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92192. */
  92193. /**
  92194. * Gets if `setParticles()` computes the particle colors or not.
  92195. * Default value : true. The SPS is faster when it's set to false.
  92196. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92197. */
  92198. computeParticleColor: boolean;
  92199. /**
  92200. * Gets if `setParticles()` computes the particle textures or not.
  92201. * Default value : true. The SPS is faster when it's set to false.
  92202. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92203. */
  92204. computeParticleTexture: boolean;
  92205. /**
  92206. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92207. * Default value : false. The SPS is faster when it's set to false.
  92208. * Note : the particle custom vertex positions aren't stored values.
  92209. */
  92210. /**
  92211. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92212. * Default value : false. The SPS is faster when it's set to false.
  92213. * Note : the particle custom vertex positions aren't stored values.
  92214. */
  92215. computeParticleVertex: boolean;
  92216. /**
  92217. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92218. */
  92219. /**
  92220. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92221. */
  92222. computeBoundingBox: boolean;
  92223. /**
  92224. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92225. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92226. * Default : `true`
  92227. */
  92228. /**
  92229. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92230. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92231. * Default : `true`
  92232. */
  92233. depthSortParticles: boolean;
  92234. /**
  92235. * This function does nothing. It may be overwritten to set all the particle first values.
  92236. * The SPS doesn't call this function, you may have to call it by your own.
  92237. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92238. */
  92239. initParticles(): void;
  92240. /**
  92241. * This function does nothing. It may be overwritten to recycle a particle.
  92242. * The SPS doesn't call this function, you may have to call it by your own.
  92243. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92244. * @param particle The particle to recycle
  92245. * @returns the recycled particle
  92246. */
  92247. recycleParticle(particle: SolidParticle): SolidParticle;
  92248. /**
  92249. * Updates a particle : this function should be overwritten by the user.
  92250. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92252. * @example : just set a particle position or velocity and recycle conditions
  92253. * @param particle The particle to update
  92254. * @returns the updated particle
  92255. */
  92256. updateParticle(particle: SolidParticle): SolidParticle;
  92257. /**
  92258. * Updates a vertex of a particle : it can be overwritten by the user.
  92259. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92260. * @param particle the current particle
  92261. * @param vertex the current index of the current particle
  92262. * @param pt the index of the current vertex in the particle shape
  92263. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92264. * @example : just set a vertex particle position
  92265. * @returns the updated vertex
  92266. */
  92267. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92268. /**
  92269. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92270. * This does nothing and may be overwritten by the user.
  92271. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92272. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92273. * @param update the boolean update value actually passed to setParticles()
  92274. */
  92275. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92276. /**
  92277. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92278. * This will be passed three parameters.
  92279. * This does nothing and may be overwritten by the user.
  92280. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92281. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92282. * @param update the boolean update value actually passed to setParticles()
  92283. */
  92284. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92285. }
  92286. }
  92287. declare module BABYLON {
  92288. /**
  92289. * Represents one particle of a solid particle system.
  92290. */
  92291. export class SolidParticle {
  92292. /**
  92293. * particle global index
  92294. */
  92295. idx: number;
  92296. /**
  92297. * The color of the particle
  92298. */
  92299. color: Nullable<Color4>;
  92300. /**
  92301. * The world space position of the particle.
  92302. */
  92303. position: Vector3;
  92304. /**
  92305. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92306. */
  92307. rotation: Vector3;
  92308. /**
  92309. * The world space rotation quaternion of the particle.
  92310. */
  92311. rotationQuaternion: Nullable<Quaternion>;
  92312. /**
  92313. * The scaling of the particle.
  92314. */
  92315. scaling: Vector3;
  92316. /**
  92317. * The uvs of the particle.
  92318. */
  92319. uvs: Vector4;
  92320. /**
  92321. * The current speed of the particle.
  92322. */
  92323. velocity: Vector3;
  92324. /**
  92325. * The pivot point in the particle local space.
  92326. */
  92327. pivot: Vector3;
  92328. /**
  92329. * Must the particle be translated from its pivot point in its local space ?
  92330. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92331. * Default : false
  92332. */
  92333. translateFromPivot: boolean;
  92334. /**
  92335. * Is the particle active or not ?
  92336. */
  92337. alive: boolean;
  92338. /**
  92339. * Is the particle visible or not ?
  92340. */
  92341. isVisible: boolean;
  92342. /**
  92343. * Index of this particle in the global "positions" array (Internal use)
  92344. * @hidden
  92345. */
  92346. _pos: number;
  92347. /**
  92348. * @hidden Index of this particle in the global "indices" array (Internal use)
  92349. */
  92350. _ind: number;
  92351. /**
  92352. * @hidden ModelShape of this particle (Internal use)
  92353. */
  92354. _model: ModelShape;
  92355. /**
  92356. * ModelShape id of this particle
  92357. */
  92358. shapeId: number;
  92359. /**
  92360. * Index of the particle in its shape id
  92361. */
  92362. idxInShape: number;
  92363. /**
  92364. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92365. */
  92366. _modelBoundingInfo: BoundingInfo;
  92367. /**
  92368. * @hidden Particle BoundingInfo object (Internal use)
  92369. */
  92370. _boundingInfo: BoundingInfo;
  92371. /**
  92372. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92373. */
  92374. _sps: SolidParticleSystem;
  92375. /**
  92376. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92377. */
  92378. _stillInvisible: boolean;
  92379. /**
  92380. * @hidden Last computed particle rotation matrix
  92381. */
  92382. _rotationMatrix: number[];
  92383. /**
  92384. * Parent particle Id, if any.
  92385. * Default null.
  92386. */
  92387. parentId: Nullable<number>;
  92388. /**
  92389. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92390. * The possible values are :
  92391. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92392. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92393. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92394. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92395. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92396. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92397. * */
  92398. cullingStrategy: number;
  92399. /**
  92400. * @hidden Internal global position in the SPS.
  92401. */
  92402. _globalPosition: Vector3;
  92403. /**
  92404. * Creates a Solid Particle object.
  92405. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92406. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92407. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92408. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92409. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92410. * @param shapeId (integer) is the model shape identifier in the SPS.
  92411. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92412. * @param sps defines the sps it is associated to
  92413. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92414. */
  92415. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92416. /**
  92417. * Legacy support, changed scale to scaling
  92418. */
  92419. /**
  92420. * Legacy support, changed scale to scaling
  92421. */
  92422. scale: Vector3;
  92423. /**
  92424. * Legacy support, changed quaternion to rotationQuaternion
  92425. */
  92426. /**
  92427. * Legacy support, changed quaternion to rotationQuaternion
  92428. */
  92429. quaternion: Nullable<Quaternion>;
  92430. /**
  92431. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92432. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92433. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92434. * @returns true if it intersects
  92435. */
  92436. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92437. /**
  92438. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92439. * A particle is in the frustum if its bounding box intersects the frustum
  92440. * @param frustumPlanes defines the frustum to test
  92441. * @returns true if the particle is in the frustum planes
  92442. */
  92443. isInFrustum(frustumPlanes: Plane[]): boolean;
  92444. /**
  92445. * get the rotation matrix of the particle
  92446. * @hidden
  92447. */
  92448. getRotationMatrix(m: Matrix): void;
  92449. }
  92450. /**
  92451. * Represents the shape of the model used by one particle of a solid particle system.
  92452. * SPS internal tool, don't use it manually.
  92453. */
  92454. export class ModelShape {
  92455. /**
  92456. * The shape id
  92457. * @hidden
  92458. */
  92459. shapeID: number;
  92460. /**
  92461. * flat array of model positions (internal use)
  92462. * @hidden
  92463. */
  92464. _shape: Vector3[];
  92465. /**
  92466. * flat array of model UVs (internal use)
  92467. * @hidden
  92468. */
  92469. _shapeUV: number[];
  92470. /**
  92471. * length of the shape in the model indices array (internal use)
  92472. * @hidden
  92473. */
  92474. _indicesLength: number;
  92475. /**
  92476. * Custom position function (internal use)
  92477. * @hidden
  92478. */
  92479. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92480. /**
  92481. * Custom vertex function (internal use)
  92482. * @hidden
  92483. */
  92484. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92485. /**
  92486. * 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.
  92487. * SPS internal tool, don't use it manually.
  92488. * @hidden
  92489. */
  92490. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  92491. }
  92492. /**
  92493. * Represents a Depth Sorted Particle in the solid particle system.
  92494. */
  92495. export class DepthSortedParticle {
  92496. /**
  92497. * Index of the particle in the "indices" array
  92498. */
  92499. ind: number;
  92500. /**
  92501. * Length of the particle shape in the "indices" array
  92502. */
  92503. indicesLength: number;
  92504. /**
  92505. * Squared distance from the particle to the camera
  92506. */
  92507. sqDistance: number;
  92508. }
  92509. }
  92510. declare module BABYLON {
  92511. /**
  92512. * @hidden
  92513. */
  92514. export class _MeshCollisionData {
  92515. _checkCollisions: boolean;
  92516. _collisionMask: number;
  92517. _collisionGroup: number;
  92518. _collider: Nullable<Collider>;
  92519. _oldPositionForCollisions: Vector3;
  92520. _diffPositionForCollisions: Vector3;
  92521. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92522. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92523. }
  92524. }
  92525. declare module BABYLON {
  92526. /** @hidden */
  92527. class _FacetDataStorage {
  92528. facetPositions: Vector3[];
  92529. facetNormals: Vector3[];
  92530. facetPartitioning: number[][];
  92531. facetNb: number;
  92532. partitioningSubdivisions: number;
  92533. partitioningBBoxRatio: number;
  92534. facetDataEnabled: boolean;
  92535. facetParameters: any;
  92536. bbSize: Vector3;
  92537. subDiv: {
  92538. max: number;
  92539. X: number;
  92540. Y: number;
  92541. Z: number;
  92542. };
  92543. facetDepthSort: boolean;
  92544. facetDepthSortEnabled: boolean;
  92545. depthSortedIndices: IndicesArray;
  92546. depthSortedFacets: {
  92547. ind: number;
  92548. sqDistance: number;
  92549. }[];
  92550. facetDepthSortFunction: (f1: {
  92551. ind: number;
  92552. sqDistance: number;
  92553. }, f2: {
  92554. ind: number;
  92555. sqDistance: number;
  92556. }) => number;
  92557. facetDepthSortFrom: Vector3;
  92558. facetDepthSortOrigin: Vector3;
  92559. invertedMatrix: Matrix;
  92560. }
  92561. /**
  92562. * @hidden
  92563. **/
  92564. class _InternalAbstractMeshDataInfo {
  92565. _hasVertexAlpha: boolean;
  92566. _useVertexColors: boolean;
  92567. _numBoneInfluencers: number;
  92568. _applyFog: boolean;
  92569. _receiveShadows: boolean;
  92570. _facetData: _FacetDataStorage;
  92571. _visibility: number;
  92572. _skeleton: Nullable<Skeleton>;
  92573. _layerMask: number;
  92574. _computeBonesUsingShaders: boolean;
  92575. _isActive: boolean;
  92576. _onlyForInstances: boolean;
  92577. _isActiveIntermediate: boolean;
  92578. _onlyForInstancesIntermediate: boolean;
  92579. }
  92580. /**
  92581. * Class used to store all common mesh properties
  92582. */
  92583. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92584. /** No occlusion */
  92585. static OCCLUSION_TYPE_NONE: number;
  92586. /** Occlusion set to optimisitic */
  92587. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92588. /** Occlusion set to strict */
  92589. static OCCLUSION_TYPE_STRICT: number;
  92590. /** Use an accurante occlusion algorithm */
  92591. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92592. /** Use a conservative occlusion algorithm */
  92593. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92594. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92595. * Test order :
  92596. * Is the bounding sphere outside the frustum ?
  92597. * If not, are the bounding box vertices outside the frustum ?
  92598. * It not, then the cullable object is in the frustum.
  92599. */
  92600. static readonly CULLINGSTRATEGY_STANDARD: number;
  92601. /** Culling strategy : Bounding Sphere Only.
  92602. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92603. * It's also less accurate than the standard because some not visible objects can still be selected.
  92604. * Test : is the bounding sphere outside the frustum ?
  92605. * If not, then the cullable object is in the frustum.
  92606. */
  92607. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92608. /** Culling strategy : Optimistic Inclusion.
  92609. * This in an inclusion test first, then the standard exclusion test.
  92610. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92611. * 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.
  92612. * Anyway, it's as accurate as the standard strategy.
  92613. * Test :
  92614. * Is the cullable object bounding sphere center in the frustum ?
  92615. * If not, apply the default culling strategy.
  92616. */
  92617. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92618. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92619. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92620. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92621. * 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.
  92622. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92623. * Test :
  92624. * Is the cullable object bounding sphere center in the frustum ?
  92625. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92626. */
  92627. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92628. /**
  92629. * No billboard
  92630. */
  92631. static readonly BILLBOARDMODE_NONE: number;
  92632. /** Billboard on X axis */
  92633. static readonly BILLBOARDMODE_X: number;
  92634. /** Billboard on Y axis */
  92635. static readonly BILLBOARDMODE_Y: number;
  92636. /** Billboard on Z axis */
  92637. static readonly BILLBOARDMODE_Z: number;
  92638. /** Billboard on all axes */
  92639. static readonly BILLBOARDMODE_ALL: number;
  92640. /** Billboard on using position instead of orientation */
  92641. static readonly BILLBOARDMODE_USE_POSITION: number;
  92642. /** @hidden */
  92643. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92644. /**
  92645. * The culling strategy to use to check whether the mesh must be rendered or not.
  92646. * This value can be changed at any time and will be used on the next render mesh selection.
  92647. * The possible values are :
  92648. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92649. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92650. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92651. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92652. * Please read each static variable documentation to get details about the culling process.
  92653. * */
  92654. cullingStrategy: number;
  92655. /**
  92656. * Gets the number of facets in the mesh
  92657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92658. */
  92659. readonly facetNb: number;
  92660. /**
  92661. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92663. */
  92664. partitioningSubdivisions: number;
  92665. /**
  92666. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92667. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92669. */
  92670. partitioningBBoxRatio: number;
  92671. /**
  92672. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92673. * Works only for updatable meshes.
  92674. * Doesn't work with multi-materials
  92675. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92676. */
  92677. mustDepthSortFacets: boolean;
  92678. /**
  92679. * The location (Vector3) where the facet depth sort must be computed from.
  92680. * By default, the active camera position.
  92681. * Used only when facet depth sort is enabled
  92682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92683. */
  92684. facetDepthSortFrom: Vector3;
  92685. /**
  92686. * gets a boolean indicating if facetData is enabled
  92687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92688. */
  92689. readonly isFacetDataEnabled: boolean;
  92690. /** @hidden */
  92691. _updateNonUniformScalingState(value: boolean): boolean;
  92692. /**
  92693. * An event triggered when this mesh collides with another one
  92694. */
  92695. onCollideObservable: Observable<AbstractMesh>;
  92696. /** Set a function to call when this mesh collides with another one */
  92697. onCollide: () => void;
  92698. /**
  92699. * An event triggered when the collision's position changes
  92700. */
  92701. onCollisionPositionChangeObservable: Observable<Vector3>;
  92702. /** Set a function to call when the collision's position changes */
  92703. onCollisionPositionChange: () => void;
  92704. /**
  92705. * An event triggered when material is changed
  92706. */
  92707. onMaterialChangedObservable: Observable<AbstractMesh>;
  92708. /**
  92709. * Gets or sets the orientation for POV movement & rotation
  92710. */
  92711. definedFacingForward: boolean;
  92712. /** @hidden */
  92713. _occlusionQuery: Nullable<WebGLQuery>;
  92714. /** @hidden */
  92715. _renderingGroup: Nullable<RenderingGroup>;
  92716. /**
  92717. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92718. */
  92719. /**
  92720. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92721. */
  92722. visibility: number;
  92723. /** Gets or sets the alpha index used to sort transparent meshes
  92724. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92725. */
  92726. alphaIndex: number;
  92727. /**
  92728. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92729. */
  92730. isVisible: boolean;
  92731. /**
  92732. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92733. */
  92734. isPickable: boolean;
  92735. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92736. showSubMeshesBoundingBox: boolean;
  92737. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92738. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92739. */
  92740. isBlocker: boolean;
  92741. /**
  92742. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92743. */
  92744. enablePointerMoveEvents: boolean;
  92745. /**
  92746. * Specifies the rendering group id for this mesh (0 by default)
  92747. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92748. */
  92749. renderingGroupId: number;
  92750. private _material;
  92751. /** Gets or sets current material */
  92752. material: Nullable<Material>;
  92753. /**
  92754. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92755. * @see http://doc.babylonjs.com/babylon101/shadows
  92756. */
  92757. receiveShadows: boolean;
  92758. /** Defines color to use when rendering outline */
  92759. outlineColor: Color3;
  92760. /** Define width to use when rendering outline */
  92761. outlineWidth: number;
  92762. /** Defines color to use when rendering overlay */
  92763. overlayColor: Color3;
  92764. /** Defines alpha to use when rendering overlay */
  92765. overlayAlpha: number;
  92766. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92767. hasVertexAlpha: boolean;
  92768. /** 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) */
  92769. useVertexColors: boolean;
  92770. /**
  92771. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92772. */
  92773. computeBonesUsingShaders: boolean;
  92774. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92775. numBoneInfluencers: number;
  92776. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92777. applyFog: boolean;
  92778. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92779. useOctreeForRenderingSelection: boolean;
  92780. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92781. useOctreeForPicking: boolean;
  92782. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92783. useOctreeForCollisions: boolean;
  92784. /**
  92785. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92786. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92787. */
  92788. layerMask: number;
  92789. /**
  92790. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92791. */
  92792. alwaysSelectAsActiveMesh: boolean;
  92793. /**
  92794. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92795. */
  92796. doNotSyncBoundingInfo: boolean;
  92797. /**
  92798. * Gets or sets the current action manager
  92799. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92800. */
  92801. actionManager: Nullable<AbstractActionManager>;
  92802. private _meshCollisionData;
  92803. /**
  92804. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92805. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92806. */
  92807. ellipsoid: Vector3;
  92808. /**
  92809. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92811. */
  92812. ellipsoidOffset: Vector3;
  92813. /**
  92814. * Gets or sets a collision mask used to mask collisions (default is -1).
  92815. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92816. */
  92817. collisionMask: number;
  92818. /**
  92819. * Gets or sets the current collision group mask (-1 by default).
  92820. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92821. */
  92822. collisionGroup: number;
  92823. /**
  92824. * Defines edge width used when edgesRenderer is enabled
  92825. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92826. */
  92827. edgesWidth: number;
  92828. /**
  92829. * Defines edge color used when edgesRenderer is enabled
  92830. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92831. */
  92832. edgesColor: Color4;
  92833. /** @hidden */
  92834. _edgesRenderer: Nullable<IEdgesRenderer>;
  92835. /** @hidden */
  92836. _masterMesh: Nullable<AbstractMesh>;
  92837. /** @hidden */
  92838. _boundingInfo: Nullable<BoundingInfo>;
  92839. /** @hidden */
  92840. _renderId: number;
  92841. /**
  92842. * Gets or sets the list of subMeshes
  92843. * @see http://doc.babylonjs.com/how_to/multi_materials
  92844. */
  92845. subMeshes: SubMesh[];
  92846. /** @hidden */
  92847. _intersectionsInProgress: AbstractMesh[];
  92848. /** @hidden */
  92849. _unIndexed: boolean;
  92850. /** @hidden */
  92851. _lightSources: Light[];
  92852. /** Gets the list of lights affecting that mesh */
  92853. readonly lightSources: Light[];
  92854. /** @hidden */
  92855. readonly _positions: Nullable<Vector3[]>;
  92856. /** @hidden */
  92857. _waitingData: {
  92858. lods: Nullable<any>;
  92859. actions: Nullable<any>;
  92860. freezeWorldMatrix: Nullable<boolean>;
  92861. };
  92862. /** @hidden */
  92863. _bonesTransformMatrices: Nullable<Float32Array>;
  92864. /** @hidden */
  92865. _transformMatrixTexture: Nullable<RawTexture>;
  92866. /**
  92867. * Gets or sets a skeleton to apply skining transformations
  92868. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92869. */
  92870. skeleton: Nullable<Skeleton>;
  92871. /**
  92872. * An event triggered when the mesh is rebuilt.
  92873. */
  92874. onRebuildObservable: Observable<AbstractMesh>;
  92875. /**
  92876. * Creates a new AbstractMesh
  92877. * @param name defines the name of the mesh
  92878. * @param scene defines the hosting scene
  92879. */
  92880. constructor(name: string, scene?: Nullable<Scene>);
  92881. /**
  92882. * Returns the string "AbstractMesh"
  92883. * @returns "AbstractMesh"
  92884. */
  92885. getClassName(): string;
  92886. /**
  92887. * Gets a string representation of the current mesh
  92888. * @param fullDetails defines a boolean indicating if full details must be included
  92889. * @returns a string representation of the current mesh
  92890. */
  92891. toString(fullDetails?: boolean): string;
  92892. /**
  92893. * @hidden
  92894. */
  92895. protected _getEffectiveParent(): Nullable<Node>;
  92896. /** @hidden */
  92897. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92898. /** @hidden */
  92899. _rebuild(): void;
  92900. /** @hidden */
  92901. _resyncLightSources(): void;
  92902. /** @hidden */
  92903. _resyncLighSource(light: Light): void;
  92904. /** @hidden */
  92905. _unBindEffect(): void;
  92906. /** @hidden */
  92907. _removeLightSource(light: Light, dispose: boolean): void;
  92908. private _markSubMeshesAsDirty;
  92909. /** @hidden */
  92910. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92911. /** @hidden */
  92912. _markSubMeshesAsAttributesDirty(): void;
  92913. /** @hidden */
  92914. _markSubMeshesAsMiscDirty(): void;
  92915. /**
  92916. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92917. */
  92918. scaling: Vector3;
  92919. /**
  92920. * Returns true if the mesh is blocked. Implemented by child classes
  92921. */
  92922. readonly isBlocked: boolean;
  92923. /**
  92924. * Returns the mesh itself by default. Implemented by child classes
  92925. * @param camera defines the camera to use to pick the right LOD level
  92926. * @returns the currentAbstractMesh
  92927. */
  92928. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92929. /**
  92930. * Returns 0 by default. Implemented by child classes
  92931. * @returns an integer
  92932. */
  92933. getTotalVertices(): number;
  92934. /**
  92935. * Returns a positive integer : the total number of indices in this mesh geometry.
  92936. * @returns the numner of indices or zero if the mesh has no geometry.
  92937. */
  92938. getTotalIndices(): number;
  92939. /**
  92940. * Returns null by default. Implemented by child classes
  92941. * @returns null
  92942. */
  92943. getIndices(): Nullable<IndicesArray>;
  92944. /**
  92945. * Returns the array of the requested vertex data kind. Implemented by child classes
  92946. * @param kind defines the vertex data kind to use
  92947. * @returns null
  92948. */
  92949. getVerticesData(kind: string): Nullable<FloatArray>;
  92950. /**
  92951. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92952. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92953. * Note that a new underlying VertexBuffer object is created each call.
  92954. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92955. * @param kind defines vertex data kind:
  92956. * * VertexBuffer.PositionKind
  92957. * * VertexBuffer.UVKind
  92958. * * VertexBuffer.UV2Kind
  92959. * * VertexBuffer.UV3Kind
  92960. * * VertexBuffer.UV4Kind
  92961. * * VertexBuffer.UV5Kind
  92962. * * VertexBuffer.UV6Kind
  92963. * * VertexBuffer.ColorKind
  92964. * * VertexBuffer.MatricesIndicesKind
  92965. * * VertexBuffer.MatricesIndicesExtraKind
  92966. * * VertexBuffer.MatricesWeightsKind
  92967. * * VertexBuffer.MatricesWeightsExtraKind
  92968. * @param data defines the data source
  92969. * @param updatable defines if the data must be flagged as updatable (or static)
  92970. * @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
  92971. * @returns the current mesh
  92972. */
  92973. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92974. /**
  92975. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92976. * If the mesh has no geometry, it is simply returned as it is.
  92977. * @param kind defines vertex data kind:
  92978. * * VertexBuffer.PositionKind
  92979. * * VertexBuffer.UVKind
  92980. * * VertexBuffer.UV2Kind
  92981. * * VertexBuffer.UV3Kind
  92982. * * VertexBuffer.UV4Kind
  92983. * * VertexBuffer.UV5Kind
  92984. * * VertexBuffer.UV6Kind
  92985. * * VertexBuffer.ColorKind
  92986. * * VertexBuffer.MatricesIndicesKind
  92987. * * VertexBuffer.MatricesIndicesExtraKind
  92988. * * VertexBuffer.MatricesWeightsKind
  92989. * * VertexBuffer.MatricesWeightsExtraKind
  92990. * @param data defines the data source
  92991. * @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
  92992. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92993. * @returns the current mesh
  92994. */
  92995. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92996. /**
  92997. * Sets the mesh indices,
  92998. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92999. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93000. * @param totalVertices Defines the total number of vertices
  93001. * @returns the current mesh
  93002. */
  93003. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93004. /**
  93005. * Gets a boolean indicating if specific vertex data is present
  93006. * @param kind defines the vertex data kind to use
  93007. * @returns true is data kind is present
  93008. */
  93009. isVerticesDataPresent(kind: string): boolean;
  93010. /**
  93011. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93012. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93013. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93014. * @returns a BoundingInfo
  93015. */
  93016. getBoundingInfo(): BoundingInfo;
  93017. /**
  93018. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93019. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93020. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93021. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93022. * @returns the current mesh
  93023. */
  93024. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93025. /**
  93026. * Overwrite the current bounding info
  93027. * @param boundingInfo defines the new bounding info
  93028. * @returns the current mesh
  93029. */
  93030. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93031. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93032. readonly useBones: boolean;
  93033. /** @hidden */
  93034. _preActivate(): void;
  93035. /** @hidden */
  93036. _preActivateForIntermediateRendering(renderId: number): void;
  93037. /** @hidden */
  93038. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93039. /** @hidden */
  93040. _postActivate(): void;
  93041. /** @hidden */
  93042. _freeze(): void;
  93043. /** @hidden */
  93044. _unFreeze(): void;
  93045. /**
  93046. * Gets the current world matrix
  93047. * @returns a Matrix
  93048. */
  93049. getWorldMatrix(): Matrix;
  93050. /** @hidden */
  93051. _getWorldMatrixDeterminant(): number;
  93052. /**
  93053. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93054. */
  93055. readonly isAnInstance: boolean;
  93056. /**
  93057. * Gets a boolean indicating if this mesh has instances
  93058. */
  93059. readonly hasInstances: boolean;
  93060. /**
  93061. * Perform relative position change from the point of view of behind the front of the mesh.
  93062. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93063. * Supports definition of mesh facing forward or backward
  93064. * @param amountRight defines the distance on the right axis
  93065. * @param amountUp defines the distance on the up axis
  93066. * @param amountForward defines the distance on the forward axis
  93067. * @returns the current mesh
  93068. */
  93069. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93070. /**
  93071. * Calculate relative position change from the point of view of behind the front of the mesh.
  93072. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93073. * Supports definition of mesh facing forward or backward
  93074. * @param amountRight defines the distance on the right axis
  93075. * @param amountUp defines the distance on the up axis
  93076. * @param amountForward defines the distance on the forward axis
  93077. * @returns the new displacement vector
  93078. */
  93079. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93080. /**
  93081. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93082. * Supports definition of mesh facing forward or backward
  93083. * @param flipBack defines the flip
  93084. * @param twirlClockwise defines the twirl
  93085. * @param tiltRight defines the tilt
  93086. * @returns the current mesh
  93087. */
  93088. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93089. /**
  93090. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93091. * Supports definition of mesh facing forward or backward.
  93092. * @param flipBack defines the flip
  93093. * @param twirlClockwise defines the twirl
  93094. * @param tiltRight defines the tilt
  93095. * @returns the new rotation vector
  93096. */
  93097. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93098. /**
  93099. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93100. * This means the mesh underlying bounding box and sphere are recomputed.
  93101. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93102. * @returns the current mesh
  93103. */
  93104. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93105. /** @hidden */
  93106. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93107. /** @hidden */
  93108. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93109. /** @hidden */
  93110. _updateBoundingInfo(): AbstractMesh;
  93111. /** @hidden */
  93112. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93113. /** @hidden */
  93114. protected _afterComputeWorldMatrix(): void;
  93115. /** @hidden */
  93116. readonly _effectiveMesh: AbstractMesh;
  93117. /**
  93118. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93119. * A mesh is in the frustum if its bounding box intersects the frustum
  93120. * @param frustumPlanes defines the frustum to test
  93121. * @returns true if the mesh is in the frustum planes
  93122. */
  93123. isInFrustum(frustumPlanes: Plane[]): boolean;
  93124. /**
  93125. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93126. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93127. * @param frustumPlanes defines the frustum to test
  93128. * @returns true if the mesh is completely in the frustum planes
  93129. */
  93130. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93131. /**
  93132. * True if the mesh intersects another mesh or a SolidParticle object
  93133. * @param mesh defines a target mesh or SolidParticle to test
  93134. * @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)
  93135. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93136. * @returns true if there is an intersection
  93137. */
  93138. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93139. /**
  93140. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93141. * @param point defines the point to test
  93142. * @returns true if there is an intersection
  93143. */
  93144. intersectsPoint(point: Vector3): boolean;
  93145. /**
  93146. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93147. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93148. */
  93149. checkCollisions: boolean;
  93150. /**
  93151. * Gets Collider object used to compute collisions (not physics)
  93152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93153. */
  93154. readonly collider: Nullable<Collider>;
  93155. /**
  93156. * Move the mesh using collision engine
  93157. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93158. * @param displacement defines the requested displacement vector
  93159. * @returns the current mesh
  93160. */
  93161. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93162. private _onCollisionPositionChange;
  93163. /** @hidden */
  93164. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93165. /** @hidden */
  93166. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93167. /** @hidden */
  93168. _checkCollision(collider: Collider): AbstractMesh;
  93169. /** @hidden */
  93170. _generatePointsArray(): boolean;
  93171. /**
  93172. * Checks if the passed Ray intersects with the mesh
  93173. * @param ray defines the ray to use
  93174. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93175. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93176. * @returns the picking info
  93177. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93178. */
  93179. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93180. /**
  93181. * Clones the current mesh
  93182. * @param name defines the mesh name
  93183. * @param newParent defines the new mesh parent
  93184. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93185. * @returns the new mesh
  93186. */
  93187. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93188. /**
  93189. * Disposes all the submeshes of the current meshnp
  93190. * @returns the current mesh
  93191. */
  93192. releaseSubMeshes(): AbstractMesh;
  93193. /**
  93194. * Releases resources associated with this abstract mesh.
  93195. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93196. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93197. */
  93198. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93199. /**
  93200. * Adds the passed mesh as a child to the current mesh
  93201. * @param mesh defines the child mesh
  93202. * @returns the current mesh
  93203. */
  93204. addChild(mesh: AbstractMesh): AbstractMesh;
  93205. /**
  93206. * Removes the passed mesh from the current mesh children list
  93207. * @param mesh defines the child mesh
  93208. * @returns the current mesh
  93209. */
  93210. removeChild(mesh: AbstractMesh): AbstractMesh;
  93211. /** @hidden */
  93212. private _initFacetData;
  93213. /**
  93214. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93215. * This method can be called within the render loop.
  93216. * 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
  93217. * @returns the current mesh
  93218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93219. */
  93220. updateFacetData(): AbstractMesh;
  93221. /**
  93222. * Returns the facetLocalNormals array.
  93223. * The normals are expressed in the mesh local spac
  93224. * @returns an array of Vector3
  93225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93226. */
  93227. getFacetLocalNormals(): Vector3[];
  93228. /**
  93229. * Returns the facetLocalPositions array.
  93230. * The facet positions are expressed in the mesh local space
  93231. * @returns an array of Vector3
  93232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93233. */
  93234. getFacetLocalPositions(): Vector3[];
  93235. /**
  93236. * Returns the facetLocalPartioning array
  93237. * @returns an array of array of numbers
  93238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93239. */
  93240. getFacetLocalPartitioning(): number[][];
  93241. /**
  93242. * Returns the i-th facet position in the world system.
  93243. * This method allocates a new Vector3 per call
  93244. * @param i defines the facet index
  93245. * @returns a new Vector3
  93246. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93247. */
  93248. getFacetPosition(i: number): Vector3;
  93249. /**
  93250. * Sets the reference Vector3 with the i-th facet position in the world system
  93251. * @param i defines the facet index
  93252. * @param ref defines the target vector
  93253. * @returns the current mesh
  93254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93255. */
  93256. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93257. /**
  93258. * Returns the i-th facet normal in the world system.
  93259. * This method allocates a new Vector3 per call
  93260. * @param i defines the facet index
  93261. * @returns a new Vector3
  93262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93263. */
  93264. getFacetNormal(i: number): Vector3;
  93265. /**
  93266. * Sets the reference Vector3 with the i-th facet normal in the world system
  93267. * @param i defines the facet index
  93268. * @param ref defines the target vector
  93269. * @returns the current mesh
  93270. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93271. */
  93272. getFacetNormalToRef(i: number, ref: Vector3): this;
  93273. /**
  93274. * 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)
  93275. * @param x defines x coordinate
  93276. * @param y defines y coordinate
  93277. * @param z defines z coordinate
  93278. * @returns the array of facet indexes
  93279. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93280. */
  93281. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93282. /**
  93283. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93284. * @param projected sets as the (x,y,z) world projection on the facet
  93285. * @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
  93286. * @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
  93287. * @param x defines x coordinate
  93288. * @param y defines y coordinate
  93289. * @param z defines z coordinate
  93290. * @returns the face index if found (or null instead)
  93291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93292. */
  93293. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93294. /**
  93295. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93296. * @param projected sets as the (x,y,z) local projection on the facet
  93297. * @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
  93298. * @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
  93299. * @param x defines x coordinate
  93300. * @param y defines y coordinate
  93301. * @param z defines z coordinate
  93302. * @returns the face index if found (or null instead)
  93303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93304. */
  93305. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93306. /**
  93307. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93308. * @returns the parameters
  93309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93310. */
  93311. getFacetDataParameters(): any;
  93312. /**
  93313. * Disables the feature FacetData and frees the related memory
  93314. * @returns the current mesh
  93315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93316. */
  93317. disableFacetData(): AbstractMesh;
  93318. /**
  93319. * Updates the AbstractMesh indices array
  93320. * @param indices defines the data source
  93321. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93322. * @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)
  93323. * @returns the current mesh
  93324. */
  93325. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93326. /**
  93327. * Creates new normals data for the mesh
  93328. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93329. * @returns the current mesh
  93330. */
  93331. createNormals(updatable: boolean): AbstractMesh;
  93332. /**
  93333. * Align the mesh with a normal
  93334. * @param normal defines the normal to use
  93335. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93336. * @returns the current mesh
  93337. */
  93338. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93339. /** @hidden */
  93340. _checkOcclusionQuery(): boolean;
  93341. /**
  93342. * Disables the mesh edge rendering mode
  93343. * @returns the currentAbstractMesh
  93344. */
  93345. disableEdgesRendering(): AbstractMesh;
  93346. /**
  93347. * Enables the edge rendering mode on the mesh.
  93348. * This mode makes the mesh edges visible
  93349. * @param epsilon defines the maximal distance between two angles to detect a face
  93350. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93351. * @returns the currentAbstractMesh
  93352. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93353. */
  93354. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93355. }
  93356. }
  93357. declare module BABYLON {
  93358. /**
  93359. * Interface used to define ActionEvent
  93360. */
  93361. export interface IActionEvent {
  93362. /** The mesh or sprite that triggered the action */
  93363. source: any;
  93364. /** The X mouse cursor position at the time of the event */
  93365. pointerX: number;
  93366. /** The Y mouse cursor position at the time of the event */
  93367. pointerY: number;
  93368. /** The mesh that is currently pointed at (can be null) */
  93369. meshUnderPointer: Nullable<AbstractMesh>;
  93370. /** the original (browser) event that triggered the ActionEvent */
  93371. sourceEvent?: any;
  93372. /** additional data for the event */
  93373. additionalData?: any;
  93374. }
  93375. /**
  93376. * ActionEvent is the event being sent when an action is triggered.
  93377. */
  93378. export class ActionEvent implements IActionEvent {
  93379. /** The mesh or sprite that triggered the action */
  93380. source: any;
  93381. /** The X mouse cursor position at the time of the event */
  93382. pointerX: number;
  93383. /** The Y mouse cursor position at the time of the event */
  93384. pointerY: number;
  93385. /** The mesh that is currently pointed at (can be null) */
  93386. meshUnderPointer: Nullable<AbstractMesh>;
  93387. /** the original (browser) event that triggered the ActionEvent */
  93388. sourceEvent?: any;
  93389. /** additional data for the event */
  93390. additionalData?: any;
  93391. /**
  93392. * Creates a new ActionEvent
  93393. * @param source The mesh or sprite that triggered the action
  93394. * @param pointerX The X mouse cursor position at the time of the event
  93395. * @param pointerY The Y mouse cursor position at the time of the event
  93396. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93397. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93398. * @param additionalData additional data for the event
  93399. */
  93400. constructor(
  93401. /** The mesh or sprite that triggered the action */
  93402. source: any,
  93403. /** The X mouse cursor position at the time of the event */
  93404. pointerX: number,
  93405. /** The Y mouse cursor position at the time of the event */
  93406. pointerY: number,
  93407. /** The mesh that is currently pointed at (can be null) */
  93408. meshUnderPointer: Nullable<AbstractMesh>,
  93409. /** the original (browser) event that triggered the ActionEvent */
  93410. sourceEvent?: any,
  93411. /** additional data for the event */
  93412. additionalData?: any);
  93413. /**
  93414. * Helper function to auto-create an ActionEvent from a source mesh.
  93415. * @param source The source mesh that triggered the event
  93416. * @param evt The original (browser) event
  93417. * @param additionalData additional data for the event
  93418. * @returns the new ActionEvent
  93419. */
  93420. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93421. /**
  93422. * Helper function to auto-create an ActionEvent from a source sprite
  93423. * @param source The source sprite that triggered the event
  93424. * @param scene Scene associated with the sprite
  93425. * @param evt The original (browser) event
  93426. * @param additionalData additional data for the event
  93427. * @returns the new ActionEvent
  93428. */
  93429. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93430. /**
  93431. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93432. * @param scene the scene where the event occurred
  93433. * @param evt The original (browser) event
  93434. * @returns the new ActionEvent
  93435. */
  93436. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93437. /**
  93438. * Helper function to auto-create an ActionEvent from a primitive
  93439. * @param prim defines the target primitive
  93440. * @param pointerPos defines the pointer position
  93441. * @param evt The original (browser) event
  93442. * @param additionalData additional data for the event
  93443. * @returns the new ActionEvent
  93444. */
  93445. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93446. }
  93447. }
  93448. declare module BABYLON {
  93449. /**
  93450. * Abstract class used to decouple action Manager from scene and meshes.
  93451. * Do not instantiate.
  93452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93453. */
  93454. export abstract class AbstractActionManager implements IDisposable {
  93455. /** Gets the list of active triggers */
  93456. static Triggers: {
  93457. [key: string]: number;
  93458. };
  93459. /** Gets the cursor to use when hovering items */
  93460. hoverCursor: string;
  93461. /** Gets the list of actions */
  93462. actions: IAction[];
  93463. /**
  93464. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93465. */
  93466. isRecursive: boolean;
  93467. /**
  93468. * Releases all associated resources
  93469. */
  93470. abstract dispose(): void;
  93471. /**
  93472. * Does this action manager has pointer triggers
  93473. */
  93474. abstract readonly hasPointerTriggers: boolean;
  93475. /**
  93476. * Does this action manager has pick triggers
  93477. */
  93478. abstract readonly hasPickTriggers: boolean;
  93479. /**
  93480. * Process a specific trigger
  93481. * @param trigger defines the trigger to process
  93482. * @param evt defines the event details to be processed
  93483. */
  93484. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93485. /**
  93486. * Does this action manager handles actions of any of the given triggers
  93487. * @param triggers defines the triggers to be tested
  93488. * @return a boolean indicating whether one (or more) of the triggers is handled
  93489. */
  93490. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93491. /**
  93492. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93493. * speed.
  93494. * @param triggerA defines the trigger to be tested
  93495. * @param triggerB defines the trigger to be tested
  93496. * @return a boolean indicating whether one (or more) of the triggers is handled
  93497. */
  93498. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93499. /**
  93500. * Does this action manager handles actions of a given trigger
  93501. * @param trigger defines the trigger to be tested
  93502. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93503. * @return whether the trigger is handled
  93504. */
  93505. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93506. /**
  93507. * Serialize this manager to a JSON object
  93508. * @param name defines the property name to store this manager
  93509. * @returns a JSON representation of this manager
  93510. */
  93511. abstract serialize(name: string): any;
  93512. /**
  93513. * Registers an action to this action manager
  93514. * @param action defines the action to be registered
  93515. * @return the action amended (prepared) after registration
  93516. */
  93517. abstract registerAction(action: IAction): Nullable<IAction>;
  93518. /**
  93519. * Unregisters an action to this action manager
  93520. * @param action defines the action to be unregistered
  93521. * @return a boolean indicating whether the action has been unregistered
  93522. */
  93523. abstract unregisterAction(action: IAction): Boolean;
  93524. /**
  93525. * Does exist one action manager with at least one trigger
  93526. **/
  93527. static readonly HasTriggers: boolean;
  93528. /**
  93529. * Does exist one action manager with at least one pick trigger
  93530. **/
  93531. static readonly HasPickTriggers: boolean;
  93532. /**
  93533. * Does exist one action manager that handles actions of a given trigger
  93534. * @param trigger defines the trigger to be tested
  93535. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93536. **/
  93537. static HasSpecificTrigger(trigger: number): boolean;
  93538. }
  93539. }
  93540. declare module BABYLON {
  93541. /**
  93542. * Defines how a node can be built from a string name.
  93543. */
  93544. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93545. /**
  93546. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93547. */
  93548. export class Node implements IBehaviorAware<Node> {
  93549. /** @hidden */
  93550. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93551. private static _NodeConstructors;
  93552. /**
  93553. * Add a new node constructor
  93554. * @param type defines the type name of the node to construct
  93555. * @param constructorFunc defines the constructor function
  93556. */
  93557. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93558. /**
  93559. * Returns a node constructor based on type name
  93560. * @param type defines the type name
  93561. * @param name defines the new node name
  93562. * @param scene defines the hosting scene
  93563. * @param options defines optional options to transmit to constructors
  93564. * @returns the new constructor or null
  93565. */
  93566. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93567. /**
  93568. * Gets or sets the name of the node
  93569. */
  93570. name: string;
  93571. /**
  93572. * Gets or sets the id of the node
  93573. */
  93574. id: string;
  93575. /**
  93576. * Gets or sets the unique id of the node
  93577. */
  93578. uniqueId: number;
  93579. /**
  93580. * Gets or sets a string used to store user defined state for the node
  93581. */
  93582. state: string;
  93583. /**
  93584. * Gets or sets an object used to store user defined information for the node
  93585. */
  93586. metadata: any;
  93587. /**
  93588. * For internal use only. Please do not use.
  93589. */
  93590. reservedDataStore: any;
  93591. /**
  93592. * List of inspectable custom properties (used by the Inspector)
  93593. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93594. */
  93595. inspectableCustomProperties: IInspectable[];
  93596. /**
  93597. * Gets or sets a boolean used to define if the node must be serialized
  93598. */
  93599. doNotSerialize: boolean;
  93600. /** @hidden */
  93601. _isDisposed: boolean;
  93602. /**
  93603. * Gets a list of Animations associated with the node
  93604. */
  93605. animations: Animation[];
  93606. protected _ranges: {
  93607. [name: string]: Nullable<AnimationRange>;
  93608. };
  93609. /**
  93610. * Callback raised when the node is ready to be used
  93611. */
  93612. onReady: Nullable<(node: Node) => void>;
  93613. private _isEnabled;
  93614. private _isParentEnabled;
  93615. private _isReady;
  93616. /** @hidden */
  93617. _currentRenderId: number;
  93618. private _parentUpdateId;
  93619. /** @hidden */
  93620. _childUpdateId: number;
  93621. /** @hidden */
  93622. _waitingParentId: Nullable<string>;
  93623. /** @hidden */
  93624. _scene: Scene;
  93625. /** @hidden */
  93626. _cache: any;
  93627. private _parentNode;
  93628. private _children;
  93629. /** @hidden */
  93630. _worldMatrix: Matrix;
  93631. /** @hidden */
  93632. _worldMatrixDeterminant: number;
  93633. /** @hidden */
  93634. _worldMatrixDeterminantIsDirty: boolean;
  93635. /** @hidden */
  93636. private _sceneRootNodesIndex;
  93637. /**
  93638. * Gets a boolean indicating if the node has been disposed
  93639. * @returns true if the node was disposed
  93640. */
  93641. isDisposed(): boolean;
  93642. /**
  93643. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93644. * @see https://doc.babylonjs.com/how_to/parenting
  93645. */
  93646. parent: Nullable<Node>;
  93647. private addToSceneRootNodes;
  93648. private removeFromSceneRootNodes;
  93649. private _animationPropertiesOverride;
  93650. /**
  93651. * Gets or sets the animation properties override
  93652. */
  93653. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93654. /**
  93655. * Gets a string idenfifying the name of the class
  93656. * @returns "Node" string
  93657. */
  93658. getClassName(): string;
  93659. /** @hidden */
  93660. readonly _isNode: boolean;
  93661. /**
  93662. * An event triggered when the mesh is disposed
  93663. */
  93664. onDisposeObservable: Observable<Node>;
  93665. private _onDisposeObserver;
  93666. /**
  93667. * Sets a callback that will be raised when the node will be disposed
  93668. */
  93669. onDispose: () => void;
  93670. /**
  93671. * Creates a new Node
  93672. * @param name the name and id to be given to this node
  93673. * @param scene the scene this node will be added to
  93674. * @param addToRootNodes the node will be added to scene.rootNodes
  93675. */
  93676. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93677. /**
  93678. * Gets the scene of the node
  93679. * @returns a scene
  93680. */
  93681. getScene(): Scene;
  93682. /**
  93683. * Gets the engine of the node
  93684. * @returns a Engine
  93685. */
  93686. getEngine(): Engine;
  93687. private _behaviors;
  93688. /**
  93689. * Attach a behavior to the node
  93690. * @see http://doc.babylonjs.com/features/behaviour
  93691. * @param behavior defines the behavior to attach
  93692. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93693. * @returns the current Node
  93694. */
  93695. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93696. /**
  93697. * Remove an attached behavior
  93698. * @see http://doc.babylonjs.com/features/behaviour
  93699. * @param behavior defines the behavior to attach
  93700. * @returns the current Node
  93701. */
  93702. removeBehavior(behavior: Behavior<Node>): Node;
  93703. /**
  93704. * Gets the list of attached behaviors
  93705. * @see http://doc.babylonjs.com/features/behaviour
  93706. */
  93707. readonly behaviors: Behavior<Node>[];
  93708. /**
  93709. * Gets an attached behavior by name
  93710. * @param name defines the name of the behavior to look for
  93711. * @see http://doc.babylonjs.com/features/behaviour
  93712. * @returns null if behavior was not found else the requested behavior
  93713. */
  93714. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93715. /**
  93716. * Returns the latest update of the World matrix
  93717. * @returns a Matrix
  93718. */
  93719. getWorldMatrix(): Matrix;
  93720. /** @hidden */
  93721. _getWorldMatrixDeterminant(): number;
  93722. /**
  93723. * Returns directly the latest state of the mesh World matrix.
  93724. * A Matrix is returned.
  93725. */
  93726. readonly worldMatrixFromCache: Matrix;
  93727. /** @hidden */
  93728. _initCache(): void;
  93729. /** @hidden */
  93730. updateCache(force?: boolean): void;
  93731. /** @hidden */
  93732. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93733. /** @hidden */
  93734. _updateCache(ignoreParentClass?: boolean): void;
  93735. /** @hidden */
  93736. _isSynchronized(): boolean;
  93737. /** @hidden */
  93738. _markSyncedWithParent(): void;
  93739. /** @hidden */
  93740. isSynchronizedWithParent(): boolean;
  93741. /** @hidden */
  93742. isSynchronized(): boolean;
  93743. /**
  93744. * Is this node ready to be used/rendered
  93745. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93746. * @return true if the node is ready
  93747. */
  93748. isReady(completeCheck?: boolean): boolean;
  93749. /**
  93750. * Is this node enabled?
  93751. * 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
  93752. * @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
  93753. * @return whether this node (and its parent) is enabled
  93754. */
  93755. isEnabled(checkAncestors?: boolean): boolean;
  93756. /** @hidden */
  93757. protected _syncParentEnabledState(): void;
  93758. /**
  93759. * Set the enabled state of this node
  93760. * @param value defines the new enabled state
  93761. */
  93762. setEnabled(value: boolean): void;
  93763. /**
  93764. * Is this node a descendant of the given node?
  93765. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93766. * @param ancestor defines the parent node to inspect
  93767. * @returns a boolean indicating if this node is a descendant of the given node
  93768. */
  93769. isDescendantOf(ancestor: Node): boolean;
  93770. /** @hidden */
  93771. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93772. /**
  93773. * Will return all nodes that have this node as ascendant
  93774. * @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
  93775. * @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
  93776. * @return all children nodes of all types
  93777. */
  93778. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93779. /**
  93780. * Get all child-meshes of this node
  93781. * @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)
  93782. * @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
  93783. * @returns an array of AbstractMesh
  93784. */
  93785. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93786. /**
  93787. * Get all direct children of this node
  93788. * @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
  93789. * @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)
  93790. * @returns an array of Node
  93791. */
  93792. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93793. /** @hidden */
  93794. _setReady(state: boolean): void;
  93795. /**
  93796. * Get an animation by name
  93797. * @param name defines the name of the animation to look for
  93798. * @returns null if not found else the requested animation
  93799. */
  93800. getAnimationByName(name: string): Nullable<Animation>;
  93801. /**
  93802. * Creates an animation range for this node
  93803. * @param name defines the name of the range
  93804. * @param from defines the starting key
  93805. * @param to defines the end key
  93806. */
  93807. createAnimationRange(name: string, from: number, to: number): void;
  93808. /**
  93809. * Delete a specific animation range
  93810. * @param name defines the name of the range to delete
  93811. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93812. */
  93813. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93814. /**
  93815. * Get an animation range by name
  93816. * @param name defines the name of the animation range to look for
  93817. * @returns null if not found else the requested animation range
  93818. */
  93819. getAnimationRange(name: string): Nullable<AnimationRange>;
  93820. /**
  93821. * Gets the list of all animation ranges defined on this node
  93822. * @returns an array
  93823. */
  93824. getAnimationRanges(): Nullable<AnimationRange>[];
  93825. /**
  93826. * Will start the animation sequence
  93827. * @param name defines the range frames for animation sequence
  93828. * @param loop defines if the animation should loop (false by default)
  93829. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93830. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93831. * @returns the object created for this animation. If range does not exist, it will return null
  93832. */
  93833. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93834. /**
  93835. * Serialize animation ranges into a JSON compatible object
  93836. * @returns serialization object
  93837. */
  93838. serializeAnimationRanges(): any;
  93839. /**
  93840. * Computes the world matrix of the node
  93841. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93842. * @returns the world matrix
  93843. */
  93844. computeWorldMatrix(force?: boolean): Matrix;
  93845. /**
  93846. * Releases resources associated with this node.
  93847. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93848. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93849. */
  93850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93851. /**
  93852. * Parse animation range data from a serialization object and store them into a given node
  93853. * @param node defines where to store the animation ranges
  93854. * @param parsedNode defines the serialization object to read data from
  93855. * @param scene defines the hosting scene
  93856. */
  93857. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93858. /**
  93859. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93860. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93861. * @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
  93862. * @returns the new bounding vectors
  93863. */
  93864. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93865. min: Vector3;
  93866. max: Vector3;
  93867. };
  93868. }
  93869. }
  93870. declare module BABYLON {
  93871. /**
  93872. * @hidden
  93873. */
  93874. export class _IAnimationState {
  93875. key: number;
  93876. repeatCount: number;
  93877. workValue?: any;
  93878. loopMode?: number;
  93879. offsetValue?: any;
  93880. highLimitValue?: any;
  93881. }
  93882. /**
  93883. * Class used to store any kind of animation
  93884. */
  93885. export class Animation {
  93886. /**Name of the animation */
  93887. name: string;
  93888. /**Property to animate */
  93889. targetProperty: string;
  93890. /**The frames per second of the animation */
  93891. framePerSecond: number;
  93892. /**The data type of the animation */
  93893. dataType: number;
  93894. /**The loop mode of the animation */
  93895. loopMode?: number | undefined;
  93896. /**Specifies if blending should be enabled */
  93897. enableBlending?: boolean | undefined;
  93898. /**
  93899. * Use matrix interpolation instead of using direct key value when animating matrices
  93900. */
  93901. static AllowMatricesInterpolation: boolean;
  93902. /**
  93903. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93904. */
  93905. static AllowMatrixDecomposeForInterpolation: boolean;
  93906. /**
  93907. * Stores the key frames of the animation
  93908. */
  93909. private _keys;
  93910. /**
  93911. * Stores the easing function of the animation
  93912. */
  93913. private _easingFunction;
  93914. /**
  93915. * @hidden Internal use only
  93916. */
  93917. _runtimeAnimations: RuntimeAnimation[];
  93918. /**
  93919. * The set of event that will be linked to this animation
  93920. */
  93921. private _events;
  93922. /**
  93923. * Stores an array of target property paths
  93924. */
  93925. targetPropertyPath: string[];
  93926. /**
  93927. * Stores the blending speed of the animation
  93928. */
  93929. blendingSpeed: number;
  93930. /**
  93931. * Stores the animation ranges for the animation
  93932. */
  93933. private _ranges;
  93934. /**
  93935. * @hidden Internal use
  93936. */
  93937. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93938. /**
  93939. * Sets up an animation
  93940. * @param property The property to animate
  93941. * @param animationType The animation type to apply
  93942. * @param framePerSecond The frames per second of the animation
  93943. * @param easingFunction The easing function used in the animation
  93944. * @returns The created animation
  93945. */
  93946. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93947. /**
  93948. * Create and start an animation on a node
  93949. * @param name defines the name of the global animation that will be run on all nodes
  93950. * @param node defines the root node where the animation will take place
  93951. * @param targetProperty defines property to animate
  93952. * @param framePerSecond defines the number of frame per second yo use
  93953. * @param totalFrame defines the number of frames in total
  93954. * @param from defines the initial value
  93955. * @param to defines the final value
  93956. * @param loopMode defines which loop mode you want to use (off by default)
  93957. * @param easingFunction defines the easing function to use (linear by default)
  93958. * @param onAnimationEnd defines the callback to call when animation end
  93959. * @returns the animatable created for this animation
  93960. */
  93961. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93962. /**
  93963. * Create and start an animation on a node and its descendants
  93964. * @param name defines the name of the global animation that will be run on all nodes
  93965. * @param node defines the root node where the animation will take place
  93966. * @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
  93967. * @param targetProperty defines property to animate
  93968. * @param framePerSecond defines the number of frame per second to use
  93969. * @param totalFrame defines the number of frames in total
  93970. * @param from defines the initial value
  93971. * @param to defines the final value
  93972. * @param loopMode defines which loop mode you want to use (off by default)
  93973. * @param easingFunction defines the easing function to use (linear by default)
  93974. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93975. * @returns the list of animatables created for all nodes
  93976. * @example https://www.babylonjs-playground.com/#MH0VLI
  93977. */
  93978. 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[]>;
  93979. /**
  93980. * Creates a new animation, merges it with the existing animations and starts it
  93981. * @param name Name of the animation
  93982. * @param node Node which contains the scene that begins the animations
  93983. * @param targetProperty Specifies which property to animate
  93984. * @param framePerSecond The frames per second of the animation
  93985. * @param totalFrame The total number of frames
  93986. * @param from The frame at the beginning of the animation
  93987. * @param to The frame at the end of the animation
  93988. * @param loopMode Specifies the loop mode of the animation
  93989. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93990. * @param onAnimationEnd Callback to run once the animation is complete
  93991. * @returns Nullable animation
  93992. */
  93993. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93994. /**
  93995. * Transition property of an host to the target Value
  93996. * @param property The property to transition
  93997. * @param targetValue The target Value of the property
  93998. * @param host The object where the property to animate belongs
  93999. * @param scene Scene used to run the animation
  94000. * @param frameRate Framerate (in frame/s) to use
  94001. * @param transition The transition type we want to use
  94002. * @param duration The duration of the animation, in milliseconds
  94003. * @param onAnimationEnd Callback trigger at the end of the animation
  94004. * @returns Nullable animation
  94005. */
  94006. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94007. /**
  94008. * Return the array of runtime animations currently using this animation
  94009. */
  94010. readonly runtimeAnimations: RuntimeAnimation[];
  94011. /**
  94012. * Specifies if any of the runtime animations are currently running
  94013. */
  94014. readonly hasRunningRuntimeAnimations: boolean;
  94015. /**
  94016. * Initializes the animation
  94017. * @param name Name of the animation
  94018. * @param targetProperty Property to animate
  94019. * @param framePerSecond The frames per second of the animation
  94020. * @param dataType The data type of the animation
  94021. * @param loopMode The loop mode of the animation
  94022. * @param enableBlending Specifies if blending should be enabled
  94023. */
  94024. constructor(
  94025. /**Name of the animation */
  94026. name: string,
  94027. /**Property to animate */
  94028. targetProperty: string,
  94029. /**The frames per second of the animation */
  94030. framePerSecond: number,
  94031. /**The data type of the animation */
  94032. dataType: number,
  94033. /**The loop mode of the animation */
  94034. loopMode?: number | undefined,
  94035. /**Specifies if blending should be enabled */
  94036. enableBlending?: boolean | undefined);
  94037. /**
  94038. * Converts the animation to a string
  94039. * @param fullDetails support for multiple levels of logging within scene loading
  94040. * @returns String form of the animation
  94041. */
  94042. toString(fullDetails?: boolean): string;
  94043. /**
  94044. * Add an event to this animation
  94045. * @param event Event to add
  94046. */
  94047. addEvent(event: AnimationEvent): void;
  94048. /**
  94049. * Remove all events found at the given frame
  94050. * @param frame The frame to remove events from
  94051. */
  94052. removeEvents(frame: number): void;
  94053. /**
  94054. * Retrieves all the events from the animation
  94055. * @returns Events from the animation
  94056. */
  94057. getEvents(): AnimationEvent[];
  94058. /**
  94059. * Creates an animation range
  94060. * @param name Name of the animation range
  94061. * @param from Starting frame of the animation range
  94062. * @param to Ending frame of the animation
  94063. */
  94064. createRange(name: string, from: number, to: number): void;
  94065. /**
  94066. * Deletes an animation range by name
  94067. * @param name Name of the animation range to delete
  94068. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94069. */
  94070. deleteRange(name: string, deleteFrames?: boolean): void;
  94071. /**
  94072. * Gets the animation range by name, or null if not defined
  94073. * @param name Name of the animation range
  94074. * @returns Nullable animation range
  94075. */
  94076. getRange(name: string): Nullable<AnimationRange>;
  94077. /**
  94078. * Gets the key frames from the animation
  94079. * @returns The key frames of the animation
  94080. */
  94081. getKeys(): Array<IAnimationKey>;
  94082. /**
  94083. * Gets the highest frame rate of the animation
  94084. * @returns Highest frame rate of the animation
  94085. */
  94086. getHighestFrame(): number;
  94087. /**
  94088. * Gets the easing function of the animation
  94089. * @returns Easing function of the animation
  94090. */
  94091. getEasingFunction(): IEasingFunction;
  94092. /**
  94093. * Sets the easing function of the animation
  94094. * @param easingFunction A custom mathematical formula for animation
  94095. */
  94096. setEasingFunction(easingFunction: EasingFunction): void;
  94097. /**
  94098. * Interpolates a scalar linearly
  94099. * @param startValue Start value of the animation curve
  94100. * @param endValue End value of the animation curve
  94101. * @param gradient Scalar amount to interpolate
  94102. * @returns Interpolated scalar value
  94103. */
  94104. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94105. /**
  94106. * Interpolates a scalar cubically
  94107. * @param startValue Start value of the animation curve
  94108. * @param outTangent End tangent of the animation
  94109. * @param endValue End value of the animation curve
  94110. * @param inTangent Start tangent of the animation curve
  94111. * @param gradient Scalar amount to interpolate
  94112. * @returns Interpolated scalar value
  94113. */
  94114. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94115. /**
  94116. * Interpolates a quaternion using a spherical linear interpolation
  94117. * @param startValue Start value of the animation curve
  94118. * @param endValue End value of the animation curve
  94119. * @param gradient Scalar amount to interpolate
  94120. * @returns Interpolated quaternion value
  94121. */
  94122. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94123. /**
  94124. * Interpolates a quaternion cubically
  94125. * @param startValue Start value of the animation curve
  94126. * @param outTangent End tangent of the animation curve
  94127. * @param endValue End value of the animation curve
  94128. * @param inTangent Start tangent of the animation curve
  94129. * @param gradient Scalar amount to interpolate
  94130. * @returns Interpolated quaternion value
  94131. */
  94132. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94133. /**
  94134. * Interpolates a Vector3 linearl
  94135. * @param startValue Start value of the animation curve
  94136. * @param endValue End value of the animation curve
  94137. * @param gradient Scalar amount to interpolate
  94138. * @returns Interpolated scalar value
  94139. */
  94140. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94141. /**
  94142. * Interpolates a Vector3 cubically
  94143. * @param startValue Start value of the animation curve
  94144. * @param outTangent End tangent of the animation
  94145. * @param endValue End value of the animation curve
  94146. * @param inTangent Start tangent of the animation curve
  94147. * @param gradient Scalar amount to interpolate
  94148. * @returns InterpolatedVector3 value
  94149. */
  94150. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94151. /**
  94152. * Interpolates a Vector2 linearly
  94153. * @param startValue Start value of the animation curve
  94154. * @param endValue End value of the animation curve
  94155. * @param gradient Scalar amount to interpolate
  94156. * @returns Interpolated Vector2 value
  94157. */
  94158. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94159. /**
  94160. * Interpolates a Vector2 cubically
  94161. * @param startValue Start value of the animation curve
  94162. * @param outTangent End tangent of the animation
  94163. * @param endValue End value of the animation curve
  94164. * @param inTangent Start tangent of the animation curve
  94165. * @param gradient Scalar amount to interpolate
  94166. * @returns Interpolated Vector2 value
  94167. */
  94168. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94169. /**
  94170. * Interpolates a size linearly
  94171. * @param startValue Start value of the animation curve
  94172. * @param endValue End value of the animation curve
  94173. * @param gradient Scalar amount to interpolate
  94174. * @returns Interpolated Size value
  94175. */
  94176. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94177. /**
  94178. * Interpolates a Color3 linearly
  94179. * @param startValue Start value of the animation curve
  94180. * @param endValue End value of the animation curve
  94181. * @param gradient Scalar amount to interpolate
  94182. * @returns Interpolated Color3 value
  94183. */
  94184. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94185. /**
  94186. * @hidden Internal use only
  94187. */
  94188. _getKeyValue(value: any): any;
  94189. /**
  94190. * @hidden Internal use only
  94191. */
  94192. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94193. /**
  94194. * Defines the function to use to interpolate matrices
  94195. * @param startValue defines the start matrix
  94196. * @param endValue defines the end matrix
  94197. * @param gradient defines the gradient between both matrices
  94198. * @param result defines an optional target matrix where to store the interpolation
  94199. * @returns the interpolated matrix
  94200. */
  94201. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94202. /**
  94203. * Makes a copy of the animation
  94204. * @returns Cloned animation
  94205. */
  94206. clone(): Animation;
  94207. /**
  94208. * Sets the key frames of the animation
  94209. * @param values The animation key frames to set
  94210. */
  94211. setKeys(values: Array<IAnimationKey>): void;
  94212. /**
  94213. * Serializes the animation to an object
  94214. * @returns Serialized object
  94215. */
  94216. serialize(): any;
  94217. /**
  94218. * Float animation type
  94219. */
  94220. private static _ANIMATIONTYPE_FLOAT;
  94221. /**
  94222. * Vector3 animation type
  94223. */
  94224. private static _ANIMATIONTYPE_VECTOR3;
  94225. /**
  94226. * Quaternion animation type
  94227. */
  94228. private static _ANIMATIONTYPE_QUATERNION;
  94229. /**
  94230. * Matrix animation type
  94231. */
  94232. private static _ANIMATIONTYPE_MATRIX;
  94233. /**
  94234. * Color3 animation type
  94235. */
  94236. private static _ANIMATIONTYPE_COLOR3;
  94237. /**
  94238. * Vector2 animation type
  94239. */
  94240. private static _ANIMATIONTYPE_VECTOR2;
  94241. /**
  94242. * Size animation type
  94243. */
  94244. private static _ANIMATIONTYPE_SIZE;
  94245. /**
  94246. * Relative Loop Mode
  94247. */
  94248. private static _ANIMATIONLOOPMODE_RELATIVE;
  94249. /**
  94250. * Cycle Loop Mode
  94251. */
  94252. private static _ANIMATIONLOOPMODE_CYCLE;
  94253. /**
  94254. * Constant Loop Mode
  94255. */
  94256. private static _ANIMATIONLOOPMODE_CONSTANT;
  94257. /**
  94258. * Get the float animation type
  94259. */
  94260. static readonly ANIMATIONTYPE_FLOAT: number;
  94261. /**
  94262. * Get the Vector3 animation type
  94263. */
  94264. static readonly ANIMATIONTYPE_VECTOR3: number;
  94265. /**
  94266. * Get the Vector2 animation type
  94267. */
  94268. static readonly ANIMATIONTYPE_VECTOR2: number;
  94269. /**
  94270. * Get the Size animation type
  94271. */
  94272. static readonly ANIMATIONTYPE_SIZE: number;
  94273. /**
  94274. * Get the Quaternion animation type
  94275. */
  94276. static readonly ANIMATIONTYPE_QUATERNION: number;
  94277. /**
  94278. * Get the Matrix animation type
  94279. */
  94280. static readonly ANIMATIONTYPE_MATRIX: number;
  94281. /**
  94282. * Get the Color3 animation type
  94283. */
  94284. static readonly ANIMATIONTYPE_COLOR3: number;
  94285. /**
  94286. * Get the Relative Loop Mode
  94287. */
  94288. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94289. /**
  94290. * Get the Cycle Loop Mode
  94291. */
  94292. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94293. /**
  94294. * Get the Constant Loop Mode
  94295. */
  94296. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94297. /** @hidden */
  94298. static _UniversalLerp(left: any, right: any, amount: number): any;
  94299. /**
  94300. * Parses an animation object and creates an animation
  94301. * @param parsedAnimation Parsed animation object
  94302. * @returns Animation object
  94303. */
  94304. static Parse(parsedAnimation: any): Animation;
  94305. /**
  94306. * Appends the serialized animations from the source animations
  94307. * @param source Source containing the animations
  94308. * @param destination Target to store the animations
  94309. */
  94310. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94311. }
  94312. }
  94313. declare module BABYLON {
  94314. /**
  94315. * Interface containing an array of animations
  94316. */
  94317. export interface IAnimatable {
  94318. /**
  94319. * Array of animations
  94320. */
  94321. animations: Nullable<Array<Animation>>;
  94322. }
  94323. }
  94324. declare module BABYLON {
  94325. /**
  94326. * This represents all the required information to add a fresnel effect on a material:
  94327. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94328. */
  94329. export class FresnelParameters {
  94330. private _isEnabled;
  94331. /**
  94332. * Define if the fresnel effect is enable or not.
  94333. */
  94334. isEnabled: boolean;
  94335. /**
  94336. * Define the color used on edges (grazing angle)
  94337. */
  94338. leftColor: Color3;
  94339. /**
  94340. * Define the color used on center
  94341. */
  94342. rightColor: Color3;
  94343. /**
  94344. * Define bias applied to computed fresnel term
  94345. */
  94346. bias: number;
  94347. /**
  94348. * Defined the power exponent applied to fresnel term
  94349. */
  94350. power: number;
  94351. /**
  94352. * Clones the current fresnel and its valuues
  94353. * @returns a clone fresnel configuration
  94354. */
  94355. clone(): FresnelParameters;
  94356. /**
  94357. * Serializes the current fresnel parameters to a JSON representation.
  94358. * @return the JSON serialization
  94359. */
  94360. serialize(): any;
  94361. /**
  94362. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94363. * @param parsedFresnelParameters Define the JSON representation
  94364. * @returns the parsed parameters
  94365. */
  94366. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94367. }
  94368. }
  94369. declare module BABYLON {
  94370. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94371. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94372. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94373. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94374. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94375. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94376. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94377. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94378. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94379. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94380. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94381. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94382. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94383. /**
  94384. * Decorator used to define property that can be serialized as reference to a camera
  94385. * @param sourceName defines the name of the property to decorate
  94386. */
  94387. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94388. /**
  94389. * Class used to help serialization objects
  94390. */
  94391. export class SerializationHelper {
  94392. /** @hidden */
  94393. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94394. /** @hidden */
  94395. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94396. /** @hidden */
  94397. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94398. /** @hidden */
  94399. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94400. /**
  94401. * Appends the serialized animations from the source animations
  94402. * @param source Source containing the animations
  94403. * @param destination Target to store the animations
  94404. */
  94405. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94406. /**
  94407. * Static function used to serialized a specific entity
  94408. * @param entity defines the entity to serialize
  94409. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94410. * @returns a JSON compatible object representing the serialization of the entity
  94411. */
  94412. static Serialize<T>(entity: T, serializationObject?: any): any;
  94413. /**
  94414. * Creates a new entity from a serialization data object
  94415. * @param creationFunction defines a function used to instanciated the new entity
  94416. * @param source defines the source serialization data
  94417. * @param scene defines the hosting scene
  94418. * @param rootUrl defines the root url for resources
  94419. * @returns a new entity
  94420. */
  94421. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94422. /**
  94423. * Clones an object
  94424. * @param creationFunction defines the function used to instanciate the new object
  94425. * @param source defines the source object
  94426. * @returns the cloned object
  94427. */
  94428. static Clone<T>(creationFunction: () => T, source: T): T;
  94429. /**
  94430. * Instanciates a new object based on a source one (some data will be shared between both object)
  94431. * @param creationFunction defines the function used to instanciate the new object
  94432. * @param source defines the source object
  94433. * @returns the new object
  94434. */
  94435. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94436. }
  94437. }
  94438. declare module BABYLON {
  94439. /**
  94440. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  94441. */
  94442. export interface CubeMapInfo {
  94443. /**
  94444. * The pixel array for the front face.
  94445. * This is stored in format, left to right, up to down format.
  94446. */
  94447. front: Nullable<ArrayBufferView>;
  94448. /**
  94449. * The pixel array for the back face.
  94450. * This is stored in format, left to right, up to down format.
  94451. */
  94452. back: Nullable<ArrayBufferView>;
  94453. /**
  94454. * The pixel array for the left face.
  94455. * This is stored in format, left to right, up to down format.
  94456. */
  94457. left: Nullable<ArrayBufferView>;
  94458. /**
  94459. * The pixel array for the right face.
  94460. * This is stored in format, left to right, up to down format.
  94461. */
  94462. right: Nullable<ArrayBufferView>;
  94463. /**
  94464. * The pixel array for the up face.
  94465. * This is stored in format, left to right, up to down format.
  94466. */
  94467. up: Nullable<ArrayBufferView>;
  94468. /**
  94469. * The pixel array for the down face.
  94470. * This is stored in format, left to right, up to down format.
  94471. */
  94472. down: Nullable<ArrayBufferView>;
  94473. /**
  94474. * The size of the cubemap stored.
  94475. *
  94476. * Each faces will be size * size pixels.
  94477. */
  94478. size: number;
  94479. /**
  94480. * The format of the texture.
  94481. *
  94482. * RGBA, RGB.
  94483. */
  94484. format: number;
  94485. /**
  94486. * The type of the texture data.
  94487. *
  94488. * UNSIGNED_INT, FLOAT.
  94489. */
  94490. type: number;
  94491. /**
  94492. * Specifies whether the texture is in gamma space.
  94493. */
  94494. gammaSpace: boolean;
  94495. }
  94496. /**
  94497. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94498. */
  94499. export class PanoramaToCubeMapTools {
  94500. private static FACE_FRONT;
  94501. private static FACE_BACK;
  94502. private static FACE_RIGHT;
  94503. private static FACE_LEFT;
  94504. private static FACE_DOWN;
  94505. private static FACE_UP;
  94506. /**
  94507. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94508. *
  94509. * @param float32Array The source data.
  94510. * @param inputWidth The width of the input panorama.
  94511. * @param inputHeight The height of the input panorama.
  94512. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94513. * @return The cubemap data
  94514. */
  94515. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  94516. private static CreateCubemapTexture;
  94517. private static CalcProjectionSpherical;
  94518. }
  94519. }
  94520. declare module BABYLON {
  94521. /**
  94522. * Helper class dealing with the extraction of spherical polynomial dataArray
  94523. * from a cube map.
  94524. */
  94525. export class CubeMapToSphericalPolynomialTools {
  94526. private static FileFaces;
  94527. /**
  94528. * Converts a texture to the according Spherical Polynomial data.
  94529. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94530. *
  94531. * @param texture The texture to extract the information from.
  94532. * @return The Spherical Polynomial data.
  94533. */
  94534. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  94535. /**
  94536. * Converts a cubemap to the according Spherical Polynomial data.
  94537. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94538. *
  94539. * @param cubeInfo The Cube map to extract the information from.
  94540. * @return The Spherical Polynomial data.
  94541. */
  94542. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  94543. }
  94544. }
  94545. declare module BABYLON {
  94546. /**
  94547. * Class used to manipulate GUIDs
  94548. */
  94549. export class GUID {
  94550. /**
  94551. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94552. * Be aware Math.random() could cause collisions, but:
  94553. * "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"
  94554. * @returns a pseudo random id
  94555. */
  94556. static RandomId(): string;
  94557. }
  94558. }
  94559. declare module BABYLON {
  94560. /**
  94561. * Base class of all the textures in babylon.
  94562. * It groups all the common properties the materials, post process, lights... might need
  94563. * in order to make a correct use of the texture.
  94564. */
  94565. export class BaseTexture implements IAnimatable {
  94566. /**
  94567. * Default anisotropic filtering level for the application.
  94568. * It is set to 4 as a good tradeoff between perf and quality.
  94569. */
  94570. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94571. /**
  94572. * Gets or sets the unique id of the texture
  94573. */
  94574. uniqueId: number;
  94575. /**
  94576. * Define the name of the texture.
  94577. */
  94578. name: string;
  94579. /**
  94580. * Gets or sets an object used to store user defined information.
  94581. */
  94582. metadata: any;
  94583. /**
  94584. * For internal use only. Please do not use.
  94585. */
  94586. reservedDataStore: any;
  94587. private _hasAlpha;
  94588. /**
  94589. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94590. */
  94591. hasAlpha: boolean;
  94592. /**
  94593. * Defines if the alpha value should be determined via the rgb values.
  94594. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94595. */
  94596. getAlphaFromRGB: boolean;
  94597. /**
  94598. * Intensity or strength of the texture.
  94599. * It is commonly used by materials to fine tune the intensity of the texture
  94600. */
  94601. level: number;
  94602. /**
  94603. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94604. * This is part of the texture as textures usually maps to one uv set.
  94605. */
  94606. coordinatesIndex: number;
  94607. private _coordinatesMode;
  94608. /**
  94609. * How a texture is mapped.
  94610. *
  94611. * | Value | Type | Description |
  94612. * | ----- | ----------------------------------- | ----------- |
  94613. * | 0 | EXPLICIT_MODE | |
  94614. * | 1 | SPHERICAL_MODE | |
  94615. * | 2 | PLANAR_MODE | |
  94616. * | 3 | CUBIC_MODE | |
  94617. * | 4 | PROJECTION_MODE | |
  94618. * | 5 | SKYBOX_MODE | |
  94619. * | 6 | INVCUBIC_MODE | |
  94620. * | 7 | EQUIRECTANGULAR_MODE | |
  94621. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94622. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94623. */
  94624. coordinatesMode: number;
  94625. /**
  94626. * | Value | Type | Description |
  94627. * | ----- | ------------------ | ----------- |
  94628. * | 0 | CLAMP_ADDRESSMODE | |
  94629. * | 1 | WRAP_ADDRESSMODE | |
  94630. * | 2 | MIRROR_ADDRESSMODE | |
  94631. */
  94632. wrapU: number;
  94633. /**
  94634. * | Value | Type | Description |
  94635. * | ----- | ------------------ | ----------- |
  94636. * | 0 | CLAMP_ADDRESSMODE | |
  94637. * | 1 | WRAP_ADDRESSMODE | |
  94638. * | 2 | MIRROR_ADDRESSMODE | |
  94639. */
  94640. wrapV: number;
  94641. /**
  94642. * | Value | Type | Description |
  94643. * | ----- | ------------------ | ----------- |
  94644. * | 0 | CLAMP_ADDRESSMODE | |
  94645. * | 1 | WRAP_ADDRESSMODE | |
  94646. * | 2 | MIRROR_ADDRESSMODE | |
  94647. */
  94648. wrapR: number;
  94649. /**
  94650. * With compliant hardware and browser (supporting anisotropic filtering)
  94651. * this defines the level of anisotropic filtering in the texture.
  94652. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94653. */
  94654. anisotropicFilteringLevel: number;
  94655. /**
  94656. * Define if the texture is a cube texture or if false a 2d texture.
  94657. */
  94658. isCube: boolean;
  94659. /**
  94660. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94661. */
  94662. is3D: boolean;
  94663. /**
  94664. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94665. * HDR texture are usually stored in linear space.
  94666. * This only impacts the PBR and Background materials
  94667. */
  94668. gammaSpace: boolean;
  94669. /**
  94670. * Gets or sets whether or not the texture contains RGBD data.
  94671. */
  94672. isRGBD: boolean;
  94673. /**
  94674. * Is Z inverted in the texture (useful in a cube texture).
  94675. */
  94676. invertZ: boolean;
  94677. /**
  94678. * Are mip maps generated for this texture or not.
  94679. */
  94680. readonly noMipmap: boolean;
  94681. /**
  94682. * @hidden
  94683. */
  94684. lodLevelInAlpha: boolean;
  94685. /**
  94686. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94687. */
  94688. lodGenerationOffset: number;
  94689. /**
  94690. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94691. */
  94692. lodGenerationScale: number;
  94693. /**
  94694. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94695. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94696. * average roughness values.
  94697. */
  94698. linearSpecularLOD: boolean;
  94699. /**
  94700. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94701. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94702. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94703. */
  94704. irradianceTexture: Nullable<BaseTexture>;
  94705. /**
  94706. * Define if the texture is a render target.
  94707. */
  94708. isRenderTarget: boolean;
  94709. /**
  94710. * Define the unique id of the texture in the scene.
  94711. */
  94712. readonly uid: string;
  94713. /**
  94714. * Return a string representation of the texture.
  94715. * @returns the texture as a string
  94716. */
  94717. toString(): string;
  94718. /**
  94719. * Get the class name of the texture.
  94720. * @returns "BaseTexture"
  94721. */
  94722. getClassName(): string;
  94723. /**
  94724. * Define the list of animation attached to the texture.
  94725. */
  94726. animations: Animation[];
  94727. /**
  94728. * An event triggered when the texture is disposed.
  94729. */
  94730. onDisposeObservable: Observable<BaseTexture>;
  94731. private _onDisposeObserver;
  94732. /**
  94733. * Callback triggered when the texture has been disposed.
  94734. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94735. */
  94736. onDispose: () => void;
  94737. /**
  94738. * Define the current state of the loading sequence when in delayed load mode.
  94739. */
  94740. delayLoadState: number;
  94741. private _scene;
  94742. /** @hidden */
  94743. _texture: Nullable<InternalTexture>;
  94744. private _uid;
  94745. /**
  94746. * Define if the texture is preventinga material to render or not.
  94747. * If not and the texture is not ready, the engine will use a default black texture instead.
  94748. */
  94749. readonly isBlocking: boolean;
  94750. /**
  94751. * Instantiates a new BaseTexture.
  94752. * Base class of all the textures in babylon.
  94753. * It groups all the common properties the materials, post process, lights... might need
  94754. * in order to make a correct use of the texture.
  94755. * @param scene Define the scene the texture blongs to
  94756. */
  94757. constructor(scene: Nullable<Scene>);
  94758. /**
  94759. * Get the scene the texture belongs to.
  94760. * @returns the scene or null if undefined
  94761. */
  94762. getScene(): Nullable<Scene>;
  94763. /**
  94764. * Get the texture transform matrix used to offset tile the texture for istance.
  94765. * @returns the transformation matrix
  94766. */
  94767. getTextureMatrix(): Matrix;
  94768. /**
  94769. * Get the texture reflection matrix used to rotate/transform the reflection.
  94770. * @returns the reflection matrix
  94771. */
  94772. getReflectionTextureMatrix(): Matrix;
  94773. /**
  94774. * Get the underlying lower level texture from Babylon.
  94775. * @returns the insternal texture
  94776. */
  94777. getInternalTexture(): Nullable<InternalTexture>;
  94778. /**
  94779. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94780. * @returns true if ready or not blocking
  94781. */
  94782. isReadyOrNotBlocking(): boolean;
  94783. /**
  94784. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94785. * @returns true if fully ready
  94786. */
  94787. isReady(): boolean;
  94788. private _cachedSize;
  94789. /**
  94790. * Get the size of the texture.
  94791. * @returns the texture size.
  94792. */
  94793. getSize(): ISize;
  94794. /**
  94795. * Get the base size of the texture.
  94796. * It can be different from the size if the texture has been resized for POT for instance
  94797. * @returns the base size
  94798. */
  94799. getBaseSize(): ISize;
  94800. /**
  94801. * Update the sampling mode of the texture.
  94802. * Default is Trilinear mode.
  94803. *
  94804. * | Value | Type | Description |
  94805. * | ----- | ------------------ | ----------- |
  94806. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94807. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94808. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94809. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94810. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94811. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94812. * | 7 | NEAREST_LINEAR | |
  94813. * | 8 | NEAREST_NEAREST | |
  94814. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94815. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94816. * | 11 | LINEAR_LINEAR | |
  94817. * | 12 | LINEAR_NEAREST | |
  94818. *
  94819. * > _mag_: magnification filter (close to the viewer)
  94820. * > _min_: minification filter (far from the viewer)
  94821. * > _mip_: filter used between mip map levels
  94822. *@param samplingMode Define the new sampling mode of the texture
  94823. */
  94824. updateSamplingMode(samplingMode: number): void;
  94825. /**
  94826. * Scales the texture if is `canRescale()`
  94827. * @param ratio the resize factor we want to use to rescale
  94828. */
  94829. scale(ratio: number): void;
  94830. /**
  94831. * Get if the texture can rescale.
  94832. */
  94833. readonly canRescale: boolean;
  94834. /** @hidden */
  94835. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94836. /** @hidden */
  94837. _rebuild(): void;
  94838. /**
  94839. * Triggers the load sequence in delayed load mode.
  94840. */
  94841. delayLoad(): void;
  94842. /**
  94843. * Clones the texture.
  94844. * @returns the cloned texture
  94845. */
  94846. clone(): Nullable<BaseTexture>;
  94847. /**
  94848. * Get the texture underlying type (INT, FLOAT...)
  94849. */
  94850. readonly textureType: number;
  94851. /**
  94852. * Get the texture underlying format (RGB, RGBA...)
  94853. */
  94854. readonly textureFormat: number;
  94855. /**
  94856. * Indicates that textures need to be re-calculated for all materials
  94857. */
  94858. protected _markAllSubMeshesAsTexturesDirty(): void;
  94859. /**
  94860. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94861. * This will returns an RGBA array buffer containing either in values (0-255) or
  94862. * float values (0-1) depending of the underlying buffer type.
  94863. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94864. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94865. * @param buffer defines a user defined buffer to fill with data (can be null)
  94866. * @returns The Array buffer containing the pixels data.
  94867. */
  94868. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94869. /**
  94870. * Release and destroy the underlying lower level texture aka internalTexture.
  94871. */
  94872. releaseInternalTexture(): void;
  94873. /**
  94874. * Get the polynomial representation of the texture data.
  94875. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94876. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94877. */
  94878. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94879. /** @hidden */
  94880. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94881. /** @hidden */
  94882. readonly _lodTextureMid: Nullable<BaseTexture>;
  94883. /** @hidden */
  94884. readonly _lodTextureLow: Nullable<BaseTexture>;
  94885. /**
  94886. * Dispose the texture and release its associated resources.
  94887. */
  94888. dispose(): void;
  94889. /**
  94890. * Serialize the texture into a JSON representation that can be parsed later on.
  94891. * @returns the JSON representation of the texture
  94892. */
  94893. serialize(): any;
  94894. /**
  94895. * Helper function to be called back once a list of texture contains only ready textures.
  94896. * @param textures Define the list of textures to wait for
  94897. * @param callback Define the callback triggered once the entire list will be ready
  94898. */
  94899. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94900. }
  94901. }
  94902. declare module BABYLON {
  94903. /**
  94904. * Options to be used when creating an effect.
  94905. */
  94906. export class EffectCreationOptions {
  94907. /**
  94908. * Atrributes that will be used in the shader.
  94909. */
  94910. attributes: string[];
  94911. /**
  94912. * Uniform varible names that will be set in the shader.
  94913. */
  94914. uniformsNames: string[];
  94915. /**
  94916. * Uniform buffer varible names that will be set in the shader.
  94917. */
  94918. uniformBuffersNames: string[];
  94919. /**
  94920. * Sampler texture variable names that will be set in the shader.
  94921. */
  94922. samplers: string[];
  94923. /**
  94924. * Define statements that will be set in the shader.
  94925. */
  94926. defines: any;
  94927. /**
  94928. * Possible fallbacks for this effect to improve performance when needed.
  94929. */
  94930. fallbacks: Nullable<IEffectFallbacks>;
  94931. /**
  94932. * Callback that will be called when the shader is compiled.
  94933. */
  94934. onCompiled: Nullable<(effect: Effect) => void>;
  94935. /**
  94936. * Callback that will be called if an error occurs during shader compilation.
  94937. */
  94938. onError: Nullable<(effect: Effect, errors: string) => void>;
  94939. /**
  94940. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94941. */
  94942. indexParameters?: any;
  94943. /**
  94944. * Max number of lights that can be used in the shader.
  94945. */
  94946. maxSimultaneousLights?: number;
  94947. /**
  94948. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94949. */
  94950. transformFeedbackVaryings?: Nullable<string[]>;
  94951. }
  94952. /**
  94953. * Effect containing vertex and fragment shader that can be executed on an object.
  94954. */
  94955. export class Effect implements IDisposable {
  94956. /**
  94957. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94958. */
  94959. static ShadersRepository: string;
  94960. /**
  94961. * Name of the effect.
  94962. */
  94963. name: any;
  94964. /**
  94965. * String container all the define statements that should be set on the shader.
  94966. */
  94967. defines: string;
  94968. /**
  94969. * Callback that will be called when the shader is compiled.
  94970. */
  94971. onCompiled: Nullable<(effect: Effect) => void>;
  94972. /**
  94973. * Callback that will be called if an error occurs during shader compilation.
  94974. */
  94975. onError: Nullable<(effect: Effect, errors: string) => void>;
  94976. /**
  94977. * Callback that will be called when effect is bound.
  94978. */
  94979. onBind: Nullable<(effect: Effect) => void>;
  94980. /**
  94981. * Unique ID of the effect.
  94982. */
  94983. uniqueId: number;
  94984. /**
  94985. * Observable that will be called when the shader is compiled.
  94986. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94987. */
  94988. onCompileObservable: Observable<Effect>;
  94989. /**
  94990. * Observable that will be called if an error occurs during shader compilation.
  94991. */
  94992. onErrorObservable: Observable<Effect>;
  94993. /** @hidden */
  94994. _onBindObservable: Nullable<Observable<Effect>>;
  94995. /**
  94996. * Observable that will be called when effect is bound.
  94997. */
  94998. readonly onBindObservable: Observable<Effect>;
  94999. /** @hidden */
  95000. _bonesComputationForcedToCPU: boolean;
  95001. private static _uniqueIdSeed;
  95002. private _engine;
  95003. private _uniformBuffersNames;
  95004. private _uniformsNames;
  95005. private _samplerList;
  95006. private _samplers;
  95007. private _isReady;
  95008. private _compilationError;
  95009. private _attributesNames;
  95010. private _attributes;
  95011. private _uniforms;
  95012. /**
  95013. * Key for the effect.
  95014. * @hidden
  95015. */
  95016. _key: string;
  95017. private _indexParameters;
  95018. private _fallbacks;
  95019. private _vertexSourceCode;
  95020. private _fragmentSourceCode;
  95021. private _vertexSourceCodeOverride;
  95022. private _fragmentSourceCodeOverride;
  95023. private _transformFeedbackVaryings;
  95024. /**
  95025. * Compiled shader to webGL program.
  95026. * @hidden
  95027. */
  95028. _pipelineContext: Nullable<IPipelineContext>;
  95029. private _valueCache;
  95030. private static _baseCache;
  95031. /**
  95032. * Instantiates an effect.
  95033. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95034. * @param baseName Name of the effect.
  95035. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95036. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95037. * @param samplers List of sampler variables that will be passed to the shader.
  95038. * @param engine Engine to be used to render the effect
  95039. * @param defines Define statements to be added to the shader.
  95040. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95041. * @param onCompiled Callback that will be called when the shader is compiled.
  95042. * @param onError Callback that will be called if an error occurs during shader compilation.
  95043. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95044. */
  95045. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, 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);
  95046. private _useFinalCode;
  95047. /**
  95048. * Unique key for this effect
  95049. */
  95050. readonly key: string;
  95051. /**
  95052. * If the effect has been compiled and prepared.
  95053. * @returns if the effect is compiled and prepared.
  95054. */
  95055. isReady(): boolean;
  95056. private _isReadyInternal;
  95057. /**
  95058. * The engine the effect was initialized with.
  95059. * @returns the engine.
  95060. */
  95061. getEngine(): Engine;
  95062. /**
  95063. * The pipeline context for this effect
  95064. * @returns the associated pipeline context
  95065. */
  95066. getPipelineContext(): Nullable<IPipelineContext>;
  95067. /**
  95068. * The set of names of attribute variables for the shader.
  95069. * @returns An array of attribute names.
  95070. */
  95071. getAttributesNames(): string[];
  95072. /**
  95073. * Returns the attribute at the given index.
  95074. * @param index The index of the attribute.
  95075. * @returns The location of the attribute.
  95076. */
  95077. getAttributeLocation(index: number): number;
  95078. /**
  95079. * Returns the attribute based on the name of the variable.
  95080. * @param name of the attribute to look up.
  95081. * @returns the attribute location.
  95082. */
  95083. getAttributeLocationByName(name: string): number;
  95084. /**
  95085. * The number of attributes.
  95086. * @returns the numnber of attributes.
  95087. */
  95088. getAttributesCount(): number;
  95089. /**
  95090. * Gets the index of a uniform variable.
  95091. * @param uniformName of the uniform to look up.
  95092. * @returns the index.
  95093. */
  95094. getUniformIndex(uniformName: string): number;
  95095. /**
  95096. * Returns the attribute based on the name of the variable.
  95097. * @param uniformName of the uniform to look up.
  95098. * @returns the location of the uniform.
  95099. */
  95100. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95101. /**
  95102. * Returns an array of sampler variable names
  95103. * @returns The array of sampler variable neames.
  95104. */
  95105. getSamplers(): string[];
  95106. /**
  95107. * The error from the last compilation.
  95108. * @returns the error string.
  95109. */
  95110. getCompilationError(): string;
  95111. /**
  95112. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95113. * @param func The callback to be used.
  95114. */
  95115. executeWhenCompiled(func: (effect: Effect) => void): void;
  95116. private _checkIsReady;
  95117. /** @hidden */
  95118. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  95119. /** @hidden */
  95120. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  95121. /** @hidden */
  95122. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  95123. /**
  95124. * Recompiles the webGL program
  95125. * @param vertexSourceCode The source code for the vertex shader.
  95126. * @param fragmentSourceCode The source code for the fragment shader.
  95127. * @param onCompiled Callback called when completed.
  95128. * @param onError Callback called on error.
  95129. * @hidden
  95130. */
  95131. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95132. /**
  95133. * Prepares the effect
  95134. * @hidden
  95135. */
  95136. _prepareEffect(): void;
  95137. private _processCompilationErrors;
  95138. /**
  95139. * Checks if the effect is supported. (Must be called after compilation)
  95140. */
  95141. readonly isSupported: boolean;
  95142. /**
  95143. * Binds a texture to the engine to be used as output of the shader.
  95144. * @param channel Name of the output variable.
  95145. * @param texture Texture to bind.
  95146. * @hidden
  95147. */
  95148. _bindTexture(channel: string, texture: InternalTexture): void;
  95149. /**
  95150. * Sets a texture on the engine to be used in the shader.
  95151. * @param channel Name of the sampler variable.
  95152. * @param texture Texture to set.
  95153. */
  95154. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95155. /**
  95156. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95157. * @param channel Name of the sampler variable.
  95158. * @param texture Texture to set.
  95159. */
  95160. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95161. /**
  95162. * Sets an array of textures on the engine to be used in the shader.
  95163. * @param channel Name of the variable.
  95164. * @param textures Textures to set.
  95165. */
  95166. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95167. /**
  95168. * 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)
  95169. * @param channel Name of the sampler variable.
  95170. * @param postProcess Post process to get the input texture from.
  95171. */
  95172. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95173. /**
  95174. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95175. * 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)
  95176. * @param channel Name of the sampler variable.
  95177. * @param postProcess Post process to get the output texture from.
  95178. */
  95179. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95180. /** @hidden */
  95181. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95182. /** @hidden */
  95183. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95184. /** @hidden */
  95185. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95186. /** @hidden */
  95187. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95188. /**
  95189. * Binds a buffer to a uniform.
  95190. * @param buffer Buffer to bind.
  95191. * @param name Name of the uniform variable to bind to.
  95192. */
  95193. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95194. /**
  95195. * Binds block to a uniform.
  95196. * @param blockName Name of the block to bind.
  95197. * @param index Index to bind.
  95198. */
  95199. bindUniformBlock(blockName: string, index: number): void;
  95200. /**
  95201. * Sets an interger value on a uniform variable.
  95202. * @param uniformName Name of the variable.
  95203. * @param value Value to be set.
  95204. * @returns this effect.
  95205. */
  95206. setInt(uniformName: string, value: number): Effect;
  95207. /**
  95208. * Sets an int array on a uniform variable.
  95209. * @param uniformName Name of the variable.
  95210. * @param array array to be set.
  95211. * @returns this effect.
  95212. */
  95213. setIntArray(uniformName: string, array: Int32Array): Effect;
  95214. /**
  95215. * 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)
  95216. * @param uniformName Name of the variable.
  95217. * @param array array to be set.
  95218. * @returns this effect.
  95219. */
  95220. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95221. /**
  95222. * 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)
  95223. * @param uniformName Name of the variable.
  95224. * @param array array to be set.
  95225. * @returns this effect.
  95226. */
  95227. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95228. /**
  95229. * 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)
  95230. * @param uniformName Name of the variable.
  95231. * @param array array to be set.
  95232. * @returns this effect.
  95233. */
  95234. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95235. /**
  95236. * Sets an float array on a uniform variable.
  95237. * @param uniformName Name of the variable.
  95238. * @param array array to be set.
  95239. * @returns this effect.
  95240. */
  95241. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95242. /**
  95243. * 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)
  95244. * @param uniformName Name of the variable.
  95245. * @param array array to be set.
  95246. * @returns this effect.
  95247. */
  95248. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95249. /**
  95250. * 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)
  95251. * @param uniformName Name of the variable.
  95252. * @param array array to be set.
  95253. * @returns this effect.
  95254. */
  95255. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95256. /**
  95257. * 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)
  95258. * @param uniformName Name of the variable.
  95259. * @param array array to be set.
  95260. * @returns this effect.
  95261. */
  95262. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95263. /**
  95264. * Sets an array on a uniform variable.
  95265. * @param uniformName Name of the variable.
  95266. * @param array array to be set.
  95267. * @returns this effect.
  95268. */
  95269. setArray(uniformName: string, array: number[]): Effect;
  95270. /**
  95271. * 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)
  95272. * @param uniformName Name of the variable.
  95273. * @param array array to be set.
  95274. * @returns this effect.
  95275. */
  95276. setArray2(uniformName: string, array: number[]): Effect;
  95277. /**
  95278. * 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)
  95279. * @param uniformName Name of the variable.
  95280. * @param array array to be set.
  95281. * @returns this effect.
  95282. */
  95283. setArray3(uniformName: string, array: number[]): Effect;
  95284. /**
  95285. * 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)
  95286. * @param uniformName Name of the variable.
  95287. * @param array array to be set.
  95288. * @returns this effect.
  95289. */
  95290. setArray4(uniformName: string, array: number[]): Effect;
  95291. /**
  95292. * Sets matrices on a uniform variable.
  95293. * @param uniformName Name of the variable.
  95294. * @param matrices matrices to be set.
  95295. * @returns this effect.
  95296. */
  95297. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95298. /**
  95299. * Sets matrix on a uniform variable.
  95300. * @param uniformName Name of the variable.
  95301. * @param matrix matrix to be set.
  95302. * @returns this effect.
  95303. */
  95304. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95305. /**
  95306. * 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)
  95307. * @param uniformName Name of the variable.
  95308. * @param matrix matrix to be set.
  95309. * @returns this effect.
  95310. */
  95311. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95312. /**
  95313. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95314. * @param uniformName Name of the variable.
  95315. * @param matrix matrix to be set.
  95316. * @returns this effect.
  95317. */
  95318. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95319. /**
  95320. * Sets a float on a uniform variable.
  95321. * @param uniformName Name of the variable.
  95322. * @param value value to be set.
  95323. * @returns this effect.
  95324. */
  95325. setFloat(uniformName: string, value: number): Effect;
  95326. /**
  95327. * Sets a boolean on a uniform variable.
  95328. * @param uniformName Name of the variable.
  95329. * @param bool value to be set.
  95330. * @returns this effect.
  95331. */
  95332. setBool(uniformName: string, bool: boolean): Effect;
  95333. /**
  95334. * Sets a Vector2 on a uniform variable.
  95335. * @param uniformName Name of the variable.
  95336. * @param vector2 vector2 to be set.
  95337. * @returns this effect.
  95338. */
  95339. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95340. /**
  95341. * Sets a float2 on a uniform variable.
  95342. * @param uniformName Name of the variable.
  95343. * @param x First float in float2.
  95344. * @param y Second float in float2.
  95345. * @returns this effect.
  95346. */
  95347. setFloat2(uniformName: string, x: number, y: number): Effect;
  95348. /**
  95349. * Sets a Vector3 on a uniform variable.
  95350. * @param uniformName Name of the variable.
  95351. * @param vector3 Value to be set.
  95352. * @returns this effect.
  95353. */
  95354. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95355. /**
  95356. * Sets a float3 on a uniform variable.
  95357. * @param uniformName Name of the variable.
  95358. * @param x First float in float3.
  95359. * @param y Second float in float3.
  95360. * @param z Third float in float3.
  95361. * @returns this effect.
  95362. */
  95363. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95364. /**
  95365. * Sets a Vector4 on a uniform variable.
  95366. * @param uniformName Name of the variable.
  95367. * @param vector4 Value to be set.
  95368. * @returns this effect.
  95369. */
  95370. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95371. /**
  95372. * Sets a float4 on a uniform variable.
  95373. * @param uniformName Name of the variable.
  95374. * @param x First float in float4.
  95375. * @param y Second float in float4.
  95376. * @param z Third float in float4.
  95377. * @param w Fourth float in float4.
  95378. * @returns this effect.
  95379. */
  95380. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95381. /**
  95382. * Sets a Color3 on a uniform variable.
  95383. * @param uniformName Name of the variable.
  95384. * @param color3 Value to be set.
  95385. * @returns this effect.
  95386. */
  95387. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95388. /**
  95389. * Sets a Color4 on a uniform variable.
  95390. * @param uniformName Name of the variable.
  95391. * @param color3 Value to be set.
  95392. * @param alpha Alpha value to be set.
  95393. * @returns this effect.
  95394. */
  95395. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95396. /**
  95397. * Sets a Color4 on a uniform variable
  95398. * @param uniformName defines the name of the variable
  95399. * @param color4 defines the value to be set
  95400. * @returns this effect.
  95401. */
  95402. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95403. /** Release all associated resources */
  95404. dispose(): void;
  95405. /**
  95406. * This function will add a new shader to the shader store
  95407. * @param name the name of the shader
  95408. * @param pixelShader optional pixel shader content
  95409. * @param vertexShader optional vertex shader content
  95410. */
  95411. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95412. /**
  95413. * Store of each shader (The can be looked up using effect.key)
  95414. */
  95415. static ShadersStore: {
  95416. [key: string]: string;
  95417. };
  95418. /**
  95419. * Store of each included file for a shader (The can be looked up using effect.key)
  95420. */
  95421. static IncludesShadersStore: {
  95422. [key: string]: string;
  95423. };
  95424. /**
  95425. * Resets the cache of effects.
  95426. */
  95427. static ResetCache(): void;
  95428. }
  95429. }
  95430. declare module BABYLON {
  95431. /**
  95432. * Class used to describe the capabilities of the engine relatively to the current browser
  95433. */
  95434. export class EngineCapabilities {
  95435. /** Maximum textures units per fragment shader */
  95436. maxTexturesImageUnits: number;
  95437. /** Maximum texture units per vertex shader */
  95438. maxVertexTextureImageUnits: number;
  95439. /** Maximum textures units in the entire pipeline */
  95440. maxCombinedTexturesImageUnits: number;
  95441. /** Maximum texture size */
  95442. maxTextureSize: number;
  95443. /** Maximum cube texture size */
  95444. maxCubemapTextureSize: number;
  95445. /** Maximum render texture size */
  95446. maxRenderTextureSize: number;
  95447. /** Maximum number of vertex attributes */
  95448. maxVertexAttribs: number;
  95449. /** Maximum number of varyings */
  95450. maxVaryingVectors: number;
  95451. /** Maximum number of uniforms per vertex shader */
  95452. maxVertexUniformVectors: number;
  95453. /** Maximum number of uniforms per fragment shader */
  95454. maxFragmentUniformVectors: number;
  95455. /** Defines if standard derivates (dx/dy) are supported */
  95456. standardDerivatives: boolean;
  95457. /** Defines if s3tc texture compression is supported */
  95458. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95459. /** Defines if pvrtc texture compression is supported */
  95460. pvrtc: any;
  95461. /** Defines if etc1 texture compression is supported */
  95462. etc1: any;
  95463. /** Defines if etc2 texture compression is supported */
  95464. etc2: any;
  95465. /** Defines if astc texture compression is supported */
  95466. astc: any;
  95467. /** Defines if float textures are supported */
  95468. textureFloat: boolean;
  95469. /** Defines if vertex array objects are supported */
  95470. vertexArrayObject: boolean;
  95471. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95472. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95473. /** Gets the maximum level of anisotropy supported */
  95474. maxAnisotropy: number;
  95475. /** Defines if instancing is supported */
  95476. instancedArrays: boolean;
  95477. /** Defines if 32 bits indices are supported */
  95478. uintIndices: boolean;
  95479. /** Defines if high precision shaders are supported */
  95480. highPrecisionShaderSupported: boolean;
  95481. /** Defines if depth reading in the fragment shader is supported */
  95482. fragmentDepthSupported: boolean;
  95483. /** Defines if float texture linear filtering is supported*/
  95484. textureFloatLinearFiltering: boolean;
  95485. /** Defines if rendering to float textures is supported */
  95486. textureFloatRender: boolean;
  95487. /** Defines if half float textures are supported*/
  95488. textureHalfFloat: boolean;
  95489. /** Defines if half float texture linear filtering is supported*/
  95490. textureHalfFloatLinearFiltering: boolean;
  95491. /** Defines if rendering to half float textures is supported */
  95492. textureHalfFloatRender: boolean;
  95493. /** Defines if textureLOD shader command is supported */
  95494. textureLOD: boolean;
  95495. /** Defines if draw buffers extension is supported */
  95496. drawBuffersExtension: boolean;
  95497. /** Defines if depth textures are supported */
  95498. depthTextureExtension: boolean;
  95499. /** Defines if float color buffer are supported */
  95500. colorBufferFloat: boolean;
  95501. /** Gets disjoint timer query extension (null if not supported) */
  95502. timerQuery: EXT_disjoint_timer_query;
  95503. /** Defines if timestamp can be used with timer query */
  95504. canUseTimestampForTimerQuery: boolean;
  95505. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95506. multiview: any;
  95507. /** Function used to let the system compiles shaders in background */
  95508. parallelShaderCompile: {
  95509. COMPLETION_STATUS_KHR: number;
  95510. };
  95511. /** Max number of texture samples for MSAA */
  95512. maxMSAASamples: number;
  95513. /** Defines if the blend min max extension is supported */
  95514. blendMinMax: boolean;
  95515. }
  95516. }
  95517. declare module BABYLON {
  95518. /**
  95519. * This class is used to track a performance counter which is number based.
  95520. * The user has access to many properties which give statistics of different nature.
  95521. *
  95522. * The implementer can track two kinds of Performance Counter: time and count.
  95523. * 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.
  95524. * 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.
  95525. */
  95526. export class PerfCounter {
  95527. /**
  95528. * Gets or sets a global boolean to turn on and off all the counters
  95529. */
  95530. static Enabled: boolean;
  95531. /**
  95532. * Returns the smallest value ever
  95533. */
  95534. readonly min: number;
  95535. /**
  95536. * Returns the biggest value ever
  95537. */
  95538. readonly max: number;
  95539. /**
  95540. * Returns the average value since the performance counter is running
  95541. */
  95542. readonly average: number;
  95543. /**
  95544. * Returns the average value of the last second the counter was monitored
  95545. */
  95546. readonly lastSecAverage: number;
  95547. /**
  95548. * Returns the current value
  95549. */
  95550. readonly current: number;
  95551. /**
  95552. * Gets the accumulated total
  95553. */
  95554. readonly total: number;
  95555. /**
  95556. * Gets the total value count
  95557. */
  95558. readonly count: number;
  95559. /**
  95560. * Creates a new counter
  95561. */
  95562. constructor();
  95563. /**
  95564. * Call this method to start monitoring a new frame.
  95565. * 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.
  95566. */
  95567. fetchNewFrame(): void;
  95568. /**
  95569. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95570. * @param newCount the count value to add to the monitored count
  95571. * @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.
  95572. */
  95573. addCount(newCount: number, fetchResult: boolean): void;
  95574. /**
  95575. * Start monitoring this performance counter
  95576. */
  95577. beginMonitoring(): void;
  95578. /**
  95579. * Compute the time lapsed since the previous beginMonitoring() call.
  95580. * @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
  95581. */
  95582. endMonitoring(newFrame?: boolean): void;
  95583. private _fetchResult;
  95584. private _startMonitoringTime;
  95585. private _min;
  95586. private _max;
  95587. private _average;
  95588. private _current;
  95589. private _totalValueCount;
  95590. private _totalAccumulated;
  95591. private _lastSecAverage;
  95592. private _lastSecAccumulated;
  95593. private _lastSecTime;
  95594. private _lastSecValueCount;
  95595. }
  95596. }
  95597. declare module BABYLON {
  95598. /**
  95599. * @hidden
  95600. **/
  95601. export class DepthCullingState {
  95602. private _isDepthTestDirty;
  95603. private _isDepthMaskDirty;
  95604. private _isDepthFuncDirty;
  95605. private _isCullFaceDirty;
  95606. private _isCullDirty;
  95607. private _isZOffsetDirty;
  95608. private _isFrontFaceDirty;
  95609. private _depthTest;
  95610. private _depthMask;
  95611. private _depthFunc;
  95612. private _cull;
  95613. private _cullFace;
  95614. private _zOffset;
  95615. private _frontFace;
  95616. /**
  95617. * Initializes the state.
  95618. */
  95619. constructor();
  95620. readonly isDirty: boolean;
  95621. zOffset: number;
  95622. cullFace: Nullable<number>;
  95623. cull: Nullable<boolean>;
  95624. depthFunc: Nullable<number>;
  95625. depthMask: boolean;
  95626. depthTest: boolean;
  95627. frontFace: Nullable<number>;
  95628. reset(): void;
  95629. apply(gl: WebGLRenderingContext): void;
  95630. }
  95631. }
  95632. declare module BABYLON {
  95633. /**
  95634. * @hidden
  95635. **/
  95636. export class StencilState {
  95637. /** 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 */
  95638. static readonly ALWAYS: number;
  95639. /** Passed to stencilOperation to specify that stencil value must be kept */
  95640. static readonly KEEP: number;
  95641. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95642. static readonly REPLACE: number;
  95643. private _isStencilTestDirty;
  95644. private _isStencilMaskDirty;
  95645. private _isStencilFuncDirty;
  95646. private _isStencilOpDirty;
  95647. private _stencilTest;
  95648. private _stencilMask;
  95649. private _stencilFunc;
  95650. private _stencilFuncRef;
  95651. private _stencilFuncMask;
  95652. private _stencilOpStencilFail;
  95653. private _stencilOpDepthFail;
  95654. private _stencilOpStencilDepthPass;
  95655. readonly isDirty: boolean;
  95656. stencilFunc: number;
  95657. stencilFuncRef: number;
  95658. stencilFuncMask: number;
  95659. stencilOpStencilFail: number;
  95660. stencilOpDepthFail: number;
  95661. stencilOpStencilDepthPass: number;
  95662. stencilMask: number;
  95663. stencilTest: boolean;
  95664. constructor();
  95665. reset(): void;
  95666. apply(gl: WebGLRenderingContext): void;
  95667. }
  95668. }
  95669. declare module BABYLON {
  95670. /**
  95671. * @hidden
  95672. **/
  95673. export class AlphaState {
  95674. private _isAlphaBlendDirty;
  95675. private _isBlendFunctionParametersDirty;
  95676. private _isBlendEquationParametersDirty;
  95677. private _isBlendConstantsDirty;
  95678. private _alphaBlend;
  95679. private _blendFunctionParameters;
  95680. private _blendEquationParameters;
  95681. private _blendConstants;
  95682. /**
  95683. * Initializes the state.
  95684. */
  95685. constructor();
  95686. readonly isDirty: boolean;
  95687. alphaBlend: boolean;
  95688. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95689. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95690. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95691. reset(): void;
  95692. apply(gl: WebGLRenderingContext): void;
  95693. }
  95694. }
  95695. declare module BABYLON {
  95696. /** @hidden */
  95697. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95698. attributeProcessor(attribute: string): string;
  95699. varyingProcessor(varying: string, isFragment: boolean): string;
  95700. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95701. }
  95702. }
  95703. declare module BABYLON {
  95704. /**
  95705. * Interface for attribute information associated with buffer instanciation
  95706. */
  95707. export class InstancingAttributeInfo {
  95708. /**
  95709. * Index/offset of the attribute in the vertex shader
  95710. */
  95711. index: number;
  95712. /**
  95713. * size of the attribute, 1, 2, 3 or 4
  95714. */
  95715. attributeSize: number;
  95716. /**
  95717. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95718. * default is FLOAT
  95719. */
  95720. attribyteType: number;
  95721. /**
  95722. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95723. */
  95724. normalized: boolean;
  95725. /**
  95726. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95727. */
  95728. offset: number;
  95729. /**
  95730. * Name of the GLSL attribute, for debugging purpose only
  95731. */
  95732. attributeName: string;
  95733. }
  95734. }
  95735. declare module BABYLON {
  95736. interface ThinEngine {
  95737. /**
  95738. * Update a video texture
  95739. * @param texture defines the texture to update
  95740. * @param video defines the video element to use
  95741. * @param invertY defines if data must be stored with Y axis inverted
  95742. */
  95743. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95744. }
  95745. }
  95746. declare module BABYLON {
  95747. /**
  95748. * Settings for finer control over video usage
  95749. */
  95750. export interface VideoTextureSettings {
  95751. /**
  95752. * Applies `autoplay` to video, if specified
  95753. */
  95754. autoPlay?: boolean;
  95755. /**
  95756. * Applies `loop` to video, if specified
  95757. */
  95758. loop?: boolean;
  95759. /**
  95760. * Automatically updates internal texture from video at every frame in the render loop
  95761. */
  95762. autoUpdateTexture: boolean;
  95763. /**
  95764. * Image src displayed during the video loading or until the user interacts with the video.
  95765. */
  95766. poster?: string;
  95767. }
  95768. /**
  95769. * If you want to display a video in your scene, this is the special texture for that.
  95770. * This special texture works similar to other textures, with the exception of a few parameters.
  95771. * @see https://doc.babylonjs.com/how_to/video_texture
  95772. */
  95773. export class VideoTexture extends Texture {
  95774. /**
  95775. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95776. */
  95777. readonly autoUpdateTexture: boolean;
  95778. /**
  95779. * The video instance used by the texture internally
  95780. */
  95781. readonly video: HTMLVideoElement;
  95782. private _onUserActionRequestedObservable;
  95783. /**
  95784. * Event triggerd when a dom action is required by the user to play the video.
  95785. * This happens due to recent changes in browser policies preventing video to auto start.
  95786. */
  95787. readonly onUserActionRequestedObservable: Observable<Texture>;
  95788. private _generateMipMaps;
  95789. private _engine;
  95790. private _stillImageCaptured;
  95791. private _displayingPosterTexture;
  95792. private _settings;
  95793. private _createInternalTextureOnEvent;
  95794. private _frameId;
  95795. /**
  95796. * Creates a video texture.
  95797. * If you want to display a video in your scene, this is the special texture for that.
  95798. * This special texture works similar to other textures, with the exception of a few parameters.
  95799. * @see https://doc.babylonjs.com/how_to/video_texture
  95800. * @param name optional name, will detect from video source, if not defined
  95801. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95802. * @param scene is obviously the current scene.
  95803. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95804. * @param invertY is false by default but can be used to invert video on Y axis
  95805. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95806. * @param settings allows finer control over video usage
  95807. */
  95808. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95809. private _getName;
  95810. private _getVideo;
  95811. private _createInternalTexture;
  95812. private reset;
  95813. /**
  95814. * @hidden Internal method to initiate `update`.
  95815. */
  95816. _rebuild(): void;
  95817. /**
  95818. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95819. */
  95820. update(): void;
  95821. /**
  95822. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95823. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95824. */
  95825. updateTexture(isVisible: boolean): void;
  95826. protected _updateInternalTexture: () => void;
  95827. /**
  95828. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95829. * @param url New url.
  95830. */
  95831. updateURL(url: string): void;
  95832. /**
  95833. * Dispose the texture and release its associated resources.
  95834. */
  95835. dispose(): void;
  95836. /**
  95837. * Creates a video texture straight from a stream.
  95838. * @param scene Define the scene the texture should be created in
  95839. * @param stream Define the stream the texture should be created from
  95840. * @returns The created video texture as a promise
  95841. */
  95842. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95843. /**
  95844. * Creates a video texture straight from your WebCam video feed.
  95845. * @param scene Define the scene the texture should be created in
  95846. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95847. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95848. * @returns The created video texture as a promise
  95849. */
  95850. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95851. minWidth: number;
  95852. maxWidth: number;
  95853. minHeight: number;
  95854. maxHeight: number;
  95855. deviceId: string;
  95856. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95857. /**
  95858. * Creates a video texture straight from your WebCam video feed.
  95859. * @param scene Define the scene the texture should be created in
  95860. * @param onReady Define a callback to triggered once the texture will be ready
  95861. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95862. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95863. */
  95864. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95865. minWidth: number;
  95866. maxWidth: number;
  95867. minHeight: number;
  95868. maxHeight: number;
  95869. deviceId: string;
  95870. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95871. }
  95872. }
  95873. declare module BABYLON {
  95874. /**
  95875. * Defines the interface used by objects working like Scene
  95876. * @hidden
  95877. */
  95878. interface ISceneLike {
  95879. _addPendingData(data: any): void;
  95880. _removePendingData(data: any): void;
  95881. offlineProvider: IOfflineProvider;
  95882. }
  95883. /** Interface defining initialization parameters for Engine class */
  95884. export interface EngineOptions extends WebGLContextAttributes {
  95885. /**
  95886. * Defines if the engine should no exceed a specified device ratio
  95887. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95888. */
  95889. limitDeviceRatio?: number;
  95890. /**
  95891. * Defines if webvr should be enabled automatically
  95892. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95893. */
  95894. autoEnableWebVR?: boolean;
  95895. /**
  95896. * Defines if webgl2 should be turned off even if supported
  95897. * @see http://doc.babylonjs.com/features/webgl2
  95898. */
  95899. disableWebGL2Support?: boolean;
  95900. /**
  95901. * Defines if webaudio should be initialized as well
  95902. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95903. */
  95904. audioEngine?: boolean;
  95905. /**
  95906. * Defines if animations should run using a deterministic lock step
  95907. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95908. */
  95909. deterministicLockstep?: boolean;
  95910. /** Defines the maximum steps to use with deterministic lock step mode */
  95911. lockstepMaxSteps?: number;
  95912. /**
  95913. * Defines that engine should ignore context lost events
  95914. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95915. */
  95916. doNotHandleContextLost?: boolean;
  95917. /**
  95918. * Defines that engine should ignore modifying touch action attribute and style
  95919. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95920. */
  95921. doNotHandleTouchAction?: boolean;
  95922. /**
  95923. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95924. */
  95925. useHighPrecisionFloats?: boolean;
  95926. }
  95927. /**
  95928. * The base engine class (root of all engines)
  95929. */
  95930. export class ThinEngine {
  95931. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95932. static ExceptionList: ({
  95933. key: string;
  95934. capture: string;
  95935. captureConstraint: number;
  95936. targets: string[];
  95937. } | {
  95938. key: string;
  95939. capture: null;
  95940. captureConstraint: null;
  95941. targets: string[];
  95942. })[];
  95943. /** @hidden */
  95944. static _TextureLoaders: IInternalTextureLoader[];
  95945. /**
  95946. * Returns the current npm package of the sdk
  95947. */
  95948. static readonly NpmPackage: string;
  95949. /**
  95950. * Returns the current version of the framework
  95951. */
  95952. static readonly Version: string;
  95953. /**
  95954. * Returns a string describing the current engine
  95955. */
  95956. readonly description: string;
  95957. /**
  95958. * Gets or sets the epsilon value used by collision engine
  95959. */
  95960. static CollisionsEpsilon: number;
  95961. /**
  95962. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95963. */
  95964. static ShadersRepository: string;
  95965. /** @hidden */
  95966. _shaderProcessor: IShaderProcessor;
  95967. /**
  95968. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95969. */
  95970. forcePOTTextures: boolean;
  95971. /**
  95972. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95973. */
  95974. isFullscreen: boolean;
  95975. /**
  95976. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95977. */
  95978. cullBackFaces: boolean;
  95979. /**
  95980. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95981. */
  95982. renderEvenInBackground: boolean;
  95983. /**
  95984. * Gets or sets a boolean indicating that cache can be kept between frames
  95985. */
  95986. preventCacheWipeBetweenFrames: boolean;
  95987. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95988. validateShaderPrograms: boolean;
  95989. /**
  95990. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95991. */
  95992. disableUniformBuffers: boolean;
  95993. /** @hidden */
  95994. _uniformBuffers: UniformBuffer[];
  95995. /**
  95996. * Gets a boolean indicating that the engine supports uniform buffers
  95997. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95998. */
  95999. readonly supportsUniformBuffers: boolean;
  96000. /** @hidden */
  96001. _gl: WebGLRenderingContext;
  96002. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96003. protected _windowIsBackground: boolean;
  96004. protected _webGLVersion: number;
  96005. protected _highPrecisionShadersAllowed: boolean;
  96006. /** @hidden */
  96007. readonly _shouldUseHighPrecisionShader: boolean;
  96008. /**
  96009. * Gets a boolean indicating that only power of 2 textures are supported
  96010. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96011. */
  96012. readonly needPOTTextures: boolean;
  96013. /** @hidden */
  96014. _badOS: boolean;
  96015. /** @hidden */
  96016. _badDesktopOS: boolean;
  96017. private _hardwareScalingLevel;
  96018. /** @hidden */
  96019. _caps: EngineCapabilities;
  96020. private _isStencilEnable;
  96021. protected _colorWrite: boolean;
  96022. /** @hidden */
  96023. _drawCalls: PerfCounter;
  96024. private _glVersion;
  96025. private _glRenderer;
  96026. private _glVendor;
  96027. /** @hidden */
  96028. _videoTextureSupported: boolean;
  96029. protected _renderingQueueLaunched: boolean;
  96030. protected _activeRenderLoops: (() => void)[];
  96031. /**
  96032. * Observable signaled when a context lost event is raised
  96033. */
  96034. onContextLostObservable: Observable<ThinEngine>;
  96035. /**
  96036. * Observable signaled when a context restored event is raised
  96037. */
  96038. onContextRestoredObservable: Observable<ThinEngine>;
  96039. private _onContextLost;
  96040. private _onContextRestored;
  96041. protected _contextWasLost: boolean;
  96042. /** @hidden */
  96043. _doNotHandleContextLost: boolean;
  96044. /**
  96045. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96046. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96047. */
  96048. doNotHandleContextLost: boolean;
  96049. /**
  96050. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96051. */
  96052. disableVertexArrayObjects: boolean;
  96053. /** @hidden */
  96054. protected _depthCullingState: DepthCullingState;
  96055. /** @hidden */
  96056. protected _stencilState: StencilState;
  96057. /** @hidden */
  96058. protected _alphaState: AlphaState;
  96059. /** @hidden */
  96060. _internalTexturesCache: InternalTexture[];
  96061. /** @hidden */
  96062. protected _activeChannel: number;
  96063. private _currentTextureChannel;
  96064. /** @hidden */
  96065. protected _boundTexturesCache: {
  96066. [key: string]: Nullable<InternalTexture>;
  96067. };
  96068. /** @hidden */
  96069. protected _currentEffect: Nullable<Effect>;
  96070. /** @hidden */
  96071. protected _currentProgram: Nullable<WebGLProgram>;
  96072. private _compiledEffects;
  96073. private _vertexAttribArraysEnabled;
  96074. /** @hidden */
  96075. protected _cachedViewport: Nullable<IViewportLike>;
  96076. private _cachedVertexArrayObject;
  96077. /** @hidden */
  96078. protected _cachedVertexBuffers: any;
  96079. /** @hidden */
  96080. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96081. /** @hidden */
  96082. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96083. /** @hidden */
  96084. _currentRenderTarget: Nullable<InternalTexture>;
  96085. private _uintIndicesCurrentlySet;
  96086. private _currentBoundBuffer;
  96087. /** @hidden */
  96088. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96089. private _currentBufferPointers;
  96090. private _currentInstanceLocations;
  96091. private _currentInstanceBuffers;
  96092. private _textureUnits;
  96093. /** @hidden */
  96094. _workingCanvas: Nullable<HTMLCanvasElement>;
  96095. /** @hidden */
  96096. _workingContext: Nullable<CanvasRenderingContext2D>;
  96097. /** @hidden */
  96098. _bindedRenderFunction: any;
  96099. private _vaoRecordInProgress;
  96100. private _mustWipeVertexAttributes;
  96101. private _emptyTexture;
  96102. private _emptyCubeTexture;
  96103. private _emptyTexture3D;
  96104. /** @hidden */
  96105. _frameHandler: number;
  96106. private _nextFreeTextureSlots;
  96107. private _maxSimultaneousTextures;
  96108. private _activeRequests;
  96109. protected _texturesSupported: string[];
  96110. /** @hidden */
  96111. _textureFormatInUse: Nullable<string>;
  96112. protected readonly _supportsHardwareTextureRescaling: boolean;
  96113. /**
  96114. * Gets the list of texture formats supported
  96115. */
  96116. readonly texturesSupported: Array<string>;
  96117. /**
  96118. * Gets the list of texture formats in use
  96119. */
  96120. readonly textureFormatInUse: Nullable<string>;
  96121. /**
  96122. * Gets the current viewport
  96123. */
  96124. readonly currentViewport: Nullable<IViewportLike>;
  96125. /**
  96126. * Gets the default empty texture
  96127. */
  96128. readonly emptyTexture: InternalTexture;
  96129. /**
  96130. * Gets the default empty 3D texture
  96131. */
  96132. readonly emptyTexture3D: InternalTexture;
  96133. /**
  96134. * Gets the default empty cube texture
  96135. */
  96136. readonly emptyCubeTexture: InternalTexture;
  96137. /**
  96138. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96139. */
  96140. readonly premultipliedAlpha: boolean;
  96141. /**
  96142. * Creates a new engine
  96143. * @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
  96144. * @param antialias defines enable antialiasing (default: false)
  96145. * @param options defines further options to be sent to the getContext() function
  96146. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96147. */
  96148. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96149. private _rebuildInternalTextures;
  96150. private _rebuildEffects;
  96151. /**
  96152. * Gets a boolean indicating if all created effects are ready
  96153. * @returns true if all effects are ready
  96154. */
  96155. areAllEffectsReady(): boolean;
  96156. protected _rebuildBuffers(): void;
  96157. private _initGLContext;
  96158. /**
  96159. * Gets version of the current webGL context
  96160. */
  96161. readonly webGLVersion: number;
  96162. /**
  96163. * Gets a string idenfifying the name of the class
  96164. * @returns "Engine" string
  96165. */
  96166. getClassName(): string;
  96167. /**
  96168. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96169. */
  96170. readonly isStencilEnable: boolean;
  96171. /** @hidden */
  96172. _prepareWorkingCanvas(): void;
  96173. /**
  96174. * Reset the texture cache to empty state
  96175. */
  96176. resetTextureCache(): void;
  96177. /**
  96178. * Gets an object containing information about the current webGL context
  96179. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96180. */
  96181. getGlInfo(): {
  96182. vendor: string;
  96183. renderer: string;
  96184. version: string;
  96185. };
  96186. /**
  96187. * Defines the hardware scaling level.
  96188. * By default the hardware scaling level is computed from the window device ratio.
  96189. * 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.
  96190. * @param level defines the level to use
  96191. */
  96192. setHardwareScalingLevel(level: number): void;
  96193. /**
  96194. * Gets the current hardware scaling level.
  96195. * By default the hardware scaling level is computed from the window device ratio.
  96196. * 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.
  96197. * @returns a number indicating the current hardware scaling level
  96198. */
  96199. getHardwareScalingLevel(): number;
  96200. /**
  96201. * Gets the list of loaded textures
  96202. * @returns an array containing all loaded textures
  96203. */
  96204. getLoadedTexturesCache(): InternalTexture[];
  96205. /**
  96206. * Gets the object containing all engine capabilities
  96207. * @returns the EngineCapabilities object
  96208. */
  96209. getCaps(): EngineCapabilities;
  96210. /**
  96211. * stop executing a render loop function and remove it from the execution array
  96212. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96213. */
  96214. stopRenderLoop(renderFunction?: () => void): void;
  96215. /** @hidden */
  96216. _renderLoop(): void;
  96217. /**
  96218. * Gets the HTML canvas attached with the current webGL context
  96219. * @returns a HTML canvas
  96220. */
  96221. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96222. /**
  96223. * Gets host window
  96224. * @returns the host window object
  96225. */
  96226. getHostWindow(): Window;
  96227. /**
  96228. * Gets the current render width
  96229. * @param useScreen defines if screen size must be used (or the current render target if any)
  96230. * @returns a number defining the current render width
  96231. */
  96232. getRenderWidth(useScreen?: boolean): number;
  96233. /**
  96234. * Gets the current render height
  96235. * @param useScreen defines if screen size must be used (or the current render target if any)
  96236. * @returns a number defining the current render height
  96237. */
  96238. getRenderHeight(useScreen?: boolean): number;
  96239. /**
  96240. * Can be used to override the current requestAnimationFrame requester.
  96241. * @hidden
  96242. */
  96243. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96244. /**
  96245. * Register and execute a render loop. The engine can have more than one render function
  96246. * @param renderFunction defines the function to continuously execute
  96247. */
  96248. runRenderLoop(renderFunction: () => void): void;
  96249. /**
  96250. * Clear the current render buffer or the current render target (if any is set up)
  96251. * @param color defines the color to use
  96252. * @param backBuffer defines if the back buffer must be cleared
  96253. * @param depth defines if the depth buffer must be cleared
  96254. * @param stencil defines if the stencil buffer must be cleared
  96255. */
  96256. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96257. private _viewportCached;
  96258. /** @hidden */
  96259. _viewport(x: number, y: number, width: number, height: number): void;
  96260. /**
  96261. * Set the WebGL's viewport
  96262. * @param viewport defines the viewport element to be used
  96263. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96264. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96265. */
  96266. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96267. /**
  96268. * Begin a new frame
  96269. */
  96270. beginFrame(): void;
  96271. /**
  96272. * Enf the current frame
  96273. */
  96274. endFrame(): void;
  96275. /**
  96276. * Resize the view according to the canvas' size
  96277. */
  96278. resize(): void;
  96279. /**
  96280. * Force a specific size of the canvas
  96281. * @param width defines the new canvas' width
  96282. * @param height defines the new canvas' height
  96283. */
  96284. setSize(width: number, height: number): void;
  96285. /**
  96286. * Binds the frame buffer to the specified texture.
  96287. * @param texture The texture to render to or null for the default canvas
  96288. * @param faceIndex The face of the texture to render to in case of cube texture
  96289. * @param requiredWidth The width of the target to render to
  96290. * @param requiredHeight The height of the target to render to
  96291. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96292. * @param depthStencilTexture The depth stencil texture to use to render
  96293. * @param lodLevel defines le lod level to bind to the frame buffer
  96294. */
  96295. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96296. /** @hidden */
  96297. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96298. /**
  96299. * Unbind the current render target texture from the webGL context
  96300. * @param texture defines the render target texture to unbind
  96301. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96302. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96303. */
  96304. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96305. /**
  96306. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96307. */
  96308. flushFramebuffer(): void;
  96309. /**
  96310. * Unbind the current render target and bind the default framebuffer
  96311. */
  96312. restoreDefaultFramebuffer(): void;
  96313. private _resetVertexBufferBinding;
  96314. /**
  96315. * Creates a vertex buffer
  96316. * @param data the data for the vertex buffer
  96317. * @returns the new WebGL static buffer
  96318. */
  96319. createVertexBuffer(data: DataArray): DataBuffer;
  96320. private _createVertexBuffer;
  96321. /**
  96322. * Creates a dynamic vertex buffer
  96323. * @param data the data for the dynamic vertex buffer
  96324. * @returns the new WebGL dynamic buffer
  96325. */
  96326. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96327. /**
  96328. * Update a dynamic index buffer
  96329. * @param indexBuffer defines the target index buffer
  96330. * @param indices defines the data to update
  96331. * @param offset defines the offset in the target index buffer where update should start
  96332. */
  96333. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96334. /**
  96335. * Updates a dynamic vertex buffer.
  96336. * @param vertexBuffer the vertex buffer to update
  96337. * @param data the data used to update the vertex buffer
  96338. * @param byteOffset the byte offset of the data
  96339. * @param byteLength the byte length of the data
  96340. */
  96341. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96342. private _resetIndexBufferBinding;
  96343. /**
  96344. * Creates a new index buffer
  96345. * @param indices defines the content of the index buffer
  96346. * @param updatable defines if the index buffer must be updatable
  96347. * @returns a new webGL buffer
  96348. */
  96349. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96350. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96351. /**
  96352. * Bind a webGL buffer to the webGL context
  96353. * @param buffer defines the buffer to bind
  96354. */
  96355. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96356. private bindIndexBuffer;
  96357. private bindBuffer;
  96358. /**
  96359. * update the bound buffer with the given data
  96360. * @param data defines the data to update
  96361. */
  96362. updateArrayBuffer(data: Float32Array): void;
  96363. private _vertexAttribPointer;
  96364. private _bindIndexBufferWithCache;
  96365. private _bindVertexBuffersAttributes;
  96366. /**
  96367. * Records a vertex array object
  96368. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96369. * @param vertexBuffers defines the list of vertex buffers to store
  96370. * @param indexBuffer defines the index buffer to store
  96371. * @param effect defines the effect to store
  96372. * @returns the new vertex array object
  96373. */
  96374. recordVertexArrayObject(vertexBuffers: {
  96375. [key: string]: VertexBuffer;
  96376. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96377. /**
  96378. * Bind a specific vertex array object
  96379. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96380. * @param vertexArrayObject defines the vertex array object to bind
  96381. * @param indexBuffer defines the index buffer to bind
  96382. */
  96383. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96384. /**
  96385. * Bind webGl buffers directly to the webGL context
  96386. * @param vertexBuffer defines the vertex buffer to bind
  96387. * @param indexBuffer defines the index buffer to bind
  96388. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96389. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96390. * @param effect defines the effect associated with the vertex buffer
  96391. */
  96392. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96393. private _unbindVertexArrayObject;
  96394. /**
  96395. * Bind a list of vertex buffers to the webGL context
  96396. * @param vertexBuffers defines the list of vertex buffers to bind
  96397. * @param indexBuffer defines the index buffer to bind
  96398. * @param effect defines the effect associated with the vertex buffers
  96399. */
  96400. bindBuffers(vertexBuffers: {
  96401. [key: string]: Nullable<VertexBuffer>;
  96402. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96403. /**
  96404. * Unbind all instance attributes
  96405. */
  96406. unbindInstanceAttributes(): void;
  96407. /**
  96408. * Release and free the memory of a vertex array object
  96409. * @param vao defines the vertex array object to delete
  96410. */
  96411. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96412. /** @hidden */
  96413. _releaseBuffer(buffer: DataBuffer): boolean;
  96414. protected _deleteBuffer(buffer: DataBuffer): void;
  96415. /**
  96416. * Creates a webGL buffer to use with instanciation
  96417. * @param capacity defines the size of the buffer
  96418. * @returns the webGL buffer
  96419. */
  96420. createInstancesBuffer(capacity: number): DataBuffer;
  96421. /**
  96422. * Delete a webGL buffer used with instanciation
  96423. * @param buffer defines the webGL buffer to delete
  96424. */
  96425. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96426. /**
  96427. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96428. * @param instancesBuffer defines the webGL buffer to update and bind
  96429. * @param data defines the data to store in the buffer
  96430. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96431. */
  96432. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96433. /**
  96434. * Apply all cached states (depth, culling, stencil and alpha)
  96435. */
  96436. applyStates(): void;
  96437. /**
  96438. * Send a draw order
  96439. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96440. * @param indexStart defines the starting index
  96441. * @param indexCount defines the number of index to draw
  96442. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96443. */
  96444. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96445. /**
  96446. * Draw a list of points
  96447. * @param verticesStart defines the index of first vertex to draw
  96448. * @param verticesCount defines the count of vertices to draw
  96449. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96450. */
  96451. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96452. /**
  96453. * Draw a list of unindexed primitives
  96454. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96455. * @param verticesStart defines the index of first vertex to draw
  96456. * @param verticesCount defines the count of vertices to draw
  96457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96458. */
  96459. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96460. /**
  96461. * Draw a list of indexed primitives
  96462. * @param fillMode defines the primitive to use
  96463. * @param indexStart defines the starting index
  96464. * @param indexCount defines the number of index to draw
  96465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96466. */
  96467. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96468. /**
  96469. * Draw a list of unindexed primitives
  96470. * @param fillMode defines the primitive to use
  96471. * @param verticesStart defines the index of first vertex to draw
  96472. * @param verticesCount defines the count of vertices to draw
  96473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96474. */
  96475. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96476. private _drawMode;
  96477. /** @hidden */
  96478. _releaseEffect(effect: Effect): void;
  96479. /** @hidden */
  96480. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96481. /**
  96482. * Create a new effect (used to store vertex/fragment shaders)
  96483. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96484. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96485. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96486. * @param samplers defines an array of string used to represent textures
  96487. * @param defines defines the string containing the defines to use to compile the shaders
  96488. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96489. * @param onCompiled defines a function to call when the effect creation is successful
  96490. * @param onError defines a function to call when the effect creation has failed
  96491. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96492. * @returns the new Effect
  96493. */
  96494. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96495. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96496. private _compileShader;
  96497. private _compileRawShader;
  96498. /**
  96499. * Directly creates a webGL program
  96500. * @param pipelineContext defines the pipeline context to attach to
  96501. * @param vertexCode defines the vertex shader code to use
  96502. * @param fragmentCode defines the fragment shader code to use
  96503. * @param context defines the webGL context to use (if not set, the current one will be used)
  96504. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96505. * @returns the new webGL program
  96506. */
  96507. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96508. /**
  96509. * Creates a webGL program
  96510. * @param pipelineContext defines the pipeline context to attach to
  96511. * @param vertexCode defines the vertex shader code to use
  96512. * @param fragmentCode defines the fragment shader code to use
  96513. * @param defines defines the string containing the defines to use to compile the shaders
  96514. * @param context defines the webGL context to use (if not set, the current one will be used)
  96515. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96516. * @returns the new webGL program
  96517. */
  96518. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96519. /**
  96520. * Creates a new pipeline context
  96521. * @returns the new pipeline
  96522. */
  96523. createPipelineContext(): IPipelineContext;
  96524. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96525. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96526. /** @hidden */
  96527. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96528. /** @hidden */
  96529. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96530. /** @hidden */
  96531. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96532. /**
  96533. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96534. * @param pipelineContext defines the pipeline context to use
  96535. * @param uniformsNames defines the list of uniform names
  96536. * @returns an array of webGL uniform locations
  96537. */
  96538. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96539. /**
  96540. * Gets the lsit of active attributes for a given webGL program
  96541. * @param pipelineContext defines the pipeline context to use
  96542. * @param attributesNames defines the list of attribute names to get
  96543. * @returns an array of indices indicating the offset of each attribute
  96544. */
  96545. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96546. /**
  96547. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96548. * @param effect defines the effect to activate
  96549. */
  96550. enableEffect(effect: Nullable<Effect>): void;
  96551. /**
  96552. * Set the value of an uniform to an array of int32
  96553. * @param uniform defines the webGL uniform location where to store the value
  96554. * @param array defines the array of int32 to store
  96555. */
  96556. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96557. /**
  96558. * Set the value of an uniform to an array of int32 (stored as vec2)
  96559. * @param uniform defines the webGL uniform location where to store the value
  96560. * @param array defines the array of int32 to store
  96561. */
  96562. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96563. /**
  96564. * Set the value of an uniform to an array of int32 (stored as vec3)
  96565. * @param uniform defines the webGL uniform location where to store the value
  96566. * @param array defines the array of int32 to store
  96567. */
  96568. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96569. /**
  96570. * Set the value of an uniform to an array of int32 (stored as vec4)
  96571. * @param uniform defines the webGL uniform location where to store the value
  96572. * @param array defines the array of int32 to store
  96573. */
  96574. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96575. /**
  96576. * Set the value of an uniform to an array of float32
  96577. * @param uniform defines the webGL uniform location where to store the value
  96578. * @param array defines the array of float32 to store
  96579. */
  96580. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96581. /**
  96582. * Set the value of an uniform to an array of float32 (stored as vec2)
  96583. * @param uniform defines the webGL uniform location where to store the value
  96584. * @param array defines the array of float32 to store
  96585. */
  96586. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96587. /**
  96588. * Set the value of an uniform to an array of float32 (stored as vec3)
  96589. * @param uniform defines the webGL uniform location where to store the value
  96590. * @param array defines the array of float32 to store
  96591. */
  96592. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96593. /**
  96594. * Set the value of an uniform to an array of float32 (stored as vec4)
  96595. * @param uniform defines the webGL uniform location where to store the value
  96596. * @param array defines the array of float32 to store
  96597. */
  96598. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96599. /**
  96600. * Set the value of an uniform to an array of number
  96601. * @param uniform defines the webGL uniform location where to store the value
  96602. * @param array defines the array of number to store
  96603. */
  96604. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96605. /**
  96606. * Set the value of an uniform to an array of number (stored as vec2)
  96607. * @param uniform defines the webGL uniform location where to store the value
  96608. * @param array defines the array of number to store
  96609. */
  96610. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96611. /**
  96612. * Set the value of an uniform to an array of number (stored as vec3)
  96613. * @param uniform defines the webGL uniform location where to store the value
  96614. * @param array defines the array of number to store
  96615. */
  96616. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96617. /**
  96618. * Set the value of an uniform to an array of number (stored as vec4)
  96619. * @param uniform defines the webGL uniform location where to store the value
  96620. * @param array defines the array of number to store
  96621. */
  96622. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96623. /**
  96624. * Set the value of an uniform to an array of float32 (stored as matrices)
  96625. * @param uniform defines the webGL uniform location where to store the value
  96626. * @param matrices defines the array of float32 to store
  96627. */
  96628. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96629. /**
  96630. * Set the value of an uniform to a matrix (3x3)
  96631. * @param uniform defines the webGL uniform location where to store the value
  96632. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96633. */
  96634. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96635. /**
  96636. * Set the value of an uniform to a matrix (2x2)
  96637. * @param uniform defines the webGL uniform location where to store the value
  96638. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96639. */
  96640. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96641. /**
  96642. * Set the value of an uniform to a number (int)
  96643. * @param uniform defines the webGL uniform location where to store the value
  96644. * @param value defines the int number to store
  96645. */
  96646. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96647. /**
  96648. * Set the value of an uniform to a number (float)
  96649. * @param uniform defines the webGL uniform location where to store the value
  96650. * @param value defines the float number to store
  96651. */
  96652. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96653. /**
  96654. * Set the value of an uniform to a vec2
  96655. * @param uniform defines the webGL uniform location where to store the value
  96656. * @param x defines the 1st component of the value
  96657. * @param y defines the 2nd component of the value
  96658. */
  96659. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96660. /**
  96661. * Set the value of an uniform to a vec3
  96662. * @param uniform defines the webGL uniform location where to store the value
  96663. * @param x defines the 1st component of the value
  96664. * @param y defines the 2nd component of the value
  96665. * @param z defines the 3rd component of the value
  96666. */
  96667. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96668. /**
  96669. * Set the value of an uniform to a boolean
  96670. * @param uniform defines the webGL uniform location where to store the value
  96671. * @param bool defines the boolean to store
  96672. */
  96673. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96674. /**
  96675. * Set the value of an uniform to a vec4
  96676. * @param uniform defines the webGL uniform location where to store the value
  96677. * @param x defines the 1st component of the value
  96678. * @param y defines the 2nd component of the value
  96679. * @param z defines the 3rd component of the value
  96680. * @param w defines the 4th component of the value
  96681. */
  96682. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96683. /**
  96684. * Sets a Color4 on a uniform variable
  96685. * @param uniform defines the uniform location
  96686. * @param color4 defines the value to be set
  96687. */
  96688. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96689. /**
  96690. * Gets the depth culling state manager
  96691. */
  96692. readonly depthCullingState: DepthCullingState;
  96693. /**
  96694. * Gets the alpha state manager
  96695. */
  96696. readonly alphaState: AlphaState;
  96697. /**
  96698. * Gets the stencil state manager
  96699. */
  96700. readonly stencilState: StencilState;
  96701. /**
  96702. * Clears the list of texture accessible through engine.
  96703. * This can help preventing texture load conflict due to name collision.
  96704. */
  96705. clearInternalTexturesCache(): void;
  96706. /**
  96707. * Force the entire cache to be cleared
  96708. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96709. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96710. */
  96711. wipeCaches(bruteForce?: boolean): void;
  96712. /** @hidden */
  96713. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96714. min: number;
  96715. mag: number;
  96716. };
  96717. /** @hidden */
  96718. _createTexture(): WebGLTexture;
  96719. /**
  96720. * Usually called from Texture.ts.
  96721. * Passed information to create a WebGLTexture
  96722. * @param urlArg defines a value which contains one of the following:
  96723. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96724. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96725. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96726. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96727. * @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)
  96728. * @param scene needed for loading to the correct scene
  96729. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96730. * @param onLoad optional callback to be called upon successful completion
  96731. * @param onError optional callback to be called upon failure
  96732. * @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
  96733. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96734. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96735. * @param forcedExtension defines the extension to use to pick the right loader
  96736. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96737. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96738. */
  96739. 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>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96740. /**
  96741. * @hidden
  96742. */
  96743. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96744. /**
  96745. * Creates a raw texture
  96746. * @param data defines the data to store in the texture
  96747. * @param width defines the width of the texture
  96748. * @param height defines the height of the texture
  96749. * @param format defines the format of the data
  96750. * @param generateMipMaps defines if the engine should generate the mip levels
  96751. * @param invertY defines if data must be stored with Y axis inverted
  96752. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96753. * @param compression defines the compression used (null by default)
  96754. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96755. * @returns the raw texture inside an InternalTexture
  96756. */
  96757. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96758. /**
  96759. * Creates a new raw cube texture
  96760. * @param data defines the array of data to use to create each face
  96761. * @param size defines the size of the textures
  96762. * @param format defines the format of the data
  96763. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96764. * @param generateMipMaps defines if the engine should generate the mip levels
  96765. * @param invertY defines if data must be stored with Y axis inverted
  96766. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96767. * @param compression defines the compression used (null by default)
  96768. * @returns the cube texture as an InternalTexture
  96769. */
  96770. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96771. /**
  96772. * Creates a new raw 3D texture
  96773. * @param data defines the data used to create the texture
  96774. * @param width defines the width of the texture
  96775. * @param height defines the height of the texture
  96776. * @param depth defines the depth of the texture
  96777. * @param format defines the format of the texture
  96778. * @param generateMipMaps defines if the engine must generate mip levels
  96779. * @param invertY defines if data must be stored with Y axis inverted
  96780. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96781. * @param compression defines the compressed used (can be null)
  96782. * @param textureType defines the compressed used (can be null)
  96783. * @returns a new raw 3D texture (stored in an InternalTexture)
  96784. */
  96785. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96786. private _unpackFlipYCached;
  96787. /**
  96788. * In case you are sharing the context with other applications, it might
  96789. * be interested to not cache the unpack flip y state to ensure a consistent
  96790. * value would be set.
  96791. */
  96792. enableUnpackFlipYCached: boolean;
  96793. /** @hidden */
  96794. _unpackFlipY(value: boolean): void;
  96795. /** @hidden */
  96796. _getUnpackAlignement(): number;
  96797. /**
  96798. * Update the sampling mode of a given texture
  96799. * @param samplingMode defines the required sampling mode
  96800. * @param texture defines the texture to update
  96801. */
  96802. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96803. /**
  96804. * Updates a depth texture Comparison Mode and Function.
  96805. * If the comparison Function is equal to 0, the mode will be set to none.
  96806. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96807. * @param texture The texture to set the comparison function for
  96808. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96809. */
  96810. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96811. /** @hidden */
  96812. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96813. width: number;
  96814. height: number;
  96815. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96816. /**
  96817. * Creates a depth stencil texture.
  96818. * This is only available in WebGL 2 or with the depth texture extension available.
  96819. * @param size The size of face edge in the texture.
  96820. * @param options The options defining the texture.
  96821. * @returns The texture
  96822. */
  96823. createDepthStencilTexture(size: number | {
  96824. width: number;
  96825. height: number;
  96826. }, options: DepthTextureCreationOptions): InternalTexture;
  96827. /**
  96828. * Creates a depth stencil texture.
  96829. * This is only available in WebGL 2 or with the depth texture extension available.
  96830. * @param size The size of face edge in the texture.
  96831. * @param options The options defining the texture.
  96832. * @returns The texture
  96833. */
  96834. private _createDepthStencilTexture;
  96835. /**
  96836. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  96837. * @param renderTarget The render target to set the frame buffer for
  96838. */
  96839. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  96840. /** @hidden */
  96841. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96842. /** @hidden */
  96843. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96844. /** @hidden */
  96845. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96846. /** @hidden */
  96847. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96848. /** @hidden */
  96849. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96850. /**
  96851. * @hidden
  96852. */
  96853. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96854. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96855. private _prepareWebGLTexture;
  96856. /** @hidden */
  96857. _releaseFramebufferObjects(texture: InternalTexture): void;
  96858. /** @hidden */
  96859. _releaseTexture(texture: InternalTexture): void;
  96860. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96861. protected _setProgram(program: WebGLProgram): void;
  96862. protected _boundUniforms: {
  96863. [key: number]: WebGLUniformLocation;
  96864. };
  96865. /**
  96866. * Binds an effect to the webGL context
  96867. * @param effect defines the effect to bind
  96868. */
  96869. bindSamplers(effect: Effect): void;
  96870. private _activateCurrentTexture;
  96871. /** @hidden */
  96872. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96873. /** @hidden */
  96874. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96875. /**
  96876. * Unbind all textures from the webGL context
  96877. */
  96878. unbindAllTextures(): void;
  96879. /**
  96880. * Sets a texture to the according uniform.
  96881. * @param channel The texture channel
  96882. * @param uniform The uniform to set
  96883. * @param texture The texture to apply
  96884. */
  96885. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96886. private _bindSamplerUniformToChannel;
  96887. private _getTextureWrapMode;
  96888. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96889. /**
  96890. * Sets an array of texture to the webGL context
  96891. * @param channel defines the channel where the texture array must be set
  96892. * @param uniform defines the associated uniform location
  96893. * @param textures defines the array of textures to bind
  96894. */
  96895. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96896. /** @hidden */
  96897. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96898. private _setTextureParameterFloat;
  96899. private _setTextureParameterInteger;
  96900. /**
  96901. * Unbind all vertex attributes from the webGL context
  96902. */
  96903. unbindAllAttributes(): void;
  96904. /**
  96905. * 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
  96906. */
  96907. releaseEffects(): void;
  96908. /**
  96909. * Dispose and release all associated resources
  96910. */
  96911. dispose(): void;
  96912. /**
  96913. * Attach a new callback raised when context lost event is fired
  96914. * @param callback defines the callback to call
  96915. */
  96916. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96917. /**
  96918. * Attach a new callback raised when context restored event is fired
  96919. * @param callback defines the callback to call
  96920. */
  96921. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96922. /**
  96923. * Get the current error code of the webGL context
  96924. * @returns the error code
  96925. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96926. */
  96927. getError(): number;
  96928. private _canRenderToFloatFramebuffer;
  96929. private _canRenderToHalfFloatFramebuffer;
  96930. private _canRenderToFramebuffer;
  96931. /** @hidden */
  96932. _getWebGLTextureType(type: number): number;
  96933. /** @hidden */
  96934. _getInternalFormat(format: number): number;
  96935. /** @hidden */
  96936. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96937. /** @hidden */
  96938. _getRGBAMultiSampleBufferFormat(type: number): number;
  96939. /** @hidden */
  96940. _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;
  96941. /**
  96942. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96943. * @returns true if the engine can be created
  96944. * @ignorenaming
  96945. */
  96946. static isSupported(): boolean;
  96947. /**
  96948. * Find the next highest power of two.
  96949. * @param x Number to start search from.
  96950. * @return Next highest power of two.
  96951. */
  96952. static CeilingPOT(x: number): number;
  96953. /**
  96954. * Find the next lowest power of two.
  96955. * @param x Number to start search from.
  96956. * @return Next lowest power of two.
  96957. */
  96958. static FloorPOT(x: number): number;
  96959. /**
  96960. * Find the nearest power of two.
  96961. * @param x Number to start search from.
  96962. * @return Next nearest power of two.
  96963. */
  96964. static NearestPOT(x: number): number;
  96965. /**
  96966. * Get the closest exponent of two
  96967. * @param value defines the value to approximate
  96968. * @param max defines the maximum value to return
  96969. * @param mode defines how to define the closest value
  96970. * @returns closest exponent of two of the given value
  96971. */
  96972. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96973. /**
  96974. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96975. * @param func - the function to be called
  96976. * @param requester - the object that will request the next frame. Falls back to window.
  96977. * @returns frame number
  96978. */
  96979. static QueueNewFrame(func: () => void, requester?: any): number;
  96980. }
  96981. }
  96982. declare module BABYLON {
  96983. /**
  96984. * Class used to store data associated with WebGL texture data for the engine
  96985. * This class should not be used directly
  96986. */
  96987. export class InternalTexture {
  96988. /** @hidden */
  96989. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  96990. /**
  96991. * The source of the texture data is unknown
  96992. */
  96993. static DATASOURCE_UNKNOWN: number;
  96994. /**
  96995. * Texture data comes from an URL
  96996. */
  96997. static DATASOURCE_URL: number;
  96998. /**
  96999. * Texture data is only used for temporary storage
  97000. */
  97001. static DATASOURCE_TEMP: number;
  97002. /**
  97003. * Texture data comes from raw data (ArrayBuffer)
  97004. */
  97005. static DATASOURCE_RAW: number;
  97006. /**
  97007. * Texture content is dynamic (video or dynamic texture)
  97008. */
  97009. static DATASOURCE_DYNAMIC: number;
  97010. /**
  97011. * Texture content is generated by rendering to it
  97012. */
  97013. static DATASOURCE_RENDERTARGET: number;
  97014. /**
  97015. * Texture content is part of a multi render target process
  97016. */
  97017. static DATASOURCE_MULTIRENDERTARGET: number;
  97018. /**
  97019. * Texture data comes from a cube data file
  97020. */
  97021. static DATASOURCE_CUBE: number;
  97022. /**
  97023. * Texture data comes from a raw cube data
  97024. */
  97025. static DATASOURCE_CUBERAW: number;
  97026. /**
  97027. * Texture data come from a prefiltered cube data file
  97028. */
  97029. static DATASOURCE_CUBEPREFILTERED: number;
  97030. /**
  97031. * Texture content is raw 3D data
  97032. */
  97033. static DATASOURCE_RAW3D: number;
  97034. /**
  97035. * Texture content is a depth texture
  97036. */
  97037. static DATASOURCE_DEPTHTEXTURE: number;
  97038. /**
  97039. * Texture data comes from a raw cube data encoded with RGBD
  97040. */
  97041. static DATASOURCE_CUBERAW_RGBD: number;
  97042. /**
  97043. * Defines if the texture is ready
  97044. */
  97045. isReady: boolean;
  97046. /**
  97047. * Defines if the texture is a cube texture
  97048. */
  97049. isCube: boolean;
  97050. /**
  97051. * Defines if the texture contains 3D data
  97052. */
  97053. is3D: boolean;
  97054. /**
  97055. * Defines if the texture contains multiview data
  97056. */
  97057. isMultiview: boolean;
  97058. /**
  97059. * Gets the URL used to load this texture
  97060. */
  97061. url: string;
  97062. /**
  97063. * Gets the sampling mode of the texture
  97064. */
  97065. samplingMode: number;
  97066. /**
  97067. * Gets a boolean indicating if the texture needs mipmaps generation
  97068. */
  97069. generateMipMaps: boolean;
  97070. /**
  97071. * Gets the number of samples used by the texture (WebGL2+ only)
  97072. */
  97073. samples: number;
  97074. /**
  97075. * Gets the type of the texture (int, float...)
  97076. */
  97077. type: number;
  97078. /**
  97079. * Gets the format of the texture (RGB, RGBA...)
  97080. */
  97081. format: number;
  97082. /**
  97083. * Observable called when the texture is loaded
  97084. */
  97085. onLoadedObservable: Observable<InternalTexture>;
  97086. /**
  97087. * Gets the width of the texture
  97088. */
  97089. width: number;
  97090. /**
  97091. * Gets the height of the texture
  97092. */
  97093. height: number;
  97094. /**
  97095. * Gets the depth of the texture
  97096. */
  97097. depth: number;
  97098. /**
  97099. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97100. */
  97101. baseWidth: number;
  97102. /**
  97103. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97104. */
  97105. baseHeight: number;
  97106. /**
  97107. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97108. */
  97109. baseDepth: number;
  97110. /**
  97111. * Gets a boolean indicating if the texture is inverted on Y axis
  97112. */
  97113. invertY: boolean;
  97114. /** @hidden */
  97115. _invertVScale: boolean;
  97116. /** @hidden */
  97117. _associatedChannel: number;
  97118. /** @hidden */
  97119. _dataSource: number;
  97120. /** @hidden */
  97121. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97122. /** @hidden */
  97123. _bufferView: Nullable<ArrayBufferView>;
  97124. /** @hidden */
  97125. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97126. /** @hidden */
  97127. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97128. /** @hidden */
  97129. _size: number;
  97130. /** @hidden */
  97131. _extension: string;
  97132. /** @hidden */
  97133. _files: Nullable<string[]>;
  97134. /** @hidden */
  97135. _workingCanvas: Nullable<HTMLCanvasElement>;
  97136. /** @hidden */
  97137. _workingContext: Nullable<CanvasRenderingContext2D>;
  97138. /** @hidden */
  97139. _framebuffer: Nullable<WebGLFramebuffer>;
  97140. /** @hidden */
  97141. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97142. /** @hidden */
  97143. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97144. /** @hidden */
  97145. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97146. /** @hidden */
  97147. _attachments: Nullable<number[]>;
  97148. /** @hidden */
  97149. _cachedCoordinatesMode: Nullable<number>;
  97150. /** @hidden */
  97151. _cachedWrapU: Nullable<number>;
  97152. /** @hidden */
  97153. _cachedWrapV: Nullable<number>;
  97154. /** @hidden */
  97155. _cachedWrapR: Nullable<number>;
  97156. /** @hidden */
  97157. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97158. /** @hidden */
  97159. _isDisabled: boolean;
  97160. /** @hidden */
  97161. _compression: Nullable<string>;
  97162. /** @hidden */
  97163. _generateStencilBuffer: boolean;
  97164. /** @hidden */
  97165. _generateDepthBuffer: boolean;
  97166. /** @hidden */
  97167. _comparisonFunction: number;
  97168. /** @hidden */
  97169. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97170. /** @hidden */
  97171. _lodGenerationScale: number;
  97172. /** @hidden */
  97173. _lodGenerationOffset: number;
  97174. /** @hidden */
  97175. _colorTextureArray: Nullable<WebGLTexture>;
  97176. /** @hidden */
  97177. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97178. /** @hidden */
  97179. _lodTextureHigh: Nullable<BaseTexture>;
  97180. /** @hidden */
  97181. _lodTextureMid: Nullable<BaseTexture>;
  97182. /** @hidden */
  97183. _lodTextureLow: Nullable<BaseTexture>;
  97184. /** @hidden */
  97185. _isRGBD: boolean;
  97186. /** @hidden */
  97187. _linearSpecularLOD: boolean;
  97188. /** @hidden */
  97189. _irradianceTexture: Nullable<BaseTexture>;
  97190. /** @hidden */
  97191. _webGLTexture: Nullable<WebGLTexture>;
  97192. /** @hidden */
  97193. _references: number;
  97194. private _engine;
  97195. /**
  97196. * Gets the Engine the texture belongs to.
  97197. * @returns The babylon engine
  97198. */
  97199. getEngine(): ThinEngine;
  97200. /**
  97201. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  97202. */
  97203. readonly dataSource: number;
  97204. /**
  97205. * Creates a new InternalTexture
  97206. * @param engine defines the engine to use
  97207. * @param dataSource defines the type of data that will be used
  97208. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97209. */
  97210. constructor(engine: ThinEngine, dataSource: number, delayAllocation?: boolean);
  97211. /**
  97212. * Increments the number of references (ie. the number of Texture that point to it)
  97213. */
  97214. incrementReferences(): void;
  97215. /**
  97216. * Change the size of the texture (not the size of the content)
  97217. * @param width defines the new width
  97218. * @param height defines the new height
  97219. * @param depth defines the new depth (1 by default)
  97220. */
  97221. updateSize(width: int, height: int, depth?: int): void;
  97222. /** @hidden */
  97223. _rebuild(): void;
  97224. /** @hidden */
  97225. _swapAndDie(target: InternalTexture): void;
  97226. /**
  97227. * Dispose the current allocated resources
  97228. */
  97229. dispose(): void;
  97230. }
  97231. }
  97232. declare module BABYLON {
  97233. /**
  97234. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97236. */
  97237. export class Analyser {
  97238. /**
  97239. * Gets or sets the smoothing
  97240. * @ignorenaming
  97241. */
  97242. SMOOTHING: number;
  97243. /**
  97244. * Gets or sets the FFT table size
  97245. * @ignorenaming
  97246. */
  97247. FFT_SIZE: number;
  97248. /**
  97249. * Gets or sets the bar graph amplitude
  97250. * @ignorenaming
  97251. */
  97252. BARGRAPHAMPLITUDE: number;
  97253. /**
  97254. * Gets or sets the position of the debug canvas
  97255. * @ignorenaming
  97256. */
  97257. DEBUGCANVASPOS: {
  97258. x: number;
  97259. y: number;
  97260. };
  97261. /**
  97262. * Gets or sets the debug canvas size
  97263. * @ignorenaming
  97264. */
  97265. DEBUGCANVASSIZE: {
  97266. width: number;
  97267. height: number;
  97268. };
  97269. private _byteFreqs;
  97270. private _byteTime;
  97271. private _floatFreqs;
  97272. private _webAudioAnalyser;
  97273. private _debugCanvas;
  97274. private _debugCanvasContext;
  97275. private _scene;
  97276. private _registerFunc;
  97277. private _audioEngine;
  97278. /**
  97279. * Creates a new analyser
  97280. * @param scene defines hosting scene
  97281. */
  97282. constructor(scene: Scene);
  97283. /**
  97284. * Get the number of data values you will have to play with for the visualization
  97285. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97286. * @returns a number
  97287. */
  97288. getFrequencyBinCount(): number;
  97289. /**
  97290. * Gets the current frequency data as a byte array
  97291. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97292. * @returns a Uint8Array
  97293. */
  97294. getByteFrequencyData(): Uint8Array;
  97295. /**
  97296. * Gets the current waveform as a byte array
  97297. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97298. * @returns a Uint8Array
  97299. */
  97300. getByteTimeDomainData(): Uint8Array;
  97301. /**
  97302. * Gets the current frequency data as a float array
  97303. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97304. * @returns a Float32Array
  97305. */
  97306. getFloatFrequencyData(): Float32Array;
  97307. /**
  97308. * Renders the debug canvas
  97309. */
  97310. drawDebugCanvas(): void;
  97311. /**
  97312. * Stops rendering the debug canvas and removes it
  97313. */
  97314. stopDebugCanvas(): void;
  97315. /**
  97316. * Connects two audio nodes
  97317. * @param inputAudioNode defines first node to connect
  97318. * @param outputAudioNode defines second node to connect
  97319. */
  97320. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97321. /**
  97322. * Releases all associated resources
  97323. */
  97324. dispose(): void;
  97325. }
  97326. }
  97327. declare module BABYLON {
  97328. /**
  97329. * This represents an audio engine and it is responsible
  97330. * to play, synchronize and analyse sounds throughout the application.
  97331. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97332. */
  97333. export interface IAudioEngine extends IDisposable {
  97334. /**
  97335. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97336. */
  97337. readonly canUseWebAudio: boolean;
  97338. /**
  97339. * Gets the current AudioContext if available.
  97340. */
  97341. readonly audioContext: Nullable<AudioContext>;
  97342. /**
  97343. * The master gain node defines the global audio volume of your audio engine.
  97344. */
  97345. readonly masterGain: GainNode;
  97346. /**
  97347. * Gets whether or not mp3 are supported by your browser.
  97348. */
  97349. readonly isMP3supported: boolean;
  97350. /**
  97351. * Gets whether or not ogg are supported by your browser.
  97352. */
  97353. readonly isOGGsupported: boolean;
  97354. /**
  97355. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97356. * @ignoreNaming
  97357. */
  97358. WarnedWebAudioUnsupported: boolean;
  97359. /**
  97360. * Defines if the audio engine relies on a custom unlocked button.
  97361. * In this case, the embedded button will not be displayed.
  97362. */
  97363. useCustomUnlockedButton: boolean;
  97364. /**
  97365. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97366. */
  97367. readonly unlocked: boolean;
  97368. /**
  97369. * Event raised when audio has been unlocked on the browser.
  97370. */
  97371. onAudioUnlockedObservable: Observable<AudioEngine>;
  97372. /**
  97373. * Event raised when audio has been locked on the browser.
  97374. */
  97375. onAudioLockedObservable: Observable<AudioEngine>;
  97376. /**
  97377. * Flags the audio engine in Locked state.
  97378. * This happens due to new browser policies preventing audio to autoplay.
  97379. */
  97380. lock(): void;
  97381. /**
  97382. * Unlocks the audio engine once a user action has been done on the dom.
  97383. * This is helpful to resume play once browser policies have been satisfied.
  97384. */
  97385. unlock(): void;
  97386. }
  97387. /**
  97388. * This represents the default audio engine used in babylon.
  97389. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97391. */
  97392. export class AudioEngine implements IAudioEngine {
  97393. private _audioContext;
  97394. private _audioContextInitialized;
  97395. private _muteButton;
  97396. private _hostElement;
  97397. /**
  97398. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97399. */
  97400. canUseWebAudio: boolean;
  97401. /**
  97402. * The master gain node defines the global audio volume of your audio engine.
  97403. */
  97404. masterGain: GainNode;
  97405. /**
  97406. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97407. * @ignoreNaming
  97408. */
  97409. WarnedWebAudioUnsupported: boolean;
  97410. /**
  97411. * Gets whether or not mp3 are supported by your browser.
  97412. */
  97413. isMP3supported: boolean;
  97414. /**
  97415. * Gets whether or not ogg are supported by your browser.
  97416. */
  97417. isOGGsupported: boolean;
  97418. /**
  97419. * Gets whether audio has been unlocked on the device.
  97420. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97421. * a user interaction has happened.
  97422. */
  97423. unlocked: boolean;
  97424. /**
  97425. * Defines if the audio engine relies on a custom unlocked button.
  97426. * In this case, the embedded button will not be displayed.
  97427. */
  97428. useCustomUnlockedButton: boolean;
  97429. /**
  97430. * Event raised when audio has been unlocked on the browser.
  97431. */
  97432. onAudioUnlockedObservable: Observable<AudioEngine>;
  97433. /**
  97434. * Event raised when audio has been locked on the browser.
  97435. */
  97436. onAudioLockedObservable: Observable<AudioEngine>;
  97437. /**
  97438. * Gets the current AudioContext if available.
  97439. */
  97440. readonly audioContext: Nullable<AudioContext>;
  97441. private _connectedAnalyser;
  97442. /**
  97443. * Instantiates a new audio engine.
  97444. *
  97445. * There should be only one per page as some browsers restrict the number
  97446. * of audio contexts you can create.
  97447. * @param hostElement defines the host element where to display the mute icon if necessary
  97448. */
  97449. constructor(hostElement?: Nullable<HTMLElement>);
  97450. /**
  97451. * Flags the audio engine in Locked state.
  97452. * This happens due to new browser policies preventing audio to autoplay.
  97453. */
  97454. lock(): void;
  97455. /**
  97456. * Unlocks the audio engine once a user action has been done on the dom.
  97457. * This is helpful to resume play once browser policies have been satisfied.
  97458. */
  97459. unlock(): void;
  97460. private _resumeAudioContext;
  97461. private _initializeAudioContext;
  97462. private _tryToRun;
  97463. private _triggerRunningState;
  97464. private _triggerSuspendedState;
  97465. private _displayMuteButton;
  97466. private _moveButtonToTopLeft;
  97467. private _onResize;
  97468. private _hideMuteButton;
  97469. /**
  97470. * Destroy and release the resources associated with the audio ccontext.
  97471. */
  97472. dispose(): void;
  97473. /**
  97474. * Gets the global volume sets on the master gain.
  97475. * @returns the global volume if set or -1 otherwise
  97476. */
  97477. getGlobalVolume(): number;
  97478. /**
  97479. * Sets the global volume of your experience (sets on the master gain).
  97480. * @param newVolume Defines the new global volume of the application
  97481. */
  97482. setGlobalVolume(newVolume: number): void;
  97483. /**
  97484. * Connect the audio engine to an audio analyser allowing some amazing
  97485. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97487. * @param analyser The analyser to connect to the engine
  97488. */
  97489. connectToAnalyser(analyser: Analyser): void;
  97490. }
  97491. }
  97492. declare module BABYLON {
  97493. /**
  97494. * Interface used to present a loading screen while loading a scene
  97495. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97496. */
  97497. export interface ILoadingScreen {
  97498. /**
  97499. * Function called to display the loading screen
  97500. */
  97501. displayLoadingUI: () => void;
  97502. /**
  97503. * Function called to hide the loading screen
  97504. */
  97505. hideLoadingUI: () => void;
  97506. /**
  97507. * Gets or sets the color to use for the background
  97508. */
  97509. loadingUIBackgroundColor: string;
  97510. /**
  97511. * Gets or sets the text to display while loading
  97512. */
  97513. loadingUIText: string;
  97514. }
  97515. /**
  97516. * Class used for the default loading screen
  97517. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97518. */
  97519. export class DefaultLoadingScreen implements ILoadingScreen {
  97520. private _renderingCanvas;
  97521. private _loadingText;
  97522. private _loadingDivBackgroundColor;
  97523. private _loadingDiv;
  97524. private _loadingTextDiv;
  97525. /** Gets or sets the logo url to use for the default loading screen */
  97526. static DefaultLogoUrl: string;
  97527. /** Gets or sets the spinner url to use for the default loading screen */
  97528. static DefaultSpinnerUrl: string;
  97529. /**
  97530. * Creates a new default loading screen
  97531. * @param _renderingCanvas defines the canvas used to render the scene
  97532. * @param _loadingText defines the default text to display
  97533. * @param _loadingDivBackgroundColor defines the default background color
  97534. */
  97535. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97536. /**
  97537. * Function called to display the loading screen
  97538. */
  97539. displayLoadingUI(): void;
  97540. /**
  97541. * Function called to hide the loading screen
  97542. */
  97543. hideLoadingUI(): void;
  97544. /**
  97545. * Gets or sets the text to display while loading
  97546. */
  97547. loadingUIText: string;
  97548. /**
  97549. * Gets or sets the color to use for the background
  97550. */
  97551. loadingUIBackgroundColor: string;
  97552. private _resizeLoadingUI;
  97553. }
  97554. }
  97555. declare module BABYLON {
  97556. /**
  97557. * Interface for any object that can request an animation frame
  97558. */
  97559. export interface ICustomAnimationFrameRequester {
  97560. /**
  97561. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97562. */
  97563. renderFunction?: Function;
  97564. /**
  97565. * Called to request the next frame to render to
  97566. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97567. */
  97568. requestAnimationFrame: Function;
  97569. /**
  97570. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97571. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97572. */
  97573. requestID?: number;
  97574. }
  97575. }
  97576. declare module BABYLON {
  97577. /**
  97578. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97579. */
  97580. export class PerformanceMonitor {
  97581. private _enabled;
  97582. private _rollingFrameTime;
  97583. private _lastFrameTimeMs;
  97584. /**
  97585. * constructor
  97586. * @param frameSampleSize The number of samples required to saturate the sliding window
  97587. */
  97588. constructor(frameSampleSize?: number);
  97589. /**
  97590. * Samples current frame
  97591. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97592. */
  97593. sampleFrame(timeMs?: number): void;
  97594. /**
  97595. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97596. */
  97597. readonly averageFrameTime: number;
  97598. /**
  97599. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97600. */
  97601. readonly averageFrameTimeVariance: number;
  97602. /**
  97603. * Returns the frame time of the most recent frame
  97604. */
  97605. readonly instantaneousFrameTime: number;
  97606. /**
  97607. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97608. */
  97609. readonly averageFPS: number;
  97610. /**
  97611. * Returns the average framerate in frames per second using the most recent frame time
  97612. */
  97613. readonly instantaneousFPS: number;
  97614. /**
  97615. * Returns true if enough samples have been taken to completely fill the sliding window
  97616. */
  97617. readonly isSaturated: boolean;
  97618. /**
  97619. * Enables contributions to the sliding window sample set
  97620. */
  97621. enable(): void;
  97622. /**
  97623. * Disables contributions to the sliding window sample set
  97624. * Samples will not be interpolated over the disabled period
  97625. */
  97626. disable(): void;
  97627. /**
  97628. * Returns true if sampling is enabled
  97629. */
  97630. readonly isEnabled: boolean;
  97631. /**
  97632. * Resets performance monitor
  97633. */
  97634. reset(): void;
  97635. }
  97636. /**
  97637. * RollingAverage
  97638. *
  97639. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97640. */
  97641. export class RollingAverage {
  97642. /**
  97643. * Current average
  97644. */
  97645. average: number;
  97646. /**
  97647. * Current variance
  97648. */
  97649. variance: number;
  97650. protected _samples: Array<number>;
  97651. protected _sampleCount: number;
  97652. protected _pos: number;
  97653. protected _m2: number;
  97654. /**
  97655. * constructor
  97656. * @param length The number of samples required to saturate the sliding window
  97657. */
  97658. constructor(length: number);
  97659. /**
  97660. * Adds a sample to the sample set
  97661. * @param v The sample value
  97662. */
  97663. add(v: number): void;
  97664. /**
  97665. * Returns previously added values or null if outside of history or outside the sliding window domain
  97666. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97667. * @return Value previously recorded with add() or null if outside of range
  97668. */
  97669. history(i: number): number;
  97670. /**
  97671. * Returns true if enough samples have been taken to completely fill the sliding window
  97672. * @return true if sample-set saturated
  97673. */
  97674. isSaturated(): boolean;
  97675. /**
  97676. * Resets the rolling average (equivalent to 0 samples taken so far)
  97677. */
  97678. reset(): void;
  97679. /**
  97680. * Wraps a value around the sample range boundaries
  97681. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97682. * @return Wrapped position in sample range
  97683. */
  97684. protected _wrapPosition(i: number): number;
  97685. }
  97686. }
  97687. declare module BABYLON {
  97688. /**
  97689. * Defines the interface used by display changed events
  97690. */
  97691. export interface IDisplayChangedEventArgs {
  97692. /** Gets the vrDisplay object (if any) */
  97693. vrDisplay: Nullable<any>;
  97694. /** Gets a boolean indicating if webVR is supported */
  97695. vrSupported: boolean;
  97696. }
  97697. /**
  97698. * Defines the interface used by objects containing a viewport (like a camera)
  97699. */
  97700. interface IViewportOwnerLike {
  97701. /**
  97702. * Gets or sets the viewport
  97703. */
  97704. viewport: IViewportLike;
  97705. }
  97706. /**
  97707. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97708. */
  97709. export class Engine extends ThinEngine {
  97710. /** Defines that alpha blending is disabled */
  97711. static readonly ALPHA_DISABLE: number;
  97712. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97713. static readonly ALPHA_ADD: number;
  97714. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97715. static readonly ALPHA_COMBINE: number;
  97716. /** Defines that alpha blending to DEST - SRC * DEST */
  97717. static readonly ALPHA_SUBTRACT: number;
  97718. /** Defines that alpha blending to SRC * DEST */
  97719. static readonly ALPHA_MULTIPLY: number;
  97720. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97721. static readonly ALPHA_MAXIMIZED: number;
  97722. /** Defines that alpha blending to SRC + DEST */
  97723. static readonly ALPHA_ONEONE: number;
  97724. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97725. static readonly ALPHA_PREMULTIPLIED: number;
  97726. /**
  97727. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97728. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97729. */
  97730. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97731. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97732. static readonly ALPHA_INTERPOLATE: number;
  97733. /**
  97734. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97735. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97736. */
  97737. static readonly ALPHA_SCREENMODE: number;
  97738. /** Defines that the ressource is not delayed*/
  97739. static readonly DELAYLOADSTATE_NONE: number;
  97740. /** Defines that the ressource was successfully delay loaded */
  97741. static readonly DELAYLOADSTATE_LOADED: number;
  97742. /** Defines that the ressource is currently delay loading */
  97743. static readonly DELAYLOADSTATE_LOADING: number;
  97744. /** Defines that the ressource is delayed and has not started loading */
  97745. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97746. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97747. static readonly NEVER: number;
  97748. /** 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 */
  97749. static readonly ALWAYS: number;
  97750. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97751. static readonly LESS: number;
  97752. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97753. static readonly EQUAL: number;
  97754. /** 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 */
  97755. static readonly LEQUAL: number;
  97756. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97757. static readonly GREATER: number;
  97758. /** 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 */
  97759. static readonly GEQUAL: number;
  97760. /** 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 */
  97761. static readonly NOTEQUAL: number;
  97762. /** Passed to stencilOperation to specify that stencil value must be kept */
  97763. static readonly KEEP: number;
  97764. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97765. static readonly REPLACE: number;
  97766. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97767. static readonly INCR: number;
  97768. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97769. static readonly DECR: number;
  97770. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97771. static readonly INVERT: number;
  97772. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97773. static readonly INCR_WRAP: number;
  97774. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97775. static readonly DECR_WRAP: number;
  97776. /** Texture is not repeating outside of 0..1 UVs */
  97777. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97778. /** Texture is repeating outside of 0..1 UVs */
  97779. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97780. /** Texture is repeating and mirrored */
  97781. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97782. /** ALPHA */
  97783. static readonly TEXTUREFORMAT_ALPHA: number;
  97784. /** LUMINANCE */
  97785. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97786. /** LUMINANCE_ALPHA */
  97787. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97788. /** RGB */
  97789. static readonly TEXTUREFORMAT_RGB: number;
  97790. /** RGBA */
  97791. static readonly TEXTUREFORMAT_RGBA: number;
  97792. /** RED */
  97793. static readonly TEXTUREFORMAT_RED: number;
  97794. /** RED (2nd reference) */
  97795. static readonly TEXTUREFORMAT_R: number;
  97796. /** RG */
  97797. static readonly TEXTUREFORMAT_RG: number;
  97798. /** RED_INTEGER */
  97799. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97800. /** RED_INTEGER (2nd reference) */
  97801. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97802. /** RG_INTEGER */
  97803. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97804. /** RGB_INTEGER */
  97805. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97806. /** RGBA_INTEGER */
  97807. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97808. /** UNSIGNED_BYTE */
  97809. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97810. /** UNSIGNED_BYTE (2nd reference) */
  97811. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97812. /** FLOAT */
  97813. static readonly TEXTURETYPE_FLOAT: number;
  97814. /** HALF_FLOAT */
  97815. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97816. /** BYTE */
  97817. static readonly TEXTURETYPE_BYTE: number;
  97818. /** SHORT */
  97819. static readonly TEXTURETYPE_SHORT: number;
  97820. /** UNSIGNED_SHORT */
  97821. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97822. /** INT */
  97823. static readonly TEXTURETYPE_INT: number;
  97824. /** UNSIGNED_INT */
  97825. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97826. /** UNSIGNED_SHORT_4_4_4_4 */
  97827. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97828. /** UNSIGNED_SHORT_5_5_5_1 */
  97829. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97830. /** UNSIGNED_SHORT_5_6_5 */
  97831. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97832. /** UNSIGNED_INT_2_10_10_10_REV */
  97833. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97834. /** UNSIGNED_INT_24_8 */
  97835. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97836. /** UNSIGNED_INT_10F_11F_11F_REV */
  97837. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97838. /** UNSIGNED_INT_5_9_9_9_REV */
  97839. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97840. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97841. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97842. /** nearest is mag = nearest and min = nearest and mip = linear */
  97843. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97844. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97845. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97846. /** Trilinear is mag = linear and min = linear and mip = linear */
  97847. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97848. /** nearest is mag = nearest and min = nearest and mip = linear */
  97849. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97850. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97851. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97852. /** Trilinear is mag = linear and min = linear and mip = linear */
  97853. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97854. /** mag = nearest and min = nearest and mip = nearest */
  97855. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97856. /** mag = nearest and min = linear and mip = nearest */
  97857. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97858. /** mag = nearest and min = linear and mip = linear */
  97859. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97860. /** mag = nearest and min = linear and mip = none */
  97861. static readonly TEXTURE_NEAREST_LINEAR: number;
  97862. /** mag = nearest and min = nearest and mip = none */
  97863. static readonly TEXTURE_NEAREST_NEAREST: number;
  97864. /** mag = linear and min = nearest and mip = nearest */
  97865. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97866. /** mag = linear and min = nearest and mip = linear */
  97867. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97868. /** mag = linear and min = linear and mip = none */
  97869. static readonly TEXTURE_LINEAR_LINEAR: number;
  97870. /** mag = linear and min = nearest and mip = none */
  97871. static readonly TEXTURE_LINEAR_NEAREST: number;
  97872. /** Explicit coordinates mode */
  97873. static readonly TEXTURE_EXPLICIT_MODE: number;
  97874. /** Spherical coordinates mode */
  97875. static readonly TEXTURE_SPHERICAL_MODE: number;
  97876. /** Planar coordinates mode */
  97877. static readonly TEXTURE_PLANAR_MODE: number;
  97878. /** Cubic coordinates mode */
  97879. static readonly TEXTURE_CUBIC_MODE: number;
  97880. /** Projection coordinates mode */
  97881. static readonly TEXTURE_PROJECTION_MODE: number;
  97882. /** Skybox coordinates mode */
  97883. static readonly TEXTURE_SKYBOX_MODE: number;
  97884. /** Inverse Cubic coordinates mode */
  97885. static readonly TEXTURE_INVCUBIC_MODE: number;
  97886. /** Equirectangular coordinates mode */
  97887. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97888. /** Equirectangular Fixed coordinates mode */
  97889. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97890. /** Equirectangular Fixed Mirrored coordinates mode */
  97891. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97892. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97893. static readonly SCALEMODE_FLOOR: number;
  97894. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97895. static readonly SCALEMODE_NEAREST: number;
  97896. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97897. static readonly SCALEMODE_CEILING: number;
  97898. /**
  97899. * Returns the current npm package of the sdk
  97900. */
  97901. static readonly NpmPackage: string;
  97902. /**
  97903. * Returns the current version of the framework
  97904. */
  97905. static readonly Version: string;
  97906. /** Gets the list of created engines */
  97907. static readonly Instances: Engine[];
  97908. /**
  97909. * Gets the latest created engine
  97910. */
  97911. static readonly LastCreatedEngine: Nullable<Engine>;
  97912. /**
  97913. * Gets the latest created scene
  97914. */
  97915. static readonly LastCreatedScene: Nullable<Scene>;
  97916. /**
  97917. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97918. * @param flag defines which part of the materials must be marked as dirty
  97919. * @param predicate defines a predicate used to filter which materials should be affected
  97920. */
  97921. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97922. /**
  97923. * Method called to create the default loading screen.
  97924. * This can be overriden in your own app.
  97925. * @param canvas The rendering canvas element
  97926. * @returns The loading screen
  97927. */
  97928. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97929. /**
  97930. * Method called to create the default rescale post process on each engine.
  97931. */
  97932. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97933. /**
  97934. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97935. **/
  97936. enableOfflineSupport: boolean;
  97937. /**
  97938. * 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)
  97939. **/
  97940. disableManifestCheck: boolean;
  97941. /**
  97942. * Gets the list of created scenes
  97943. */
  97944. scenes: Scene[];
  97945. /**
  97946. * Event raised when a new scene is created
  97947. */
  97948. onNewSceneAddedObservable: Observable<Scene>;
  97949. /**
  97950. * Gets the list of created postprocesses
  97951. */
  97952. postProcesses: PostProcess[];
  97953. /**
  97954. * Gets a boolean indicating if the pointer is currently locked
  97955. */
  97956. isPointerLock: boolean;
  97957. /**
  97958. * Observable event triggered each time the rendering canvas is resized
  97959. */
  97960. onResizeObservable: Observable<Engine>;
  97961. /**
  97962. * Observable event triggered each time the canvas loses focus
  97963. */
  97964. onCanvasBlurObservable: Observable<Engine>;
  97965. /**
  97966. * Observable event triggered each time the canvas gains focus
  97967. */
  97968. onCanvasFocusObservable: Observable<Engine>;
  97969. /**
  97970. * Observable event triggered each time the canvas receives pointerout event
  97971. */
  97972. onCanvasPointerOutObservable: Observable<PointerEvent>;
  97973. /**
  97974. * Observable event triggered before each texture is initialized
  97975. */
  97976. onBeforeTextureInitObservable: Observable<Texture>;
  97977. /**
  97978. * Observable raised when the engine begins a new frame
  97979. */
  97980. onBeginFrameObservable: Observable<Engine>;
  97981. /**
  97982. * If set, will be used to request the next animation frame for the render loop
  97983. */
  97984. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  97985. /**
  97986. * Observable raised when the engine ends the current frame
  97987. */
  97988. onEndFrameObservable: Observable<Engine>;
  97989. /**
  97990. * Observable raised when the engine is about to compile a shader
  97991. */
  97992. onBeforeShaderCompilationObservable: Observable<Engine>;
  97993. /**
  97994. * Observable raised when the engine has jsut compiled a shader
  97995. */
  97996. onAfterShaderCompilationObservable: Observable<Engine>;
  97997. /**
  97998. * Gets the audio engine
  97999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98000. * @ignorenaming
  98001. */
  98002. static audioEngine: IAudioEngine;
  98003. /**
  98004. * Default AudioEngine factory responsible of creating the Audio Engine.
  98005. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98006. */
  98007. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98008. /**
  98009. * Default offline support factory responsible of creating a tool used to store data locally.
  98010. * By default, this will create a Database object if the workload has been embedded.
  98011. */
  98012. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98013. private _loadingScreen;
  98014. private _pointerLockRequested;
  98015. private _dummyFramebuffer;
  98016. private _rescalePostProcess;
  98017. /** @hidden */
  98018. protected _alphaMode: number;
  98019. /** @hidden */
  98020. protected _alphaEquation: number;
  98021. private _deterministicLockstep;
  98022. private _lockstepMaxSteps;
  98023. protected readonly _supportsHardwareTextureRescaling: boolean;
  98024. private _fps;
  98025. private _deltaTime;
  98026. /**
  98027. * Turn this value on if you want to pause FPS computation when in background
  98028. */
  98029. disablePerformanceMonitorInBackground: boolean;
  98030. private _performanceMonitor;
  98031. /**
  98032. * Gets the performance monitor attached to this engine
  98033. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98034. */
  98035. readonly performanceMonitor: PerformanceMonitor;
  98036. private _onFocus;
  98037. private _onBlur;
  98038. private _onCanvasPointerOut;
  98039. private _onCanvasBlur;
  98040. private _onCanvasFocus;
  98041. private _onFullscreenChange;
  98042. private _onPointerLockChange;
  98043. /**
  98044. * Creates a new engine
  98045. * @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
  98046. * @param antialias defines enable antialiasing (default: false)
  98047. * @param options defines further options to be sent to the getContext() function
  98048. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98049. */
  98050. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98051. /**
  98052. * Gets current aspect ratio
  98053. * @param viewportOwner defines the camera to use to get the aspect ratio
  98054. * @param useScreen defines if screen size must be used (or the current render target if any)
  98055. * @returns a number defining the aspect ratio
  98056. */
  98057. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98058. /**
  98059. * Gets current screen aspect ratio
  98060. * @returns a number defining the aspect ratio
  98061. */
  98062. getScreenAspectRatio(): number;
  98063. /**
  98064. * Gets host document
  98065. * @returns the host document object
  98066. */
  98067. getHostDocument(): Document;
  98068. /**
  98069. * Gets the client rect of the HTML canvas attached with the current webGL context
  98070. * @returns a client rectanglee
  98071. */
  98072. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98073. /**
  98074. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98075. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98076. * @returns true if engine is in deterministic lock step mode
  98077. */
  98078. isDeterministicLockStep(): boolean;
  98079. /**
  98080. * Gets the max steps when engine is running in deterministic lock step
  98081. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98082. * @returns the max steps
  98083. */
  98084. getLockstepMaxSteps(): number;
  98085. /**
  98086. * Force the mipmap generation for the given render target texture
  98087. * @param texture defines the render target texture to use
  98088. */
  98089. generateMipMapsForCubemap(texture: InternalTexture): void;
  98090. /** States */
  98091. /**
  98092. * Set various states to the webGL context
  98093. * @param culling defines backface culling state
  98094. * @param zOffset defines the value to apply to zOffset (0 by default)
  98095. * @param force defines if states must be applied even if cache is up to date
  98096. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98097. */
  98098. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98099. /**
  98100. * Set the z offset to apply to current rendering
  98101. * @param value defines the offset to apply
  98102. */
  98103. setZOffset(value: number): void;
  98104. /**
  98105. * Gets the current value of the zOffset
  98106. * @returns the current zOffset state
  98107. */
  98108. getZOffset(): number;
  98109. /**
  98110. * Enable or disable depth buffering
  98111. * @param enable defines the state to set
  98112. */
  98113. setDepthBuffer(enable: boolean): void;
  98114. /**
  98115. * Gets a boolean indicating if depth writing is enabled
  98116. * @returns the current depth writing state
  98117. */
  98118. getDepthWrite(): boolean;
  98119. /**
  98120. * Enable or disable depth writing
  98121. * @param enable defines the state to set
  98122. */
  98123. setDepthWrite(enable: boolean): void;
  98124. /**
  98125. * Enable or disable color writing
  98126. * @param enable defines the state to set
  98127. */
  98128. setColorWrite(enable: boolean): void;
  98129. /**
  98130. * Gets a boolean indicating if color writing is enabled
  98131. * @returns the current color writing state
  98132. */
  98133. getColorWrite(): boolean;
  98134. /**
  98135. * Sets alpha constants used by some alpha blending modes
  98136. * @param r defines the red component
  98137. * @param g defines the green component
  98138. * @param b defines the blue component
  98139. * @param a defines the alpha component
  98140. */
  98141. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98142. /**
  98143. * Sets the current alpha mode
  98144. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98145. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98146. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98147. */
  98148. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98149. /**
  98150. * Gets the current alpha mode
  98151. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98152. * @returns the current alpha mode
  98153. */
  98154. getAlphaMode(): number;
  98155. /**
  98156. * Sets the current alpha equation
  98157. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98158. */
  98159. setAlphaEquation(equation: number): void;
  98160. /**
  98161. * Gets the current alpha equation.
  98162. * @returns the current alpha equation
  98163. */
  98164. getAlphaEquation(): number;
  98165. /**
  98166. * Gets a boolean indicating if stencil buffer is enabled
  98167. * @returns the current stencil buffer state
  98168. */
  98169. getStencilBuffer(): boolean;
  98170. /**
  98171. * Enable or disable the stencil buffer
  98172. * @param enable defines if the stencil buffer must be enabled or disabled
  98173. */
  98174. setStencilBuffer(enable: boolean): void;
  98175. /**
  98176. * Gets the current stencil mask
  98177. * @returns a number defining the new stencil mask to use
  98178. */
  98179. getStencilMask(): number;
  98180. /**
  98181. * Sets the current stencil mask
  98182. * @param mask defines the new stencil mask to use
  98183. */
  98184. setStencilMask(mask: number): void;
  98185. /**
  98186. * Gets the current stencil function
  98187. * @returns a number defining the stencil function to use
  98188. */
  98189. getStencilFunction(): number;
  98190. /**
  98191. * Gets the current stencil reference value
  98192. * @returns a number defining the stencil reference value to use
  98193. */
  98194. getStencilFunctionReference(): number;
  98195. /**
  98196. * Gets the current stencil mask
  98197. * @returns a number defining the stencil mask to use
  98198. */
  98199. getStencilFunctionMask(): number;
  98200. /**
  98201. * Sets the current stencil function
  98202. * @param stencilFunc defines the new stencil function to use
  98203. */
  98204. setStencilFunction(stencilFunc: number): void;
  98205. /**
  98206. * Sets the current stencil reference
  98207. * @param reference defines the new stencil reference to use
  98208. */
  98209. setStencilFunctionReference(reference: number): void;
  98210. /**
  98211. * Sets the current stencil mask
  98212. * @param mask defines the new stencil mask to use
  98213. */
  98214. setStencilFunctionMask(mask: number): void;
  98215. /**
  98216. * Gets the current stencil operation when stencil fails
  98217. * @returns a number defining stencil operation to use when stencil fails
  98218. */
  98219. getStencilOperationFail(): number;
  98220. /**
  98221. * Gets the current stencil operation when depth fails
  98222. * @returns a number defining stencil operation to use when depth fails
  98223. */
  98224. getStencilOperationDepthFail(): number;
  98225. /**
  98226. * Gets the current stencil operation when stencil passes
  98227. * @returns a number defining stencil operation to use when stencil passes
  98228. */
  98229. getStencilOperationPass(): number;
  98230. /**
  98231. * Sets the stencil operation to use when stencil fails
  98232. * @param operation defines the stencil operation to use when stencil fails
  98233. */
  98234. setStencilOperationFail(operation: number): void;
  98235. /**
  98236. * Sets the stencil operation to use when depth fails
  98237. * @param operation defines the stencil operation to use when depth fails
  98238. */
  98239. setStencilOperationDepthFail(operation: number): void;
  98240. /**
  98241. * Sets the stencil operation to use when stencil passes
  98242. * @param operation defines the stencil operation to use when stencil passes
  98243. */
  98244. setStencilOperationPass(operation: number): void;
  98245. /**
  98246. * Sets a boolean indicating if the dithering state is enabled or disabled
  98247. * @param value defines the dithering state
  98248. */
  98249. setDitheringState(value: boolean): void;
  98250. /**
  98251. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98252. * @param value defines the rasterizer state
  98253. */
  98254. setRasterizerState(value: boolean): void;
  98255. /**
  98256. * Gets the current depth function
  98257. * @returns a number defining the depth function
  98258. */
  98259. getDepthFunction(): Nullable<number>;
  98260. /**
  98261. * Sets the current depth function
  98262. * @param depthFunc defines the function to use
  98263. */
  98264. setDepthFunction(depthFunc: number): void;
  98265. /**
  98266. * Sets the current depth function to GREATER
  98267. */
  98268. setDepthFunctionToGreater(): void;
  98269. /**
  98270. * Sets the current depth function to GEQUAL
  98271. */
  98272. setDepthFunctionToGreaterOrEqual(): void;
  98273. /**
  98274. * Sets the current depth function to LESS
  98275. */
  98276. setDepthFunctionToLess(): void;
  98277. /**
  98278. * Sets the current depth function to LEQUAL
  98279. */
  98280. setDepthFunctionToLessOrEqual(): void;
  98281. private _cachedStencilBuffer;
  98282. private _cachedStencilFunction;
  98283. private _cachedStencilMask;
  98284. private _cachedStencilOperationPass;
  98285. private _cachedStencilOperationFail;
  98286. private _cachedStencilOperationDepthFail;
  98287. private _cachedStencilReference;
  98288. /**
  98289. * Caches the the state of the stencil buffer
  98290. */
  98291. cacheStencilState(): void;
  98292. /**
  98293. * Restores the state of the stencil buffer
  98294. */
  98295. restoreStencilState(): void;
  98296. /**
  98297. * Directly set the WebGL Viewport
  98298. * @param x defines the x coordinate of the viewport (in screen space)
  98299. * @param y defines the y coordinate of the viewport (in screen space)
  98300. * @param width defines the width of the viewport (in screen space)
  98301. * @param height defines the height of the viewport (in screen space)
  98302. * @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
  98303. */
  98304. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98305. /**
  98306. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98307. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98308. * @param y defines the y-coordinate of the corner of the clear rectangle
  98309. * @param width defines the width of the clear rectangle
  98310. * @param height defines the height of the clear rectangle
  98311. * @param clearColor defines the clear color
  98312. */
  98313. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98314. /**
  98315. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98316. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98317. * @param y defines the y-coordinate of the corner of the clear rectangle
  98318. * @param width defines the width of the clear rectangle
  98319. * @param height defines the height of the clear rectangle
  98320. */
  98321. enableScissor(x: number, y: number, width: number, height: number): void;
  98322. /**
  98323. * Disable previously set scissor test rectangle
  98324. */
  98325. disableScissor(): void;
  98326. /**
  98327. * Initializes a webVR display and starts listening to display change events
  98328. * The onVRDisplayChangedObservable will be notified upon these changes
  98329. * @returns The onVRDisplayChangedObservable
  98330. */
  98331. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98332. /** @hidden */
  98333. _prepareVRComponent(): void;
  98334. /** @hidden */
  98335. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98336. /** @hidden */
  98337. _submitVRFrame(): void;
  98338. /**
  98339. * Call this function to leave webVR mode
  98340. * Will do nothing if webVR is not supported or if there is no webVR device
  98341. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98342. */
  98343. disableVR(): void;
  98344. /**
  98345. * Gets a boolean indicating that the system is in VR mode and is presenting
  98346. * @returns true if VR mode is engaged
  98347. */
  98348. isVRPresenting(): boolean;
  98349. /** @hidden */
  98350. _requestVRFrame(): void;
  98351. /** @hidden */
  98352. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98353. /**
  98354. * Gets the source code of the vertex shader associated with a specific webGL program
  98355. * @param program defines the program to use
  98356. * @returns a string containing the source code of the vertex shader associated with the program
  98357. */
  98358. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98359. /**
  98360. * Gets the source code of the fragment shader associated with a specific webGL program
  98361. * @param program defines the program to use
  98362. * @returns a string containing the source code of the fragment shader associated with the program
  98363. */
  98364. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98365. /**
  98366. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98367. * @param x defines the x coordinate of the rectangle where pixels must be read
  98368. * @param y defines the y coordinate of the rectangle where pixels must be read
  98369. * @param width defines the width of the rectangle where pixels must be read
  98370. * @param height defines the height of the rectangle where pixels must be read
  98371. * @returns a Uint8Array containing RGBA colors
  98372. */
  98373. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98374. /**
  98375. * Sets a depth stencil texture from a render target to the according uniform.
  98376. * @param channel The texture channel
  98377. * @param uniform The uniform to set
  98378. * @param texture The render target texture containing the depth stencil texture to apply
  98379. */
  98380. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98381. /**
  98382. * Sets a texture to the webGL context from a postprocess
  98383. * @param channel defines the channel to use
  98384. * @param postProcess defines the source postprocess
  98385. */
  98386. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98387. /**
  98388. * Binds the output of the passed in post process to the texture channel specified
  98389. * @param channel The channel the texture should be bound to
  98390. * @param postProcess The post process which's output should be bound
  98391. */
  98392. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98393. /** @hidden */
  98394. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98395. protected _rebuildBuffers(): void;
  98396. _renderLoop(): void;
  98397. /**
  98398. * Toggle full screen mode
  98399. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98400. */
  98401. switchFullscreen(requestPointerLock: boolean): void;
  98402. /**
  98403. * Enters full screen mode
  98404. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98405. */
  98406. enterFullscreen(requestPointerLock: boolean): void;
  98407. /**
  98408. * Exits full screen mode
  98409. */
  98410. exitFullscreen(): void;
  98411. /**
  98412. * Enters Pointerlock mode
  98413. */
  98414. enterPointerlock(): void;
  98415. /**
  98416. * Exits Pointerlock mode
  98417. */
  98418. exitPointerlock(): void;
  98419. /**
  98420. * Begin a new frame
  98421. */
  98422. beginFrame(): void;
  98423. /**
  98424. * Enf the current frame
  98425. */
  98426. endFrame(): void;
  98427. resize(): void;
  98428. /**
  98429. * Set the compressed texture format to use, based on the formats you have, and the formats
  98430. * supported by the hardware / browser.
  98431. *
  98432. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98433. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98434. * to API arguments needed to compressed textures. This puts the burden on the container
  98435. * generator to house the arcane code for determining these for current & future formats.
  98436. *
  98437. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98438. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98439. *
  98440. * Note: The result of this call is not taken into account when a texture is base64.
  98441. *
  98442. * @param formatsAvailable defines the list of those format families you have created
  98443. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98444. *
  98445. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98446. * @returns The extension selected.
  98447. */
  98448. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98449. /**
  98450. * Force a specific size of the canvas
  98451. * @param width defines the new canvas' width
  98452. * @param height defines the new canvas' height
  98453. */
  98454. setSize(width: number, height: number): void;
  98455. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98456. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98457. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98458. _releaseTexture(texture: InternalTexture): void;
  98459. /**
  98460. * @hidden
  98461. * Rescales a texture
  98462. * @param source input texutre
  98463. * @param destination destination texture
  98464. * @param scene scene to use to render the resize
  98465. * @param internalFormat format to use when resizing
  98466. * @param onComplete callback to be called when resize has completed
  98467. */
  98468. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98469. /**
  98470. * Gets the current framerate
  98471. * @returns a number representing the framerate
  98472. */
  98473. getFps(): number;
  98474. /**
  98475. * Gets the time spent between current and previous frame
  98476. * @returns a number representing the delta time in ms
  98477. */
  98478. getDeltaTime(): number;
  98479. private _measureFps;
  98480. /**
  98481. * Creates a new render target texture
  98482. * @param size defines the size of the texture
  98483. * @param options defines the options used to create the texture
  98484. * @returns a new render target texture stored in an InternalTexture
  98485. */
  98486. createRenderTargetTexture(size: number | {
  98487. width: number;
  98488. height: number;
  98489. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98490. /**
  98491. * Updates the sample count of a render target texture
  98492. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98493. * @param texture defines the texture to update
  98494. * @param samples defines the sample count to set
  98495. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98496. */
  98497. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98498. /** @hidden */
  98499. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98500. dispose(): void;
  98501. private _disableTouchAction;
  98502. /**
  98503. * Display the loading screen
  98504. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98505. */
  98506. displayLoadingUI(): void;
  98507. /**
  98508. * Hide the loading screen
  98509. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98510. */
  98511. hideLoadingUI(): void;
  98512. /**
  98513. * Gets the current loading screen object
  98514. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98515. */
  98516. /**
  98517. * Sets the current loading screen object
  98518. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98519. */
  98520. loadingScreen: ILoadingScreen;
  98521. /**
  98522. * Sets the current loading screen text
  98523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98524. */
  98525. loadingUIText: string;
  98526. /**
  98527. * Sets the current loading screen background color
  98528. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98529. */
  98530. loadingUIBackgroundColor: string;
  98531. /** Pointerlock and fullscreen */
  98532. /**
  98533. * Ask the browser to promote the current element to pointerlock mode
  98534. * @param element defines the DOM element to promote
  98535. */
  98536. static _RequestPointerlock(element: HTMLElement): void;
  98537. /**
  98538. * Asks the browser to exit pointerlock mode
  98539. */
  98540. static _ExitPointerlock(): void;
  98541. /**
  98542. * Ask the browser to promote the current element to fullscreen rendering mode
  98543. * @param element defines the DOM element to promote
  98544. */
  98545. static _RequestFullscreen(element: HTMLElement): void;
  98546. /**
  98547. * Asks the browser to exit fullscreen mode
  98548. */
  98549. static _ExitFullscreen(): void;
  98550. }
  98551. }
  98552. declare module BABYLON {
  98553. /**
  98554. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98555. * during the life time of the application.
  98556. */
  98557. export class EngineStore {
  98558. /** Gets the list of created engines */
  98559. static Instances: Engine[];
  98560. /** @hidden */
  98561. static _LastCreatedScene: Nullable<Scene>;
  98562. /**
  98563. * Gets the latest created engine
  98564. */
  98565. static readonly LastCreatedEngine: Nullable<Engine>;
  98566. /**
  98567. * Gets the latest created scene
  98568. */
  98569. static readonly LastCreatedScene: Nullable<Scene>;
  98570. /**
  98571. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98572. * @ignorenaming
  98573. */
  98574. static UseFallbackTexture: boolean;
  98575. /**
  98576. * Texture content used if a texture cannot loaded
  98577. * @ignorenaming
  98578. */
  98579. static FallbackTexture: string;
  98580. }
  98581. }
  98582. declare module BABYLON {
  98583. /**
  98584. * Helper class that provides a small promise polyfill
  98585. */
  98586. export class PromisePolyfill {
  98587. /**
  98588. * Static function used to check if the polyfill is required
  98589. * If this is the case then the function will inject the polyfill to window.Promise
  98590. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98591. */
  98592. static Apply(force?: boolean): void;
  98593. }
  98594. }
  98595. declare module BABYLON {
  98596. /**
  98597. * Interface for screenshot methods with describe argument called `size` as object with options
  98598. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98599. */
  98600. export interface IScreenshotSize {
  98601. /**
  98602. * number in pixels for canvas height
  98603. */
  98604. height?: number;
  98605. /**
  98606. * multiplier allowing render at a higher or lower resolution
  98607. * If value is defined then height and width will be ignored and taken from camera
  98608. */
  98609. precision?: number;
  98610. /**
  98611. * number in pixels for canvas width
  98612. */
  98613. width?: number;
  98614. }
  98615. }
  98616. declare module BABYLON {
  98617. interface IColor4Like {
  98618. r: float;
  98619. g: float;
  98620. b: float;
  98621. a: float;
  98622. }
  98623. /**
  98624. * Class containing a set of static utilities functions
  98625. */
  98626. export class Tools {
  98627. /**
  98628. * Gets or sets the base URL to use to load assets
  98629. */
  98630. static BaseUrl: string;
  98631. /**
  98632. * Enable/Disable Custom HTTP Request Headers globally.
  98633. * default = false
  98634. * @see CustomRequestHeaders
  98635. */
  98636. static UseCustomRequestHeaders: boolean;
  98637. /**
  98638. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98639. * i.e. when loading files, where the server/service expects an Authorization header
  98640. */
  98641. static CustomRequestHeaders: {
  98642. [key: string]: string;
  98643. };
  98644. /**
  98645. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98646. */
  98647. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98648. /**
  98649. * Default behaviour for cors in the application.
  98650. * It can be a string if the expected behavior is identical in the entire app.
  98651. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98652. */
  98653. static CorsBehavior: string | ((url: string | string[]) => string);
  98654. /**
  98655. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98656. * @ignorenaming
  98657. */
  98658. static UseFallbackTexture: boolean;
  98659. /**
  98660. * Use this object to register external classes like custom textures or material
  98661. * to allow the laoders to instantiate them
  98662. */
  98663. static RegisteredExternalClasses: {
  98664. [key: string]: Object;
  98665. };
  98666. /**
  98667. * Texture content used if a texture cannot loaded
  98668. * @ignorenaming
  98669. */
  98670. static fallbackTexture: string;
  98671. /**
  98672. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98673. * @param u defines the coordinate on X axis
  98674. * @param v defines the coordinate on Y axis
  98675. * @param width defines the width of the source data
  98676. * @param height defines the height of the source data
  98677. * @param pixels defines the source byte array
  98678. * @param color defines the output color
  98679. */
  98680. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98681. /**
  98682. * Interpolates between a and b via alpha
  98683. * @param a The lower value (returned when alpha = 0)
  98684. * @param b The upper value (returned when alpha = 1)
  98685. * @param alpha The interpolation-factor
  98686. * @return The mixed value
  98687. */
  98688. static Mix(a: number, b: number, alpha: number): number;
  98689. /**
  98690. * Tries to instantiate a new object from a given class name
  98691. * @param className defines the class name to instantiate
  98692. * @returns the new object or null if the system was not able to do the instantiation
  98693. */
  98694. static Instantiate(className: string): any;
  98695. /**
  98696. * Provides a slice function that will work even on IE
  98697. * @param data defines the array to slice
  98698. * @param start defines the start of the data (optional)
  98699. * @param end defines the end of the data (optional)
  98700. * @returns the new sliced array
  98701. */
  98702. static Slice<T>(data: T, start?: number, end?: number): T;
  98703. /**
  98704. * Polyfill for setImmediate
  98705. * @param action defines the action to execute after the current execution block
  98706. */
  98707. static SetImmediate(action: () => void): void;
  98708. /**
  98709. * Function indicating if a number is an exponent of 2
  98710. * @param value defines the value to test
  98711. * @returns true if the value is an exponent of 2
  98712. */
  98713. static IsExponentOfTwo(value: number): boolean;
  98714. private static _tmpFloatArray;
  98715. /**
  98716. * Returns the nearest 32-bit single precision float representation of a Number
  98717. * @param value A Number. If the parameter is of a different type, it will get converted
  98718. * to a number or to NaN if it cannot be converted
  98719. * @returns number
  98720. */
  98721. static FloatRound(value: number): number;
  98722. /**
  98723. * Extracts the filename from a path
  98724. * @param path defines the path to use
  98725. * @returns the filename
  98726. */
  98727. static GetFilename(path: string): string;
  98728. /**
  98729. * Extracts the "folder" part of a path (everything before the filename).
  98730. * @param uri The URI to extract the info from
  98731. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98732. * @returns The "folder" part of the path
  98733. */
  98734. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98735. /**
  98736. * Extracts text content from a DOM element hierarchy
  98737. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98738. */
  98739. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98740. /**
  98741. * Convert an angle in radians to degrees
  98742. * @param angle defines the angle to convert
  98743. * @returns the angle in degrees
  98744. */
  98745. static ToDegrees(angle: number): number;
  98746. /**
  98747. * Convert an angle in degrees to radians
  98748. * @param angle defines the angle to convert
  98749. * @returns the angle in radians
  98750. */
  98751. static ToRadians(angle: number): number;
  98752. /**
  98753. * Encode a buffer to a base64 string
  98754. * @param buffer defines the buffer to encode
  98755. * @returns the encoded string
  98756. */
  98757. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98758. /**
  98759. * Returns an array if obj is not an array
  98760. * @param obj defines the object to evaluate as an array
  98761. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98762. * @returns either obj directly if obj is an array or a new array containing obj
  98763. */
  98764. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98765. /**
  98766. * Gets the pointer prefix to use
  98767. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98768. */
  98769. static GetPointerPrefix(): string;
  98770. /**
  98771. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98772. * @param url define the url we are trying
  98773. * @param element define the dom element where to configure the cors policy
  98774. */
  98775. static SetCorsBehavior(url: string | string[], element: {
  98776. crossOrigin: string | null;
  98777. }): void;
  98778. /**
  98779. * Removes unwanted characters from an url
  98780. * @param url defines the url to clean
  98781. * @returns the cleaned url
  98782. */
  98783. static CleanUrl(url: string): string;
  98784. /**
  98785. * Gets or sets a function used to pre-process url before using them to load assets
  98786. */
  98787. static PreprocessUrl: (url: string) => string;
  98788. /**
  98789. * Loads an image as an HTMLImageElement.
  98790. * @param input url string, ArrayBuffer, or Blob to load
  98791. * @param onLoad callback called when the image successfully loads
  98792. * @param onError callback called when the image fails to load
  98793. * @param offlineProvider offline provider for caching
  98794. * @returns the HTMLImageElement of the loaded image
  98795. */
  98796. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98797. /**
  98798. * Loads a file
  98799. * @param url url string, ArrayBuffer, or Blob to load
  98800. * @param onSuccess callback called when the file successfully loads
  98801. * @param onProgress callback called while file is loading (if the server supports this mode)
  98802. * @param offlineProvider defines the offline provider for caching
  98803. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98804. * @param onError callback called when the file fails to load
  98805. * @returns a file request object
  98806. */
  98807. 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;
  98808. /**
  98809. * Loads a file from a url
  98810. * @param url the file url to load
  98811. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98812. */
  98813. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98814. /**
  98815. * Load a script (identified by an url). When the url returns, the
  98816. * content of this file is added into a new script element, attached to the DOM (body element)
  98817. * @param scriptUrl defines the url of the script to laod
  98818. * @param onSuccess defines the callback called when the script is loaded
  98819. * @param onError defines the callback to call if an error occurs
  98820. * @param scriptId defines the id of the script element
  98821. */
  98822. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98823. /**
  98824. * Load an asynchronous script (identified by an url). When the url returns, the
  98825. * content of this file is added into a new script element, attached to the DOM (body element)
  98826. * @param scriptUrl defines the url of the script to laod
  98827. * @param scriptId defines the id of the script element
  98828. * @returns a promise request object
  98829. */
  98830. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98831. /**
  98832. * Loads a file from a blob
  98833. * @param fileToLoad defines the blob to use
  98834. * @param callback defines the callback to call when data is loaded
  98835. * @param progressCallback defines the callback to call during loading process
  98836. * @returns a file request object
  98837. */
  98838. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98839. /**
  98840. * Loads a file
  98841. * @param fileToLoad defines the file to load
  98842. * @param callback defines the callback to call when data is loaded
  98843. * @param progressCallBack defines the callback to call during loading process
  98844. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98845. * @returns a file request object
  98846. */
  98847. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98848. /**
  98849. * Creates a data url from a given string content
  98850. * @param content defines the content to convert
  98851. * @returns the new data url link
  98852. */
  98853. static FileAsURL(content: string): string;
  98854. /**
  98855. * Format the given number to a specific decimal format
  98856. * @param value defines the number to format
  98857. * @param decimals defines the number of decimals to use
  98858. * @returns the formatted string
  98859. */
  98860. static Format(value: number, decimals?: number): string;
  98861. /**
  98862. * Tries to copy an object by duplicating every property
  98863. * @param source defines the source object
  98864. * @param destination defines the target object
  98865. * @param doNotCopyList defines a list of properties to avoid
  98866. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98867. */
  98868. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98869. /**
  98870. * Gets a boolean indicating if the given object has no own property
  98871. * @param obj defines the object to test
  98872. * @returns true if object has no own property
  98873. */
  98874. static IsEmpty(obj: any): boolean;
  98875. /**
  98876. * Function used to register events at window level
  98877. * @param windowElement defines the Window object to use
  98878. * @param events defines the events to register
  98879. */
  98880. static RegisterTopRootEvents(windowElement: Window, events: {
  98881. name: string;
  98882. handler: Nullable<(e: FocusEvent) => any>;
  98883. }[]): void;
  98884. /**
  98885. * Function used to unregister events from window level
  98886. * @param windowElement defines the Window object to use
  98887. * @param events defines the events to unregister
  98888. */
  98889. static UnregisterTopRootEvents(windowElement: Window, events: {
  98890. name: string;
  98891. handler: Nullable<(e: FocusEvent) => any>;
  98892. }[]): void;
  98893. /**
  98894. * @ignore
  98895. */
  98896. static _ScreenshotCanvas: HTMLCanvasElement;
  98897. /**
  98898. * Dumps the current bound framebuffer
  98899. * @param width defines the rendering width
  98900. * @param height defines the rendering height
  98901. * @param engine defines the hosting engine
  98902. * @param successCallback defines the callback triggered once the data are available
  98903. * @param mimeType defines the mime type of the result
  98904. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98905. */
  98906. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98907. /**
  98908. * Converts the canvas data to blob.
  98909. * This acts as a polyfill for browsers not supporting the to blob function.
  98910. * @param canvas Defines the canvas to extract the data from
  98911. * @param successCallback Defines the callback triggered once the data are available
  98912. * @param mimeType Defines the mime type of the result
  98913. */
  98914. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98915. /**
  98916. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98917. * @param successCallback defines the callback triggered once the data are available
  98918. * @param mimeType defines the mime type of the result
  98919. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98920. */
  98921. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98922. /**
  98923. * Downloads a blob in the browser
  98924. * @param blob defines the blob to download
  98925. * @param fileName defines the name of the downloaded file
  98926. */
  98927. static Download(blob: Blob, fileName: string): void;
  98928. /**
  98929. * Captures a screenshot of the current rendering
  98930. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98931. * @param engine defines the rendering engine
  98932. * @param camera defines the source camera
  98933. * @param size This parameter can be set to a single number or to an object with the
  98934. * following (optional) properties: precision, width, height. If a single number is passed,
  98935. * it will be used for both width and height. If an object is passed, the screenshot size
  98936. * will be derived from the parameters. The precision property is a multiplier allowing
  98937. * rendering at a higher or lower resolution
  98938. * @param successCallback defines the callback receives a single parameter which contains the
  98939. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98940. * src parameter of an <img> to display it
  98941. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98942. * Check your browser for supported MIME types
  98943. */
  98944. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98945. /**
  98946. * Captures a screenshot of the current rendering
  98947. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98948. * @param engine defines the rendering engine
  98949. * @param camera defines the source camera
  98950. * @param size This parameter can be set to a single number or to an object with the
  98951. * following (optional) properties: precision, width, height. If a single number is passed,
  98952. * it will be used for both width and height. If an object is passed, the screenshot size
  98953. * will be derived from the parameters. The precision property is a multiplier allowing
  98954. * rendering at a higher or lower resolution
  98955. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98956. * Check your browser for supported MIME types
  98957. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98958. * to the src parameter of an <img> to display it
  98959. */
  98960. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98961. /**
  98962. * Generates an image screenshot from the specified camera.
  98963. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98964. * @param engine The engine to use for rendering
  98965. * @param camera The camera to use for rendering
  98966. * @param size This parameter can be set to a single number or to an object with the
  98967. * following (optional) properties: precision, width, height. If a single number is passed,
  98968. * it will be used for both width and height. If an object is passed, the screenshot size
  98969. * will be derived from the parameters. The precision property is a multiplier allowing
  98970. * rendering at a higher or lower resolution
  98971. * @param successCallback The callback receives a single parameter which contains the
  98972. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98973. * src parameter of an <img> to display it
  98974. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98975. * Check your browser for supported MIME types
  98976. * @param samples Texture samples (default: 1)
  98977. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98978. * @param fileName A name for for the downloaded file.
  98979. */
  98980. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98981. /**
  98982. * Generates an image screenshot from the specified camera.
  98983. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98984. * @param engine The engine to use for rendering
  98985. * @param camera The camera to use for rendering
  98986. * @param size This parameter can be set to a single number or to an object with the
  98987. * following (optional) properties: precision, width, height. If a single number is passed,
  98988. * it will be used for both width and height. If an object is passed, the screenshot size
  98989. * will be derived from the parameters. The precision property is a multiplier allowing
  98990. * rendering at a higher or lower resolution
  98991. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98992. * Check your browser for supported MIME types
  98993. * @param samples Texture samples (default: 1)
  98994. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98995. * @param fileName A name for for the downloaded file.
  98996. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98997. * to the src parameter of an <img> to display it
  98998. */
  98999. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99000. /**
  99001. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99002. * Be aware Math.random() could cause collisions, but:
  99003. * "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"
  99004. * @returns a pseudo random id
  99005. */
  99006. static RandomId(): string;
  99007. /**
  99008. * Test if the given uri is a base64 string
  99009. * @param uri The uri to test
  99010. * @return True if the uri is a base64 string or false otherwise
  99011. */
  99012. static IsBase64(uri: string): boolean;
  99013. /**
  99014. * Decode the given base64 uri.
  99015. * @param uri The uri to decode
  99016. * @return The decoded base64 data.
  99017. */
  99018. static DecodeBase64(uri: string): ArrayBuffer;
  99019. /**
  99020. * Gets the absolute url.
  99021. * @param url the input url
  99022. * @return the absolute url
  99023. */
  99024. static GetAbsoluteUrl(url: string): string;
  99025. /**
  99026. * No log
  99027. */
  99028. static readonly NoneLogLevel: number;
  99029. /**
  99030. * Only message logs
  99031. */
  99032. static readonly MessageLogLevel: number;
  99033. /**
  99034. * Only warning logs
  99035. */
  99036. static readonly WarningLogLevel: number;
  99037. /**
  99038. * Only error logs
  99039. */
  99040. static readonly ErrorLogLevel: number;
  99041. /**
  99042. * All logs
  99043. */
  99044. static readonly AllLogLevel: number;
  99045. /**
  99046. * Gets a value indicating the number of loading errors
  99047. * @ignorenaming
  99048. */
  99049. static readonly errorsCount: number;
  99050. /**
  99051. * Callback called when a new log is added
  99052. */
  99053. static OnNewCacheEntry: (entry: string) => void;
  99054. /**
  99055. * Log a message to the console
  99056. * @param message defines the message to log
  99057. */
  99058. static Log(message: string): void;
  99059. /**
  99060. * Write a warning message to the console
  99061. * @param message defines the message to log
  99062. */
  99063. static Warn(message: string): void;
  99064. /**
  99065. * Write an error message to the console
  99066. * @param message defines the message to log
  99067. */
  99068. static Error(message: string): void;
  99069. /**
  99070. * Gets current log cache (list of logs)
  99071. */
  99072. static readonly LogCache: string;
  99073. /**
  99074. * Clears the log cache
  99075. */
  99076. static ClearLogCache(): void;
  99077. /**
  99078. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99079. */
  99080. static LogLevels: number;
  99081. /**
  99082. * Checks if the window object exists
  99083. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99084. */
  99085. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99086. /**
  99087. * No performance log
  99088. */
  99089. static readonly PerformanceNoneLogLevel: number;
  99090. /**
  99091. * Use user marks to log performance
  99092. */
  99093. static readonly PerformanceUserMarkLogLevel: number;
  99094. /**
  99095. * Log performance to the console
  99096. */
  99097. static readonly PerformanceConsoleLogLevel: number;
  99098. private static _performance;
  99099. /**
  99100. * Sets the current performance log level
  99101. */
  99102. static PerformanceLogLevel: number;
  99103. private static _StartPerformanceCounterDisabled;
  99104. private static _EndPerformanceCounterDisabled;
  99105. private static _StartUserMark;
  99106. private static _EndUserMark;
  99107. private static _StartPerformanceConsole;
  99108. private static _EndPerformanceConsole;
  99109. /**
  99110. * Starts a performance counter
  99111. */
  99112. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99113. /**
  99114. * Ends a specific performance coutner
  99115. */
  99116. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99117. /**
  99118. * Gets either window.performance.now() if supported or Date.now() else
  99119. */
  99120. static readonly Now: number;
  99121. /**
  99122. * This method will return the name of the class used to create the instance of the given object.
  99123. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99124. * @param object the object to get the class name from
  99125. * @param isType defines if the object is actually a type
  99126. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99127. */
  99128. static GetClassName(object: any, isType?: boolean): string;
  99129. /**
  99130. * Gets the first element of an array satisfying a given predicate
  99131. * @param array defines the array to browse
  99132. * @param predicate defines the predicate to use
  99133. * @returns null if not found or the element
  99134. */
  99135. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99136. /**
  99137. * This method will return the name of the full name of the class, including its owning module (if any).
  99138. * 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).
  99139. * @param object the object to get the class name from
  99140. * @param isType defines if the object is actually a type
  99141. * @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.
  99142. * @ignorenaming
  99143. */
  99144. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99145. /**
  99146. * Returns a promise that resolves after the given amount of time.
  99147. * @param delay Number of milliseconds to delay
  99148. * @returns Promise that resolves after the given amount of time
  99149. */
  99150. static DelayAsync(delay: number): Promise<void>;
  99151. }
  99152. /**
  99153. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99154. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99155. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99156. * @param name The name of the class, case should be preserved
  99157. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99158. */
  99159. export function className(name: string, module?: string): (target: Object) => void;
  99160. /**
  99161. * An implementation of a loop for asynchronous functions.
  99162. */
  99163. export class AsyncLoop {
  99164. /**
  99165. * Defines the number of iterations for the loop
  99166. */
  99167. iterations: number;
  99168. /**
  99169. * Defines the current index of the loop.
  99170. */
  99171. index: number;
  99172. private _done;
  99173. private _fn;
  99174. private _successCallback;
  99175. /**
  99176. * Constructor.
  99177. * @param iterations the number of iterations.
  99178. * @param func the function to run each iteration
  99179. * @param successCallback the callback that will be called upon succesful execution
  99180. * @param offset starting offset.
  99181. */
  99182. constructor(
  99183. /**
  99184. * Defines the number of iterations for the loop
  99185. */
  99186. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99187. /**
  99188. * Execute the next iteration. Must be called after the last iteration was finished.
  99189. */
  99190. executeNext(): void;
  99191. /**
  99192. * Break the loop and run the success callback.
  99193. */
  99194. breakLoop(): void;
  99195. /**
  99196. * Create and run an async loop.
  99197. * @param iterations the number of iterations.
  99198. * @param fn the function to run each iteration
  99199. * @param successCallback the callback that will be called upon succesful execution
  99200. * @param offset starting offset.
  99201. * @returns the created async loop object
  99202. */
  99203. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99204. /**
  99205. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99206. * @param iterations total number of iterations
  99207. * @param syncedIterations number of synchronous iterations in each async iteration.
  99208. * @param fn the function to call each iteration.
  99209. * @param callback a success call back that will be called when iterating stops.
  99210. * @param breakFunction a break condition (optional)
  99211. * @param timeout timeout settings for the setTimeout function. default - 0.
  99212. * @returns the created async loop object
  99213. */
  99214. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99215. }
  99216. }
  99217. declare module BABYLON {
  99218. /**
  99219. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99220. * The underlying implementation relies on an associative array to ensure the best performances.
  99221. * The value can be anything including 'null' but except 'undefined'
  99222. */
  99223. export class StringDictionary<T> {
  99224. /**
  99225. * This will clear this dictionary and copy the content from the 'source' one.
  99226. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99227. * @param source the dictionary to take the content from and copy to this dictionary
  99228. */
  99229. copyFrom(source: StringDictionary<T>): void;
  99230. /**
  99231. * Get a value based from its key
  99232. * @param key the given key to get the matching value from
  99233. * @return the value if found, otherwise undefined is returned
  99234. */
  99235. get(key: string): T | undefined;
  99236. /**
  99237. * Get a value from its key or add it if it doesn't exist.
  99238. * This method will ensure you that a given key/data will be present in the dictionary.
  99239. * @param key the given key to get the matching value from
  99240. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99241. * The factory will only be invoked if there's no data for the given key.
  99242. * @return the value corresponding to the key.
  99243. */
  99244. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99245. /**
  99246. * Get a value from its key if present in the dictionary otherwise add it
  99247. * @param key the key to get the value from
  99248. * @param val if there's no such key/value pair in the dictionary add it with this value
  99249. * @return the value corresponding to the key
  99250. */
  99251. getOrAdd(key: string, val: T): T;
  99252. /**
  99253. * Check if there's a given key in the dictionary
  99254. * @param key the key to check for
  99255. * @return true if the key is present, false otherwise
  99256. */
  99257. contains(key: string): boolean;
  99258. /**
  99259. * Add a new key and its corresponding value
  99260. * @param key the key to add
  99261. * @param value the value corresponding to the key
  99262. * @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
  99263. */
  99264. add(key: string, value: T): boolean;
  99265. /**
  99266. * Update a specific value associated to a key
  99267. * @param key defines the key to use
  99268. * @param value defines the value to store
  99269. * @returns true if the value was updated (or false if the key was not found)
  99270. */
  99271. set(key: string, value: T): boolean;
  99272. /**
  99273. * Get the element of the given key and remove it from the dictionary
  99274. * @param key defines the key to search
  99275. * @returns the value associated with the key or null if not found
  99276. */
  99277. getAndRemove(key: string): Nullable<T>;
  99278. /**
  99279. * Remove a key/value from the dictionary.
  99280. * @param key the key to remove
  99281. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99282. */
  99283. remove(key: string): boolean;
  99284. /**
  99285. * Clear the whole content of the dictionary
  99286. */
  99287. clear(): void;
  99288. /**
  99289. * Gets the current count
  99290. */
  99291. readonly count: number;
  99292. /**
  99293. * Execute a callback on each key/val of the dictionary.
  99294. * Note that you can remove any element in this dictionary in the callback implementation
  99295. * @param callback the callback to execute on a given key/value pair
  99296. */
  99297. forEach(callback: (key: string, val: T) => void): void;
  99298. /**
  99299. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99300. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99301. * Note that you can remove any element in this dictionary in the callback implementation
  99302. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99303. * @returns the first item
  99304. */
  99305. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99306. private _count;
  99307. private _data;
  99308. }
  99309. }
  99310. declare module BABYLON {
  99311. /** @hidden */
  99312. export interface ICollisionCoordinator {
  99313. createCollider(): Collider;
  99314. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99315. init(scene: Scene): void;
  99316. }
  99317. /** @hidden */
  99318. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99319. private _scene;
  99320. private _scaledPosition;
  99321. private _scaledVelocity;
  99322. private _finalPosition;
  99323. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99324. createCollider(): Collider;
  99325. init(scene: Scene): void;
  99326. private _collideWithWorld;
  99327. }
  99328. }
  99329. declare module BABYLON {
  99330. /**
  99331. * Class used to manage all inputs for the scene.
  99332. */
  99333. export class InputManager {
  99334. /** The distance in pixel that you have to move to prevent some events */
  99335. static DragMovementThreshold: number;
  99336. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99337. static LongPressDelay: number;
  99338. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99339. static DoubleClickDelay: number;
  99340. /** If you need to check double click without raising a single click at first click, enable this flag */
  99341. static ExclusiveDoubleClickMode: boolean;
  99342. private _wheelEventName;
  99343. private _onPointerMove;
  99344. private _onPointerDown;
  99345. private _onPointerUp;
  99346. private _initClickEvent;
  99347. private _initActionManager;
  99348. private _delayedSimpleClick;
  99349. private _delayedSimpleClickTimeout;
  99350. private _previousDelayedSimpleClickTimeout;
  99351. private _meshPickProceed;
  99352. private _previousButtonPressed;
  99353. private _currentPickResult;
  99354. private _previousPickResult;
  99355. private _totalPointersPressed;
  99356. private _doubleClickOccured;
  99357. private _pointerOverMesh;
  99358. private _pickedDownMesh;
  99359. private _pickedUpMesh;
  99360. private _pointerX;
  99361. private _pointerY;
  99362. private _unTranslatedPointerX;
  99363. private _unTranslatedPointerY;
  99364. private _startingPointerPosition;
  99365. private _previousStartingPointerPosition;
  99366. private _startingPointerTime;
  99367. private _previousStartingPointerTime;
  99368. private _pointerCaptures;
  99369. private _onKeyDown;
  99370. private _onKeyUp;
  99371. private _onCanvasFocusObserver;
  99372. private _onCanvasBlurObserver;
  99373. private _scene;
  99374. /**
  99375. * Creates a new InputManager
  99376. * @param scene defines the hosting scene
  99377. */
  99378. constructor(scene: Scene);
  99379. /**
  99380. * Gets the mesh that is currently under the pointer
  99381. */
  99382. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99383. /**
  99384. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99385. */
  99386. readonly unTranslatedPointer: Vector2;
  99387. /**
  99388. * Gets or sets the current on-screen X position of the pointer
  99389. */
  99390. pointerX: number;
  99391. /**
  99392. * Gets or sets the current on-screen Y position of the pointer
  99393. */
  99394. pointerY: number;
  99395. private _updatePointerPosition;
  99396. private _processPointerMove;
  99397. private _setRayOnPointerInfo;
  99398. private _checkPrePointerObservable;
  99399. /**
  99400. * Use this method to simulate a pointer move on a mesh
  99401. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99402. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99403. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99404. */
  99405. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99406. /**
  99407. * Use this method to simulate a pointer down on a mesh
  99408. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99409. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99410. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99411. */
  99412. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99413. private _processPointerDown;
  99414. /** @hidden */
  99415. _isPointerSwiping(): boolean;
  99416. /**
  99417. * Use this method to simulate a pointer up on a mesh
  99418. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99419. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99420. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99421. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99422. */
  99423. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99424. private _processPointerUp;
  99425. /**
  99426. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99427. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99428. * @returns true if the pointer was captured
  99429. */
  99430. isPointerCaptured(pointerId?: number): boolean;
  99431. /**
  99432. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99433. * @param attachUp defines if you want to attach events to pointerup
  99434. * @param attachDown defines if you want to attach events to pointerdown
  99435. * @param attachMove defines if you want to attach events to pointermove
  99436. */
  99437. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99438. /**
  99439. * Detaches all event handlers
  99440. */
  99441. detachControl(): void;
  99442. /**
  99443. * Force the value of meshUnderPointer
  99444. * @param mesh defines the mesh to use
  99445. */
  99446. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99447. /**
  99448. * Gets the mesh under the pointer
  99449. * @returns a Mesh or null if no mesh is under the pointer
  99450. */
  99451. getPointerOverMesh(): Nullable<AbstractMesh>;
  99452. }
  99453. }
  99454. declare module BABYLON {
  99455. /**
  99456. * Helper class used to generate session unique ID
  99457. */
  99458. export class UniqueIdGenerator {
  99459. private static _UniqueIdCounter;
  99460. /**
  99461. * Gets an unique (relatively to the current scene) Id
  99462. */
  99463. static readonly UniqueId: number;
  99464. }
  99465. }
  99466. declare module BABYLON {
  99467. /**
  99468. * This class defines the direct association between an animation and a target
  99469. */
  99470. export class TargetedAnimation {
  99471. /**
  99472. * Animation to perform
  99473. */
  99474. animation: Animation;
  99475. /**
  99476. * Target to animate
  99477. */
  99478. target: any;
  99479. /**
  99480. * Serialize the object
  99481. * @returns the JSON object representing the current entity
  99482. */
  99483. serialize(): any;
  99484. }
  99485. /**
  99486. * Use this class to create coordinated animations on multiple targets
  99487. */
  99488. export class AnimationGroup implements IDisposable {
  99489. /** The name of the animation group */
  99490. name: string;
  99491. private _scene;
  99492. private _targetedAnimations;
  99493. private _animatables;
  99494. private _from;
  99495. private _to;
  99496. private _isStarted;
  99497. private _isPaused;
  99498. private _speedRatio;
  99499. private _loopAnimation;
  99500. /**
  99501. * Gets or sets the unique id of the node
  99502. */
  99503. uniqueId: number;
  99504. /**
  99505. * This observable will notify when one animation have ended
  99506. */
  99507. onAnimationEndObservable: Observable<TargetedAnimation>;
  99508. /**
  99509. * Observer raised when one animation loops
  99510. */
  99511. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99512. /**
  99513. * This observable will notify when all animations have ended.
  99514. */
  99515. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99516. /**
  99517. * This observable will notify when all animations have paused.
  99518. */
  99519. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99520. /**
  99521. * This observable will notify when all animations are playing.
  99522. */
  99523. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99524. /**
  99525. * Gets the first frame
  99526. */
  99527. readonly from: number;
  99528. /**
  99529. * Gets the last frame
  99530. */
  99531. readonly to: number;
  99532. /**
  99533. * Define if the animations are started
  99534. */
  99535. readonly isStarted: boolean;
  99536. /**
  99537. * Gets a value indicating that the current group is playing
  99538. */
  99539. readonly isPlaying: boolean;
  99540. /**
  99541. * Gets or sets the speed ratio to use for all animations
  99542. */
  99543. /**
  99544. * Gets or sets the speed ratio to use for all animations
  99545. */
  99546. speedRatio: number;
  99547. /**
  99548. * Gets or sets if all animations should loop or not
  99549. */
  99550. loopAnimation: boolean;
  99551. /**
  99552. * Gets the targeted animations for this animation group
  99553. */
  99554. readonly targetedAnimations: Array<TargetedAnimation>;
  99555. /**
  99556. * returning the list of animatables controlled by this animation group.
  99557. */
  99558. readonly animatables: Array<Animatable>;
  99559. /**
  99560. * Instantiates a new Animation Group.
  99561. * This helps managing several animations at once.
  99562. * @see http://doc.babylonjs.com/how_to/group
  99563. * @param name Defines the name of the group
  99564. * @param scene Defines the scene the group belongs to
  99565. */
  99566. constructor(
  99567. /** The name of the animation group */
  99568. name: string, scene?: Nullable<Scene>);
  99569. /**
  99570. * Add an animation (with its target) in the group
  99571. * @param animation defines the animation we want to add
  99572. * @param target defines the target of the animation
  99573. * @returns the TargetedAnimation object
  99574. */
  99575. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99576. /**
  99577. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99578. * It can add constant keys at begin or end
  99579. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99580. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99581. * @returns the animation group
  99582. */
  99583. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99584. /**
  99585. * Start all animations on given targets
  99586. * @param loop defines if animations must loop
  99587. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99588. * @param from defines the from key (optional)
  99589. * @param to defines the to key (optional)
  99590. * @returns the current animation group
  99591. */
  99592. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99593. /**
  99594. * Pause all animations
  99595. * @returns the animation group
  99596. */
  99597. pause(): AnimationGroup;
  99598. /**
  99599. * Play all animations to initial state
  99600. * This function will start() the animations if they were not started or will restart() them if they were paused
  99601. * @param loop defines if animations must loop
  99602. * @returns the animation group
  99603. */
  99604. play(loop?: boolean): AnimationGroup;
  99605. /**
  99606. * Reset all animations to initial state
  99607. * @returns the animation group
  99608. */
  99609. reset(): AnimationGroup;
  99610. /**
  99611. * Restart animations from key 0
  99612. * @returns the animation group
  99613. */
  99614. restart(): AnimationGroup;
  99615. /**
  99616. * Stop all animations
  99617. * @returns the animation group
  99618. */
  99619. stop(): AnimationGroup;
  99620. /**
  99621. * Set animation weight for all animatables
  99622. * @param weight defines the weight to use
  99623. * @return the animationGroup
  99624. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99625. */
  99626. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99627. /**
  99628. * Synchronize and normalize all animatables with a source animatable
  99629. * @param root defines the root animatable to synchronize with
  99630. * @return the animationGroup
  99631. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99632. */
  99633. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99634. /**
  99635. * Goes to a specific frame in this animation group
  99636. * @param frame the frame number to go to
  99637. * @return the animationGroup
  99638. */
  99639. goToFrame(frame: number): AnimationGroup;
  99640. /**
  99641. * Dispose all associated resources
  99642. */
  99643. dispose(): void;
  99644. private _checkAnimationGroupEnded;
  99645. /**
  99646. * Clone the current animation group and returns a copy
  99647. * @param newName defines the name of the new group
  99648. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99649. * @returns the new aniamtion group
  99650. */
  99651. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99652. /**
  99653. * Serializes the animationGroup to an object
  99654. * @returns Serialized object
  99655. */
  99656. serialize(): any;
  99657. /**
  99658. * Returns a new AnimationGroup object parsed from the source provided.
  99659. * @param parsedAnimationGroup defines the source
  99660. * @param scene defines the scene that will receive the animationGroup
  99661. * @returns a new AnimationGroup
  99662. */
  99663. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99664. /**
  99665. * Returns the string "AnimationGroup"
  99666. * @returns "AnimationGroup"
  99667. */
  99668. getClassName(): string;
  99669. /**
  99670. * Creates a detailled string about the object
  99671. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99672. * @returns a string representing the object
  99673. */
  99674. toString(fullDetails?: boolean): string;
  99675. }
  99676. }
  99677. declare module BABYLON {
  99678. /**
  99679. * Define an interface for all classes that will hold resources
  99680. */
  99681. export interface IDisposable {
  99682. /**
  99683. * Releases all held resources
  99684. */
  99685. dispose(): void;
  99686. }
  99687. /** Interface defining initialization parameters for Scene class */
  99688. export interface SceneOptions {
  99689. /**
  99690. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99691. * It will improve performance when the number of geometries becomes important.
  99692. */
  99693. useGeometryUniqueIdsMap?: boolean;
  99694. /**
  99695. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99696. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99697. */
  99698. useMaterialMeshMap?: boolean;
  99699. /**
  99700. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99701. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99702. */
  99703. useClonedMeshhMap?: boolean;
  99704. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99705. virtual?: boolean;
  99706. }
  99707. /**
  99708. * Represents a scene to be rendered by the engine.
  99709. * @see http://doc.babylonjs.com/features/scene
  99710. */
  99711. export class Scene extends AbstractScene implements IAnimatable {
  99712. /** The fog is deactivated */
  99713. static readonly FOGMODE_NONE: number;
  99714. /** The fog density is following an exponential function */
  99715. static readonly FOGMODE_EXP: number;
  99716. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99717. static readonly FOGMODE_EXP2: number;
  99718. /** The fog density is following a linear function. */
  99719. static readonly FOGMODE_LINEAR: number;
  99720. /**
  99721. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99722. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99723. */
  99724. static MinDeltaTime: number;
  99725. /**
  99726. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99727. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99728. */
  99729. static MaxDeltaTime: number;
  99730. /**
  99731. * Factory used to create the default material.
  99732. * @param name The name of the material to create
  99733. * @param scene The scene to create the material for
  99734. * @returns The default material
  99735. */
  99736. static DefaultMaterialFactory(scene: Scene): Material;
  99737. /**
  99738. * Factory used to create the a collision coordinator.
  99739. * @returns The collision coordinator
  99740. */
  99741. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99742. /** @hidden */
  99743. _inputManager: InputManager;
  99744. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99745. cameraToUseForPointers: Nullable<Camera>;
  99746. /** @hidden */
  99747. readonly _isScene: boolean;
  99748. /**
  99749. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99750. */
  99751. autoClear: boolean;
  99752. /**
  99753. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99754. */
  99755. autoClearDepthAndStencil: boolean;
  99756. /**
  99757. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99758. */
  99759. clearColor: Color4;
  99760. /**
  99761. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99762. */
  99763. ambientColor: Color3;
  99764. /**
  99765. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99766. * It should only be one of the following (if not the default embedded one):
  99767. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99768. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99769. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99770. * The material properties need to be setup according to the type of texture in use.
  99771. */
  99772. environmentBRDFTexture: BaseTexture;
  99773. /** @hidden */
  99774. protected _environmentTexture: Nullable<BaseTexture>;
  99775. /**
  99776. * Texture used in all pbr material as the reflection texture.
  99777. * As in the majority of the scene they are the same (exception for multi room and so on),
  99778. * this is easier to reference from here than from all the materials.
  99779. */
  99780. /**
  99781. * Texture used in all pbr material as the reflection texture.
  99782. * As in the majority of the scene they are the same (exception for multi room and so on),
  99783. * this is easier to set here than in all the materials.
  99784. */
  99785. environmentTexture: Nullable<BaseTexture>;
  99786. /** @hidden */
  99787. protected _environmentIntensity: number;
  99788. /**
  99789. * Intensity of the environment in all pbr material.
  99790. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99791. * As in the majority of the scene they are the same (exception for multi room and so on),
  99792. * this is easier to reference from here than from all the materials.
  99793. */
  99794. /**
  99795. * Intensity of the environment in all pbr material.
  99796. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99797. * As in the majority of the scene they are the same (exception for multi room and so on),
  99798. * this is easier to set here than in all the materials.
  99799. */
  99800. environmentIntensity: number;
  99801. /** @hidden */
  99802. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99803. /**
  99804. * Default image processing configuration used either in the rendering
  99805. * Forward main pass or through the imageProcessingPostProcess if present.
  99806. * As in the majority of the scene they are the same (exception for multi camera),
  99807. * this is easier to reference from here than from all the materials and post process.
  99808. *
  99809. * No setter as we it is a shared configuration, you can set the values instead.
  99810. */
  99811. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99812. private _forceWireframe;
  99813. /**
  99814. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99815. */
  99816. forceWireframe: boolean;
  99817. private _forcePointsCloud;
  99818. /**
  99819. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99820. */
  99821. forcePointsCloud: boolean;
  99822. /**
  99823. * Gets or sets the active clipplane 1
  99824. */
  99825. clipPlane: Nullable<Plane>;
  99826. /**
  99827. * Gets or sets the active clipplane 2
  99828. */
  99829. clipPlane2: Nullable<Plane>;
  99830. /**
  99831. * Gets or sets the active clipplane 3
  99832. */
  99833. clipPlane3: Nullable<Plane>;
  99834. /**
  99835. * Gets or sets the active clipplane 4
  99836. */
  99837. clipPlane4: Nullable<Plane>;
  99838. /**
  99839. * Gets or sets a boolean indicating if animations are enabled
  99840. */
  99841. animationsEnabled: boolean;
  99842. private _animationPropertiesOverride;
  99843. /**
  99844. * Gets or sets the animation properties override
  99845. */
  99846. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99847. /**
  99848. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99849. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99850. */
  99851. useConstantAnimationDeltaTime: boolean;
  99852. /**
  99853. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99854. * Please note that it requires to run a ray cast through the scene on every frame
  99855. */
  99856. constantlyUpdateMeshUnderPointer: boolean;
  99857. /**
  99858. * Defines the HTML cursor to use when hovering over interactive elements
  99859. */
  99860. hoverCursor: string;
  99861. /**
  99862. * Defines the HTML default cursor to use (empty by default)
  99863. */
  99864. defaultCursor: string;
  99865. /**
  99866. * This is used to call preventDefault() on pointer down
  99867. * in order to block unwanted artifacts like system double clicks
  99868. */
  99869. preventDefaultOnPointerDown: boolean;
  99870. /**
  99871. * This is used to call preventDefault() on pointer up
  99872. * in order to block unwanted artifacts like system double clicks
  99873. */
  99874. preventDefaultOnPointerUp: boolean;
  99875. /**
  99876. * Gets or sets user defined metadata
  99877. */
  99878. metadata: any;
  99879. /**
  99880. * For internal use only. Please do not use.
  99881. */
  99882. reservedDataStore: any;
  99883. /**
  99884. * Gets the name of the plugin used to load this scene (null by default)
  99885. */
  99886. loadingPluginName: string;
  99887. /**
  99888. * Use this array to add regular expressions used to disable offline support for specific urls
  99889. */
  99890. disableOfflineSupportExceptionRules: RegExp[];
  99891. /**
  99892. * An event triggered when the scene is disposed.
  99893. */
  99894. onDisposeObservable: Observable<Scene>;
  99895. private _onDisposeObserver;
  99896. /** Sets a function to be executed when this scene is disposed. */
  99897. onDispose: () => void;
  99898. /**
  99899. * An event triggered before rendering the scene (right after animations and physics)
  99900. */
  99901. onBeforeRenderObservable: Observable<Scene>;
  99902. private _onBeforeRenderObserver;
  99903. /** Sets a function to be executed before rendering this scene */
  99904. beforeRender: Nullable<() => void>;
  99905. /**
  99906. * An event triggered after rendering the scene
  99907. */
  99908. onAfterRenderObservable: Observable<Scene>;
  99909. /**
  99910. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99911. */
  99912. onAfterRenderCameraObservable: Observable<Camera>;
  99913. private _onAfterRenderObserver;
  99914. /** Sets a function to be executed after rendering this scene */
  99915. afterRender: Nullable<() => void>;
  99916. /**
  99917. * An event triggered before animating the scene
  99918. */
  99919. onBeforeAnimationsObservable: Observable<Scene>;
  99920. /**
  99921. * An event triggered after animations processing
  99922. */
  99923. onAfterAnimationsObservable: Observable<Scene>;
  99924. /**
  99925. * An event triggered before draw calls are ready to be sent
  99926. */
  99927. onBeforeDrawPhaseObservable: Observable<Scene>;
  99928. /**
  99929. * An event triggered after draw calls have been sent
  99930. */
  99931. onAfterDrawPhaseObservable: Observable<Scene>;
  99932. /**
  99933. * An event triggered when the scene is ready
  99934. */
  99935. onReadyObservable: Observable<Scene>;
  99936. /**
  99937. * An event triggered before rendering a camera
  99938. */
  99939. onBeforeCameraRenderObservable: Observable<Camera>;
  99940. private _onBeforeCameraRenderObserver;
  99941. /** Sets a function to be executed before rendering a camera*/
  99942. beforeCameraRender: () => void;
  99943. /**
  99944. * An event triggered after rendering a camera
  99945. */
  99946. onAfterCameraRenderObservable: Observable<Camera>;
  99947. private _onAfterCameraRenderObserver;
  99948. /** Sets a function to be executed after rendering a camera*/
  99949. afterCameraRender: () => void;
  99950. /**
  99951. * An event triggered when active meshes evaluation is about to start
  99952. */
  99953. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  99954. /**
  99955. * An event triggered when active meshes evaluation is done
  99956. */
  99957. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  99958. /**
  99959. * An event triggered when particles rendering is about to start
  99960. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99961. */
  99962. onBeforeParticlesRenderingObservable: Observable<Scene>;
  99963. /**
  99964. * An event triggered when particles rendering is done
  99965. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99966. */
  99967. onAfterParticlesRenderingObservable: Observable<Scene>;
  99968. /**
  99969. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99970. */
  99971. onDataLoadedObservable: Observable<Scene>;
  99972. /**
  99973. * An event triggered when a camera is created
  99974. */
  99975. onNewCameraAddedObservable: Observable<Camera>;
  99976. /**
  99977. * An event triggered when a camera is removed
  99978. */
  99979. onCameraRemovedObservable: Observable<Camera>;
  99980. /**
  99981. * An event triggered when a light is created
  99982. */
  99983. onNewLightAddedObservable: Observable<Light>;
  99984. /**
  99985. * An event triggered when a light is removed
  99986. */
  99987. onLightRemovedObservable: Observable<Light>;
  99988. /**
  99989. * An event triggered when a geometry is created
  99990. */
  99991. onNewGeometryAddedObservable: Observable<Geometry>;
  99992. /**
  99993. * An event triggered when a geometry is removed
  99994. */
  99995. onGeometryRemovedObservable: Observable<Geometry>;
  99996. /**
  99997. * An event triggered when a transform node is created
  99998. */
  99999. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100000. /**
  100001. * An event triggered when a transform node is removed
  100002. */
  100003. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100004. /**
  100005. * An event triggered when a mesh is created
  100006. */
  100007. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100008. /**
  100009. * An event triggered when a mesh is removed
  100010. */
  100011. onMeshRemovedObservable: Observable<AbstractMesh>;
  100012. /**
  100013. * An event triggered when a skeleton is created
  100014. */
  100015. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100016. /**
  100017. * An event triggered when a skeleton is removed
  100018. */
  100019. onSkeletonRemovedObservable: Observable<Skeleton>;
  100020. /**
  100021. * An event triggered when a material is created
  100022. */
  100023. onNewMaterialAddedObservable: Observable<Material>;
  100024. /**
  100025. * An event triggered when a material is removed
  100026. */
  100027. onMaterialRemovedObservable: Observable<Material>;
  100028. /**
  100029. * An event triggered when a texture is created
  100030. */
  100031. onNewTextureAddedObservable: Observable<BaseTexture>;
  100032. /**
  100033. * An event triggered when a texture is removed
  100034. */
  100035. onTextureRemovedObservable: Observable<BaseTexture>;
  100036. /**
  100037. * An event triggered when render targets are about to be rendered
  100038. * Can happen multiple times per frame.
  100039. */
  100040. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100041. /**
  100042. * An event triggered when render targets were rendered.
  100043. * Can happen multiple times per frame.
  100044. */
  100045. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100046. /**
  100047. * An event triggered before calculating deterministic simulation step
  100048. */
  100049. onBeforeStepObservable: Observable<Scene>;
  100050. /**
  100051. * An event triggered after calculating deterministic simulation step
  100052. */
  100053. onAfterStepObservable: Observable<Scene>;
  100054. /**
  100055. * An event triggered when the activeCamera property is updated
  100056. */
  100057. onActiveCameraChanged: Observable<Scene>;
  100058. /**
  100059. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100060. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100061. * 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)
  100062. */
  100063. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100064. /**
  100065. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100066. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100067. * 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)
  100068. */
  100069. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100070. /**
  100071. * This Observable will when a mesh has been imported into the scene.
  100072. */
  100073. onMeshImportedObservable: Observable<AbstractMesh>;
  100074. /**
  100075. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100076. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100077. */
  100078. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100079. /** @hidden */
  100080. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100081. /**
  100082. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100083. */
  100084. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100085. /**
  100086. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100087. */
  100088. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100089. /**
  100090. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100091. */
  100092. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100093. /** Callback called when a pointer move is detected */
  100094. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100095. /** Callback called when a pointer down is detected */
  100096. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100097. /** Callback called when a pointer up is detected */
  100098. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100099. /** Callback called when a pointer pick is detected */
  100100. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100101. /**
  100102. * 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).
  100103. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100104. */
  100105. onPrePointerObservable: Observable<PointerInfoPre>;
  100106. /**
  100107. * Observable event triggered each time an input event is received from the rendering canvas
  100108. */
  100109. onPointerObservable: Observable<PointerInfo>;
  100110. /**
  100111. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100112. */
  100113. readonly unTranslatedPointer: Vector2;
  100114. /**
  100115. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100116. */
  100117. static DragMovementThreshold: number;
  100118. /**
  100119. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100120. */
  100121. static LongPressDelay: number;
  100122. /**
  100123. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100124. */
  100125. static DoubleClickDelay: number;
  100126. /** If you need to check double click without raising a single click at first click, enable this flag */
  100127. static ExclusiveDoubleClickMode: boolean;
  100128. /** @hidden */
  100129. _mirroredCameraPosition: Nullable<Vector3>;
  100130. /**
  100131. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100132. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100133. */
  100134. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100135. /**
  100136. * Observable event triggered each time an keyboard event is received from the hosting window
  100137. */
  100138. onKeyboardObservable: Observable<KeyboardInfo>;
  100139. private _useRightHandedSystem;
  100140. /**
  100141. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100142. */
  100143. useRightHandedSystem: boolean;
  100144. private _timeAccumulator;
  100145. private _currentStepId;
  100146. private _currentInternalStep;
  100147. /**
  100148. * Sets the step Id used by deterministic lock step
  100149. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100150. * @param newStepId defines the step Id
  100151. */
  100152. setStepId(newStepId: number): void;
  100153. /**
  100154. * Gets the step Id used by deterministic lock step
  100155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100156. * @returns the step Id
  100157. */
  100158. getStepId(): number;
  100159. /**
  100160. * Gets the internal step used by deterministic lock step
  100161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100162. * @returns the internal step
  100163. */
  100164. getInternalStep(): number;
  100165. private _fogEnabled;
  100166. /**
  100167. * Gets or sets a boolean indicating if fog is enabled on this scene
  100168. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100169. * (Default is true)
  100170. */
  100171. fogEnabled: boolean;
  100172. private _fogMode;
  100173. /**
  100174. * Gets or sets the fog mode to use
  100175. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100176. * | mode | value |
  100177. * | --- | --- |
  100178. * | FOGMODE_NONE | 0 |
  100179. * | FOGMODE_EXP | 1 |
  100180. * | FOGMODE_EXP2 | 2 |
  100181. * | FOGMODE_LINEAR | 3 |
  100182. */
  100183. fogMode: number;
  100184. /**
  100185. * Gets or sets the fog color to use
  100186. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100187. * (Default is Color3(0.2, 0.2, 0.3))
  100188. */
  100189. fogColor: Color3;
  100190. /**
  100191. * Gets or sets the fog density to use
  100192. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100193. * (Default is 0.1)
  100194. */
  100195. fogDensity: number;
  100196. /**
  100197. * Gets or sets the fog start distance to use
  100198. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100199. * (Default is 0)
  100200. */
  100201. fogStart: number;
  100202. /**
  100203. * Gets or sets the fog end distance to use
  100204. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100205. * (Default is 1000)
  100206. */
  100207. fogEnd: number;
  100208. private _shadowsEnabled;
  100209. /**
  100210. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100211. */
  100212. shadowsEnabled: boolean;
  100213. private _lightsEnabled;
  100214. /**
  100215. * Gets or sets a boolean indicating if lights are enabled on this scene
  100216. */
  100217. lightsEnabled: boolean;
  100218. /** All of the active cameras added to this scene. */
  100219. activeCameras: Camera[];
  100220. /** @hidden */
  100221. _activeCamera: Nullable<Camera>;
  100222. /** Gets or sets the current active camera */
  100223. activeCamera: Nullable<Camera>;
  100224. private _defaultMaterial;
  100225. /** The default material used on meshes when no material is affected */
  100226. /** The default material used on meshes when no material is affected */
  100227. defaultMaterial: Material;
  100228. private _texturesEnabled;
  100229. /**
  100230. * Gets or sets a boolean indicating if textures are enabled on this scene
  100231. */
  100232. texturesEnabled: boolean;
  100233. /**
  100234. * Gets or sets a boolean indicating if particles are enabled on this scene
  100235. */
  100236. particlesEnabled: boolean;
  100237. /**
  100238. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100239. */
  100240. spritesEnabled: boolean;
  100241. private _skeletonsEnabled;
  100242. /**
  100243. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100244. */
  100245. skeletonsEnabled: boolean;
  100246. /**
  100247. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100248. */
  100249. lensFlaresEnabled: boolean;
  100250. /**
  100251. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100252. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100253. */
  100254. collisionsEnabled: boolean;
  100255. private _collisionCoordinator;
  100256. /** @hidden */
  100257. readonly collisionCoordinator: ICollisionCoordinator;
  100258. /**
  100259. * Defines the gravity applied to this scene (used only for collisions)
  100260. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100261. */
  100262. gravity: Vector3;
  100263. /**
  100264. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100265. */
  100266. postProcessesEnabled: boolean;
  100267. /**
  100268. * The list of postprocesses added to the scene
  100269. */
  100270. postProcesses: PostProcess[];
  100271. /**
  100272. * Gets the current postprocess manager
  100273. */
  100274. postProcessManager: PostProcessManager;
  100275. /**
  100276. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100277. */
  100278. renderTargetsEnabled: boolean;
  100279. /**
  100280. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100281. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100282. */
  100283. dumpNextRenderTargets: boolean;
  100284. /**
  100285. * The list of user defined render targets added to the scene
  100286. */
  100287. customRenderTargets: RenderTargetTexture[];
  100288. /**
  100289. * Defines if texture loading must be delayed
  100290. * If true, textures will only be loaded when they need to be rendered
  100291. */
  100292. useDelayedTextureLoading: boolean;
  100293. /**
  100294. * Gets the list of meshes imported to the scene through SceneLoader
  100295. */
  100296. importedMeshesFiles: String[];
  100297. /**
  100298. * Gets or sets a boolean indicating if probes are enabled on this scene
  100299. */
  100300. probesEnabled: boolean;
  100301. /**
  100302. * Gets or sets the current offline provider to use to store scene data
  100303. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100304. */
  100305. offlineProvider: IOfflineProvider;
  100306. /**
  100307. * Gets or sets the action manager associated with the scene
  100308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100309. */
  100310. actionManager: AbstractActionManager;
  100311. private _meshesForIntersections;
  100312. /**
  100313. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100314. */
  100315. proceduralTexturesEnabled: boolean;
  100316. private _engine;
  100317. private _totalVertices;
  100318. /** @hidden */
  100319. _activeIndices: PerfCounter;
  100320. /** @hidden */
  100321. _activeParticles: PerfCounter;
  100322. /** @hidden */
  100323. _activeBones: PerfCounter;
  100324. private _animationRatio;
  100325. /** @hidden */
  100326. _animationTimeLast: number;
  100327. /** @hidden */
  100328. _animationTime: number;
  100329. /**
  100330. * Gets or sets a general scale for animation speed
  100331. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100332. */
  100333. animationTimeScale: number;
  100334. /** @hidden */
  100335. _cachedMaterial: Nullable<Material>;
  100336. /** @hidden */
  100337. _cachedEffect: Nullable<Effect>;
  100338. /** @hidden */
  100339. _cachedVisibility: Nullable<number>;
  100340. private _renderId;
  100341. private _frameId;
  100342. private _executeWhenReadyTimeoutId;
  100343. private _intermediateRendering;
  100344. private _viewUpdateFlag;
  100345. private _projectionUpdateFlag;
  100346. /** @hidden */
  100347. _toBeDisposed: Nullable<IDisposable>[];
  100348. private _activeRequests;
  100349. /** @hidden */
  100350. _pendingData: any[];
  100351. private _isDisposed;
  100352. /**
  100353. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100354. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100355. */
  100356. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100357. private _activeMeshes;
  100358. private _processedMaterials;
  100359. private _renderTargets;
  100360. /** @hidden */
  100361. _activeParticleSystems: SmartArray<IParticleSystem>;
  100362. private _activeSkeletons;
  100363. private _softwareSkinnedMeshes;
  100364. private _renderingManager;
  100365. /** @hidden */
  100366. _activeAnimatables: Animatable[];
  100367. private _transformMatrix;
  100368. private _sceneUbo;
  100369. /** @hidden */
  100370. _viewMatrix: Matrix;
  100371. private _projectionMatrix;
  100372. /** @hidden */
  100373. _forcedViewPosition: Nullable<Vector3>;
  100374. /** @hidden */
  100375. _frustumPlanes: Plane[];
  100376. /**
  100377. * Gets the list of frustum planes (built from the active camera)
  100378. */
  100379. readonly frustumPlanes: Plane[];
  100380. /**
  100381. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100382. * This is useful if there are more lights that the maximum simulteanous authorized
  100383. */
  100384. requireLightSorting: boolean;
  100385. /** @hidden */
  100386. readonly useMaterialMeshMap: boolean;
  100387. /** @hidden */
  100388. readonly useClonedMeshhMap: boolean;
  100389. private _externalData;
  100390. private _uid;
  100391. /**
  100392. * @hidden
  100393. * Backing store of defined scene components.
  100394. */
  100395. _components: ISceneComponent[];
  100396. /**
  100397. * @hidden
  100398. * Backing store of defined scene components.
  100399. */
  100400. _serializableComponents: ISceneSerializableComponent[];
  100401. /**
  100402. * List of components to register on the next registration step.
  100403. */
  100404. private _transientComponents;
  100405. /**
  100406. * Registers the transient components if needed.
  100407. */
  100408. private _registerTransientComponents;
  100409. /**
  100410. * @hidden
  100411. * Add a component to the scene.
  100412. * Note that the ccomponent could be registered on th next frame if this is called after
  100413. * the register component stage.
  100414. * @param component Defines the component to add to the scene
  100415. */
  100416. _addComponent(component: ISceneComponent): void;
  100417. /**
  100418. * @hidden
  100419. * Gets a component from the scene.
  100420. * @param name defines the name of the component to retrieve
  100421. * @returns the component or null if not present
  100422. */
  100423. _getComponent(name: string): Nullable<ISceneComponent>;
  100424. /**
  100425. * @hidden
  100426. * Defines the actions happening before camera updates.
  100427. */
  100428. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100429. /**
  100430. * @hidden
  100431. * Defines the actions happening before clear the canvas.
  100432. */
  100433. _beforeClearStage: Stage<SimpleStageAction>;
  100434. /**
  100435. * @hidden
  100436. * Defines the actions when collecting render targets for the frame.
  100437. */
  100438. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100439. /**
  100440. * @hidden
  100441. * Defines the actions happening for one camera in the frame.
  100442. */
  100443. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100444. /**
  100445. * @hidden
  100446. * Defines the actions happening during the per mesh ready checks.
  100447. */
  100448. _isReadyForMeshStage: Stage<MeshStageAction>;
  100449. /**
  100450. * @hidden
  100451. * Defines the actions happening before evaluate active mesh checks.
  100452. */
  100453. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100454. /**
  100455. * @hidden
  100456. * Defines the actions happening during the evaluate sub mesh checks.
  100457. */
  100458. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100459. /**
  100460. * @hidden
  100461. * Defines the actions happening during the active mesh stage.
  100462. */
  100463. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100464. /**
  100465. * @hidden
  100466. * Defines the actions happening during the per camera render target step.
  100467. */
  100468. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100469. /**
  100470. * @hidden
  100471. * Defines the actions happening just before the active camera is drawing.
  100472. */
  100473. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100474. /**
  100475. * @hidden
  100476. * Defines the actions happening just before a render target is drawing.
  100477. */
  100478. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100479. /**
  100480. * @hidden
  100481. * Defines the actions happening just before a rendering group is drawing.
  100482. */
  100483. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100484. /**
  100485. * @hidden
  100486. * Defines the actions happening just before a mesh is drawing.
  100487. */
  100488. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100489. /**
  100490. * @hidden
  100491. * Defines the actions happening just after a mesh has been drawn.
  100492. */
  100493. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100494. /**
  100495. * @hidden
  100496. * Defines the actions happening just after a rendering group has been drawn.
  100497. */
  100498. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100499. /**
  100500. * @hidden
  100501. * Defines the actions happening just after the active camera has been drawn.
  100502. */
  100503. _afterCameraDrawStage: Stage<CameraStageAction>;
  100504. /**
  100505. * @hidden
  100506. * Defines the actions happening just after a render target has been drawn.
  100507. */
  100508. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100509. /**
  100510. * @hidden
  100511. * Defines the actions happening just after rendering all cameras and computing intersections.
  100512. */
  100513. _afterRenderStage: Stage<SimpleStageAction>;
  100514. /**
  100515. * @hidden
  100516. * Defines the actions happening when a pointer move event happens.
  100517. */
  100518. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100519. /**
  100520. * @hidden
  100521. * Defines the actions happening when a pointer down event happens.
  100522. */
  100523. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100524. /**
  100525. * @hidden
  100526. * Defines the actions happening when a pointer up event happens.
  100527. */
  100528. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100529. /**
  100530. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100531. */
  100532. private geometriesByUniqueId;
  100533. /**
  100534. * Creates a new Scene
  100535. * @param engine defines the engine to use to render this scene
  100536. * @param options defines the scene options
  100537. */
  100538. constructor(engine: Engine, options?: SceneOptions);
  100539. /**
  100540. * Gets a string idenfifying the name of the class
  100541. * @returns "Scene" string
  100542. */
  100543. getClassName(): string;
  100544. private _defaultMeshCandidates;
  100545. /**
  100546. * @hidden
  100547. */
  100548. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100549. private _defaultSubMeshCandidates;
  100550. /**
  100551. * @hidden
  100552. */
  100553. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100554. /**
  100555. * Sets the default candidate providers for the scene.
  100556. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100557. * and getCollidingSubMeshCandidates to their default function
  100558. */
  100559. setDefaultCandidateProviders(): void;
  100560. /**
  100561. * Gets the mesh that is currently under the pointer
  100562. */
  100563. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100564. /**
  100565. * Gets or sets the current on-screen X position of the pointer
  100566. */
  100567. pointerX: number;
  100568. /**
  100569. * Gets or sets the current on-screen Y position of the pointer
  100570. */
  100571. pointerY: number;
  100572. /**
  100573. * Gets the cached material (ie. the latest rendered one)
  100574. * @returns the cached material
  100575. */
  100576. getCachedMaterial(): Nullable<Material>;
  100577. /**
  100578. * Gets the cached effect (ie. the latest rendered one)
  100579. * @returns the cached effect
  100580. */
  100581. getCachedEffect(): Nullable<Effect>;
  100582. /**
  100583. * Gets the cached visibility state (ie. the latest rendered one)
  100584. * @returns the cached visibility state
  100585. */
  100586. getCachedVisibility(): Nullable<number>;
  100587. /**
  100588. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100589. * @param material defines the current material
  100590. * @param effect defines the current effect
  100591. * @param visibility defines the current visibility state
  100592. * @returns true if one parameter is not cached
  100593. */
  100594. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100595. /**
  100596. * Gets the engine associated with the scene
  100597. * @returns an Engine
  100598. */
  100599. getEngine(): Engine;
  100600. /**
  100601. * Gets the total number of vertices rendered per frame
  100602. * @returns the total number of vertices rendered per frame
  100603. */
  100604. getTotalVertices(): number;
  100605. /**
  100606. * Gets the performance counter for total vertices
  100607. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100608. */
  100609. readonly totalVerticesPerfCounter: PerfCounter;
  100610. /**
  100611. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100612. * @returns the total number of active indices rendered per frame
  100613. */
  100614. getActiveIndices(): number;
  100615. /**
  100616. * Gets the performance counter for active indices
  100617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100618. */
  100619. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100620. /**
  100621. * Gets the total number of active particles rendered per frame
  100622. * @returns the total number of active particles rendered per frame
  100623. */
  100624. getActiveParticles(): number;
  100625. /**
  100626. * Gets the performance counter for active particles
  100627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100628. */
  100629. readonly activeParticlesPerfCounter: PerfCounter;
  100630. /**
  100631. * Gets the total number of active bones rendered per frame
  100632. * @returns the total number of active bones rendered per frame
  100633. */
  100634. getActiveBones(): number;
  100635. /**
  100636. * Gets the performance counter for active bones
  100637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100638. */
  100639. readonly activeBonesPerfCounter: PerfCounter;
  100640. /**
  100641. * Gets the array of active meshes
  100642. * @returns an array of AbstractMesh
  100643. */
  100644. getActiveMeshes(): SmartArray<AbstractMesh>;
  100645. /**
  100646. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100647. * @returns a number
  100648. */
  100649. getAnimationRatio(): number;
  100650. /**
  100651. * Gets an unique Id for the current render phase
  100652. * @returns a number
  100653. */
  100654. getRenderId(): number;
  100655. /**
  100656. * Gets an unique Id for the current frame
  100657. * @returns a number
  100658. */
  100659. getFrameId(): number;
  100660. /** Call this function if you want to manually increment the render Id*/
  100661. incrementRenderId(): void;
  100662. private _createUbo;
  100663. /**
  100664. * Use this method to simulate a pointer move on a mesh
  100665. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100666. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100667. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100668. * @returns the current scene
  100669. */
  100670. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100671. /**
  100672. * Use this method to simulate a pointer down on a mesh
  100673. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100674. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100675. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100676. * @returns the current scene
  100677. */
  100678. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100679. /**
  100680. * Use this method to simulate a pointer up on a mesh
  100681. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100682. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100683. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100684. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100685. * @returns the current scene
  100686. */
  100687. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100688. /**
  100689. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100690. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100691. * @returns true if the pointer was captured
  100692. */
  100693. isPointerCaptured(pointerId?: number): boolean;
  100694. /**
  100695. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100696. * @param attachUp defines if you want to attach events to pointerup
  100697. * @param attachDown defines if you want to attach events to pointerdown
  100698. * @param attachMove defines if you want to attach events to pointermove
  100699. */
  100700. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100701. /** Detaches all event handlers*/
  100702. detachControl(): void;
  100703. /**
  100704. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100705. * Delay loaded resources are not taking in account
  100706. * @return true if all required resources are ready
  100707. */
  100708. isReady(): boolean;
  100709. /** Resets all cached information relative to material (including effect and visibility) */
  100710. resetCachedMaterial(): void;
  100711. /**
  100712. * Registers a function to be called before every frame render
  100713. * @param func defines the function to register
  100714. */
  100715. registerBeforeRender(func: () => void): void;
  100716. /**
  100717. * Unregisters a function called before every frame render
  100718. * @param func defines the function to unregister
  100719. */
  100720. unregisterBeforeRender(func: () => void): void;
  100721. /**
  100722. * Registers a function to be called after every frame render
  100723. * @param func defines the function to register
  100724. */
  100725. registerAfterRender(func: () => void): void;
  100726. /**
  100727. * Unregisters a function called after every frame render
  100728. * @param func defines the function to unregister
  100729. */
  100730. unregisterAfterRender(func: () => void): void;
  100731. private _executeOnceBeforeRender;
  100732. /**
  100733. * The provided function will run before render once and will be disposed afterwards.
  100734. * A timeout delay can be provided so that the function will be executed in N ms.
  100735. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100736. * @param func The function to be executed.
  100737. * @param timeout optional delay in ms
  100738. */
  100739. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100740. /** @hidden */
  100741. _addPendingData(data: any): void;
  100742. /** @hidden */
  100743. _removePendingData(data: any): void;
  100744. /**
  100745. * Returns the number of items waiting to be loaded
  100746. * @returns the number of items waiting to be loaded
  100747. */
  100748. getWaitingItemsCount(): number;
  100749. /**
  100750. * Returns a boolean indicating if the scene is still loading data
  100751. */
  100752. readonly isLoading: boolean;
  100753. /**
  100754. * Registers a function to be executed when the scene is ready
  100755. * @param {Function} func - the function to be executed
  100756. */
  100757. executeWhenReady(func: () => void): void;
  100758. /**
  100759. * Returns a promise that resolves when the scene is ready
  100760. * @returns A promise that resolves when the scene is ready
  100761. */
  100762. whenReadyAsync(): Promise<void>;
  100763. /** @hidden */
  100764. _checkIsReady(): void;
  100765. /**
  100766. * Gets all animatable attached to the scene
  100767. */
  100768. readonly animatables: Animatable[];
  100769. /**
  100770. * Resets the last animation time frame.
  100771. * Useful to override when animations start running when loading a scene for the first time.
  100772. */
  100773. resetLastAnimationTimeFrame(): void;
  100774. /**
  100775. * Gets the current view matrix
  100776. * @returns a Matrix
  100777. */
  100778. getViewMatrix(): Matrix;
  100779. /**
  100780. * Gets the current projection matrix
  100781. * @returns a Matrix
  100782. */
  100783. getProjectionMatrix(): Matrix;
  100784. /**
  100785. * Gets the current transform matrix
  100786. * @returns a Matrix made of View * Projection
  100787. */
  100788. getTransformMatrix(): Matrix;
  100789. /**
  100790. * Sets the current transform matrix
  100791. * @param viewL defines the View matrix to use
  100792. * @param projectionL defines the Projection matrix to use
  100793. * @param viewR defines the right View matrix to use (if provided)
  100794. * @param projectionR defines the right Projection matrix to use (if provided)
  100795. */
  100796. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100797. /**
  100798. * Gets the uniform buffer used to store scene data
  100799. * @returns a UniformBuffer
  100800. */
  100801. getSceneUniformBuffer(): UniformBuffer;
  100802. /**
  100803. * Gets an unique (relatively to the current scene) Id
  100804. * @returns an unique number for the scene
  100805. */
  100806. getUniqueId(): number;
  100807. /**
  100808. * Add a mesh to the list of scene's meshes
  100809. * @param newMesh defines the mesh to add
  100810. * @param recursive if all child meshes should also be added to the scene
  100811. */
  100812. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100813. /**
  100814. * Remove a mesh for the list of scene's meshes
  100815. * @param toRemove defines the mesh to remove
  100816. * @param recursive if all child meshes should also be removed from the scene
  100817. * @returns the index where the mesh was in the mesh list
  100818. */
  100819. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100820. /**
  100821. * Add a transform node to the list of scene's transform nodes
  100822. * @param newTransformNode defines the transform node to add
  100823. */
  100824. addTransformNode(newTransformNode: TransformNode): void;
  100825. /**
  100826. * Remove a transform node for the list of scene's transform nodes
  100827. * @param toRemove defines the transform node to remove
  100828. * @returns the index where the transform node was in the transform node list
  100829. */
  100830. removeTransformNode(toRemove: TransformNode): number;
  100831. /**
  100832. * Remove a skeleton for the list of scene's skeletons
  100833. * @param toRemove defines the skeleton to remove
  100834. * @returns the index where the skeleton was in the skeleton list
  100835. */
  100836. removeSkeleton(toRemove: Skeleton): number;
  100837. /**
  100838. * Remove a morph target for the list of scene's morph targets
  100839. * @param toRemove defines the morph target to remove
  100840. * @returns the index where the morph target was in the morph target list
  100841. */
  100842. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100843. /**
  100844. * Remove a light for the list of scene's lights
  100845. * @param toRemove defines the light to remove
  100846. * @returns the index where the light was in the light list
  100847. */
  100848. removeLight(toRemove: Light): number;
  100849. /**
  100850. * Remove a camera for the list of scene's cameras
  100851. * @param toRemove defines the camera to remove
  100852. * @returns the index where the camera was in the camera list
  100853. */
  100854. removeCamera(toRemove: Camera): number;
  100855. /**
  100856. * Remove a particle system for the list of scene's particle systems
  100857. * @param toRemove defines the particle system to remove
  100858. * @returns the index where the particle system was in the particle system list
  100859. */
  100860. removeParticleSystem(toRemove: IParticleSystem): number;
  100861. /**
  100862. * Remove a animation for the list of scene's animations
  100863. * @param toRemove defines the animation to remove
  100864. * @returns the index where the animation was in the animation list
  100865. */
  100866. removeAnimation(toRemove: Animation): number;
  100867. /**
  100868. * Will stop the animation of the given target
  100869. * @param target - the target
  100870. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100871. * @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)
  100872. */
  100873. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100874. /**
  100875. * Removes the given animation group from this scene.
  100876. * @param toRemove The animation group to remove
  100877. * @returns The index of the removed animation group
  100878. */
  100879. removeAnimationGroup(toRemove: AnimationGroup): number;
  100880. /**
  100881. * Removes the given multi-material from this scene.
  100882. * @param toRemove The multi-material to remove
  100883. * @returns The index of the removed multi-material
  100884. */
  100885. removeMultiMaterial(toRemove: MultiMaterial): number;
  100886. /**
  100887. * Removes the given material from this scene.
  100888. * @param toRemove The material to remove
  100889. * @returns The index of the removed material
  100890. */
  100891. removeMaterial(toRemove: Material): number;
  100892. /**
  100893. * Removes the given action manager from this scene.
  100894. * @param toRemove The action manager to remove
  100895. * @returns The index of the removed action manager
  100896. */
  100897. removeActionManager(toRemove: AbstractActionManager): number;
  100898. /**
  100899. * Removes the given texture from this scene.
  100900. * @param toRemove The texture to remove
  100901. * @returns The index of the removed texture
  100902. */
  100903. removeTexture(toRemove: BaseTexture): number;
  100904. /**
  100905. * Adds the given light to this scene
  100906. * @param newLight The light to add
  100907. */
  100908. addLight(newLight: Light): void;
  100909. /**
  100910. * Sorts the list list based on light priorities
  100911. */
  100912. sortLightsByPriority(): void;
  100913. /**
  100914. * Adds the given camera to this scene
  100915. * @param newCamera The camera to add
  100916. */
  100917. addCamera(newCamera: Camera): void;
  100918. /**
  100919. * Adds the given skeleton to this scene
  100920. * @param newSkeleton The skeleton to add
  100921. */
  100922. addSkeleton(newSkeleton: Skeleton): void;
  100923. /**
  100924. * Adds the given particle system to this scene
  100925. * @param newParticleSystem The particle system to add
  100926. */
  100927. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100928. /**
  100929. * Adds the given animation to this scene
  100930. * @param newAnimation The animation to add
  100931. */
  100932. addAnimation(newAnimation: Animation): void;
  100933. /**
  100934. * Adds the given animation group to this scene.
  100935. * @param newAnimationGroup The animation group to add
  100936. */
  100937. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100938. /**
  100939. * Adds the given multi-material to this scene
  100940. * @param newMultiMaterial The multi-material to add
  100941. */
  100942. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100943. /**
  100944. * Adds the given material to this scene
  100945. * @param newMaterial The material to add
  100946. */
  100947. addMaterial(newMaterial: Material): void;
  100948. /**
  100949. * Adds the given morph target to this scene
  100950. * @param newMorphTargetManager The morph target to add
  100951. */
  100952. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  100953. /**
  100954. * Adds the given geometry to this scene
  100955. * @param newGeometry The geometry to add
  100956. */
  100957. addGeometry(newGeometry: Geometry): void;
  100958. /**
  100959. * Adds the given action manager to this scene
  100960. * @param newActionManager The action manager to add
  100961. */
  100962. addActionManager(newActionManager: AbstractActionManager): void;
  100963. /**
  100964. * Adds the given texture to this scene.
  100965. * @param newTexture The texture to add
  100966. */
  100967. addTexture(newTexture: BaseTexture): void;
  100968. /**
  100969. * Switch active camera
  100970. * @param newCamera defines the new active camera
  100971. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  100972. */
  100973. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  100974. /**
  100975. * sets the active camera of the scene using its ID
  100976. * @param id defines the camera's ID
  100977. * @return the new active camera or null if none found.
  100978. */
  100979. setActiveCameraByID(id: string): Nullable<Camera>;
  100980. /**
  100981. * sets the active camera of the scene using its name
  100982. * @param name defines the camera's name
  100983. * @returns the new active camera or null if none found.
  100984. */
  100985. setActiveCameraByName(name: string): Nullable<Camera>;
  100986. /**
  100987. * get an animation group using its name
  100988. * @param name defines the material's name
  100989. * @return the animation group or null if none found.
  100990. */
  100991. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100992. /**
  100993. * Get a material using its unique id
  100994. * @param uniqueId defines the material's unique id
  100995. * @return the material or null if none found.
  100996. */
  100997. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100998. /**
  100999. * get a material using its id
  101000. * @param id defines the material's ID
  101001. * @return the material or null if none found.
  101002. */
  101003. getMaterialByID(id: string): Nullable<Material>;
  101004. /**
  101005. * Gets a the last added material using a given id
  101006. * @param id defines the material's ID
  101007. * @return the last material with the given id or null if none found.
  101008. */
  101009. getLastMaterialByID(id: string): Nullable<Material>;
  101010. /**
  101011. * Gets a material using its name
  101012. * @param name defines the material's name
  101013. * @return the material or null if none found.
  101014. */
  101015. getMaterialByName(name: string): Nullable<Material>;
  101016. /**
  101017. * Get a texture using its unique id
  101018. * @param uniqueId defines the texture's unique id
  101019. * @return the texture or null if none found.
  101020. */
  101021. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101022. /**
  101023. * Gets a camera using its id
  101024. * @param id defines the id to look for
  101025. * @returns the camera or null if not found
  101026. */
  101027. getCameraByID(id: string): Nullable<Camera>;
  101028. /**
  101029. * Gets a camera using its unique id
  101030. * @param uniqueId defines the unique id to look for
  101031. * @returns the camera or null if not found
  101032. */
  101033. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101034. /**
  101035. * Gets a camera using its name
  101036. * @param name defines the camera's name
  101037. * @return the camera or null if none found.
  101038. */
  101039. getCameraByName(name: string): Nullable<Camera>;
  101040. /**
  101041. * Gets a bone using its id
  101042. * @param id defines the bone's id
  101043. * @return the bone or null if not found
  101044. */
  101045. getBoneByID(id: string): Nullable<Bone>;
  101046. /**
  101047. * Gets a bone using its id
  101048. * @param name defines the bone's name
  101049. * @return the bone or null if not found
  101050. */
  101051. getBoneByName(name: string): Nullable<Bone>;
  101052. /**
  101053. * Gets a light node using its name
  101054. * @param name defines the the light's name
  101055. * @return the light or null if none found.
  101056. */
  101057. getLightByName(name: string): Nullable<Light>;
  101058. /**
  101059. * Gets a light node using its id
  101060. * @param id defines the light's id
  101061. * @return the light or null if none found.
  101062. */
  101063. getLightByID(id: string): Nullable<Light>;
  101064. /**
  101065. * Gets a light node using its scene-generated unique ID
  101066. * @param uniqueId defines the light's unique id
  101067. * @return the light or null if none found.
  101068. */
  101069. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101070. /**
  101071. * Gets a particle system by id
  101072. * @param id defines the particle system id
  101073. * @return the corresponding system or null if none found
  101074. */
  101075. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101076. /**
  101077. * Gets a geometry using its ID
  101078. * @param id defines the geometry's id
  101079. * @return the geometry or null if none found.
  101080. */
  101081. getGeometryByID(id: string): Nullable<Geometry>;
  101082. private _getGeometryByUniqueID;
  101083. /**
  101084. * Add a new geometry to this scene
  101085. * @param geometry defines the geometry to be added to the scene.
  101086. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101087. * @return a boolean defining if the geometry was added or not
  101088. */
  101089. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101090. /**
  101091. * Removes an existing geometry
  101092. * @param geometry defines the geometry to be removed from the scene
  101093. * @return a boolean defining if the geometry was removed or not
  101094. */
  101095. removeGeometry(geometry: Geometry): boolean;
  101096. /**
  101097. * Gets the list of geometries attached to the scene
  101098. * @returns an array of Geometry
  101099. */
  101100. getGeometries(): Geometry[];
  101101. /**
  101102. * Gets the first added mesh found of a given ID
  101103. * @param id defines the id to search for
  101104. * @return the mesh found or null if not found at all
  101105. */
  101106. getMeshByID(id: string): Nullable<AbstractMesh>;
  101107. /**
  101108. * Gets a list of meshes using their id
  101109. * @param id defines the id to search for
  101110. * @returns a list of meshes
  101111. */
  101112. getMeshesByID(id: string): Array<AbstractMesh>;
  101113. /**
  101114. * Gets the first added transform node found of a given ID
  101115. * @param id defines the id to search for
  101116. * @return the found transform node or null if not found at all.
  101117. */
  101118. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101119. /**
  101120. * Gets a transform node with its auto-generated unique id
  101121. * @param uniqueId efines the unique id to search for
  101122. * @return the found transform node or null if not found at all.
  101123. */
  101124. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101125. /**
  101126. * Gets a list of transform nodes using their id
  101127. * @param id defines the id to search for
  101128. * @returns a list of transform nodes
  101129. */
  101130. getTransformNodesByID(id: string): Array<TransformNode>;
  101131. /**
  101132. * Gets a mesh with its auto-generated unique id
  101133. * @param uniqueId defines the unique id to search for
  101134. * @return the found mesh or null if not found at all.
  101135. */
  101136. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101137. /**
  101138. * Gets a the last added mesh using a given id
  101139. * @param id defines the id to search for
  101140. * @return the found mesh or null if not found at all.
  101141. */
  101142. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101143. /**
  101144. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101145. * @param id defines the id to search for
  101146. * @return the found node or null if not found at all
  101147. */
  101148. getLastEntryByID(id: string): Nullable<Node>;
  101149. /**
  101150. * Gets a node (Mesh, Camera, Light) using a given id
  101151. * @param id defines the id to search for
  101152. * @return the found node or null if not found at all
  101153. */
  101154. getNodeByID(id: string): Nullable<Node>;
  101155. /**
  101156. * Gets a node (Mesh, Camera, Light) using a given name
  101157. * @param name defines the name to search for
  101158. * @return the found node or null if not found at all.
  101159. */
  101160. getNodeByName(name: string): Nullable<Node>;
  101161. /**
  101162. * Gets a mesh using a given name
  101163. * @param name defines the name to search for
  101164. * @return the found mesh or null if not found at all.
  101165. */
  101166. getMeshByName(name: string): Nullable<AbstractMesh>;
  101167. /**
  101168. * Gets a transform node using a given name
  101169. * @param name defines the name to search for
  101170. * @return the found transform node or null if not found at all.
  101171. */
  101172. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101173. /**
  101174. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101175. * @param id defines the id to search for
  101176. * @return the found skeleton or null if not found at all.
  101177. */
  101178. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101179. /**
  101180. * Gets a skeleton using a given auto generated unique id
  101181. * @param uniqueId defines the unique id to search for
  101182. * @return the found skeleton or null if not found at all.
  101183. */
  101184. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101185. /**
  101186. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101187. * @param id defines the id to search for
  101188. * @return the found skeleton or null if not found at all.
  101189. */
  101190. getSkeletonById(id: string): Nullable<Skeleton>;
  101191. /**
  101192. * Gets a skeleton using a given name
  101193. * @param name defines the name to search for
  101194. * @return the found skeleton or null if not found at all.
  101195. */
  101196. getSkeletonByName(name: string): Nullable<Skeleton>;
  101197. /**
  101198. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101199. * @param id defines the id to search for
  101200. * @return the found morph target manager or null if not found at all.
  101201. */
  101202. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101203. /**
  101204. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101205. * @param id defines the id to search for
  101206. * @return the found morph target or null if not found at all.
  101207. */
  101208. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101209. /**
  101210. * Gets a boolean indicating if the given mesh is active
  101211. * @param mesh defines the mesh to look for
  101212. * @returns true if the mesh is in the active list
  101213. */
  101214. isActiveMesh(mesh: AbstractMesh): boolean;
  101215. /**
  101216. * Return a unique id as a string which can serve as an identifier for the scene
  101217. */
  101218. readonly uid: string;
  101219. /**
  101220. * Add an externaly attached data from its key.
  101221. * This method call will fail and return false, if such key already exists.
  101222. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101223. * @param key the unique key that identifies the data
  101224. * @param data the data object to associate to the key for this Engine instance
  101225. * @return true if no such key were already present and the data was added successfully, false otherwise
  101226. */
  101227. addExternalData<T>(key: string, data: T): boolean;
  101228. /**
  101229. * Get an externaly attached data from its key
  101230. * @param key the unique key that identifies the data
  101231. * @return the associated data, if present (can be null), or undefined if not present
  101232. */
  101233. getExternalData<T>(key: string): Nullable<T>;
  101234. /**
  101235. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101236. * @param key the unique key that identifies the data
  101237. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101238. * @return the associated data, can be null if the factory returned null.
  101239. */
  101240. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101241. /**
  101242. * Remove an externaly attached data from the Engine instance
  101243. * @param key the unique key that identifies the data
  101244. * @return true if the data was successfully removed, false if it doesn't exist
  101245. */
  101246. removeExternalData(key: string): boolean;
  101247. private _evaluateSubMesh;
  101248. /**
  101249. * Clear the processed materials smart array preventing retention point in material dispose.
  101250. */
  101251. freeProcessedMaterials(): void;
  101252. private _preventFreeActiveMeshesAndRenderingGroups;
  101253. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101254. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101255. * when disposing several meshes in a row or a hierarchy of meshes.
  101256. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101257. */
  101258. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101259. /**
  101260. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101261. */
  101262. freeActiveMeshes(): void;
  101263. /**
  101264. * Clear the info related to rendering groups preventing retention points during dispose.
  101265. */
  101266. freeRenderingGroups(): void;
  101267. /** @hidden */
  101268. _isInIntermediateRendering(): boolean;
  101269. /**
  101270. * Lambda returning the list of potentially active meshes.
  101271. */
  101272. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101273. /**
  101274. * Lambda returning the list of potentially active sub meshes.
  101275. */
  101276. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101277. /**
  101278. * Lambda returning the list of potentially intersecting sub meshes.
  101279. */
  101280. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101281. /**
  101282. * Lambda returning the list of potentially colliding sub meshes.
  101283. */
  101284. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101285. private _activeMeshesFrozen;
  101286. /**
  101287. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101288. * @returns the current scene
  101289. */
  101290. freezeActiveMeshes(): Scene;
  101291. /**
  101292. * Use this function to restart evaluating active meshes on every frame
  101293. * @returns the current scene
  101294. */
  101295. unfreezeActiveMeshes(): Scene;
  101296. private _evaluateActiveMeshes;
  101297. private _activeMesh;
  101298. /**
  101299. * Update the transform matrix to update from the current active camera
  101300. * @param force defines a boolean used to force the update even if cache is up to date
  101301. */
  101302. updateTransformMatrix(force?: boolean): void;
  101303. private _bindFrameBuffer;
  101304. /** @hidden */
  101305. _allowPostProcessClearColor: boolean;
  101306. /** @hidden */
  101307. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101308. private _processSubCameras;
  101309. private _checkIntersections;
  101310. /** @hidden */
  101311. _advancePhysicsEngineStep(step: number): void;
  101312. /**
  101313. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101314. */
  101315. getDeterministicFrameTime: () => number;
  101316. /** @hidden */
  101317. _animate(): void;
  101318. /** Execute all animations (for a frame) */
  101319. animate(): void;
  101320. /**
  101321. * Render the scene
  101322. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101323. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101324. */
  101325. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101326. /**
  101327. * Freeze all materials
  101328. * A frozen material will not be updatable but should be faster to render
  101329. */
  101330. freezeMaterials(): void;
  101331. /**
  101332. * Unfreeze all materials
  101333. * A frozen material will not be updatable but should be faster to render
  101334. */
  101335. unfreezeMaterials(): void;
  101336. /**
  101337. * Releases all held ressources
  101338. */
  101339. dispose(): void;
  101340. /**
  101341. * Gets if the scene is already disposed
  101342. */
  101343. readonly isDisposed: boolean;
  101344. /**
  101345. * Call this function to reduce memory footprint of the scene.
  101346. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101347. */
  101348. clearCachedVertexData(): void;
  101349. /**
  101350. * This function will remove the local cached buffer data from texture.
  101351. * It will save memory but will prevent the texture from being rebuilt
  101352. */
  101353. cleanCachedTextureBuffer(): void;
  101354. /**
  101355. * Get the world extend vectors with an optional filter
  101356. *
  101357. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101358. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101359. */
  101360. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101361. min: Vector3;
  101362. max: Vector3;
  101363. };
  101364. /**
  101365. * Creates a ray that can be used to pick in the scene
  101366. * @param x defines the x coordinate of the origin (on-screen)
  101367. * @param y defines the y coordinate of the origin (on-screen)
  101368. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101369. * @param camera defines the camera to use for the picking
  101370. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101371. * @returns a Ray
  101372. */
  101373. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101374. /**
  101375. * Creates a ray that can be used to pick in the scene
  101376. * @param x defines the x coordinate of the origin (on-screen)
  101377. * @param y defines the y coordinate of the origin (on-screen)
  101378. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101379. * @param result defines the ray where to store the picking ray
  101380. * @param camera defines the camera to use for the picking
  101381. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101382. * @returns the current scene
  101383. */
  101384. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101385. /**
  101386. * Creates a ray that can be used to pick in the scene
  101387. * @param x defines the x coordinate of the origin (on-screen)
  101388. * @param y defines the y coordinate of the origin (on-screen)
  101389. * @param camera defines the camera to use for the picking
  101390. * @returns a Ray
  101391. */
  101392. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101393. /**
  101394. * Creates a ray that can be used to pick in the scene
  101395. * @param x defines the x coordinate of the origin (on-screen)
  101396. * @param y defines the y coordinate of the origin (on-screen)
  101397. * @param result defines the ray where to store the picking ray
  101398. * @param camera defines the camera to use for the picking
  101399. * @returns the current scene
  101400. */
  101401. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101402. /** Launch a ray to try to pick a mesh in the scene
  101403. * @param x position on screen
  101404. * @param y position on screen
  101405. * @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
  101406. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101407. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101408. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101409. * @returns a PickingInfo
  101410. */
  101411. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101412. /** Use the given ray to pick a mesh in the scene
  101413. * @param ray The ray to use to pick meshes
  101414. * @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
  101415. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101416. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101417. * @returns a PickingInfo
  101418. */
  101419. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101420. /**
  101421. * Launch a ray to try to pick a mesh in the scene
  101422. * @param x X position on screen
  101423. * @param y Y position on screen
  101424. * @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
  101425. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101427. * @returns an array of PickingInfo
  101428. */
  101429. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101430. /**
  101431. * Launch a ray to try to pick a mesh in the scene
  101432. * @param ray Ray to use
  101433. * @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
  101434. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101435. * @returns an array of PickingInfo
  101436. */
  101437. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101438. /**
  101439. * Force the value of meshUnderPointer
  101440. * @param mesh defines the mesh to use
  101441. */
  101442. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101443. /**
  101444. * Gets the mesh under the pointer
  101445. * @returns a Mesh or null if no mesh is under the pointer
  101446. */
  101447. getPointerOverMesh(): Nullable<AbstractMesh>;
  101448. /** @hidden */
  101449. _rebuildGeometries(): void;
  101450. /** @hidden */
  101451. _rebuildTextures(): void;
  101452. private _getByTags;
  101453. /**
  101454. * Get a list of meshes by tags
  101455. * @param tagsQuery defines the tags query to use
  101456. * @param forEach defines a predicate used to filter results
  101457. * @returns an array of Mesh
  101458. */
  101459. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101460. /**
  101461. * Get a list of cameras by tags
  101462. * @param tagsQuery defines the tags query to use
  101463. * @param forEach defines a predicate used to filter results
  101464. * @returns an array of Camera
  101465. */
  101466. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101467. /**
  101468. * Get a list of lights by tags
  101469. * @param tagsQuery defines the tags query to use
  101470. * @param forEach defines a predicate used to filter results
  101471. * @returns an array of Light
  101472. */
  101473. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101474. /**
  101475. * Get a list of materials by tags
  101476. * @param tagsQuery defines the tags query to use
  101477. * @param forEach defines a predicate used to filter results
  101478. * @returns an array of Material
  101479. */
  101480. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101481. /**
  101482. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101483. * This allowed control for front to back rendering or reversly depending of the special needs.
  101484. *
  101485. * @param renderingGroupId The rendering group id corresponding to its index
  101486. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101487. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101488. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101489. */
  101490. 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;
  101491. /**
  101492. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101493. *
  101494. * @param renderingGroupId The rendering group id corresponding to its index
  101495. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101496. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101497. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101498. */
  101499. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101500. /**
  101501. * Gets the current auto clear configuration for one rendering group of the rendering
  101502. * manager.
  101503. * @param index the rendering group index to get the information for
  101504. * @returns The auto clear setup for the requested rendering group
  101505. */
  101506. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101507. private _blockMaterialDirtyMechanism;
  101508. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101509. blockMaterialDirtyMechanism: boolean;
  101510. /**
  101511. * Will flag all materials as dirty to trigger new shader compilation
  101512. * @param flag defines the flag used to specify which material part must be marked as dirty
  101513. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101514. */
  101515. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101516. /** @hidden */
  101517. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  101518. /** @hidden */
  101519. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101520. }
  101521. }
  101522. declare module BABYLON {
  101523. /**
  101524. * Set of assets to keep when moving a scene into an asset container.
  101525. */
  101526. export class KeepAssets extends AbstractScene {
  101527. }
  101528. /**
  101529. * Container with a set of assets that can be added or removed from a scene.
  101530. */
  101531. export class AssetContainer extends AbstractScene {
  101532. /**
  101533. * The scene the AssetContainer belongs to.
  101534. */
  101535. scene: Scene;
  101536. /**
  101537. * Instantiates an AssetContainer.
  101538. * @param scene The scene the AssetContainer belongs to.
  101539. */
  101540. constructor(scene: Scene);
  101541. /**
  101542. * Adds all the assets from the container to the scene.
  101543. */
  101544. addAllToScene(): void;
  101545. /**
  101546. * Removes all the assets in the container from the scene
  101547. */
  101548. removeAllFromScene(): void;
  101549. /**
  101550. * Disposes all the assets in the container
  101551. */
  101552. dispose(): void;
  101553. private _moveAssets;
  101554. /**
  101555. * Removes all the assets contained in the scene and adds them to the container.
  101556. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101557. */
  101558. moveAllFromScene(keepAssets?: KeepAssets): void;
  101559. /**
  101560. * 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.
  101561. * @returns the root mesh
  101562. */
  101563. createRootMesh(): Mesh;
  101564. }
  101565. }
  101566. declare module BABYLON {
  101567. /**
  101568. * Defines how the parser contract is defined.
  101569. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101570. */
  101571. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101572. /**
  101573. * Defines how the individual parser contract is defined.
  101574. * These parser can parse an individual asset
  101575. */
  101576. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101577. /**
  101578. * Base class of the scene acting as a container for the different elements composing a scene.
  101579. * This class is dynamically extended by the different components of the scene increasing
  101580. * flexibility and reducing coupling
  101581. */
  101582. export abstract class AbstractScene {
  101583. /**
  101584. * Stores the list of available parsers in the application.
  101585. */
  101586. private static _BabylonFileParsers;
  101587. /**
  101588. * Stores the list of available individual parsers in the application.
  101589. */
  101590. private static _IndividualBabylonFileParsers;
  101591. /**
  101592. * Adds a parser in the list of available ones
  101593. * @param name Defines the name of the parser
  101594. * @param parser Defines the parser to add
  101595. */
  101596. static AddParser(name: string, parser: BabylonFileParser): void;
  101597. /**
  101598. * Gets a general parser from the list of avaialble ones
  101599. * @param name Defines the name of the parser
  101600. * @returns the requested parser or null
  101601. */
  101602. static GetParser(name: string): Nullable<BabylonFileParser>;
  101603. /**
  101604. * Adds n individual parser in the list of available ones
  101605. * @param name Defines the name of the parser
  101606. * @param parser Defines the parser to add
  101607. */
  101608. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101609. /**
  101610. * Gets an individual parser from the list of avaialble ones
  101611. * @param name Defines the name of the parser
  101612. * @returns the requested parser or null
  101613. */
  101614. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101615. /**
  101616. * Parser json data and populate both a scene and its associated container object
  101617. * @param jsonData Defines the data to parse
  101618. * @param scene Defines the scene to parse the data for
  101619. * @param container Defines the container attached to the parsing sequence
  101620. * @param rootUrl Defines the root url of the data
  101621. */
  101622. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101623. /**
  101624. * Gets the list of root nodes (ie. nodes with no parent)
  101625. */
  101626. rootNodes: Node[];
  101627. /** All of the cameras added to this scene
  101628. * @see http://doc.babylonjs.com/babylon101/cameras
  101629. */
  101630. cameras: Camera[];
  101631. /**
  101632. * All of the lights added to this scene
  101633. * @see http://doc.babylonjs.com/babylon101/lights
  101634. */
  101635. lights: Light[];
  101636. /**
  101637. * All of the (abstract) meshes added to this scene
  101638. */
  101639. meshes: AbstractMesh[];
  101640. /**
  101641. * The list of skeletons added to the scene
  101642. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101643. */
  101644. skeletons: Skeleton[];
  101645. /**
  101646. * All of the particle systems added to this scene
  101647. * @see http://doc.babylonjs.com/babylon101/particles
  101648. */
  101649. particleSystems: IParticleSystem[];
  101650. /**
  101651. * Gets a list of Animations associated with the scene
  101652. */
  101653. animations: Animation[];
  101654. /**
  101655. * All of the animation groups added to this scene
  101656. * @see http://doc.babylonjs.com/how_to/group
  101657. */
  101658. animationGroups: AnimationGroup[];
  101659. /**
  101660. * All of the multi-materials added to this scene
  101661. * @see http://doc.babylonjs.com/how_to/multi_materials
  101662. */
  101663. multiMaterials: MultiMaterial[];
  101664. /**
  101665. * All of the materials added to this scene
  101666. * In the context of a Scene, it is not supposed to be modified manually.
  101667. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101668. * Note also that the order of the Material wihin the array is not significant and might change.
  101669. * @see http://doc.babylonjs.com/babylon101/materials
  101670. */
  101671. materials: Material[];
  101672. /**
  101673. * The list of morph target managers added to the scene
  101674. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101675. */
  101676. morphTargetManagers: MorphTargetManager[];
  101677. /**
  101678. * The list of geometries used in the scene.
  101679. */
  101680. geometries: Geometry[];
  101681. /**
  101682. * All of the tranform nodes added to this scene
  101683. * In the context of a Scene, it is not supposed to be modified manually.
  101684. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101685. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101686. * @see http://doc.babylonjs.com/how_to/transformnode
  101687. */
  101688. transformNodes: TransformNode[];
  101689. /**
  101690. * ActionManagers available on the scene.
  101691. */
  101692. actionManagers: AbstractActionManager[];
  101693. /**
  101694. * Textures to keep.
  101695. */
  101696. textures: BaseTexture[];
  101697. /**
  101698. * Environment texture for the scene
  101699. */
  101700. environmentTexture: Nullable<BaseTexture>;
  101701. }
  101702. }
  101703. declare module BABYLON {
  101704. /**
  101705. * Interface used to define options for Sound class
  101706. */
  101707. export interface ISoundOptions {
  101708. /**
  101709. * Does the sound autoplay once loaded.
  101710. */
  101711. autoplay?: boolean;
  101712. /**
  101713. * Does the sound loop after it finishes playing once.
  101714. */
  101715. loop?: boolean;
  101716. /**
  101717. * Sound's volume
  101718. */
  101719. volume?: number;
  101720. /**
  101721. * Is it a spatial sound?
  101722. */
  101723. spatialSound?: boolean;
  101724. /**
  101725. * Maximum distance to hear that sound
  101726. */
  101727. maxDistance?: number;
  101728. /**
  101729. * Uses user defined attenuation function
  101730. */
  101731. useCustomAttenuation?: boolean;
  101732. /**
  101733. * Define the roll off factor of spatial sounds.
  101734. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101735. */
  101736. rolloffFactor?: number;
  101737. /**
  101738. * Define the reference distance the sound should be heard perfectly.
  101739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101740. */
  101741. refDistance?: number;
  101742. /**
  101743. * Define the distance attenuation model the sound will follow.
  101744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101745. */
  101746. distanceModel?: string;
  101747. /**
  101748. * Defines the playback speed (1 by default)
  101749. */
  101750. playbackRate?: number;
  101751. /**
  101752. * Defines if the sound is from a streaming source
  101753. */
  101754. streaming?: boolean;
  101755. /**
  101756. * Defines an optional length (in seconds) inside the sound file
  101757. */
  101758. length?: number;
  101759. /**
  101760. * Defines an optional offset (in seconds) inside the sound file
  101761. */
  101762. offset?: number;
  101763. /**
  101764. * If true, URLs will not be required to state the audio file codec to use.
  101765. */
  101766. skipCodecCheck?: boolean;
  101767. }
  101768. /**
  101769. * Defines a sound that can be played in the application.
  101770. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101772. */
  101773. export class Sound {
  101774. /**
  101775. * The name of the sound in the scene.
  101776. */
  101777. name: string;
  101778. /**
  101779. * Does the sound autoplay once loaded.
  101780. */
  101781. autoplay: boolean;
  101782. /**
  101783. * Does the sound loop after it finishes playing once.
  101784. */
  101785. loop: boolean;
  101786. /**
  101787. * Does the sound use a custom attenuation curve to simulate the falloff
  101788. * happening when the source gets further away from the camera.
  101789. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101790. */
  101791. useCustomAttenuation: boolean;
  101792. /**
  101793. * The sound track id this sound belongs to.
  101794. */
  101795. soundTrackId: number;
  101796. /**
  101797. * Is this sound currently played.
  101798. */
  101799. isPlaying: boolean;
  101800. /**
  101801. * Is this sound currently paused.
  101802. */
  101803. isPaused: boolean;
  101804. /**
  101805. * Does this sound enables spatial sound.
  101806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101807. */
  101808. spatialSound: boolean;
  101809. /**
  101810. * Define the reference distance the sound should be heard perfectly.
  101811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101812. */
  101813. refDistance: number;
  101814. /**
  101815. * Define the roll off factor of spatial sounds.
  101816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101817. */
  101818. rolloffFactor: number;
  101819. /**
  101820. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101822. */
  101823. maxDistance: number;
  101824. /**
  101825. * Define the distance attenuation model the sound will follow.
  101826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101827. */
  101828. distanceModel: string;
  101829. /**
  101830. * @hidden
  101831. * Back Compat
  101832. **/
  101833. onended: () => any;
  101834. /**
  101835. * Observable event when the current playing sound finishes.
  101836. */
  101837. onEndedObservable: Observable<Sound>;
  101838. private _panningModel;
  101839. private _playbackRate;
  101840. private _streaming;
  101841. private _startTime;
  101842. private _startOffset;
  101843. private _position;
  101844. /** @hidden */
  101845. _positionInEmitterSpace: boolean;
  101846. private _localDirection;
  101847. private _volume;
  101848. private _isReadyToPlay;
  101849. private _isDirectional;
  101850. private _readyToPlayCallback;
  101851. private _audioBuffer;
  101852. private _soundSource;
  101853. private _streamingSource;
  101854. private _soundPanner;
  101855. private _soundGain;
  101856. private _inputAudioNode;
  101857. private _outputAudioNode;
  101858. private _coneInnerAngle;
  101859. private _coneOuterAngle;
  101860. private _coneOuterGain;
  101861. private _scene;
  101862. private _connectedTransformNode;
  101863. private _customAttenuationFunction;
  101864. private _registerFunc;
  101865. private _isOutputConnected;
  101866. private _htmlAudioElement;
  101867. private _urlType;
  101868. private _length?;
  101869. private _offset?;
  101870. /** @hidden */
  101871. static _SceneComponentInitialization: (scene: Scene) => void;
  101872. /**
  101873. * Create a sound and attach it to a scene
  101874. * @param name Name of your sound
  101875. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101876. * @param scene defines the scene the sound belongs to
  101877. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101878. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101879. */
  101880. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101881. /**
  101882. * Release the sound and its associated resources
  101883. */
  101884. dispose(): void;
  101885. /**
  101886. * Gets if the sounds is ready to be played or not.
  101887. * @returns true if ready, otherwise false
  101888. */
  101889. isReady(): boolean;
  101890. private _soundLoaded;
  101891. /**
  101892. * Sets the data of the sound from an audiobuffer
  101893. * @param audioBuffer The audioBuffer containing the data
  101894. */
  101895. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101896. /**
  101897. * Updates the current sounds options such as maxdistance, loop...
  101898. * @param options A JSON object containing values named as the object properties
  101899. */
  101900. updateOptions(options: ISoundOptions): void;
  101901. private _createSpatialParameters;
  101902. private _updateSpatialParameters;
  101903. /**
  101904. * Switch the panning model to HRTF:
  101905. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101907. */
  101908. switchPanningModelToHRTF(): void;
  101909. /**
  101910. * Switch the panning model to Equal Power:
  101911. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101913. */
  101914. switchPanningModelToEqualPower(): void;
  101915. private _switchPanningModel;
  101916. /**
  101917. * Connect this sound to a sound track audio node like gain...
  101918. * @param soundTrackAudioNode the sound track audio node to connect to
  101919. */
  101920. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101921. /**
  101922. * Transform this sound into a directional source
  101923. * @param coneInnerAngle Size of the inner cone in degree
  101924. * @param coneOuterAngle Size of the outer cone in degree
  101925. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101926. */
  101927. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101928. /**
  101929. * Gets or sets the inner angle for the directional cone.
  101930. */
  101931. /**
  101932. * Gets or sets the inner angle for the directional cone.
  101933. */
  101934. directionalConeInnerAngle: number;
  101935. /**
  101936. * Gets or sets the outer angle for the directional cone.
  101937. */
  101938. /**
  101939. * Gets or sets the outer angle for the directional cone.
  101940. */
  101941. directionalConeOuterAngle: number;
  101942. /**
  101943. * Sets the position of the emitter if spatial sound is enabled
  101944. * @param newPosition Defines the new posisiton
  101945. */
  101946. setPosition(newPosition: Vector3): void;
  101947. /**
  101948. * Sets the local direction of the emitter if spatial sound is enabled
  101949. * @param newLocalDirection Defines the new local direction
  101950. */
  101951. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  101952. private _updateDirection;
  101953. /** @hidden */
  101954. updateDistanceFromListener(): void;
  101955. /**
  101956. * Sets a new custom attenuation function for the sound.
  101957. * @param callback Defines the function used for the attenuation
  101958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101959. */
  101960. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  101961. /**
  101962. * Play the sound
  101963. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101964. * @param offset (optional) Start the sound at a specific time in seconds
  101965. * @param length (optional) Sound duration (in seconds)
  101966. */
  101967. play(time?: number, offset?: number, length?: number): void;
  101968. private _onended;
  101969. /**
  101970. * Stop the sound
  101971. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  101972. */
  101973. stop(time?: number): void;
  101974. /**
  101975. * Put the sound in pause
  101976. */
  101977. pause(): void;
  101978. /**
  101979. * Sets a dedicated volume for this sounds
  101980. * @param newVolume Define the new volume of the sound
  101981. * @param time Define time for gradual change to new volume
  101982. */
  101983. setVolume(newVolume: number, time?: number): void;
  101984. /**
  101985. * Set the sound play back rate
  101986. * @param newPlaybackRate Define the playback rate the sound should be played at
  101987. */
  101988. setPlaybackRate(newPlaybackRate: number): void;
  101989. /**
  101990. * Gets the volume of the sound.
  101991. * @returns the volume of the sound
  101992. */
  101993. getVolume(): number;
  101994. /**
  101995. * Attach the sound to a dedicated mesh
  101996. * @param transformNode The transform node to connect the sound with
  101997. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101998. */
  101999. attachToMesh(transformNode: TransformNode): void;
  102000. /**
  102001. * Detach the sound from the previously attached mesh
  102002. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102003. */
  102004. detachFromMesh(): void;
  102005. private _onRegisterAfterWorldMatrixUpdate;
  102006. /**
  102007. * Clone the current sound in the scene.
  102008. * @returns the new sound clone
  102009. */
  102010. clone(): Nullable<Sound>;
  102011. /**
  102012. * Gets the current underlying audio buffer containing the data
  102013. * @returns the audio buffer
  102014. */
  102015. getAudioBuffer(): Nullable<AudioBuffer>;
  102016. /**
  102017. * Serializes the Sound in a JSON representation
  102018. * @returns the JSON representation of the sound
  102019. */
  102020. serialize(): any;
  102021. /**
  102022. * Parse a JSON representation of a sound to innstantiate in a given scene
  102023. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102024. * @param scene Define the scene the new parsed sound should be created in
  102025. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102026. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102027. * @returns the newly parsed sound
  102028. */
  102029. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102030. }
  102031. }
  102032. declare module BABYLON {
  102033. /**
  102034. * This defines an action helpful to play a defined sound on a triggered action.
  102035. */
  102036. export class PlaySoundAction extends Action {
  102037. private _sound;
  102038. /**
  102039. * Instantiate the action
  102040. * @param triggerOptions defines the trigger options
  102041. * @param sound defines the sound to play
  102042. * @param condition defines the trigger related conditions
  102043. */
  102044. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102045. /** @hidden */
  102046. _prepare(): void;
  102047. /**
  102048. * Execute the action and play the sound.
  102049. */
  102050. execute(): void;
  102051. /**
  102052. * Serializes the actions and its related information.
  102053. * @param parent defines the object to serialize in
  102054. * @returns the serialized object
  102055. */
  102056. serialize(parent: any): any;
  102057. }
  102058. /**
  102059. * This defines an action helpful to stop a defined sound on a triggered action.
  102060. */
  102061. export class StopSoundAction extends Action {
  102062. private _sound;
  102063. /**
  102064. * Instantiate the action
  102065. * @param triggerOptions defines the trigger options
  102066. * @param sound defines the sound to stop
  102067. * @param condition defines the trigger related conditions
  102068. */
  102069. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102070. /** @hidden */
  102071. _prepare(): void;
  102072. /**
  102073. * Execute the action and stop the sound.
  102074. */
  102075. execute(): void;
  102076. /**
  102077. * Serializes the actions and its related information.
  102078. * @param parent defines the object to serialize in
  102079. * @returns the serialized object
  102080. */
  102081. serialize(parent: any): any;
  102082. }
  102083. }
  102084. declare module BABYLON {
  102085. /**
  102086. * This defines an action responsible to change the value of a property
  102087. * by interpolating between its current value and the newly set one once triggered.
  102088. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102089. */
  102090. export class InterpolateValueAction extends Action {
  102091. /**
  102092. * Defines the path of the property where the value should be interpolated
  102093. */
  102094. propertyPath: string;
  102095. /**
  102096. * Defines the target value at the end of the interpolation.
  102097. */
  102098. value: any;
  102099. /**
  102100. * Defines the time it will take for the property to interpolate to the value.
  102101. */
  102102. duration: number;
  102103. /**
  102104. * Defines if the other scene animations should be stopped when the action has been triggered
  102105. */
  102106. stopOtherAnimations?: boolean;
  102107. /**
  102108. * Defines a callback raised once the interpolation animation has been done.
  102109. */
  102110. onInterpolationDone?: () => void;
  102111. /**
  102112. * Observable triggered once the interpolation animation has been done.
  102113. */
  102114. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102115. private _target;
  102116. private _effectiveTarget;
  102117. private _property;
  102118. /**
  102119. * Instantiate the action
  102120. * @param triggerOptions defines the trigger options
  102121. * @param target defines the object containing the value to interpolate
  102122. * @param propertyPath defines the path to the property in the target object
  102123. * @param value defines the target value at the end of the interpolation
  102124. * @param duration deines the time it will take for the property to interpolate to the value.
  102125. * @param condition defines the trigger related conditions
  102126. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102127. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102128. */
  102129. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102130. /** @hidden */
  102131. _prepare(): void;
  102132. /**
  102133. * Execute the action starts the value interpolation.
  102134. */
  102135. execute(): void;
  102136. /**
  102137. * Serializes the actions and its related information.
  102138. * @param parent defines the object to serialize in
  102139. * @returns the serialized object
  102140. */
  102141. serialize(parent: any): any;
  102142. }
  102143. }
  102144. declare module BABYLON {
  102145. /**
  102146. * Options allowed during the creation of a sound track.
  102147. */
  102148. export interface ISoundTrackOptions {
  102149. /**
  102150. * The volume the sound track should take during creation
  102151. */
  102152. volume?: number;
  102153. /**
  102154. * Define if the sound track is the main sound track of the scene
  102155. */
  102156. mainTrack?: boolean;
  102157. }
  102158. /**
  102159. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102160. * It will be also used in a future release to apply effects on a specific track.
  102161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102162. */
  102163. export class SoundTrack {
  102164. /**
  102165. * The unique identifier of the sound track in the scene.
  102166. */
  102167. id: number;
  102168. /**
  102169. * The list of sounds included in the sound track.
  102170. */
  102171. soundCollection: Array<Sound>;
  102172. private _outputAudioNode;
  102173. private _scene;
  102174. private _isMainTrack;
  102175. private _connectedAnalyser;
  102176. private _options;
  102177. private _isInitialized;
  102178. /**
  102179. * Creates a new sound track.
  102180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102181. * @param scene Define the scene the sound track belongs to
  102182. * @param options
  102183. */
  102184. constructor(scene: Scene, options?: ISoundTrackOptions);
  102185. private _initializeSoundTrackAudioGraph;
  102186. /**
  102187. * Release the sound track and its associated resources
  102188. */
  102189. dispose(): void;
  102190. /**
  102191. * Adds a sound to this sound track
  102192. * @param sound define the cound to add
  102193. * @ignoreNaming
  102194. */
  102195. AddSound(sound: Sound): void;
  102196. /**
  102197. * Removes a sound to this sound track
  102198. * @param sound define the cound to remove
  102199. * @ignoreNaming
  102200. */
  102201. RemoveSound(sound: Sound): void;
  102202. /**
  102203. * Set a global volume for the full sound track.
  102204. * @param newVolume Define the new volume of the sound track
  102205. */
  102206. setVolume(newVolume: number): void;
  102207. /**
  102208. * Switch the panning model to HRTF:
  102209. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102211. */
  102212. switchPanningModelToHRTF(): void;
  102213. /**
  102214. * Switch the panning model to Equal Power:
  102215. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102217. */
  102218. switchPanningModelToEqualPower(): void;
  102219. /**
  102220. * Connect the sound track to an audio analyser allowing some amazing
  102221. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102223. * @param analyser The analyser to connect to the engine
  102224. */
  102225. connectToAnalyser(analyser: Analyser): void;
  102226. }
  102227. }
  102228. declare module BABYLON {
  102229. interface AbstractScene {
  102230. /**
  102231. * The list of sounds used in the scene.
  102232. */
  102233. sounds: Nullable<Array<Sound>>;
  102234. }
  102235. interface Scene {
  102236. /**
  102237. * @hidden
  102238. * Backing field
  102239. */
  102240. _mainSoundTrack: SoundTrack;
  102241. /**
  102242. * The main sound track played by the scene.
  102243. * It cotains your primary collection of sounds.
  102244. */
  102245. mainSoundTrack: SoundTrack;
  102246. /**
  102247. * The list of sound tracks added to the scene
  102248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102249. */
  102250. soundTracks: Nullable<Array<SoundTrack>>;
  102251. /**
  102252. * Gets a sound using a given name
  102253. * @param name defines the name to search for
  102254. * @return the found sound or null if not found at all.
  102255. */
  102256. getSoundByName(name: string): Nullable<Sound>;
  102257. /**
  102258. * Gets or sets if audio support is enabled
  102259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102260. */
  102261. audioEnabled: boolean;
  102262. /**
  102263. * Gets or sets if audio will be output to headphones
  102264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102265. */
  102266. headphone: boolean;
  102267. /**
  102268. * Gets or sets custom audio listener position provider
  102269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102270. */
  102271. audioListenerPositionProvider: Nullable<() => Vector3>;
  102272. }
  102273. /**
  102274. * Defines the sound scene component responsible to manage any sounds
  102275. * in a given scene.
  102276. */
  102277. export class AudioSceneComponent implements ISceneSerializableComponent {
  102278. /**
  102279. * The component name helpfull to identify the component in the list of scene components.
  102280. */
  102281. readonly name: string;
  102282. /**
  102283. * The scene the component belongs to.
  102284. */
  102285. scene: Scene;
  102286. private _audioEnabled;
  102287. /**
  102288. * Gets whether audio is enabled or not.
  102289. * Please use related enable/disable method to switch state.
  102290. */
  102291. readonly audioEnabled: boolean;
  102292. private _headphone;
  102293. /**
  102294. * Gets whether audio is outputing to headphone or not.
  102295. * Please use the according Switch methods to change output.
  102296. */
  102297. readonly headphone: boolean;
  102298. private _audioListenerPositionProvider;
  102299. /**
  102300. * Gets the current audio listener position provider
  102301. */
  102302. /**
  102303. * Sets a custom listener position for all sounds in the scene
  102304. * By default, this is the position of the first active camera
  102305. */
  102306. audioListenerPositionProvider: Nullable<() => Vector3>;
  102307. /**
  102308. * Creates a new instance of the component for the given scene
  102309. * @param scene Defines the scene to register the component in
  102310. */
  102311. constructor(scene: Scene);
  102312. /**
  102313. * Registers the component in a given scene
  102314. */
  102315. register(): void;
  102316. /**
  102317. * Rebuilds the elements related to this component in case of
  102318. * context lost for instance.
  102319. */
  102320. rebuild(): void;
  102321. /**
  102322. * Serializes the component data to the specified json object
  102323. * @param serializationObject The object to serialize to
  102324. */
  102325. serialize(serializationObject: any): void;
  102326. /**
  102327. * Adds all the elements from the container to the scene
  102328. * @param container the container holding the elements
  102329. */
  102330. addFromContainer(container: AbstractScene): void;
  102331. /**
  102332. * Removes all the elements in the container from the scene
  102333. * @param container contains the elements to remove
  102334. * @param dispose if the removed element should be disposed (default: false)
  102335. */
  102336. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102337. /**
  102338. * Disposes the component and the associated ressources.
  102339. */
  102340. dispose(): void;
  102341. /**
  102342. * Disables audio in the associated scene.
  102343. */
  102344. disableAudio(): void;
  102345. /**
  102346. * Enables audio in the associated scene.
  102347. */
  102348. enableAudio(): void;
  102349. /**
  102350. * Switch audio to headphone output.
  102351. */
  102352. switchAudioModeForHeadphones(): void;
  102353. /**
  102354. * Switch audio to normal speakers.
  102355. */
  102356. switchAudioModeForNormalSpeakers(): void;
  102357. private _afterRender;
  102358. }
  102359. }
  102360. declare module BABYLON {
  102361. /**
  102362. * Wraps one or more Sound objects and selects one with random weight for playback.
  102363. */
  102364. export class WeightedSound {
  102365. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102366. loop: boolean;
  102367. private _coneInnerAngle;
  102368. private _coneOuterAngle;
  102369. private _volume;
  102370. /** A Sound is currently playing. */
  102371. isPlaying: boolean;
  102372. /** A Sound is currently paused. */
  102373. isPaused: boolean;
  102374. private _sounds;
  102375. private _weights;
  102376. private _currentIndex?;
  102377. /**
  102378. * Creates a new WeightedSound from the list of sounds given.
  102379. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102380. * @param sounds Array of Sounds that will be selected from.
  102381. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102382. */
  102383. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102384. /**
  102385. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102386. */
  102387. /**
  102388. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102389. */
  102390. directionalConeInnerAngle: number;
  102391. /**
  102392. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102393. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102394. */
  102395. /**
  102396. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102397. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102398. */
  102399. directionalConeOuterAngle: number;
  102400. /**
  102401. * Playback volume.
  102402. */
  102403. /**
  102404. * Playback volume.
  102405. */
  102406. volume: number;
  102407. private _onended;
  102408. /**
  102409. * Suspend playback
  102410. */
  102411. pause(): void;
  102412. /**
  102413. * Stop playback
  102414. */
  102415. stop(): void;
  102416. /**
  102417. * Start playback.
  102418. * @param startOffset Position the clip head at a specific time in seconds.
  102419. */
  102420. play(startOffset?: number): void;
  102421. }
  102422. }
  102423. declare module BABYLON {
  102424. /**
  102425. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102426. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102427. */
  102428. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102429. /**
  102430. * Gets the name of the behavior.
  102431. */
  102432. readonly name: string;
  102433. /**
  102434. * The easing function used by animations
  102435. */
  102436. static EasingFunction: BackEase;
  102437. /**
  102438. * The easing mode used by animations
  102439. */
  102440. static EasingMode: number;
  102441. /**
  102442. * The duration of the animation, in milliseconds
  102443. */
  102444. transitionDuration: number;
  102445. /**
  102446. * Length of the distance animated by the transition when lower radius is reached
  102447. */
  102448. lowerRadiusTransitionRange: number;
  102449. /**
  102450. * Length of the distance animated by the transition when upper radius is reached
  102451. */
  102452. upperRadiusTransitionRange: number;
  102453. private _autoTransitionRange;
  102454. /**
  102455. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102456. */
  102457. /**
  102458. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102459. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102460. */
  102461. autoTransitionRange: boolean;
  102462. private _attachedCamera;
  102463. private _onAfterCheckInputsObserver;
  102464. private _onMeshTargetChangedObserver;
  102465. /**
  102466. * Initializes the behavior.
  102467. */
  102468. init(): void;
  102469. /**
  102470. * Attaches the behavior to its arc rotate camera.
  102471. * @param camera Defines the camera to attach the behavior to
  102472. */
  102473. attach(camera: ArcRotateCamera): void;
  102474. /**
  102475. * Detaches the behavior from its current arc rotate camera.
  102476. */
  102477. detach(): void;
  102478. private _radiusIsAnimating;
  102479. private _radiusBounceTransition;
  102480. private _animatables;
  102481. private _cachedWheelPrecision;
  102482. /**
  102483. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102484. * @param radiusLimit The limit to check against.
  102485. * @return Bool to indicate if at limit.
  102486. */
  102487. private _isRadiusAtLimit;
  102488. /**
  102489. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102490. * @param radiusDelta The delta by which to animate to. Can be negative.
  102491. */
  102492. private _applyBoundRadiusAnimation;
  102493. /**
  102494. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102495. */
  102496. protected _clearAnimationLocks(): void;
  102497. /**
  102498. * Stops and removes all animations that have been applied to the camera
  102499. */
  102500. stopAllAnimations(): void;
  102501. }
  102502. }
  102503. declare module BABYLON {
  102504. /**
  102505. * 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.
  102506. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102507. */
  102508. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102509. /**
  102510. * Gets the name of the behavior.
  102511. */
  102512. readonly name: string;
  102513. private _mode;
  102514. private _radiusScale;
  102515. private _positionScale;
  102516. private _defaultElevation;
  102517. private _elevationReturnTime;
  102518. private _elevationReturnWaitTime;
  102519. private _zoomStopsAnimation;
  102520. private _framingTime;
  102521. /**
  102522. * The easing function used by animations
  102523. */
  102524. static EasingFunction: ExponentialEase;
  102525. /**
  102526. * The easing mode used by animations
  102527. */
  102528. static EasingMode: number;
  102529. /**
  102530. * Sets the current mode used by the behavior
  102531. */
  102532. /**
  102533. * Gets current mode used by the behavior.
  102534. */
  102535. mode: number;
  102536. /**
  102537. * Sets the scale applied to the radius (1 by default)
  102538. */
  102539. /**
  102540. * Gets the scale applied to the radius
  102541. */
  102542. radiusScale: number;
  102543. /**
  102544. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102545. */
  102546. /**
  102547. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102548. */
  102549. positionScale: number;
  102550. /**
  102551. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102552. * behaviour is triggered, in radians.
  102553. */
  102554. /**
  102555. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102556. * behaviour is triggered, in radians.
  102557. */
  102558. defaultElevation: number;
  102559. /**
  102560. * Sets the time (in milliseconds) taken to return to the default beta position.
  102561. * Negative value indicates camera should not return to default.
  102562. */
  102563. /**
  102564. * Gets the time (in milliseconds) taken to return to the default beta position.
  102565. * Negative value indicates camera should not return to default.
  102566. */
  102567. elevationReturnTime: number;
  102568. /**
  102569. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102570. */
  102571. /**
  102572. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102573. */
  102574. elevationReturnWaitTime: number;
  102575. /**
  102576. * Sets the flag that indicates if user zooming should stop animation.
  102577. */
  102578. /**
  102579. * Gets the flag that indicates if user zooming should stop animation.
  102580. */
  102581. zoomStopsAnimation: boolean;
  102582. /**
  102583. * Sets the transition time when framing the mesh, in milliseconds
  102584. */
  102585. /**
  102586. * Gets the transition time when framing the mesh, in milliseconds
  102587. */
  102588. framingTime: number;
  102589. /**
  102590. * Define if the behavior should automatically change the configured
  102591. * camera limits and sensibilities.
  102592. */
  102593. autoCorrectCameraLimitsAndSensibility: boolean;
  102594. private _onPrePointerObservableObserver;
  102595. private _onAfterCheckInputsObserver;
  102596. private _onMeshTargetChangedObserver;
  102597. private _attachedCamera;
  102598. private _isPointerDown;
  102599. private _lastInteractionTime;
  102600. /**
  102601. * Initializes the behavior.
  102602. */
  102603. init(): void;
  102604. /**
  102605. * Attaches the behavior to its arc rotate camera.
  102606. * @param camera Defines the camera to attach the behavior to
  102607. */
  102608. attach(camera: ArcRotateCamera): void;
  102609. /**
  102610. * Detaches the behavior from its current arc rotate camera.
  102611. */
  102612. detach(): void;
  102613. private _animatables;
  102614. private _betaIsAnimating;
  102615. private _betaTransition;
  102616. private _radiusTransition;
  102617. private _vectorTransition;
  102618. /**
  102619. * Targets the given mesh and updates zoom level accordingly.
  102620. * @param mesh The mesh to target.
  102621. * @param radius Optional. If a cached radius position already exists, overrides default.
  102622. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102623. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102624. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102625. */
  102626. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102627. /**
  102628. * Targets the given mesh with its children and updates zoom level accordingly.
  102629. * @param mesh The mesh to target.
  102630. * @param radius Optional. If a cached radius position already exists, overrides default.
  102631. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102632. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102633. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102634. */
  102635. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102636. /**
  102637. * Targets the given meshes with their children and updates zoom level accordingly.
  102638. * @param meshes The mesh to target.
  102639. * @param radius Optional. If a cached radius position already exists, overrides default.
  102640. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102641. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102642. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102643. */
  102644. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102645. /**
  102646. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102647. * @param minimumWorld Determines the smaller position of the bounding box extend
  102648. * @param maximumWorld Determines the bigger position of the bounding box extend
  102649. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102650. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102651. */
  102652. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102653. /**
  102654. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102655. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102656. * frustum width.
  102657. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102658. * to fully enclose the mesh in the viewing frustum.
  102659. */
  102660. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102661. /**
  102662. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102663. * is automatically returned to its default position (expected to be above ground plane).
  102664. */
  102665. private _maintainCameraAboveGround;
  102666. /**
  102667. * Returns the frustum slope based on the canvas ratio and camera FOV
  102668. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102669. */
  102670. private _getFrustumSlope;
  102671. /**
  102672. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102673. */
  102674. private _clearAnimationLocks;
  102675. /**
  102676. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102677. */
  102678. private _applyUserInteraction;
  102679. /**
  102680. * Stops and removes all animations that have been applied to the camera
  102681. */
  102682. stopAllAnimations(): void;
  102683. /**
  102684. * Gets a value indicating if the user is moving the camera
  102685. */
  102686. readonly isUserIsMoving: boolean;
  102687. /**
  102688. * The camera can move all the way towards the mesh.
  102689. */
  102690. static IgnoreBoundsSizeMode: number;
  102691. /**
  102692. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102693. */
  102694. static FitFrustumSidesMode: number;
  102695. }
  102696. }
  102697. declare module BABYLON {
  102698. /**
  102699. * Base class for Camera Pointer Inputs.
  102700. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102701. * for example usage.
  102702. */
  102703. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102704. /**
  102705. * Defines the camera the input is attached to.
  102706. */
  102707. abstract camera: Camera;
  102708. /**
  102709. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102710. */
  102711. protected _altKey: boolean;
  102712. protected _ctrlKey: boolean;
  102713. protected _metaKey: boolean;
  102714. protected _shiftKey: boolean;
  102715. /**
  102716. * Which mouse buttons were pressed at time of last mouse event.
  102717. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102718. */
  102719. protected _buttonsPressed: number;
  102720. /**
  102721. * Defines the buttons associated with the input to handle camera move.
  102722. */
  102723. buttons: number[];
  102724. /**
  102725. * Attach the input controls to a specific dom element to get the input from.
  102726. * @param element Defines the element the controls should be listened from
  102727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102728. */
  102729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102730. /**
  102731. * Detach the current controls from the specified dom element.
  102732. * @param element Defines the element to stop listening the inputs from
  102733. */
  102734. detachControl(element: Nullable<HTMLElement>): void;
  102735. /**
  102736. * Gets the class name of the current input.
  102737. * @returns the class name
  102738. */
  102739. getClassName(): string;
  102740. /**
  102741. * Get the friendly name associated with the input class.
  102742. * @returns the input friendly name
  102743. */
  102744. getSimpleName(): string;
  102745. /**
  102746. * Called on pointer POINTERDOUBLETAP event.
  102747. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102748. */
  102749. protected onDoubleTap(type: string): void;
  102750. /**
  102751. * Called on pointer POINTERMOVE event if only a single touch is active.
  102752. * Override this method to provide functionality.
  102753. */
  102754. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102755. /**
  102756. * Called on pointer POINTERMOVE event if multiple touches are active.
  102757. * Override this method to provide functionality.
  102758. */
  102759. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102760. /**
  102761. * Called on JS contextmenu event.
  102762. * Override this method to provide functionality.
  102763. */
  102764. protected onContextMenu(evt: PointerEvent): void;
  102765. /**
  102766. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102767. * press.
  102768. * Override this method to provide functionality.
  102769. */
  102770. protected onButtonDown(evt: PointerEvent): void;
  102771. /**
  102772. * Called each time a new POINTERUP event occurs. Ie, for each button
  102773. * release.
  102774. * Override this method to provide functionality.
  102775. */
  102776. protected onButtonUp(evt: PointerEvent): void;
  102777. /**
  102778. * Called when window becomes inactive.
  102779. * Override this method to provide functionality.
  102780. */
  102781. protected onLostFocus(): void;
  102782. private _pointerInput;
  102783. private _observer;
  102784. private _onLostFocus;
  102785. private pointA;
  102786. private pointB;
  102787. }
  102788. }
  102789. declare module BABYLON {
  102790. /**
  102791. * Manage the pointers inputs to control an arc rotate camera.
  102792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102793. */
  102794. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102795. /**
  102796. * Defines the camera the input is attached to.
  102797. */
  102798. camera: ArcRotateCamera;
  102799. /**
  102800. * Gets the class name of the current input.
  102801. * @returns the class name
  102802. */
  102803. getClassName(): string;
  102804. /**
  102805. * Defines the buttons associated with the input to handle camera move.
  102806. */
  102807. buttons: number[];
  102808. /**
  102809. * Defines the pointer angular sensibility along the X axis or how fast is
  102810. * the camera rotating.
  102811. */
  102812. angularSensibilityX: number;
  102813. /**
  102814. * Defines the pointer angular sensibility along the Y axis or how fast is
  102815. * the camera rotating.
  102816. */
  102817. angularSensibilityY: number;
  102818. /**
  102819. * Defines the pointer pinch precision or how fast is the camera zooming.
  102820. */
  102821. pinchPrecision: number;
  102822. /**
  102823. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102824. * from 0.
  102825. * It defines the percentage of current camera.radius to use as delta when
  102826. * pinch zoom is used.
  102827. */
  102828. pinchDeltaPercentage: number;
  102829. /**
  102830. * Defines the pointer panning sensibility or how fast is the camera moving.
  102831. */
  102832. panningSensibility: number;
  102833. /**
  102834. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102835. */
  102836. multiTouchPanning: boolean;
  102837. /**
  102838. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102839. * zoom (pinch) through multitouch.
  102840. */
  102841. multiTouchPanAndZoom: boolean;
  102842. /**
  102843. * Revers pinch action direction.
  102844. */
  102845. pinchInwards: boolean;
  102846. private _isPanClick;
  102847. private _twoFingerActivityCount;
  102848. private _isPinching;
  102849. /**
  102850. * Called on pointer POINTERMOVE event if only a single touch is active.
  102851. */
  102852. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102853. /**
  102854. * Called on pointer POINTERDOUBLETAP event.
  102855. */
  102856. protected onDoubleTap(type: string): void;
  102857. /**
  102858. * Called on pointer POINTERMOVE event if multiple touches are active.
  102859. */
  102860. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102861. /**
  102862. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102863. * press.
  102864. */
  102865. protected onButtonDown(evt: PointerEvent): void;
  102866. /**
  102867. * Called each time a new POINTERUP event occurs. Ie, for each button
  102868. * release.
  102869. */
  102870. protected onButtonUp(evt: PointerEvent): void;
  102871. /**
  102872. * Called when window becomes inactive.
  102873. */
  102874. protected onLostFocus(): void;
  102875. }
  102876. }
  102877. declare module BABYLON {
  102878. /**
  102879. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102880. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102881. */
  102882. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102883. /**
  102884. * Defines the camera the input is attached to.
  102885. */
  102886. camera: ArcRotateCamera;
  102887. /**
  102888. * Defines the list of key codes associated with the up action (increase alpha)
  102889. */
  102890. keysUp: number[];
  102891. /**
  102892. * Defines the list of key codes associated with the down action (decrease alpha)
  102893. */
  102894. keysDown: number[];
  102895. /**
  102896. * Defines the list of key codes associated with the left action (increase beta)
  102897. */
  102898. keysLeft: number[];
  102899. /**
  102900. * Defines the list of key codes associated with the right action (decrease beta)
  102901. */
  102902. keysRight: number[];
  102903. /**
  102904. * Defines the list of key codes associated with the reset action.
  102905. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102906. */
  102907. keysReset: number[];
  102908. /**
  102909. * Defines the panning sensibility of the inputs.
  102910. * (How fast is the camera paning)
  102911. */
  102912. panningSensibility: number;
  102913. /**
  102914. * Defines the zooming sensibility of the inputs.
  102915. * (How fast is the camera zooming)
  102916. */
  102917. zoomingSensibility: number;
  102918. /**
  102919. * Defines wether maintaining the alt key down switch the movement mode from
  102920. * orientation to zoom.
  102921. */
  102922. useAltToZoom: boolean;
  102923. /**
  102924. * Rotation speed of the camera
  102925. */
  102926. angularSpeed: number;
  102927. private _keys;
  102928. private _ctrlPressed;
  102929. private _altPressed;
  102930. private _onCanvasBlurObserver;
  102931. private _onKeyboardObserver;
  102932. private _engine;
  102933. private _scene;
  102934. /**
  102935. * Attach the input controls to a specific dom element to get the input from.
  102936. * @param element Defines the element the controls should be listened from
  102937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102938. */
  102939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102940. /**
  102941. * Detach the current controls from the specified dom element.
  102942. * @param element Defines the element to stop listening the inputs from
  102943. */
  102944. detachControl(element: Nullable<HTMLElement>): void;
  102945. /**
  102946. * Update the current camera state depending on the inputs that have been used this frame.
  102947. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102948. */
  102949. checkInputs(): void;
  102950. /**
  102951. * Gets the class name of the current intput.
  102952. * @returns the class name
  102953. */
  102954. getClassName(): string;
  102955. /**
  102956. * Get the friendly name associated with the input class.
  102957. * @returns the input friendly name
  102958. */
  102959. getSimpleName(): string;
  102960. }
  102961. }
  102962. declare module BABYLON {
  102963. /**
  102964. * Manage the mouse wheel inputs to control an arc rotate camera.
  102965. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102966. */
  102967. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102968. /**
  102969. * Defines the camera the input is attached to.
  102970. */
  102971. camera: ArcRotateCamera;
  102972. /**
  102973. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102974. */
  102975. wheelPrecision: number;
  102976. /**
  102977. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  102978. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  102979. */
  102980. wheelDeltaPercentage: number;
  102981. private _wheel;
  102982. private _observer;
  102983. private computeDeltaFromMouseWheelLegacyEvent;
  102984. /**
  102985. * Attach the input controls to a specific dom element to get the input from.
  102986. * @param element Defines the element the controls should be listened from
  102987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102988. */
  102989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102990. /**
  102991. * Detach the current controls from the specified dom element.
  102992. * @param element Defines the element to stop listening the inputs from
  102993. */
  102994. detachControl(element: Nullable<HTMLElement>): void;
  102995. /**
  102996. * Gets the class name of the current intput.
  102997. * @returns the class name
  102998. */
  102999. getClassName(): string;
  103000. /**
  103001. * Get the friendly name associated with the input class.
  103002. * @returns the input friendly name
  103003. */
  103004. getSimpleName(): string;
  103005. }
  103006. }
  103007. declare module BABYLON {
  103008. /**
  103009. * Default Inputs manager for the ArcRotateCamera.
  103010. * It groups all the default supported inputs for ease of use.
  103011. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103012. */
  103013. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103014. /**
  103015. * Instantiates a new ArcRotateCameraInputsManager.
  103016. * @param camera Defines the camera the inputs belong to
  103017. */
  103018. constructor(camera: ArcRotateCamera);
  103019. /**
  103020. * Add mouse wheel input support to the input manager.
  103021. * @returns the current input manager
  103022. */
  103023. addMouseWheel(): ArcRotateCameraInputsManager;
  103024. /**
  103025. * Add pointers input support to the input manager.
  103026. * @returns the current input manager
  103027. */
  103028. addPointers(): ArcRotateCameraInputsManager;
  103029. /**
  103030. * Add keyboard input support to the input manager.
  103031. * @returns the current input manager
  103032. */
  103033. addKeyboard(): ArcRotateCameraInputsManager;
  103034. }
  103035. }
  103036. declare module BABYLON {
  103037. /**
  103038. * This represents an orbital type of camera.
  103039. *
  103040. * 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.
  103041. * 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.
  103042. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103043. */
  103044. export class ArcRotateCamera extends TargetCamera {
  103045. /**
  103046. * Defines the rotation angle of the camera along the longitudinal axis.
  103047. */
  103048. alpha: number;
  103049. /**
  103050. * Defines the rotation angle of the camera along the latitudinal axis.
  103051. */
  103052. beta: number;
  103053. /**
  103054. * Defines the radius of the camera from it s target point.
  103055. */
  103056. radius: number;
  103057. protected _target: Vector3;
  103058. protected _targetHost: Nullable<AbstractMesh>;
  103059. /**
  103060. * Defines the target point of the camera.
  103061. * The camera looks towards it form the radius distance.
  103062. */
  103063. target: Vector3;
  103064. /**
  103065. * Define the current local position of the camera in the scene
  103066. */
  103067. position: Vector3;
  103068. protected _upVector: Vector3;
  103069. protected _upToYMatrix: Matrix;
  103070. protected _YToUpMatrix: Matrix;
  103071. /**
  103072. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103073. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103074. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103075. */
  103076. upVector: Vector3;
  103077. /**
  103078. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103079. */
  103080. setMatUp(): void;
  103081. /**
  103082. * Current inertia value on the longitudinal axis.
  103083. * The bigger this number the longer it will take for the camera to stop.
  103084. */
  103085. inertialAlphaOffset: number;
  103086. /**
  103087. * Current inertia value on the latitudinal axis.
  103088. * The bigger this number the longer it will take for the camera to stop.
  103089. */
  103090. inertialBetaOffset: number;
  103091. /**
  103092. * Current inertia value on the radius axis.
  103093. * The bigger this number the longer it will take for the camera to stop.
  103094. */
  103095. inertialRadiusOffset: number;
  103096. /**
  103097. * Minimum allowed angle on the longitudinal axis.
  103098. * This can help limiting how the Camera is able to move in the scene.
  103099. */
  103100. lowerAlphaLimit: Nullable<number>;
  103101. /**
  103102. * Maximum allowed angle on the longitudinal axis.
  103103. * This can help limiting how the Camera is able to move in the scene.
  103104. */
  103105. upperAlphaLimit: Nullable<number>;
  103106. /**
  103107. * Minimum allowed angle on the latitudinal axis.
  103108. * This can help limiting how the Camera is able to move in the scene.
  103109. */
  103110. lowerBetaLimit: number;
  103111. /**
  103112. * Maximum allowed angle on the latitudinal axis.
  103113. * This can help limiting how the Camera is able to move in the scene.
  103114. */
  103115. upperBetaLimit: number;
  103116. /**
  103117. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103118. * This can help limiting how the Camera is able to move in the scene.
  103119. */
  103120. lowerRadiusLimit: Nullable<number>;
  103121. /**
  103122. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103123. * This can help limiting how the Camera is able to move in the scene.
  103124. */
  103125. upperRadiusLimit: Nullable<number>;
  103126. /**
  103127. * Defines the current inertia value used during panning of the camera along the X axis.
  103128. */
  103129. inertialPanningX: number;
  103130. /**
  103131. * Defines the current inertia value used during panning of the camera along the Y axis.
  103132. */
  103133. inertialPanningY: number;
  103134. /**
  103135. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103136. * Basically if your fingers moves away from more than this distance you will be considered
  103137. * in pinch mode.
  103138. */
  103139. pinchToPanMaxDistance: number;
  103140. /**
  103141. * Defines the maximum distance the camera can pan.
  103142. * This could help keeping the cammera always in your scene.
  103143. */
  103144. panningDistanceLimit: Nullable<number>;
  103145. /**
  103146. * Defines the target of the camera before paning.
  103147. */
  103148. panningOriginTarget: Vector3;
  103149. /**
  103150. * Defines the value of the inertia used during panning.
  103151. * 0 would mean stop inertia and one would mean no decelleration at all.
  103152. */
  103153. panningInertia: number;
  103154. /**
  103155. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103156. */
  103157. angularSensibilityX: number;
  103158. /**
  103159. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103160. */
  103161. angularSensibilityY: number;
  103162. /**
  103163. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103164. */
  103165. pinchPrecision: number;
  103166. /**
  103167. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103168. * It will be used instead of pinchDeltaPrecision if different from 0.
  103169. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103170. */
  103171. pinchDeltaPercentage: number;
  103172. /**
  103173. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103174. */
  103175. panningSensibility: number;
  103176. /**
  103177. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103178. */
  103179. keysUp: number[];
  103180. /**
  103181. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103182. */
  103183. keysDown: number[];
  103184. /**
  103185. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103186. */
  103187. keysLeft: number[];
  103188. /**
  103189. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103190. */
  103191. keysRight: number[];
  103192. /**
  103193. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103194. */
  103195. wheelPrecision: number;
  103196. /**
  103197. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103198. * It will be used instead of pinchDeltaPrecision if different from 0.
  103199. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103200. */
  103201. wheelDeltaPercentage: number;
  103202. /**
  103203. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103204. */
  103205. zoomOnFactor: number;
  103206. /**
  103207. * Defines a screen offset for the camera position.
  103208. */
  103209. targetScreenOffset: Vector2;
  103210. /**
  103211. * Allows the camera to be completely reversed.
  103212. * If false the camera can not arrive upside down.
  103213. */
  103214. allowUpsideDown: boolean;
  103215. /**
  103216. * Define if double tap/click is used to restore the previously saved state of the camera.
  103217. */
  103218. useInputToRestoreState: boolean;
  103219. /** @hidden */
  103220. _viewMatrix: Matrix;
  103221. /** @hidden */
  103222. _useCtrlForPanning: boolean;
  103223. /** @hidden */
  103224. _panningMouseButton: number;
  103225. /**
  103226. * Defines the input associated to the camera.
  103227. */
  103228. inputs: ArcRotateCameraInputsManager;
  103229. /** @hidden */
  103230. _reset: () => void;
  103231. /**
  103232. * Defines the allowed panning axis.
  103233. */
  103234. panningAxis: Vector3;
  103235. protected _localDirection: Vector3;
  103236. protected _transformedDirection: Vector3;
  103237. private _bouncingBehavior;
  103238. /**
  103239. * Gets the bouncing behavior of the camera if it has been enabled.
  103240. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103241. */
  103242. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103243. /**
  103244. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103245. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103246. */
  103247. useBouncingBehavior: boolean;
  103248. private _framingBehavior;
  103249. /**
  103250. * Gets the framing behavior of the camera if it has been enabled.
  103251. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103252. */
  103253. readonly framingBehavior: Nullable<FramingBehavior>;
  103254. /**
  103255. * Defines if the framing behavior of the camera is enabled on the camera.
  103256. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103257. */
  103258. useFramingBehavior: boolean;
  103259. private _autoRotationBehavior;
  103260. /**
  103261. * Gets the auto rotation behavior of the camera if it has been enabled.
  103262. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103263. */
  103264. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103265. /**
  103266. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103267. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103268. */
  103269. useAutoRotationBehavior: boolean;
  103270. /**
  103271. * Observable triggered when the mesh target has been changed on the camera.
  103272. */
  103273. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103274. /**
  103275. * Event raised when the camera is colliding with a mesh.
  103276. */
  103277. onCollide: (collidedMesh: AbstractMesh) => void;
  103278. /**
  103279. * Defines whether the camera should check collision with the objects oh the scene.
  103280. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103281. */
  103282. checkCollisions: boolean;
  103283. /**
  103284. * Defines the collision radius of the camera.
  103285. * This simulates a sphere around the camera.
  103286. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103287. */
  103288. collisionRadius: Vector3;
  103289. protected _collider: Collider;
  103290. protected _previousPosition: Vector3;
  103291. protected _collisionVelocity: Vector3;
  103292. protected _newPosition: Vector3;
  103293. protected _previousAlpha: number;
  103294. protected _previousBeta: number;
  103295. protected _previousRadius: number;
  103296. protected _collisionTriggered: boolean;
  103297. protected _targetBoundingCenter: Nullable<Vector3>;
  103298. private _computationVector;
  103299. /**
  103300. * Instantiates a new ArcRotateCamera in a given scene
  103301. * @param name Defines the name of the camera
  103302. * @param alpha Defines the camera rotation along the logitudinal axis
  103303. * @param beta Defines the camera rotation along the latitudinal axis
  103304. * @param radius Defines the camera distance from its target
  103305. * @param target Defines the camera target
  103306. * @param scene Defines the scene the camera belongs to
  103307. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103308. */
  103309. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103310. /** @hidden */
  103311. _initCache(): void;
  103312. /** @hidden */
  103313. _updateCache(ignoreParentClass?: boolean): void;
  103314. protected _getTargetPosition(): Vector3;
  103315. private _storedAlpha;
  103316. private _storedBeta;
  103317. private _storedRadius;
  103318. private _storedTarget;
  103319. private _storedTargetScreenOffset;
  103320. /**
  103321. * Stores the current state of the camera (alpha, beta, radius and target)
  103322. * @returns the camera itself
  103323. */
  103324. storeState(): Camera;
  103325. /**
  103326. * @hidden
  103327. * Restored camera state. You must call storeState() first
  103328. */
  103329. _restoreStateValues(): boolean;
  103330. /** @hidden */
  103331. _isSynchronizedViewMatrix(): boolean;
  103332. /**
  103333. * Attached controls to the current camera.
  103334. * @param element Defines the element the controls should be listened from
  103335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103336. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103337. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103338. */
  103339. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103340. /**
  103341. * Detach the current controls from the camera.
  103342. * The camera will stop reacting to inputs.
  103343. * @param element Defines the element to stop listening the inputs from
  103344. */
  103345. detachControl(element: HTMLElement): void;
  103346. /** @hidden */
  103347. _checkInputs(): void;
  103348. protected _checkLimits(): void;
  103349. /**
  103350. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103351. */
  103352. rebuildAnglesAndRadius(): void;
  103353. /**
  103354. * Use a position to define the current camera related information like aplha, beta and radius
  103355. * @param position Defines the position to set the camera at
  103356. */
  103357. setPosition(position: Vector3): void;
  103358. /**
  103359. * Defines the target the camera should look at.
  103360. * This will automatically adapt alpha beta and radius to fit within the new target.
  103361. * @param target Defines the new target as a Vector or a mesh
  103362. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103363. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103364. */
  103365. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103366. /** @hidden */
  103367. _getViewMatrix(): Matrix;
  103368. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103369. /**
  103370. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103371. * @param meshes Defines the mesh to zoom on
  103372. * @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)
  103373. */
  103374. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103375. /**
  103376. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103377. * The target will be changed but the radius
  103378. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103379. * @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)
  103380. */
  103381. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103382. min: Vector3;
  103383. max: Vector3;
  103384. distance: number;
  103385. }, doNotUpdateMaxZ?: boolean): void;
  103386. /**
  103387. * @override
  103388. * Override Camera.createRigCamera
  103389. */
  103390. createRigCamera(name: string, cameraIndex: number): Camera;
  103391. /**
  103392. * @hidden
  103393. * @override
  103394. * Override Camera._updateRigCameras
  103395. */
  103396. _updateRigCameras(): void;
  103397. /**
  103398. * Destroy the camera and release the current resources hold by it.
  103399. */
  103400. dispose(): void;
  103401. /**
  103402. * Gets the current object class name.
  103403. * @return the class name
  103404. */
  103405. getClassName(): string;
  103406. }
  103407. }
  103408. declare module BABYLON {
  103409. /**
  103410. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103411. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103412. */
  103413. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103414. /**
  103415. * Gets the name of the behavior.
  103416. */
  103417. readonly name: string;
  103418. private _zoomStopsAnimation;
  103419. private _idleRotationSpeed;
  103420. private _idleRotationWaitTime;
  103421. private _idleRotationSpinupTime;
  103422. /**
  103423. * Sets the flag that indicates if user zooming should stop animation.
  103424. */
  103425. /**
  103426. * Gets the flag that indicates if user zooming should stop animation.
  103427. */
  103428. zoomStopsAnimation: boolean;
  103429. /**
  103430. * Sets the default speed at which the camera rotates around the model.
  103431. */
  103432. /**
  103433. * Gets the default speed at which the camera rotates around the model.
  103434. */
  103435. idleRotationSpeed: number;
  103436. /**
  103437. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103438. */
  103439. /**
  103440. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103441. */
  103442. idleRotationWaitTime: number;
  103443. /**
  103444. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103445. */
  103446. /**
  103447. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103448. */
  103449. idleRotationSpinupTime: number;
  103450. /**
  103451. * Gets a value indicating if the camera is currently rotating because of this behavior
  103452. */
  103453. readonly rotationInProgress: boolean;
  103454. private _onPrePointerObservableObserver;
  103455. private _onAfterCheckInputsObserver;
  103456. private _attachedCamera;
  103457. private _isPointerDown;
  103458. private _lastFrameTime;
  103459. private _lastInteractionTime;
  103460. private _cameraRotationSpeed;
  103461. /**
  103462. * Initializes the behavior.
  103463. */
  103464. init(): void;
  103465. /**
  103466. * Attaches the behavior to its arc rotate camera.
  103467. * @param camera Defines the camera to attach the behavior to
  103468. */
  103469. attach(camera: ArcRotateCamera): void;
  103470. /**
  103471. * Detaches the behavior from its current arc rotate camera.
  103472. */
  103473. detach(): void;
  103474. /**
  103475. * Returns true if user is scrolling.
  103476. * @return true if user is scrolling.
  103477. */
  103478. private _userIsZooming;
  103479. private _lastFrameRadius;
  103480. private _shouldAnimationStopForInteraction;
  103481. /**
  103482. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103483. */
  103484. private _applyUserInteraction;
  103485. private _userIsMoving;
  103486. }
  103487. }
  103488. declare module BABYLON {
  103489. /**
  103490. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103491. */
  103492. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103493. private ui;
  103494. /**
  103495. * The name of the behavior
  103496. */
  103497. name: string;
  103498. /**
  103499. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103500. */
  103501. distanceAwayFromFace: number;
  103502. /**
  103503. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103504. */
  103505. distanceAwayFromBottomOfFace: number;
  103506. private _faceVectors;
  103507. private _target;
  103508. private _scene;
  103509. private _onRenderObserver;
  103510. private _tmpMatrix;
  103511. private _tmpVector;
  103512. /**
  103513. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103514. * @param ui The transform node that should be attched to the mesh
  103515. */
  103516. constructor(ui: TransformNode);
  103517. /**
  103518. * Initializes the behavior
  103519. */
  103520. init(): void;
  103521. private _closestFace;
  103522. private _zeroVector;
  103523. private _lookAtTmpMatrix;
  103524. private _lookAtToRef;
  103525. /**
  103526. * Attaches the AttachToBoxBehavior to the passed in mesh
  103527. * @param target The mesh that the specified node will be attached to
  103528. */
  103529. attach(target: Mesh): void;
  103530. /**
  103531. * Detaches the behavior from the mesh
  103532. */
  103533. detach(): void;
  103534. }
  103535. }
  103536. declare module BABYLON {
  103537. /**
  103538. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103539. */
  103540. export class FadeInOutBehavior implements Behavior<Mesh> {
  103541. /**
  103542. * Time in milliseconds to delay before fading in (Default: 0)
  103543. */
  103544. delay: number;
  103545. /**
  103546. * Time in milliseconds for the mesh to fade in (Default: 300)
  103547. */
  103548. fadeInTime: number;
  103549. private _millisecondsPerFrame;
  103550. private _hovered;
  103551. private _hoverValue;
  103552. private _ownerNode;
  103553. /**
  103554. * Instatiates the FadeInOutBehavior
  103555. */
  103556. constructor();
  103557. /**
  103558. * The name of the behavior
  103559. */
  103560. readonly name: string;
  103561. /**
  103562. * Initializes the behavior
  103563. */
  103564. init(): void;
  103565. /**
  103566. * Attaches the fade behavior on the passed in mesh
  103567. * @param ownerNode The mesh that will be faded in/out once attached
  103568. */
  103569. attach(ownerNode: Mesh): void;
  103570. /**
  103571. * Detaches the behavior from the mesh
  103572. */
  103573. detach(): void;
  103574. /**
  103575. * Triggers the mesh to begin fading in or out
  103576. * @param value if the object should fade in or out (true to fade in)
  103577. */
  103578. fadeIn(value: boolean): void;
  103579. private _update;
  103580. private _setAllVisibility;
  103581. }
  103582. }
  103583. declare module BABYLON {
  103584. /**
  103585. * Class containing a set of static utilities functions for managing Pivots
  103586. * @hidden
  103587. */
  103588. export class PivotTools {
  103589. private static _PivotCached;
  103590. private static _OldPivotPoint;
  103591. private static _PivotTranslation;
  103592. private static _PivotTmpVector;
  103593. /** @hidden */
  103594. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103595. /** @hidden */
  103596. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103597. }
  103598. }
  103599. declare module BABYLON {
  103600. /**
  103601. * Class containing static functions to help procedurally build meshes
  103602. */
  103603. export class PlaneBuilder {
  103604. /**
  103605. * Creates a plane mesh
  103606. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103607. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103608. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103609. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103610. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103612. * @param name defines the name of the mesh
  103613. * @param options defines the options used to create the mesh
  103614. * @param scene defines the hosting scene
  103615. * @returns the plane mesh
  103616. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103617. */
  103618. static CreatePlane(name: string, options: {
  103619. size?: number;
  103620. width?: number;
  103621. height?: number;
  103622. sideOrientation?: number;
  103623. frontUVs?: Vector4;
  103624. backUVs?: Vector4;
  103625. updatable?: boolean;
  103626. sourcePlane?: Plane;
  103627. }, scene?: Nullable<Scene>): Mesh;
  103628. }
  103629. }
  103630. declare module BABYLON {
  103631. /**
  103632. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103633. */
  103634. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103635. private static _AnyMouseID;
  103636. /**
  103637. * Abstract mesh the behavior is set on
  103638. */
  103639. attachedNode: AbstractMesh;
  103640. private _dragPlane;
  103641. private _scene;
  103642. private _pointerObserver;
  103643. private _beforeRenderObserver;
  103644. private static _planeScene;
  103645. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103646. /**
  103647. * 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)
  103648. */
  103649. maxDragAngle: number;
  103650. /**
  103651. * @hidden
  103652. */
  103653. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103654. /**
  103655. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103656. */
  103657. currentDraggingPointerID: number;
  103658. /**
  103659. * The last position where the pointer hit the drag plane in world space
  103660. */
  103661. lastDragPosition: Vector3;
  103662. /**
  103663. * If the behavior is currently in a dragging state
  103664. */
  103665. dragging: boolean;
  103666. /**
  103667. * 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)
  103668. */
  103669. dragDeltaRatio: number;
  103670. /**
  103671. * If the drag plane orientation should be updated during the dragging (Default: true)
  103672. */
  103673. updateDragPlane: boolean;
  103674. private _debugMode;
  103675. private _moving;
  103676. /**
  103677. * Fires each time the attached mesh is dragged with the pointer
  103678. * * delta between last drag position and current drag position in world space
  103679. * * dragDistance along the drag axis
  103680. * * dragPlaneNormal normal of the current drag plane used during the drag
  103681. * * dragPlanePoint in world space where the drag intersects the drag plane
  103682. */
  103683. onDragObservable: Observable<{
  103684. delta: Vector3;
  103685. dragPlanePoint: Vector3;
  103686. dragPlaneNormal: Vector3;
  103687. dragDistance: number;
  103688. pointerId: number;
  103689. }>;
  103690. /**
  103691. * Fires each time a drag begins (eg. mouse down on mesh)
  103692. */
  103693. onDragStartObservable: Observable<{
  103694. dragPlanePoint: Vector3;
  103695. pointerId: number;
  103696. }>;
  103697. /**
  103698. * Fires each time a drag ends (eg. mouse release after drag)
  103699. */
  103700. onDragEndObservable: Observable<{
  103701. dragPlanePoint: Vector3;
  103702. pointerId: number;
  103703. }>;
  103704. /**
  103705. * If the attached mesh should be moved when dragged
  103706. */
  103707. moveAttached: boolean;
  103708. /**
  103709. * If the drag behavior will react to drag events (Default: true)
  103710. */
  103711. enabled: boolean;
  103712. /**
  103713. * If pointer events should start and release the drag (Default: true)
  103714. */
  103715. startAndReleaseDragOnPointerEvents: boolean;
  103716. /**
  103717. * If camera controls should be detached during the drag
  103718. */
  103719. detachCameraControls: boolean;
  103720. /**
  103721. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103722. */
  103723. useObjectOrienationForDragging: boolean;
  103724. private _options;
  103725. /**
  103726. * Creates a pointer drag behavior that can be attached to a mesh
  103727. * @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)
  103728. */
  103729. constructor(options?: {
  103730. dragAxis?: Vector3;
  103731. dragPlaneNormal?: Vector3;
  103732. });
  103733. /**
  103734. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103735. */
  103736. validateDrag: (targetPosition: Vector3) => boolean;
  103737. /**
  103738. * The name of the behavior
  103739. */
  103740. readonly name: string;
  103741. /**
  103742. * Initializes the behavior
  103743. */
  103744. init(): void;
  103745. private _tmpVector;
  103746. private _alternatePickedPoint;
  103747. private _worldDragAxis;
  103748. private _targetPosition;
  103749. private _attachedElement;
  103750. /**
  103751. * Attaches the drag behavior the passed in mesh
  103752. * @param ownerNode The mesh that will be dragged around once attached
  103753. * @param predicate Predicate to use for pick filtering
  103754. */
  103755. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103756. /**
  103757. * Force relase the drag action by code.
  103758. */
  103759. releaseDrag(): void;
  103760. private _startDragRay;
  103761. private _lastPointerRay;
  103762. /**
  103763. * Simulates the start of a pointer drag event on the behavior
  103764. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103765. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103766. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103767. */
  103768. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103769. private _startDrag;
  103770. private _dragDelta;
  103771. private _moveDrag;
  103772. private _pickWithRayOnDragPlane;
  103773. private _pointA;
  103774. private _pointB;
  103775. private _pointC;
  103776. private _lineA;
  103777. private _lineB;
  103778. private _localAxis;
  103779. private _lookAt;
  103780. private _updateDragPlanePosition;
  103781. /**
  103782. * Detaches the behavior from the mesh
  103783. */
  103784. detach(): void;
  103785. }
  103786. }
  103787. declare module BABYLON {
  103788. /**
  103789. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103790. */
  103791. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103792. private _dragBehaviorA;
  103793. private _dragBehaviorB;
  103794. private _startDistance;
  103795. private _initialScale;
  103796. private _targetScale;
  103797. private _ownerNode;
  103798. private _sceneRenderObserver;
  103799. /**
  103800. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103801. */
  103802. constructor();
  103803. /**
  103804. * The name of the behavior
  103805. */
  103806. readonly name: string;
  103807. /**
  103808. * Initializes the behavior
  103809. */
  103810. init(): void;
  103811. private _getCurrentDistance;
  103812. /**
  103813. * Attaches the scale behavior the passed in mesh
  103814. * @param ownerNode The mesh that will be scaled around once attached
  103815. */
  103816. attach(ownerNode: Mesh): void;
  103817. /**
  103818. * Detaches the behavior from the mesh
  103819. */
  103820. detach(): void;
  103821. }
  103822. }
  103823. declare module BABYLON {
  103824. /**
  103825. * 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
  103826. */
  103827. export class SixDofDragBehavior implements Behavior<Mesh> {
  103828. private static _virtualScene;
  103829. private _ownerNode;
  103830. private _sceneRenderObserver;
  103831. private _scene;
  103832. private _targetPosition;
  103833. private _virtualOriginMesh;
  103834. private _virtualDragMesh;
  103835. private _pointerObserver;
  103836. private _moving;
  103837. private _startingOrientation;
  103838. /**
  103839. * 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)
  103840. */
  103841. private zDragFactor;
  103842. /**
  103843. * If the object should rotate to face the drag origin
  103844. */
  103845. rotateDraggedObject: boolean;
  103846. /**
  103847. * If the behavior is currently in a dragging state
  103848. */
  103849. dragging: boolean;
  103850. /**
  103851. * 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)
  103852. */
  103853. dragDeltaRatio: number;
  103854. /**
  103855. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103856. */
  103857. currentDraggingPointerID: number;
  103858. /**
  103859. * If camera controls should be detached during the drag
  103860. */
  103861. detachCameraControls: boolean;
  103862. /**
  103863. * Fires each time a drag starts
  103864. */
  103865. onDragStartObservable: Observable<{}>;
  103866. /**
  103867. * Fires each time a drag ends (eg. mouse release after drag)
  103868. */
  103869. onDragEndObservable: Observable<{}>;
  103870. /**
  103871. * 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
  103872. */
  103873. constructor();
  103874. /**
  103875. * The name of the behavior
  103876. */
  103877. readonly name: string;
  103878. /**
  103879. * Initializes the behavior
  103880. */
  103881. init(): void;
  103882. /**
  103883. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103884. */
  103885. private readonly _pointerCamera;
  103886. /**
  103887. * Attaches the scale behavior the passed in mesh
  103888. * @param ownerNode The mesh that will be scaled around once attached
  103889. */
  103890. attach(ownerNode: Mesh): void;
  103891. /**
  103892. * Detaches the behavior from the mesh
  103893. */
  103894. detach(): void;
  103895. }
  103896. }
  103897. declare module BABYLON {
  103898. /**
  103899. * Class used to apply inverse kinematics to bones
  103900. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103901. */
  103902. export class BoneIKController {
  103903. private static _tmpVecs;
  103904. private static _tmpQuat;
  103905. private static _tmpMats;
  103906. /**
  103907. * Gets or sets the target mesh
  103908. */
  103909. targetMesh: AbstractMesh;
  103910. /** Gets or sets the mesh used as pole */
  103911. poleTargetMesh: AbstractMesh;
  103912. /**
  103913. * Gets or sets the bone used as pole
  103914. */
  103915. poleTargetBone: Nullable<Bone>;
  103916. /**
  103917. * Gets or sets the target position
  103918. */
  103919. targetPosition: Vector3;
  103920. /**
  103921. * Gets or sets the pole target position
  103922. */
  103923. poleTargetPosition: Vector3;
  103924. /**
  103925. * Gets or sets the pole target local offset
  103926. */
  103927. poleTargetLocalOffset: Vector3;
  103928. /**
  103929. * Gets or sets the pole angle
  103930. */
  103931. poleAngle: number;
  103932. /**
  103933. * Gets or sets the mesh associated with the controller
  103934. */
  103935. mesh: AbstractMesh;
  103936. /**
  103937. * 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)
  103938. */
  103939. slerpAmount: number;
  103940. private _bone1Quat;
  103941. private _bone1Mat;
  103942. private _bone2Ang;
  103943. private _bone1;
  103944. private _bone2;
  103945. private _bone1Length;
  103946. private _bone2Length;
  103947. private _maxAngle;
  103948. private _maxReach;
  103949. private _rightHandedSystem;
  103950. private _bendAxis;
  103951. private _slerping;
  103952. private _adjustRoll;
  103953. /**
  103954. * Gets or sets maximum allowed angle
  103955. */
  103956. maxAngle: number;
  103957. /**
  103958. * Creates a new BoneIKController
  103959. * @param mesh defines the mesh to control
  103960. * @param bone defines the bone to control
  103961. * @param options defines options to set up the controller
  103962. */
  103963. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103964. targetMesh?: AbstractMesh;
  103965. poleTargetMesh?: AbstractMesh;
  103966. poleTargetBone?: Bone;
  103967. poleTargetLocalOffset?: Vector3;
  103968. poleAngle?: number;
  103969. bendAxis?: Vector3;
  103970. maxAngle?: number;
  103971. slerpAmount?: number;
  103972. });
  103973. private _setMaxAngle;
  103974. /**
  103975. * Force the controller to update the bones
  103976. */
  103977. update(): void;
  103978. }
  103979. }
  103980. declare module BABYLON {
  103981. /**
  103982. * Class used to make a bone look toward a point in space
  103983. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  103984. */
  103985. export class BoneLookController {
  103986. private static _tmpVecs;
  103987. private static _tmpQuat;
  103988. private static _tmpMats;
  103989. /**
  103990. * The target Vector3 that the bone will look at
  103991. */
  103992. target: Vector3;
  103993. /**
  103994. * The mesh that the bone is attached to
  103995. */
  103996. mesh: AbstractMesh;
  103997. /**
  103998. * The bone that will be looking to the target
  103999. */
  104000. bone: Bone;
  104001. /**
  104002. * The up axis of the coordinate system that is used when the bone is rotated
  104003. */
  104004. upAxis: Vector3;
  104005. /**
  104006. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104007. */
  104008. upAxisSpace: Space;
  104009. /**
  104010. * Used to make an adjustment to the yaw of the bone
  104011. */
  104012. adjustYaw: number;
  104013. /**
  104014. * Used to make an adjustment to the pitch of the bone
  104015. */
  104016. adjustPitch: number;
  104017. /**
  104018. * Used to make an adjustment to the roll of the bone
  104019. */
  104020. adjustRoll: number;
  104021. /**
  104022. * 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)
  104023. */
  104024. slerpAmount: number;
  104025. private _minYaw;
  104026. private _maxYaw;
  104027. private _minPitch;
  104028. private _maxPitch;
  104029. private _minYawSin;
  104030. private _minYawCos;
  104031. private _maxYawSin;
  104032. private _maxYawCos;
  104033. private _midYawConstraint;
  104034. private _minPitchTan;
  104035. private _maxPitchTan;
  104036. private _boneQuat;
  104037. private _slerping;
  104038. private _transformYawPitch;
  104039. private _transformYawPitchInv;
  104040. private _firstFrameSkipped;
  104041. private _yawRange;
  104042. private _fowardAxis;
  104043. /**
  104044. * Gets or sets the minimum yaw angle that the bone can look to
  104045. */
  104046. minYaw: number;
  104047. /**
  104048. * Gets or sets the maximum yaw angle that the bone can look to
  104049. */
  104050. maxYaw: number;
  104051. /**
  104052. * Gets or sets the minimum pitch angle that the bone can look to
  104053. */
  104054. minPitch: number;
  104055. /**
  104056. * Gets or sets the maximum pitch angle that the bone can look to
  104057. */
  104058. maxPitch: number;
  104059. /**
  104060. * Create a BoneLookController
  104061. * @param mesh the mesh that the bone belongs to
  104062. * @param bone the bone that will be looking to the target
  104063. * @param target the target Vector3 to look at
  104064. * @param options optional settings:
  104065. * * maxYaw: the maximum angle the bone will yaw to
  104066. * * minYaw: the minimum angle the bone will yaw to
  104067. * * maxPitch: the maximum angle the bone will pitch to
  104068. * * minPitch: the minimum angle the bone will yaw to
  104069. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104070. * * upAxis: the up axis of the coordinate system
  104071. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104072. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104073. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104074. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104075. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104076. * * adjustRoll: used to make an adjustment to the roll of the bone
  104077. **/
  104078. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104079. maxYaw?: number;
  104080. minYaw?: number;
  104081. maxPitch?: number;
  104082. minPitch?: number;
  104083. slerpAmount?: number;
  104084. upAxis?: Vector3;
  104085. upAxisSpace?: Space;
  104086. yawAxis?: Vector3;
  104087. pitchAxis?: Vector3;
  104088. adjustYaw?: number;
  104089. adjustPitch?: number;
  104090. adjustRoll?: number;
  104091. });
  104092. /**
  104093. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104094. */
  104095. update(): void;
  104096. private _getAngleDiff;
  104097. private _getAngleBetween;
  104098. private _isAngleBetween;
  104099. }
  104100. }
  104101. declare module BABYLON {
  104102. /**
  104103. * Manage the gamepad inputs to control an arc rotate camera.
  104104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104105. */
  104106. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104107. /**
  104108. * Defines the camera the input is attached to.
  104109. */
  104110. camera: ArcRotateCamera;
  104111. /**
  104112. * Defines the gamepad the input is gathering event from.
  104113. */
  104114. gamepad: Nullable<Gamepad>;
  104115. /**
  104116. * Defines the gamepad rotation sensiblity.
  104117. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104118. */
  104119. gamepadRotationSensibility: number;
  104120. /**
  104121. * Defines the gamepad move sensiblity.
  104122. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104123. */
  104124. gamepadMoveSensibility: number;
  104125. private _onGamepadConnectedObserver;
  104126. private _onGamepadDisconnectedObserver;
  104127. /**
  104128. * Attach the input controls to a specific dom element to get the input from.
  104129. * @param element Defines the element the controls should be listened from
  104130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104131. */
  104132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104133. /**
  104134. * Detach the current controls from the specified dom element.
  104135. * @param element Defines the element to stop listening the inputs from
  104136. */
  104137. detachControl(element: Nullable<HTMLElement>): void;
  104138. /**
  104139. * Update the current camera state depending on the inputs that have been used this frame.
  104140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104141. */
  104142. checkInputs(): void;
  104143. /**
  104144. * Gets the class name of the current intput.
  104145. * @returns the class name
  104146. */
  104147. getClassName(): string;
  104148. /**
  104149. * Get the friendly name associated with the input class.
  104150. * @returns the input friendly name
  104151. */
  104152. getSimpleName(): string;
  104153. }
  104154. }
  104155. declare module BABYLON {
  104156. interface ArcRotateCameraInputsManager {
  104157. /**
  104158. * Add orientation input support to the input manager.
  104159. * @returns the current input manager
  104160. */
  104161. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104162. }
  104163. /**
  104164. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104166. */
  104167. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104168. /**
  104169. * Defines the camera the input is attached to.
  104170. */
  104171. camera: ArcRotateCamera;
  104172. /**
  104173. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104174. */
  104175. alphaCorrection: number;
  104176. /**
  104177. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104178. */
  104179. gammaCorrection: number;
  104180. private _alpha;
  104181. private _gamma;
  104182. private _dirty;
  104183. private _deviceOrientationHandler;
  104184. /**
  104185. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104186. */
  104187. constructor();
  104188. /**
  104189. * Attach the input controls to a specific dom element to get the input from.
  104190. * @param element Defines the element the controls should be listened from
  104191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104192. */
  104193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104194. /** @hidden */
  104195. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104196. /**
  104197. * Update the current camera state depending on the inputs that have been used this frame.
  104198. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104199. */
  104200. checkInputs(): void;
  104201. /**
  104202. * Detach the current controls from the specified dom element.
  104203. * @param element Defines the element to stop listening the inputs from
  104204. */
  104205. detachControl(element: Nullable<HTMLElement>): void;
  104206. /**
  104207. * Gets the class name of the current intput.
  104208. * @returns the class name
  104209. */
  104210. getClassName(): string;
  104211. /**
  104212. * Get the friendly name associated with the input class.
  104213. * @returns the input friendly name
  104214. */
  104215. getSimpleName(): string;
  104216. }
  104217. }
  104218. declare module BABYLON {
  104219. /**
  104220. * Listen to mouse events to control the camera.
  104221. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104222. */
  104223. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104224. /**
  104225. * Defines the camera the input is attached to.
  104226. */
  104227. camera: FlyCamera;
  104228. /**
  104229. * Defines if touch is enabled. (Default is true.)
  104230. */
  104231. touchEnabled: boolean;
  104232. /**
  104233. * Defines the buttons associated with the input to handle camera rotation.
  104234. */
  104235. buttons: number[];
  104236. /**
  104237. * Assign buttons for Yaw control.
  104238. */
  104239. buttonsYaw: number[];
  104240. /**
  104241. * Assign buttons for Pitch control.
  104242. */
  104243. buttonsPitch: number[];
  104244. /**
  104245. * Assign buttons for Roll control.
  104246. */
  104247. buttonsRoll: number[];
  104248. /**
  104249. * Detect if any button is being pressed while mouse is moved.
  104250. * -1 = Mouse locked.
  104251. * 0 = Left button.
  104252. * 1 = Middle Button.
  104253. * 2 = Right Button.
  104254. */
  104255. activeButton: number;
  104256. /**
  104257. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104258. * Higher values reduce its sensitivity.
  104259. */
  104260. angularSensibility: number;
  104261. private _mousemoveCallback;
  104262. private _observer;
  104263. private _rollObserver;
  104264. private previousPosition;
  104265. private noPreventDefault;
  104266. private element;
  104267. /**
  104268. * Listen to mouse events to control the camera.
  104269. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104270. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104271. */
  104272. constructor(touchEnabled?: boolean);
  104273. /**
  104274. * Attach the mouse control to the HTML DOM element.
  104275. * @param element Defines the element that listens to the input events.
  104276. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104277. */
  104278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104279. /**
  104280. * Detach the current controls from the specified dom element.
  104281. * @param element Defines the element to stop listening the inputs from
  104282. */
  104283. detachControl(element: Nullable<HTMLElement>): void;
  104284. /**
  104285. * Gets the class name of the current input.
  104286. * @returns the class name.
  104287. */
  104288. getClassName(): string;
  104289. /**
  104290. * Get the friendly name associated with the input class.
  104291. * @returns the input's friendly name.
  104292. */
  104293. getSimpleName(): string;
  104294. private _pointerInput;
  104295. private _onMouseMove;
  104296. /**
  104297. * Rotate camera by mouse offset.
  104298. */
  104299. private rotateCamera;
  104300. }
  104301. }
  104302. declare module BABYLON {
  104303. /**
  104304. * Default Inputs manager for the FlyCamera.
  104305. * It groups all the default supported inputs for ease of use.
  104306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104307. */
  104308. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104309. /**
  104310. * Instantiates a new FlyCameraInputsManager.
  104311. * @param camera Defines the camera the inputs belong to.
  104312. */
  104313. constructor(camera: FlyCamera);
  104314. /**
  104315. * Add keyboard input support to the input manager.
  104316. * @returns the new FlyCameraKeyboardMoveInput().
  104317. */
  104318. addKeyboard(): FlyCameraInputsManager;
  104319. /**
  104320. * Add mouse input support to the input manager.
  104321. * @param touchEnabled Enable touch screen support.
  104322. * @returns the new FlyCameraMouseInput().
  104323. */
  104324. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104325. }
  104326. }
  104327. declare module BABYLON {
  104328. /**
  104329. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104330. * such as in a 3D Space Shooter or a Flight Simulator.
  104331. */
  104332. export class FlyCamera extends TargetCamera {
  104333. /**
  104334. * Define the collision ellipsoid of the camera.
  104335. * This is helpful for simulating a camera body, like a player's body.
  104336. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104337. */
  104338. ellipsoid: Vector3;
  104339. /**
  104340. * Define an offset for the position of the ellipsoid around the camera.
  104341. * This can be helpful if the camera is attached away from the player's body center,
  104342. * such as at its head.
  104343. */
  104344. ellipsoidOffset: Vector3;
  104345. /**
  104346. * Enable or disable collisions of the camera with the rest of the scene objects.
  104347. */
  104348. checkCollisions: boolean;
  104349. /**
  104350. * Enable or disable gravity on the camera.
  104351. */
  104352. applyGravity: boolean;
  104353. /**
  104354. * Define the current direction the camera is moving to.
  104355. */
  104356. cameraDirection: Vector3;
  104357. /**
  104358. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104359. * This overrides and empties cameraRotation.
  104360. */
  104361. rotationQuaternion: Quaternion;
  104362. /**
  104363. * Track Roll to maintain the wanted Rolling when looking around.
  104364. */
  104365. _trackRoll: number;
  104366. /**
  104367. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104368. */
  104369. rollCorrect: number;
  104370. /**
  104371. * Mimic a banked turn, Rolling the camera when Yawing.
  104372. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104373. */
  104374. bankedTurn: boolean;
  104375. /**
  104376. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104377. */
  104378. bankedTurnLimit: number;
  104379. /**
  104380. * Value of 0 disables the banked Roll.
  104381. * Value of 1 is equal to the Yaw angle in radians.
  104382. */
  104383. bankedTurnMultiplier: number;
  104384. /**
  104385. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104386. */
  104387. inputs: FlyCameraInputsManager;
  104388. /**
  104389. * Gets the input sensibility for mouse input.
  104390. * Higher values reduce sensitivity.
  104391. */
  104392. /**
  104393. * Sets the input sensibility for a mouse input.
  104394. * Higher values reduce sensitivity.
  104395. */
  104396. angularSensibility: number;
  104397. /**
  104398. * Get the keys for camera movement forward.
  104399. */
  104400. /**
  104401. * Set the keys for camera movement forward.
  104402. */
  104403. keysForward: number[];
  104404. /**
  104405. * Get the keys for camera movement backward.
  104406. */
  104407. keysBackward: number[];
  104408. /**
  104409. * Get the keys for camera movement up.
  104410. */
  104411. /**
  104412. * Set the keys for camera movement up.
  104413. */
  104414. keysUp: number[];
  104415. /**
  104416. * Get the keys for camera movement down.
  104417. */
  104418. /**
  104419. * Set the keys for camera movement down.
  104420. */
  104421. keysDown: number[];
  104422. /**
  104423. * Get the keys for camera movement left.
  104424. */
  104425. /**
  104426. * Set the keys for camera movement left.
  104427. */
  104428. keysLeft: number[];
  104429. /**
  104430. * Set the keys for camera movement right.
  104431. */
  104432. /**
  104433. * Set the keys for camera movement right.
  104434. */
  104435. keysRight: number[];
  104436. /**
  104437. * Event raised when the camera collides with a mesh in the scene.
  104438. */
  104439. onCollide: (collidedMesh: AbstractMesh) => void;
  104440. private _collider;
  104441. private _needMoveForGravity;
  104442. private _oldPosition;
  104443. private _diffPosition;
  104444. private _newPosition;
  104445. /** @hidden */
  104446. _localDirection: Vector3;
  104447. /** @hidden */
  104448. _transformedDirection: Vector3;
  104449. /**
  104450. * Instantiates a FlyCamera.
  104451. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104452. * such as in a 3D Space Shooter or a Flight Simulator.
  104453. * @param name Define the name of the camera in the scene.
  104454. * @param position Define the starting position of the camera in the scene.
  104455. * @param scene Define the scene the camera belongs to.
  104456. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104457. */
  104458. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104459. /**
  104460. * Attach a control to the HTML DOM element.
  104461. * @param element Defines the element that listens to the input events.
  104462. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104463. */
  104464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104465. /**
  104466. * Detach a control from the HTML DOM element.
  104467. * The camera will stop reacting to that input.
  104468. * @param element Defines the element that listens to the input events.
  104469. */
  104470. detachControl(element: HTMLElement): void;
  104471. private _collisionMask;
  104472. /**
  104473. * Get the mask that the camera ignores in collision events.
  104474. */
  104475. /**
  104476. * Set the mask that the camera ignores in collision events.
  104477. */
  104478. collisionMask: number;
  104479. /** @hidden */
  104480. _collideWithWorld(displacement: Vector3): void;
  104481. /** @hidden */
  104482. private _onCollisionPositionChange;
  104483. /** @hidden */
  104484. _checkInputs(): void;
  104485. /** @hidden */
  104486. _decideIfNeedsToMove(): boolean;
  104487. /** @hidden */
  104488. _updatePosition(): void;
  104489. /**
  104490. * Restore the Roll to its target value at the rate specified.
  104491. * @param rate - Higher means slower restoring.
  104492. * @hidden
  104493. */
  104494. restoreRoll(rate: number): void;
  104495. /**
  104496. * Destroy the camera and release the current resources held by it.
  104497. */
  104498. dispose(): void;
  104499. /**
  104500. * Get the current object class name.
  104501. * @returns the class name.
  104502. */
  104503. getClassName(): string;
  104504. }
  104505. }
  104506. declare module BABYLON {
  104507. /**
  104508. * Listen to keyboard events to control the camera.
  104509. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104510. */
  104511. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104512. /**
  104513. * Defines the camera the input is attached to.
  104514. */
  104515. camera: FlyCamera;
  104516. /**
  104517. * The list of keyboard keys used to control the forward move of the camera.
  104518. */
  104519. keysForward: number[];
  104520. /**
  104521. * The list of keyboard keys used to control the backward move of the camera.
  104522. */
  104523. keysBackward: number[];
  104524. /**
  104525. * The list of keyboard keys used to control the forward move of the camera.
  104526. */
  104527. keysUp: number[];
  104528. /**
  104529. * The list of keyboard keys used to control the backward move of the camera.
  104530. */
  104531. keysDown: number[];
  104532. /**
  104533. * The list of keyboard keys used to control the right strafe move of the camera.
  104534. */
  104535. keysRight: number[];
  104536. /**
  104537. * The list of keyboard keys used to control the left strafe move of the camera.
  104538. */
  104539. keysLeft: number[];
  104540. private _keys;
  104541. private _onCanvasBlurObserver;
  104542. private _onKeyboardObserver;
  104543. private _engine;
  104544. private _scene;
  104545. /**
  104546. * Attach the input controls to a specific dom element to get the input from.
  104547. * @param element Defines the element the controls should be listened from
  104548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104549. */
  104550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104551. /**
  104552. * Detach the current controls from the specified dom element.
  104553. * @param element Defines the element to stop listening the inputs from
  104554. */
  104555. detachControl(element: Nullable<HTMLElement>): void;
  104556. /**
  104557. * Gets the class name of the current intput.
  104558. * @returns the class name
  104559. */
  104560. getClassName(): string;
  104561. /** @hidden */
  104562. _onLostFocus(e: FocusEvent): void;
  104563. /**
  104564. * Get the friendly name associated with the input class.
  104565. * @returns the input friendly name
  104566. */
  104567. getSimpleName(): string;
  104568. /**
  104569. * Update the current camera state depending on the inputs that have been used this frame.
  104570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104571. */
  104572. checkInputs(): void;
  104573. }
  104574. }
  104575. declare module BABYLON {
  104576. /**
  104577. * Manage the mouse wheel inputs to control a follow camera.
  104578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104579. */
  104580. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104581. /**
  104582. * Defines the camera the input is attached to.
  104583. */
  104584. camera: FollowCamera;
  104585. /**
  104586. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104587. */
  104588. axisControlRadius: boolean;
  104589. /**
  104590. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104591. */
  104592. axisControlHeight: boolean;
  104593. /**
  104594. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104595. */
  104596. axisControlRotation: boolean;
  104597. /**
  104598. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104599. * relation to mouseWheel events.
  104600. */
  104601. wheelPrecision: number;
  104602. /**
  104603. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104604. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104605. */
  104606. wheelDeltaPercentage: number;
  104607. private _wheel;
  104608. private _observer;
  104609. /**
  104610. * Attach the input controls to a specific dom element to get the input from.
  104611. * @param element Defines the element the controls should be listened from
  104612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104613. */
  104614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104615. /**
  104616. * Detach the current controls from the specified dom element.
  104617. * @param element Defines the element to stop listening the inputs from
  104618. */
  104619. detachControl(element: Nullable<HTMLElement>): void;
  104620. /**
  104621. * Gets the class name of the current intput.
  104622. * @returns the class name
  104623. */
  104624. getClassName(): string;
  104625. /**
  104626. * Get the friendly name associated with the input class.
  104627. * @returns the input friendly name
  104628. */
  104629. getSimpleName(): string;
  104630. }
  104631. }
  104632. declare module BABYLON {
  104633. /**
  104634. * Manage the pointers inputs to control an follow camera.
  104635. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104636. */
  104637. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104638. /**
  104639. * Defines the camera the input is attached to.
  104640. */
  104641. camera: FollowCamera;
  104642. /**
  104643. * Gets the class name of the current input.
  104644. * @returns the class name
  104645. */
  104646. getClassName(): string;
  104647. /**
  104648. * Defines the pointer angular sensibility along the X axis or how fast is
  104649. * the camera rotating.
  104650. * A negative number will reverse the axis direction.
  104651. */
  104652. angularSensibilityX: number;
  104653. /**
  104654. * Defines the pointer angular sensibility along the Y axis or how fast is
  104655. * the camera rotating.
  104656. * A negative number will reverse the axis direction.
  104657. */
  104658. angularSensibilityY: number;
  104659. /**
  104660. * Defines the pointer pinch precision or how fast is the camera zooming.
  104661. * A negative number will reverse the axis direction.
  104662. */
  104663. pinchPrecision: number;
  104664. /**
  104665. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104666. * from 0.
  104667. * It defines the percentage of current camera.radius to use as delta when
  104668. * pinch zoom is used.
  104669. */
  104670. pinchDeltaPercentage: number;
  104671. /**
  104672. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104673. */
  104674. axisXControlRadius: boolean;
  104675. /**
  104676. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104677. */
  104678. axisXControlHeight: boolean;
  104679. /**
  104680. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104681. */
  104682. axisXControlRotation: boolean;
  104683. /**
  104684. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104685. */
  104686. axisYControlRadius: boolean;
  104687. /**
  104688. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104689. */
  104690. axisYControlHeight: boolean;
  104691. /**
  104692. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104693. */
  104694. axisYControlRotation: boolean;
  104695. /**
  104696. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104697. */
  104698. axisPinchControlRadius: boolean;
  104699. /**
  104700. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104701. */
  104702. axisPinchControlHeight: boolean;
  104703. /**
  104704. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104705. */
  104706. axisPinchControlRotation: boolean;
  104707. /**
  104708. * Log error messages if basic misconfiguration has occurred.
  104709. */
  104710. warningEnable: boolean;
  104711. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104712. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104713. private _warningCounter;
  104714. private _warning;
  104715. }
  104716. }
  104717. declare module BABYLON {
  104718. /**
  104719. * Default Inputs manager for the FollowCamera.
  104720. * It groups all the default supported inputs for ease of use.
  104721. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104722. */
  104723. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104724. /**
  104725. * Instantiates a new FollowCameraInputsManager.
  104726. * @param camera Defines the camera the inputs belong to
  104727. */
  104728. constructor(camera: FollowCamera);
  104729. /**
  104730. * Add keyboard input support to the input manager.
  104731. * @returns the current input manager
  104732. */
  104733. addKeyboard(): FollowCameraInputsManager;
  104734. /**
  104735. * Add mouse wheel input support to the input manager.
  104736. * @returns the current input manager
  104737. */
  104738. addMouseWheel(): FollowCameraInputsManager;
  104739. /**
  104740. * Add pointers input support to the input manager.
  104741. * @returns the current input manager
  104742. */
  104743. addPointers(): FollowCameraInputsManager;
  104744. /**
  104745. * Add orientation input support to the input manager.
  104746. * @returns the current input manager
  104747. */
  104748. addVRDeviceOrientation(): FollowCameraInputsManager;
  104749. }
  104750. }
  104751. declare module BABYLON {
  104752. /**
  104753. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104754. * an arc rotate version arcFollowCamera are available.
  104755. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104756. */
  104757. export class FollowCamera extends TargetCamera {
  104758. /**
  104759. * Distance the follow camera should follow an object at
  104760. */
  104761. radius: number;
  104762. /**
  104763. * Minimum allowed distance of the camera to the axis of rotation
  104764. * (The camera can not get closer).
  104765. * This can help limiting how the Camera is able to move in the scene.
  104766. */
  104767. lowerRadiusLimit: Nullable<number>;
  104768. /**
  104769. * Maximum allowed distance of the camera to the axis of rotation
  104770. * (The camera can not get further).
  104771. * This can help limiting how the Camera is able to move in the scene.
  104772. */
  104773. upperRadiusLimit: Nullable<number>;
  104774. /**
  104775. * Define a rotation offset between the camera and the object it follows
  104776. */
  104777. rotationOffset: number;
  104778. /**
  104779. * Minimum allowed angle to camera position relative to target object.
  104780. * This can help limiting how the Camera is able to move in the scene.
  104781. */
  104782. lowerRotationOffsetLimit: Nullable<number>;
  104783. /**
  104784. * Maximum allowed angle to camera position relative to target object.
  104785. * This can help limiting how the Camera is able to move in the scene.
  104786. */
  104787. upperRotationOffsetLimit: Nullable<number>;
  104788. /**
  104789. * Define a height offset between the camera and the object it follows.
  104790. * It can help following an object from the top (like a car chaing a plane)
  104791. */
  104792. heightOffset: number;
  104793. /**
  104794. * Minimum allowed height of camera position relative to target object.
  104795. * This can help limiting how the Camera is able to move in the scene.
  104796. */
  104797. lowerHeightOffsetLimit: Nullable<number>;
  104798. /**
  104799. * Maximum allowed height of camera position relative to target object.
  104800. * This can help limiting how the Camera is able to move in the scene.
  104801. */
  104802. upperHeightOffsetLimit: Nullable<number>;
  104803. /**
  104804. * Define how fast the camera can accelerate to follow it s target.
  104805. */
  104806. cameraAcceleration: number;
  104807. /**
  104808. * Define the speed limit of the camera following an object.
  104809. */
  104810. maxCameraSpeed: number;
  104811. /**
  104812. * Define the target of the camera.
  104813. */
  104814. lockedTarget: Nullable<AbstractMesh>;
  104815. /**
  104816. * Defines the input associated with the camera.
  104817. */
  104818. inputs: FollowCameraInputsManager;
  104819. /**
  104820. * Instantiates the follow camera.
  104821. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104822. * @param name Define the name of the camera in the scene
  104823. * @param position Define the position of the camera
  104824. * @param scene Define the scene the camera belong to
  104825. * @param lockedTarget Define the target of the camera
  104826. */
  104827. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104828. private _follow;
  104829. /**
  104830. * Attached controls to the current camera.
  104831. * @param element Defines the element the controls should be listened from
  104832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104833. */
  104834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104835. /**
  104836. * Detach the current controls from the camera.
  104837. * The camera will stop reacting to inputs.
  104838. * @param element Defines the element to stop listening the inputs from
  104839. */
  104840. detachControl(element: HTMLElement): void;
  104841. /** @hidden */
  104842. _checkInputs(): void;
  104843. private _checkLimits;
  104844. /**
  104845. * Gets the camera class name.
  104846. * @returns the class name
  104847. */
  104848. getClassName(): string;
  104849. }
  104850. /**
  104851. * Arc Rotate version of the follow camera.
  104852. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104853. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104854. */
  104855. export class ArcFollowCamera extends TargetCamera {
  104856. /** The longitudinal angle of the camera */
  104857. alpha: number;
  104858. /** The latitudinal angle of the camera */
  104859. beta: number;
  104860. /** The radius of the camera from its target */
  104861. radius: number;
  104862. /** Define the camera target (the messh it should follow) */
  104863. target: Nullable<AbstractMesh>;
  104864. private _cartesianCoordinates;
  104865. /**
  104866. * Instantiates a new ArcFollowCamera
  104867. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104868. * @param name Define the name of the camera
  104869. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104870. * @param beta Define the rotation angle of the camera around the elevation axis
  104871. * @param radius Define the radius of the camera from its target point
  104872. * @param target Define the target of the camera
  104873. * @param scene Define the scene the camera belongs to
  104874. */
  104875. constructor(name: string,
  104876. /** The longitudinal angle of the camera */
  104877. alpha: number,
  104878. /** The latitudinal angle of the camera */
  104879. beta: number,
  104880. /** The radius of the camera from its target */
  104881. radius: number,
  104882. /** Define the camera target (the messh it should follow) */
  104883. target: Nullable<AbstractMesh>, scene: Scene);
  104884. private _follow;
  104885. /** @hidden */
  104886. _checkInputs(): void;
  104887. /**
  104888. * Returns the class name of the object.
  104889. * It is mostly used internally for serialization purposes.
  104890. */
  104891. getClassName(): string;
  104892. }
  104893. }
  104894. declare module BABYLON {
  104895. /**
  104896. * Manage the keyboard inputs to control the movement of a follow camera.
  104897. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104898. */
  104899. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104900. /**
  104901. * Defines the camera the input is attached to.
  104902. */
  104903. camera: FollowCamera;
  104904. /**
  104905. * Defines the list of key codes associated with the up action (increase heightOffset)
  104906. */
  104907. keysHeightOffsetIncr: number[];
  104908. /**
  104909. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104910. */
  104911. keysHeightOffsetDecr: number[];
  104912. /**
  104913. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104914. */
  104915. keysHeightOffsetModifierAlt: boolean;
  104916. /**
  104917. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104918. */
  104919. keysHeightOffsetModifierCtrl: boolean;
  104920. /**
  104921. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104922. */
  104923. keysHeightOffsetModifierShift: boolean;
  104924. /**
  104925. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104926. */
  104927. keysRotationOffsetIncr: number[];
  104928. /**
  104929. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104930. */
  104931. keysRotationOffsetDecr: number[];
  104932. /**
  104933. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104934. */
  104935. keysRotationOffsetModifierAlt: boolean;
  104936. /**
  104937. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104938. */
  104939. keysRotationOffsetModifierCtrl: boolean;
  104940. /**
  104941. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104942. */
  104943. keysRotationOffsetModifierShift: boolean;
  104944. /**
  104945. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104946. */
  104947. keysRadiusIncr: number[];
  104948. /**
  104949. * Defines the list of key codes associated with the zoom-out action (increase radius)
  104950. */
  104951. keysRadiusDecr: number[];
  104952. /**
  104953. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  104954. */
  104955. keysRadiusModifierAlt: boolean;
  104956. /**
  104957. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  104958. */
  104959. keysRadiusModifierCtrl: boolean;
  104960. /**
  104961. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  104962. */
  104963. keysRadiusModifierShift: boolean;
  104964. /**
  104965. * Defines the rate of change of heightOffset.
  104966. */
  104967. heightSensibility: number;
  104968. /**
  104969. * Defines the rate of change of rotationOffset.
  104970. */
  104971. rotationSensibility: number;
  104972. /**
  104973. * Defines the rate of change of radius.
  104974. */
  104975. radiusSensibility: number;
  104976. private _keys;
  104977. private _ctrlPressed;
  104978. private _altPressed;
  104979. private _shiftPressed;
  104980. private _onCanvasBlurObserver;
  104981. private _onKeyboardObserver;
  104982. private _engine;
  104983. private _scene;
  104984. /**
  104985. * Attach the input controls to a specific dom element to get the input from.
  104986. * @param element Defines the element the controls should be listened from
  104987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104988. */
  104989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104990. /**
  104991. * Detach the current controls from the specified dom element.
  104992. * @param element Defines the element to stop listening the inputs from
  104993. */
  104994. detachControl(element: Nullable<HTMLElement>): void;
  104995. /**
  104996. * Update the current camera state depending on the inputs that have been used this frame.
  104997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104998. */
  104999. checkInputs(): void;
  105000. /**
  105001. * Gets the class name of the current input.
  105002. * @returns the class name
  105003. */
  105004. getClassName(): string;
  105005. /**
  105006. * Get the friendly name associated with the input class.
  105007. * @returns the input friendly name
  105008. */
  105009. getSimpleName(): string;
  105010. /**
  105011. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105012. * allow modification of the heightOffset value.
  105013. */
  105014. private _modifierHeightOffset;
  105015. /**
  105016. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105017. * allow modification of the rotationOffset value.
  105018. */
  105019. private _modifierRotationOffset;
  105020. /**
  105021. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105022. * allow modification of the radius value.
  105023. */
  105024. private _modifierRadius;
  105025. }
  105026. }
  105027. declare module BABYLON {
  105028. interface FreeCameraInputsManager {
  105029. /**
  105030. * @hidden
  105031. */
  105032. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105033. /**
  105034. * Add orientation input support to the input manager.
  105035. * @returns the current input manager
  105036. */
  105037. addDeviceOrientation(): FreeCameraInputsManager;
  105038. }
  105039. /**
  105040. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105041. * Screen rotation is taken into account.
  105042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105043. */
  105044. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105045. private _camera;
  105046. private _screenOrientationAngle;
  105047. private _constantTranform;
  105048. private _screenQuaternion;
  105049. private _alpha;
  105050. private _beta;
  105051. private _gamma;
  105052. /**
  105053. * Can be used to detect if a device orientation sensor is availible on a device
  105054. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105055. * @returns a promise that will resolve on orientation change
  105056. */
  105057. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105058. /**
  105059. * @hidden
  105060. */
  105061. _onDeviceOrientationChangedObservable: Observable<void>;
  105062. /**
  105063. * Instantiates a new input
  105064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105065. */
  105066. constructor();
  105067. /**
  105068. * Define the camera controlled by the input.
  105069. */
  105070. camera: FreeCamera;
  105071. /**
  105072. * Attach the input controls to a specific dom element to get the input from.
  105073. * @param element Defines the element the controls should be listened from
  105074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105075. */
  105076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105077. private _orientationChanged;
  105078. private _deviceOrientation;
  105079. /**
  105080. * Detach the current controls from the specified dom element.
  105081. * @param element Defines the element to stop listening the inputs from
  105082. */
  105083. detachControl(element: Nullable<HTMLElement>): void;
  105084. /**
  105085. * Update the current camera state depending on the inputs that have been used this frame.
  105086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105087. */
  105088. checkInputs(): void;
  105089. /**
  105090. * Gets the class name of the current intput.
  105091. * @returns the class name
  105092. */
  105093. getClassName(): string;
  105094. /**
  105095. * Get the friendly name associated with the input class.
  105096. * @returns the input friendly name
  105097. */
  105098. getSimpleName(): string;
  105099. }
  105100. }
  105101. declare module BABYLON {
  105102. /**
  105103. * Manage the gamepad inputs to control a free camera.
  105104. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105105. */
  105106. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105107. /**
  105108. * Define the camera the input is attached to.
  105109. */
  105110. camera: FreeCamera;
  105111. /**
  105112. * Define the Gamepad controlling the input
  105113. */
  105114. gamepad: Nullable<Gamepad>;
  105115. /**
  105116. * Defines the gamepad rotation sensiblity.
  105117. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105118. */
  105119. gamepadAngularSensibility: number;
  105120. /**
  105121. * Defines the gamepad move sensiblity.
  105122. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105123. */
  105124. gamepadMoveSensibility: number;
  105125. private _onGamepadConnectedObserver;
  105126. private _onGamepadDisconnectedObserver;
  105127. private _cameraTransform;
  105128. private _deltaTransform;
  105129. private _vector3;
  105130. private _vector2;
  105131. /**
  105132. * Attach the input controls to a specific dom element to get the input from.
  105133. * @param element Defines the element the controls should be listened from
  105134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105135. */
  105136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105137. /**
  105138. * Detach the current controls from the specified dom element.
  105139. * @param element Defines the element to stop listening the inputs from
  105140. */
  105141. detachControl(element: Nullable<HTMLElement>): void;
  105142. /**
  105143. * Update the current camera state depending on the inputs that have been used this frame.
  105144. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105145. */
  105146. checkInputs(): void;
  105147. /**
  105148. * Gets the class name of the current intput.
  105149. * @returns the class name
  105150. */
  105151. getClassName(): string;
  105152. /**
  105153. * Get the friendly name associated with the input class.
  105154. * @returns the input friendly name
  105155. */
  105156. getSimpleName(): string;
  105157. }
  105158. }
  105159. declare module BABYLON {
  105160. /**
  105161. * Defines the potential axis of a Joystick
  105162. */
  105163. export enum JoystickAxis {
  105164. /** X axis */
  105165. X = 0,
  105166. /** Y axis */
  105167. Y = 1,
  105168. /** Z axis */
  105169. Z = 2
  105170. }
  105171. /**
  105172. * Class used to define virtual joystick (used in touch mode)
  105173. */
  105174. export class VirtualJoystick {
  105175. /**
  105176. * Gets or sets a boolean indicating that left and right values must be inverted
  105177. */
  105178. reverseLeftRight: boolean;
  105179. /**
  105180. * Gets or sets a boolean indicating that up and down values must be inverted
  105181. */
  105182. reverseUpDown: boolean;
  105183. /**
  105184. * Gets the offset value for the position (ie. the change of the position value)
  105185. */
  105186. deltaPosition: Vector3;
  105187. /**
  105188. * Gets a boolean indicating if the virtual joystick was pressed
  105189. */
  105190. pressed: boolean;
  105191. /**
  105192. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105193. */
  105194. static Canvas: Nullable<HTMLCanvasElement>;
  105195. private static _globalJoystickIndex;
  105196. private static vjCanvasContext;
  105197. private static vjCanvasWidth;
  105198. private static vjCanvasHeight;
  105199. private static halfWidth;
  105200. private _action;
  105201. private _axisTargetedByLeftAndRight;
  105202. private _axisTargetedByUpAndDown;
  105203. private _joystickSensibility;
  105204. private _inversedSensibility;
  105205. private _joystickPointerID;
  105206. private _joystickColor;
  105207. private _joystickPointerPos;
  105208. private _joystickPreviousPointerPos;
  105209. private _joystickPointerStartPos;
  105210. private _deltaJoystickVector;
  105211. private _leftJoystick;
  105212. private _touches;
  105213. private _onPointerDownHandlerRef;
  105214. private _onPointerMoveHandlerRef;
  105215. private _onPointerUpHandlerRef;
  105216. private _onResize;
  105217. /**
  105218. * Creates a new virtual joystick
  105219. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105220. */
  105221. constructor(leftJoystick?: boolean);
  105222. /**
  105223. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105224. * @param newJoystickSensibility defines the new sensibility
  105225. */
  105226. setJoystickSensibility(newJoystickSensibility: number): void;
  105227. private _onPointerDown;
  105228. private _onPointerMove;
  105229. private _onPointerUp;
  105230. /**
  105231. * Change the color of the virtual joystick
  105232. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105233. */
  105234. setJoystickColor(newColor: string): void;
  105235. /**
  105236. * Defines a callback to call when the joystick is touched
  105237. * @param action defines the callback
  105238. */
  105239. setActionOnTouch(action: () => any): void;
  105240. /**
  105241. * Defines which axis you'd like to control for left & right
  105242. * @param axis defines the axis to use
  105243. */
  105244. setAxisForLeftRight(axis: JoystickAxis): void;
  105245. /**
  105246. * Defines which axis you'd like to control for up & down
  105247. * @param axis defines the axis to use
  105248. */
  105249. setAxisForUpDown(axis: JoystickAxis): void;
  105250. private _drawVirtualJoystick;
  105251. /**
  105252. * Release internal HTML canvas
  105253. */
  105254. releaseCanvas(): void;
  105255. }
  105256. }
  105257. declare module BABYLON {
  105258. interface FreeCameraInputsManager {
  105259. /**
  105260. * Add virtual joystick input support to the input manager.
  105261. * @returns the current input manager
  105262. */
  105263. addVirtualJoystick(): FreeCameraInputsManager;
  105264. }
  105265. /**
  105266. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105267. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105268. */
  105269. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105270. /**
  105271. * Defines the camera the input is attached to.
  105272. */
  105273. camera: FreeCamera;
  105274. private _leftjoystick;
  105275. private _rightjoystick;
  105276. /**
  105277. * Gets the left stick of the virtual joystick.
  105278. * @returns The virtual Joystick
  105279. */
  105280. getLeftJoystick(): VirtualJoystick;
  105281. /**
  105282. * Gets the right stick of the virtual joystick.
  105283. * @returns The virtual Joystick
  105284. */
  105285. getRightJoystick(): VirtualJoystick;
  105286. /**
  105287. * Update the current camera state depending on the inputs that have been used this frame.
  105288. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105289. */
  105290. checkInputs(): void;
  105291. /**
  105292. * Attach the input controls to a specific dom element to get the input from.
  105293. * @param element Defines the element the controls should be listened from
  105294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105295. */
  105296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105297. /**
  105298. * Detach the current controls from the specified dom element.
  105299. * @param element Defines the element to stop listening the inputs from
  105300. */
  105301. detachControl(element: Nullable<HTMLElement>): void;
  105302. /**
  105303. * Gets the class name of the current intput.
  105304. * @returns the class name
  105305. */
  105306. getClassName(): string;
  105307. /**
  105308. * Get the friendly name associated with the input class.
  105309. * @returns the input friendly name
  105310. */
  105311. getSimpleName(): string;
  105312. }
  105313. }
  105314. declare module BABYLON {
  105315. /**
  105316. * This represents a FPS type of camera controlled by touch.
  105317. * This is like a universal camera minus the Gamepad controls.
  105318. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105319. */
  105320. export class TouchCamera extends FreeCamera {
  105321. /**
  105322. * Defines the touch sensibility for rotation.
  105323. * The higher the faster.
  105324. */
  105325. touchAngularSensibility: number;
  105326. /**
  105327. * Defines the touch sensibility for move.
  105328. * The higher the faster.
  105329. */
  105330. touchMoveSensibility: number;
  105331. /**
  105332. * Instantiates a new touch camera.
  105333. * This represents a FPS type of camera controlled by touch.
  105334. * This is like a universal camera minus the Gamepad controls.
  105335. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105336. * @param name Define the name of the camera in the scene
  105337. * @param position Define the start position of the camera in the scene
  105338. * @param scene Define the scene the camera belongs to
  105339. */
  105340. constructor(name: string, position: Vector3, scene: Scene);
  105341. /**
  105342. * Gets the current object class name.
  105343. * @return the class name
  105344. */
  105345. getClassName(): string;
  105346. /** @hidden */
  105347. _setupInputs(): void;
  105348. }
  105349. }
  105350. declare module BABYLON {
  105351. /**
  105352. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105353. * being tilted forward or back and left or right.
  105354. */
  105355. export class DeviceOrientationCamera extends FreeCamera {
  105356. private _initialQuaternion;
  105357. private _quaternionCache;
  105358. private _tmpDragQuaternion;
  105359. private _disablePointerInputWhenUsingDeviceOrientation;
  105360. /**
  105361. * Creates a new device orientation camera
  105362. * @param name The name of the camera
  105363. * @param position The start position camera
  105364. * @param scene The scene the camera belongs to
  105365. */
  105366. constructor(name: string, position: Vector3, scene: Scene);
  105367. /**
  105368. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105369. */
  105370. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105371. private _dragFactor;
  105372. /**
  105373. * Enabled turning on the y axis when the orientation sensor is active
  105374. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105375. */
  105376. enableHorizontalDragging(dragFactor?: number): void;
  105377. /**
  105378. * Gets the current instance class name ("DeviceOrientationCamera").
  105379. * This helps avoiding instanceof at run time.
  105380. * @returns the class name
  105381. */
  105382. getClassName(): string;
  105383. /**
  105384. * @hidden
  105385. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105386. */
  105387. _checkInputs(): void;
  105388. /**
  105389. * Reset the camera to its default orientation on the specified axis only.
  105390. * @param axis The axis to reset
  105391. */
  105392. resetToCurrentRotation(axis?: Axis): void;
  105393. }
  105394. }
  105395. declare module BABYLON {
  105396. /**
  105397. * Defines supported buttons for XBox360 compatible gamepads
  105398. */
  105399. export enum Xbox360Button {
  105400. /** A */
  105401. A = 0,
  105402. /** B */
  105403. B = 1,
  105404. /** X */
  105405. X = 2,
  105406. /** Y */
  105407. Y = 3,
  105408. /** Start */
  105409. Start = 4,
  105410. /** Back */
  105411. Back = 5,
  105412. /** Left button */
  105413. LB = 6,
  105414. /** Right button */
  105415. RB = 7,
  105416. /** Left stick */
  105417. LeftStick = 8,
  105418. /** Right stick */
  105419. RightStick = 9
  105420. }
  105421. /** Defines values for XBox360 DPad */
  105422. export enum Xbox360Dpad {
  105423. /** Up */
  105424. Up = 0,
  105425. /** Down */
  105426. Down = 1,
  105427. /** Left */
  105428. Left = 2,
  105429. /** Right */
  105430. Right = 3
  105431. }
  105432. /**
  105433. * Defines a XBox360 gamepad
  105434. */
  105435. export class Xbox360Pad extends Gamepad {
  105436. private _leftTrigger;
  105437. private _rightTrigger;
  105438. private _onlefttriggerchanged;
  105439. private _onrighttriggerchanged;
  105440. private _onbuttondown;
  105441. private _onbuttonup;
  105442. private _ondpaddown;
  105443. private _ondpadup;
  105444. /** Observable raised when a button is pressed */
  105445. onButtonDownObservable: Observable<Xbox360Button>;
  105446. /** Observable raised when a button is released */
  105447. onButtonUpObservable: Observable<Xbox360Button>;
  105448. /** Observable raised when a pad is pressed */
  105449. onPadDownObservable: Observable<Xbox360Dpad>;
  105450. /** Observable raised when a pad is released */
  105451. onPadUpObservable: Observable<Xbox360Dpad>;
  105452. private _buttonA;
  105453. private _buttonB;
  105454. private _buttonX;
  105455. private _buttonY;
  105456. private _buttonBack;
  105457. private _buttonStart;
  105458. private _buttonLB;
  105459. private _buttonRB;
  105460. private _buttonLeftStick;
  105461. private _buttonRightStick;
  105462. private _dPadUp;
  105463. private _dPadDown;
  105464. private _dPadLeft;
  105465. private _dPadRight;
  105466. private _isXboxOnePad;
  105467. /**
  105468. * Creates a new XBox360 gamepad object
  105469. * @param id defines the id of this gamepad
  105470. * @param index defines its index
  105471. * @param gamepad defines the internal HTML gamepad object
  105472. * @param xboxOne defines if it is a XBox One gamepad
  105473. */
  105474. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105475. /**
  105476. * Defines the callback to call when left trigger is pressed
  105477. * @param callback defines the callback to use
  105478. */
  105479. onlefttriggerchanged(callback: (value: number) => void): void;
  105480. /**
  105481. * Defines the callback to call when right trigger is pressed
  105482. * @param callback defines the callback to use
  105483. */
  105484. onrighttriggerchanged(callback: (value: number) => void): void;
  105485. /**
  105486. * Gets the left trigger value
  105487. */
  105488. /**
  105489. * Sets the left trigger value
  105490. */
  105491. leftTrigger: number;
  105492. /**
  105493. * Gets the right trigger value
  105494. */
  105495. /**
  105496. * Sets the right trigger value
  105497. */
  105498. rightTrigger: number;
  105499. /**
  105500. * Defines the callback to call when a button is pressed
  105501. * @param callback defines the callback to use
  105502. */
  105503. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105504. /**
  105505. * Defines the callback to call when a button is released
  105506. * @param callback defines the callback to use
  105507. */
  105508. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105509. /**
  105510. * Defines the callback to call when a pad is pressed
  105511. * @param callback defines the callback to use
  105512. */
  105513. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105514. /**
  105515. * Defines the callback to call when a pad is released
  105516. * @param callback defines the callback to use
  105517. */
  105518. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105519. private _setButtonValue;
  105520. private _setDPadValue;
  105521. /**
  105522. * Gets the value of the `A` button
  105523. */
  105524. /**
  105525. * Sets the value of the `A` button
  105526. */
  105527. buttonA: number;
  105528. /**
  105529. * Gets the value of the `B` button
  105530. */
  105531. /**
  105532. * Sets the value of the `B` button
  105533. */
  105534. buttonB: number;
  105535. /**
  105536. * Gets the value of the `X` button
  105537. */
  105538. /**
  105539. * Sets the value of the `X` button
  105540. */
  105541. buttonX: number;
  105542. /**
  105543. * Gets the value of the `Y` button
  105544. */
  105545. /**
  105546. * Sets the value of the `Y` button
  105547. */
  105548. buttonY: number;
  105549. /**
  105550. * Gets the value of the `Start` button
  105551. */
  105552. /**
  105553. * Sets the value of the `Start` button
  105554. */
  105555. buttonStart: number;
  105556. /**
  105557. * Gets the value of the `Back` button
  105558. */
  105559. /**
  105560. * Sets the value of the `Back` button
  105561. */
  105562. buttonBack: number;
  105563. /**
  105564. * Gets the value of the `Left` button
  105565. */
  105566. /**
  105567. * Sets the value of the `Left` button
  105568. */
  105569. buttonLB: number;
  105570. /**
  105571. * Gets the value of the `Right` button
  105572. */
  105573. /**
  105574. * Sets the value of the `Right` button
  105575. */
  105576. buttonRB: number;
  105577. /**
  105578. * Gets the value of the Left joystick
  105579. */
  105580. /**
  105581. * Sets the value of the Left joystick
  105582. */
  105583. buttonLeftStick: number;
  105584. /**
  105585. * Gets the value of the Right joystick
  105586. */
  105587. /**
  105588. * Sets the value of the Right joystick
  105589. */
  105590. buttonRightStick: number;
  105591. /**
  105592. * Gets the value of D-pad up
  105593. */
  105594. /**
  105595. * Sets the value of D-pad up
  105596. */
  105597. dPadUp: number;
  105598. /**
  105599. * Gets the value of D-pad down
  105600. */
  105601. /**
  105602. * Sets the value of D-pad down
  105603. */
  105604. dPadDown: number;
  105605. /**
  105606. * Gets the value of D-pad left
  105607. */
  105608. /**
  105609. * Sets the value of D-pad left
  105610. */
  105611. dPadLeft: number;
  105612. /**
  105613. * Gets the value of D-pad right
  105614. */
  105615. /**
  105616. * Sets the value of D-pad right
  105617. */
  105618. dPadRight: number;
  105619. /**
  105620. * Force the gamepad to synchronize with device values
  105621. */
  105622. update(): void;
  105623. /**
  105624. * Disposes the gamepad
  105625. */
  105626. dispose(): void;
  105627. }
  105628. }
  105629. declare module BABYLON {
  105630. /**
  105631. * Defines supported buttons for DualShock compatible gamepads
  105632. */
  105633. export enum DualShockButton {
  105634. /** Cross */
  105635. Cross = 0,
  105636. /** Circle */
  105637. Circle = 1,
  105638. /** Square */
  105639. Square = 2,
  105640. /** Triangle */
  105641. Triangle = 3,
  105642. /** Options */
  105643. Options = 4,
  105644. /** Share */
  105645. Share = 5,
  105646. /** L1 */
  105647. L1 = 6,
  105648. /** R1 */
  105649. R1 = 7,
  105650. /** Left stick */
  105651. LeftStick = 8,
  105652. /** Right stick */
  105653. RightStick = 9
  105654. }
  105655. /** Defines values for DualShock DPad */
  105656. export enum DualShockDpad {
  105657. /** Up */
  105658. Up = 0,
  105659. /** Down */
  105660. Down = 1,
  105661. /** Left */
  105662. Left = 2,
  105663. /** Right */
  105664. Right = 3
  105665. }
  105666. /**
  105667. * Defines a DualShock gamepad
  105668. */
  105669. export class DualShockPad extends Gamepad {
  105670. private _leftTrigger;
  105671. private _rightTrigger;
  105672. private _onlefttriggerchanged;
  105673. private _onrighttriggerchanged;
  105674. private _onbuttondown;
  105675. private _onbuttonup;
  105676. private _ondpaddown;
  105677. private _ondpadup;
  105678. /** Observable raised when a button is pressed */
  105679. onButtonDownObservable: Observable<DualShockButton>;
  105680. /** Observable raised when a button is released */
  105681. onButtonUpObservable: Observable<DualShockButton>;
  105682. /** Observable raised when a pad is pressed */
  105683. onPadDownObservable: Observable<DualShockDpad>;
  105684. /** Observable raised when a pad is released */
  105685. onPadUpObservable: Observable<DualShockDpad>;
  105686. private _buttonCross;
  105687. private _buttonCircle;
  105688. private _buttonSquare;
  105689. private _buttonTriangle;
  105690. private _buttonShare;
  105691. private _buttonOptions;
  105692. private _buttonL1;
  105693. private _buttonR1;
  105694. private _buttonLeftStick;
  105695. private _buttonRightStick;
  105696. private _dPadUp;
  105697. private _dPadDown;
  105698. private _dPadLeft;
  105699. private _dPadRight;
  105700. /**
  105701. * Creates a new DualShock gamepad object
  105702. * @param id defines the id of this gamepad
  105703. * @param index defines its index
  105704. * @param gamepad defines the internal HTML gamepad object
  105705. */
  105706. constructor(id: string, index: number, gamepad: any);
  105707. /**
  105708. * Defines the callback to call when left trigger is pressed
  105709. * @param callback defines the callback to use
  105710. */
  105711. onlefttriggerchanged(callback: (value: number) => void): void;
  105712. /**
  105713. * Defines the callback to call when right trigger is pressed
  105714. * @param callback defines the callback to use
  105715. */
  105716. onrighttriggerchanged(callback: (value: number) => void): void;
  105717. /**
  105718. * Gets the left trigger value
  105719. */
  105720. /**
  105721. * Sets the left trigger value
  105722. */
  105723. leftTrigger: number;
  105724. /**
  105725. * Gets the right trigger value
  105726. */
  105727. /**
  105728. * Sets the right trigger value
  105729. */
  105730. rightTrigger: number;
  105731. /**
  105732. * Defines the callback to call when a button is pressed
  105733. * @param callback defines the callback to use
  105734. */
  105735. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105736. /**
  105737. * Defines the callback to call when a button is released
  105738. * @param callback defines the callback to use
  105739. */
  105740. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105741. /**
  105742. * Defines the callback to call when a pad is pressed
  105743. * @param callback defines the callback to use
  105744. */
  105745. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105746. /**
  105747. * Defines the callback to call when a pad is released
  105748. * @param callback defines the callback to use
  105749. */
  105750. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105751. private _setButtonValue;
  105752. private _setDPadValue;
  105753. /**
  105754. * Gets the value of the `Cross` button
  105755. */
  105756. /**
  105757. * Sets the value of the `Cross` button
  105758. */
  105759. buttonCross: number;
  105760. /**
  105761. * Gets the value of the `Circle` button
  105762. */
  105763. /**
  105764. * Sets the value of the `Circle` button
  105765. */
  105766. buttonCircle: number;
  105767. /**
  105768. * Gets the value of the `Square` button
  105769. */
  105770. /**
  105771. * Sets the value of the `Square` button
  105772. */
  105773. buttonSquare: number;
  105774. /**
  105775. * Gets the value of the `Triangle` button
  105776. */
  105777. /**
  105778. * Sets the value of the `Triangle` button
  105779. */
  105780. buttonTriangle: number;
  105781. /**
  105782. * Gets the value of the `Options` button
  105783. */
  105784. /**
  105785. * Sets the value of the `Options` button
  105786. */
  105787. buttonOptions: number;
  105788. /**
  105789. * Gets the value of the `Share` button
  105790. */
  105791. /**
  105792. * Sets the value of the `Share` button
  105793. */
  105794. buttonShare: number;
  105795. /**
  105796. * Gets the value of the `L1` button
  105797. */
  105798. /**
  105799. * Sets the value of the `L1` button
  105800. */
  105801. buttonL1: number;
  105802. /**
  105803. * Gets the value of the `R1` button
  105804. */
  105805. /**
  105806. * Sets the value of the `R1` button
  105807. */
  105808. buttonR1: number;
  105809. /**
  105810. * Gets the value of the Left joystick
  105811. */
  105812. /**
  105813. * Sets the value of the Left joystick
  105814. */
  105815. buttonLeftStick: number;
  105816. /**
  105817. * Gets the value of the Right joystick
  105818. */
  105819. /**
  105820. * Sets the value of the Right joystick
  105821. */
  105822. buttonRightStick: number;
  105823. /**
  105824. * Gets the value of D-pad up
  105825. */
  105826. /**
  105827. * Sets the value of D-pad up
  105828. */
  105829. dPadUp: number;
  105830. /**
  105831. * Gets the value of D-pad down
  105832. */
  105833. /**
  105834. * Sets the value of D-pad down
  105835. */
  105836. dPadDown: number;
  105837. /**
  105838. * Gets the value of D-pad left
  105839. */
  105840. /**
  105841. * Sets the value of D-pad left
  105842. */
  105843. dPadLeft: number;
  105844. /**
  105845. * Gets the value of D-pad right
  105846. */
  105847. /**
  105848. * Sets the value of D-pad right
  105849. */
  105850. dPadRight: number;
  105851. /**
  105852. * Force the gamepad to synchronize with device values
  105853. */
  105854. update(): void;
  105855. /**
  105856. * Disposes the gamepad
  105857. */
  105858. dispose(): void;
  105859. }
  105860. }
  105861. declare module BABYLON {
  105862. /**
  105863. * Manager for handling gamepads
  105864. */
  105865. export class GamepadManager {
  105866. private _scene?;
  105867. private _babylonGamepads;
  105868. private _oneGamepadConnected;
  105869. /** @hidden */
  105870. _isMonitoring: boolean;
  105871. private _gamepadEventSupported;
  105872. private _gamepadSupport;
  105873. /**
  105874. * observable to be triggered when the gamepad controller has been connected
  105875. */
  105876. onGamepadConnectedObservable: Observable<Gamepad>;
  105877. /**
  105878. * observable to be triggered when the gamepad controller has been disconnected
  105879. */
  105880. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105881. private _onGamepadConnectedEvent;
  105882. private _onGamepadDisconnectedEvent;
  105883. /**
  105884. * Initializes the gamepad manager
  105885. * @param _scene BabylonJS scene
  105886. */
  105887. constructor(_scene?: Scene | undefined);
  105888. /**
  105889. * The gamepads in the game pad manager
  105890. */
  105891. readonly gamepads: Gamepad[];
  105892. /**
  105893. * Get the gamepad controllers based on type
  105894. * @param type The type of gamepad controller
  105895. * @returns Nullable gamepad
  105896. */
  105897. getGamepadByType(type?: number): Nullable<Gamepad>;
  105898. /**
  105899. * Disposes the gamepad manager
  105900. */
  105901. dispose(): void;
  105902. private _addNewGamepad;
  105903. private _startMonitoringGamepads;
  105904. private _stopMonitoringGamepads;
  105905. /** @hidden */
  105906. _checkGamepadsStatus(): void;
  105907. private _updateGamepadObjects;
  105908. }
  105909. }
  105910. declare module BABYLON {
  105911. interface Scene {
  105912. /** @hidden */
  105913. _gamepadManager: Nullable<GamepadManager>;
  105914. /**
  105915. * Gets the gamepad manager associated with the scene
  105916. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105917. */
  105918. gamepadManager: GamepadManager;
  105919. }
  105920. /**
  105921. * Interface representing a free camera inputs manager
  105922. */
  105923. interface FreeCameraInputsManager {
  105924. /**
  105925. * Adds gamepad input support to the FreeCameraInputsManager.
  105926. * @returns the FreeCameraInputsManager
  105927. */
  105928. addGamepad(): FreeCameraInputsManager;
  105929. }
  105930. /**
  105931. * Interface representing an arc rotate camera inputs manager
  105932. */
  105933. interface ArcRotateCameraInputsManager {
  105934. /**
  105935. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105936. * @returns the camera inputs manager
  105937. */
  105938. addGamepad(): ArcRotateCameraInputsManager;
  105939. }
  105940. /**
  105941. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  105942. */
  105943. export class GamepadSystemSceneComponent implements ISceneComponent {
  105944. /**
  105945. * The component name helpfull to identify the component in the list of scene components.
  105946. */
  105947. readonly name: string;
  105948. /**
  105949. * The scene the component belongs to.
  105950. */
  105951. scene: Scene;
  105952. /**
  105953. * Creates a new instance of the component for the given scene
  105954. * @param scene Defines the scene to register the component in
  105955. */
  105956. constructor(scene: Scene);
  105957. /**
  105958. * Registers the component in a given scene
  105959. */
  105960. register(): void;
  105961. /**
  105962. * Rebuilds the elements related to this component in case of
  105963. * context lost for instance.
  105964. */
  105965. rebuild(): void;
  105966. /**
  105967. * Disposes the component and the associated ressources
  105968. */
  105969. dispose(): void;
  105970. private _beforeCameraUpdate;
  105971. }
  105972. }
  105973. declare module BABYLON {
  105974. /**
  105975. * 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,
  105976. * which still works and will still be found in many Playgrounds.
  105977. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105978. */
  105979. export class UniversalCamera extends TouchCamera {
  105980. /**
  105981. * Defines the gamepad rotation sensiblity.
  105982. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105983. */
  105984. gamepadAngularSensibility: number;
  105985. /**
  105986. * Defines the gamepad move sensiblity.
  105987. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105988. */
  105989. gamepadMoveSensibility: number;
  105990. /**
  105991. * 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,
  105992. * which still works and will still be found in many Playgrounds.
  105993. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105994. * @param name Define the name of the camera in the scene
  105995. * @param position Define the start position of the camera in the scene
  105996. * @param scene Define the scene the camera belongs to
  105997. */
  105998. constructor(name: string, position: Vector3, scene: Scene);
  105999. /**
  106000. * Gets the current object class name.
  106001. * @return the class name
  106002. */
  106003. getClassName(): string;
  106004. }
  106005. }
  106006. declare module BABYLON {
  106007. /**
  106008. * This represents a FPS type of camera. This is only here for back compat purpose.
  106009. * Please use the UniversalCamera instead as both are identical.
  106010. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106011. */
  106012. export class GamepadCamera extends UniversalCamera {
  106013. /**
  106014. * Instantiates a new Gamepad Camera
  106015. * This represents a FPS type of camera. This is only here for back compat purpose.
  106016. * Please use the UniversalCamera instead as both are identical.
  106017. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106018. * @param name Define the name of the camera in the scene
  106019. * @param position Define the start position of the camera in the scene
  106020. * @param scene Define the scene the camera belongs to
  106021. */
  106022. constructor(name: string, position: Vector3, scene: Scene);
  106023. /**
  106024. * Gets the current object class name.
  106025. * @return the class name
  106026. */
  106027. getClassName(): string;
  106028. }
  106029. }
  106030. declare module BABYLON {
  106031. /** @hidden */
  106032. export var passPixelShader: {
  106033. name: string;
  106034. shader: string;
  106035. };
  106036. }
  106037. declare module BABYLON {
  106038. /** @hidden */
  106039. export var passCubePixelShader: {
  106040. name: string;
  106041. shader: string;
  106042. };
  106043. }
  106044. declare module BABYLON {
  106045. /**
  106046. * PassPostProcess which produces an output the same as it's input
  106047. */
  106048. export class PassPostProcess extends PostProcess {
  106049. /**
  106050. * Creates the PassPostProcess
  106051. * @param name The name of the effect.
  106052. * @param options The required width/height ratio to downsize to before computing the render pass.
  106053. * @param camera The camera to apply the render pass to.
  106054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106055. * @param engine The engine which the post process will be applied. (default: current engine)
  106056. * @param reusable If the post process can be reused on the same frame. (default: false)
  106057. * @param textureType The type of texture to be used when performing the post processing.
  106058. * @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)
  106059. */
  106060. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106061. }
  106062. /**
  106063. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106064. */
  106065. export class PassCubePostProcess extends PostProcess {
  106066. private _face;
  106067. /**
  106068. * Gets or sets the cube face to display.
  106069. * * 0 is +X
  106070. * * 1 is -X
  106071. * * 2 is +Y
  106072. * * 3 is -Y
  106073. * * 4 is +Z
  106074. * * 5 is -Z
  106075. */
  106076. face: number;
  106077. /**
  106078. * Creates the PassCubePostProcess
  106079. * @param name The name of the effect.
  106080. * @param options The required width/height ratio to downsize to before computing the render pass.
  106081. * @param camera The camera to apply the render pass to.
  106082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106083. * @param engine The engine which the post process will be applied. (default: current engine)
  106084. * @param reusable If the post process can be reused on the same frame. (default: false)
  106085. * @param textureType The type of texture to be used when performing the post processing.
  106086. * @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)
  106087. */
  106088. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106089. }
  106090. }
  106091. declare module BABYLON {
  106092. /** @hidden */
  106093. export var anaglyphPixelShader: {
  106094. name: string;
  106095. shader: string;
  106096. };
  106097. }
  106098. declare module BABYLON {
  106099. /**
  106100. * Postprocess used to generate anaglyphic rendering
  106101. */
  106102. export class AnaglyphPostProcess extends PostProcess {
  106103. private _passedProcess;
  106104. /**
  106105. * Creates a new AnaglyphPostProcess
  106106. * @param name defines postprocess name
  106107. * @param options defines creation options or target ratio scale
  106108. * @param rigCameras defines cameras using this postprocess
  106109. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106110. * @param engine defines hosting engine
  106111. * @param reusable defines if the postprocess will be reused multiple times per frame
  106112. */
  106113. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106114. }
  106115. }
  106116. declare module BABYLON {
  106117. /**
  106118. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106119. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106120. */
  106121. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106122. /**
  106123. * Creates a new AnaglyphArcRotateCamera
  106124. * @param name defines camera name
  106125. * @param alpha defines alpha angle (in radians)
  106126. * @param beta defines beta angle (in radians)
  106127. * @param radius defines radius
  106128. * @param target defines camera target
  106129. * @param interaxialDistance defines distance between each color axis
  106130. * @param scene defines the hosting scene
  106131. */
  106132. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106133. /**
  106134. * Gets camera class name
  106135. * @returns AnaglyphArcRotateCamera
  106136. */
  106137. getClassName(): string;
  106138. }
  106139. }
  106140. declare module BABYLON {
  106141. /**
  106142. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106143. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106144. */
  106145. export class AnaglyphFreeCamera extends FreeCamera {
  106146. /**
  106147. * Creates a new AnaglyphFreeCamera
  106148. * @param name defines camera name
  106149. * @param position defines initial position
  106150. * @param interaxialDistance defines distance between each color axis
  106151. * @param scene defines the hosting scene
  106152. */
  106153. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106154. /**
  106155. * Gets camera class name
  106156. * @returns AnaglyphFreeCamera
  106157. */
  106158. getClassName(): string;
  106159. }
  106160. }
  106161. declare module BABYLON {
  106162. /**
  106163. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106164. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106165. */
  106166. export class AnaglyphGamepadCamera extends GamepadCamera {
  106167. /**
  106168. * Creates a new AnaglyphGamepadCamera
  106169. * @param name defines camera name
  106170. * @param position defines initial position
  106171. * @param interaxialDistance defines distance between each color axis
  106172. * @param scene defines the hosting scene
  106173. */
  106174. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106175. /**
  106176. * Gets camera class name
  106177. * @returns AnaglyphGamepadCamera
  106178. */
  106179. getClassName(): string;
  106180. }
  106181. }
  106182. declare module BABYLON {
  106183. /**
  106184. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106185. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106186. */
  106187. export class AnaglyphUniversalCamera extends UniversalCamera {
  106188. /**
  106189. * Creates a new AnaglyphUniversalCamera
  106190. * @param name defines camera name
  106191. * @param position defines initial position
  106192. * @param interaxialDistance defines distance between each color axis
  106193. * @param scene defines the hosting scene
  106194. */
  106195. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106196. /**
  106197. * Gets camera class name
  106198. * @returns AnaglyphUniversalCamera
  106199. */
  106200. getClassName(): string;
  106201. }
  106202. }
  106203. declare module BABYLON {
  106204. /** @hidden */
  106205. export var stereoscopicInterlacePixelShader: {
  106206. name: string;
  106207. shader: string;
  106208. };
  106209. }
  106210. declare module BABYLON {
  106211. /**
  106212. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106213. */
  106214. export class StereoscopicInterlacePostProcess extends PostProcess {
  106215. private _stepSize;
  106216. private _passedProcess;
  106217. /**
  106218. * Initializes a StereoscopicInterlacePostProcess
  106219. * @param name The name of the effect.
  106220. * @param rigCameras The rig cameras to be appled to the post process
  106221. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106223. * @param engine The engine which the post process will be applied. (default: current engine)
  106224. * @param reusable If the post process can be reused on the same frame. (default: false)
  106225. */
  106226. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106227. }
  106228. }
  106229. declare module BABYLON {
  106230. /**
  106231. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106232. * @see http://doc.babylonjs.com/features/cameras
  106233. */
  106234. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106235. /**
  106236. * Creates a new StereoscopicArcRotateCamera
  106237. * @param name defines camera name
  106238. * @param alpha defines alpha angle (in radians)
  106239. * @param beta defines beta angle (in radians)
  106240. * @param radius defines radius
  106241. * @param target defines camera target
  106242. * @param interaxialDistance defines distance between each color axis
  106243. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106244. * @param scene defines the hosting scene
  106245. */
  106246. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106247. /**
  106248. * Gets camera class name
  106249. * @returns StereoscopicArcRotateCamera
  106250. */
  106251. getClassName(): string;
  106252. }
  106253. }
  106254. declare module BABYLON {
  106255. /**
  106256. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106257. * @see http://doc.babylonjs.com/features/cameras
  106258. */
  106259. export class StereoscopicFreeCamera extends FreeCamera {
  106260. /**
  106261. * Creates a new StereoscopicFreeCamera
  106262. * @param name defines camera name
  106263. * @param position defines initial position
  106264. * @param interaxialDistance defines distance between each color axis
  106265. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106266. * @param scene defines the hosting scene
  106267. */
  106268. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106269. /**
  106270. * Gets camera class name
  106271. * @returns StereoscopicFreeCamera
  106272. */
  106273. getClassName(): string;
  106274. }
  106275. }
  106276. declare module BABYLON {
  106277. /**
  106278. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106279. * @see http://doc.babylonjs.com/features/cameras
  106280. */
  106281. export class StereoscopicGamepadCamera extends GamepadCamera {
  106282. /**
  106283. * Creates a new StereoscopicGamepadCamera
  106284. * @param name defines camera name
  106285. * @param position defines initial position
  106286. * @param interaxialDistance defines distance between each color axis
  106287. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106288. * @param scene defines the hosting scene
  106289. */
  106290. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106291. /**
  106292. * Gets camera class name
  106293. * @returns StereoscopicGamepadCamera
  106294. */
  106295. getClassName(): string;
  106296. }
  106297. }
  106298. declare module BABYLON {
  106299. /**
  106300. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106301. * @see http://doc.babylonjs.com/features/cameras
  106302. */
  106303. export class StereoscopicUniversalCamera extends UniversalCamera {
  106304. /**
  106305. * Creates a new StereoscopicUniversalCamera
  106306. * @param name defines camera name
  106307. * @param position defines initial position
  106308. * @param interaxialDistance defines distance between each color axis
  106309. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106310. * @param scene defines the hosting scene
  106311. */
  106312. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106313. /**
  106314. * Gets camera class name
  106315. * @returns StereoscopicUniversalCamera
  106316. */
  106317. getClassName(): string;
  106318. }
  106319. }
  106320. declare module BABYLON {
  106321. /**
  106322. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106323. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106324. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106325. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106326. */
  106327. export class VirtualJoysticksCamera extends FreeCamera {
  106328. /**
  106329. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106330. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106331. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106332. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106333. * @param name Define the name of the camera in the scene
  106334. * @param position Define the start position of the camera in the scene
  106335. * @param scene Define the scene the camera belongs to
  106336. */
  106337. constructor(name: string, position: Vector3, scene: Scene);
  106338. /**
  106339. * Gets the current object class name.
  106340. * @return the class name
  106341. */
  106342. getClassName(): string;
  106343. }
  106344. }
  106345. declare module BABYLON {
  106346. /**
  106347. * This represents all the required metrics to create a VR camera.
  106348. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106349. */
  106350. export class VRCameraMetrics {
  106351. /**
  106352. * Define the horizontal resolution off the screen.
  106353. */
  106354. hResolution: number;
  106355. /**
  106356. * Define the vertical resolution off the screen.
  106357. */
  106358. vResolution: number;
  106359. /**
  106360. * Define the horizontal screen size.
  106361. */
  106362. hScreenSize: number;
  106363. /**
  106364. * Define the vertical screen size.
  106365. */
  106366. vScreenSize: number;
  106367. /**
  106368. * Define the vertical screen center position.
  106369. */
  106370. vScreenCenter: number;
  106371. /**
  106372. * Define the distance of the eyes to the screen.
  106373. */
  106374. eyeToScreenDistance: number;
  106375. /**
  106376. * Define the distance between both lenses
  106377. */
  106378. lensSeparationDistance: number;
  106379. /**
  106380. * Define the distance between both viewer's eyes.
  106381. */
  106382. interpupillaryDistance: number;
  106383. /**
  106384. * Define the distortion factor of the VR postprocess.
  106385. * Please, touch with care.
  106386. */
  106387. distortionK: number[];
  106388. /**
  106389. * Define the chromatic aberration correction factors for the VR post process.
  106390. */
  106391. chromaAbCorrection: number[];
  106392. /**
  106393. * Define the scale factor of the post process.
  106394. * The smaller the better but the slower.
  106395. */
  106396. postProcessScaleFactor: number;
  106397. /**
  106398. * Define an offset for the lens center.
  106399. */
  106400. lensCenterOffset: number;
  106401. /**
  106402. * Define if the current vr camera should compensate the distortion of the lense or not.
  106403. */
  106404. compensateDistortion: boolean;
  106405. /**
  106406. * Defines if multiview should be enabled when rendering (Default: false)
  106407. */
  106408. multiviewEnabled: boolean;
  106409. /**
  106410. * Gets the rendering aspect ratio based on the provided resolutions.
  106411. */
  106412. readonly aspectRatio: number;
  106413. /**
  106414. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106415. */
  106416. readonly aspectRatioFov: number;
  106417. /**
  106418. * @hidden
  106419. */
  106420. readonly leftHMatrix: Matrix;
  106421. /**
  106422. * @hidden
  106423. */
  106424. readonly rightHMatrix: Matrix;
  106425. /**
  106426. * @hidden
  106427. */
  106428. readonly leftPreViewMatrix: Matrix;
  106429. /**
  106430. * @hidden
  106431. */
  106432. readonly rightPreViewMatrix: Matrix;
  106433. /**
  106434. * Get the default VRMetrics based on the most generic setup.
  106435. * @returns the default vr metrics
  106436. */
  106437. static GetDefault(): VRCameraMetrics;
  106438. }
  106439. }
  106440. declare module BABYLON {
  106441. /** @hidden */
  106442. export var vrDistortionCorrectionPixelShader: {
  106443. name: string;
  106444. shader: string;
  106445. };
  106446. }
  106447. declare module BABYLON {
  106448. /**
  106449. * VRDistortionCorrectionPostProcess used for mobile VR
  106450. */
  106451. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106452. private _isRightEye;
  106453. private _distortionFactors;
  106454. private _postProcessScaleFactor;
  106455. private _lensCenterOffset;
  106456. private _scaleIn;
  106457. private _scaleFactor;
  106458. private _lensCenter;
  106459. /**
  106460. * Initializes the VRDistortionCorrectionPostProcess
  106461. * @param name The name of the effect.
  106462. * @param camera The camera to apply the render pass to.
  106463. * @param isRightEye If this is for the right eye distortion
  106464. * @param vrMetrics All the required metrics for the VR camera
  106465. */
  106466. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106467. }
  106468. }
  106469. declare module BABYLON {
  106470. /**
  106471. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106472. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106473. */
  106474. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106475. /**
  106476. * Creates a new VRDeviceOrientationArcRotateCamera
  106477. * @param name defines camera name
  106478. * @param alpha defines the camera rotation along the logitudinal axis
  106479. * @param beta defines the camera rotation along the latitudinal axis
  106480. * @param radius defines the camera distance from its target
  106481. * @param target defines the camera target
  106482. * @param scene defines the scene the camera belongs to
  106483. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106484. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106485. */
  106486. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106487. /**
  106488. * Gets camera class name
  106489. * @returns VRDeviceOrientationArcRotateCamera
  106490. */
  106491. getClassName(): string;
  106492. }
  106493. }
  106494. declare module BABYLON {
  106495. /**
  106496. * Camera used to simulate VR rendering (based on FreeCamera)
  106497. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106498. */
  106499. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106500. /**
  106501. * Creates a new VRDeviceOrientationFreeCamera
  106502. * @param name defines camera name
  106503. * @param position defines the start position of the camera
  106504. * @param scene defines the scene the camera belongs to
  106505. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106506. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106507. */
  106508. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106509. /**
  106510. * Gets camera class name
  106511. * @returns VRDeviceOrientationFreeCamera
  106512. */
  106513. getClassName(): string;
  106514. }
  106515. }
  106516. declare module BABYLON {
  106517. /**
  106518. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106519. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106520. */
  106521. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106522. /**
  106523. * Creates a new VRDeviceOrientationGamepadCamera
  106524. * @param name defines camera name
  106525. * @param position defines the start position of the camera
  106526. * @param scene defines the scene the camera belongs to
  106527. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106528. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106529. */
  106530. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106531. /**
  106532. * Gets camera class name
  106533. * @returns VRDeviceOrientationGamepadCamera
  106534. */
  106535. getClassName(): string;
  106536. }
  106537. }
  106538. declare module BABYLON {
  106539. /**
  106540. * Base class of materials working in push mode in babylon JS
  106541. * @hidden
  106542. */
  106543. export class PushMaterial extends Material {
  106544. protected _activeEffect: Effect;
  106545. protected _normalMatrix: Matrix;
  106546. /**
  106547. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106548. * This means that the material can keep using a previous shader while a new one is being compiled.
  106549. * This is mostly used when shader parallel compilation is supported (true by default)
  106550. */
  106551. allowShaderHotSwapping: boolean;
  106552. constructor(name: string, scene: Scene);
  106553. getEffect(): Effect;
  106554. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106555. /**
  106556. * Binds the given world matrix to the active effect
  106557. *
  106558. * @param world the matrix to bind
  106559. */
  106560. bindOnlyWorldMatrix(world: Matrix): void;
  106561. /**
  106562. * Binds the given normal matrix to the active effect
  106563. *
  106564. * @param normalMatrix the matrix to bind
  106565. */
  106566. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106567. bind(world: Matrix, mesh?: Mesh): void;
  106568. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106569. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106570. }
  106571. }
  106572. declare module BABYLON {
  106573. /**
  106574. * This groups all the flags used to control the materials channel.
  106575. */
  106576. export class MaterialFlags {
  106577. private static _DiffuseTextureEnabled;
  106578. /**
  106579. * Are diffuse textures enabled in the application.
  106580. */
  106581. static DiffuseTextureEnabled: boolean;
  106582. private static _AmbientTextureEnabled;
  106583. /**
  106584. * Are ambient textures enabled in the application.
  106585. */
  106586. static AmbientTextureEnabled: boolean;
  106587. private static _OpacityTextureEnabled;
  106588. /**
  106589. * Are opacity textures enabled in the application.
  106590. */
  106591. static OpacityTextureEnabled: boolean;
  106592. private static _ReflectionTextureEnabled;
  106593. /**
  106594. * Are reflection textures enabled in the application.
  106595. */
  106596. static ReflectionTextureEnabled: boolean;
  106597. private static _EmissiveTextureEnabled;
  106598. /**
  106599. * Are emissive textures enabled in the application.
  106600. */
  106601. static EmissiveTextureEnabled: boolean;
  106602. private static _SpecularTextureEnabled;
  106603. /**
  106604. * Are specular textures enabled in the application.
  106605. */
  106606. static SpecularTextureEnabled: boolean;
  106607. private static _BumpTextureEnabled;
  106608. /**
  106609. * Are bump textures enabled in the application.
  106610. */
  106611. static BumpTextureEnabled: boolean;
  106612. private static _LightmapTextureEnabled;
  106613. /**
  106614. * Are lightmap textures enabled in the application.
  106615. */
  106616. static LightmapTextureEnabled: boolean;
  106617. private static _RefractionTextureEnabled;
  106618. /**
  106619. * Are refraction textures enabled in the application.
  106620. */
  106621. static RefractionTextureEnabled: boolean;
  106622. private static _ColorGradingTextureEnabled;
  106623. /**
  106624. * Are color grading textures enabled in the application.
  106625. */
  106626. static ColorGradingTextureEnabled: boolean;
  106627. private static _FresnelEnabled;
  106628. /**
  106629. * Are fresnels enabled in the application.
  106630. */
  106631. static FresnelEnabled: boolean;
  106632. private static _ClearCoatTextureEnabled;
  106633. /**
  106634. * Are clear coat textures enabled in the application.
  106635. */
  106636. static ClearCoatTextureEnabled: boolean;
  106637. private static _ClearCoatBumpTextureEnabled;
  106638. /**
  106639. * Are clear coat bump textures enabled in the application.
  106640. */
  106641. static ClearCoatBumpTextureEnabled: boolean;
  106642. private static _ClearCoatTintTextureEnabled;
  106643. /**
  106644. * Are clear coat tint textures enabled in the application.
  106645. */
  106646. static ClearCoatTintTextureEnabled: boolean;
  106647. private static _SheenTextureEnabled;
  106648. /**
  106649. * Are sheen textures enabled in the application.
  106650. */
  106651. static SheenTextureEnabled: boolean;
  106652. private static _AnisotropicTextureEnabled;
  106653. /**
  106654. * Are anisotropic textures enabled in the application.
  106655. */
  106656. static AnisotropicTextureEnabled: boolean;
  106657. private static _ThicknessTextureEnabled;
  106658. /**
  106659. * Are thickness textures enabled in the application.
  106660. */
  106661. static ThicknessTextureEnabled: boolean;
  106662. }
  106663. }
  106664. declare module BABYLON {
  106665. /** @hidden */
  106666. export var defaultFragmentDeclaration: {
  106667. name: string;
  106668. shader: string;
  106669. };
  106670. }
  106671. declare module BABYLON {
  106672. /** @hidden */
  106673. export var defaultUboDeclaration: {
  106674. name: string;
  106675. shader: string;
  106676. };
  106677. }
  106678. declare module BABYLON {
  106679. /** @hidden */
  106680. export var lightFragmentDeclaration: {
  106681. name: string;
  106682. shader: string;
  106683. };
  106684. }
  106685. declare module BABYLON {
  106686. /** @hidden */
  106687. export var lightUboDeclaration: {
  106688. name: string;
  106689. shader: string;
  106690. };
  106691. }
  106692. declare module BABYLON {
  106693. /** @hidden */
  106694. export var lightsFragmentFunctions: {
  106695. name: string;
  106696. shader: string;
  106697. };
  106698. }
  106699. declare module BABYLON {
  106700. /** @hidden */
  106701. export var shadowsFragmentFunctions: {
  106702. name: string;
  106703. shader: string;
  106704. };
  106705. }
  106706. declare module BABYLON {
  106707. /** @hidden */
  106708. export var fresnelFunction: {
  106709. name: string;
  106710. shader: string;
  106711. };
  106712. }
  106713. declare module BABYLON {
  106714. /** @hidden */
  106715. export var reflectionFunction: {
  106716. name: string;
  106717. shader: string;
  106718. };
  106719. }
  106720. declare module BABYLON {
  106721. /** @hidden */
  106722. export var bumpFragmentFunctions: {
  106723. name: string;
  106724. shader: string;
  106725. };
  106726. }
  106727. declare module BABYLON {
  106728. /** @hidden */
  106729. export var logDepthDeclaration: {
  106730. name: string;
  106731. shader: string;
  106732. };
  106733. }
  106734. declare module BABYLON {
  106735. /** @hidden */
  106736. export var bumpFragment: {
  106737. name: string;
  106738. shader: string;
  106739. };
  106740. }
  106741. declare module BABYLON {
  106742. /** @hidden */
  106743. export var depthPrePass: {
  106744. name: string;
  106745. shader: string;
  106746. };
  106747. }
  106748. declare module BABYLON {
  106749. /** @hidden */
  106750. export var lightFragment: {
  106751. name: string;
  106752. shader: string;
  106753. };
  106754. }
  106755. declare module BABYLON {
  106756. /** @hidden */
  106757. export var logDepthFragment: {
  106758. name: string;
  106759. shader: string;
  106760. };
  106761. }
  106762. declare module BABYLON {
  106763. /** @hidden */
  106764. export var defaultPixelShader: {
  106765. name: string;
  106766. shader: string;
  106767. };
  106768. }
  106769. declare module BABYLON {
  106770. /** @hidden */
  106771. export var defaultVertexDeclaration: {
  106772. name: string;
  106773. shader: string;
  106774. };
  106775. }
  106776. declare module BABYLON {
  106777. /** @hidden */
  106778. export var bumpVertexDeclaration: {
  106779. name: string;
  106780. shader: string;
  106781. };
  106782. }
  106783. declare module BABYLON {
  106784. /** @hidden */
  106785. export var bumpVertex: {
  106786. name: string;
  106787. shader: string;
  106788. };
  106789. }
  106790. declare module BABYLON {
  106791. /** @hidden */
  106792. export var fogVertex: {
  106793. name: string;
  106794. shader: string;
  106795. };
  106796. }
  106797. declare module BABYLON {
  106798. /** @hidden */
  106799. export var shadowsVertex: {
  106800. name: string;
  106801. shader: string;
  106802. };
  106803. }
  106804. declare module BABYLON {
  106805. /** @hidden */
  106806. export var pointCloudVertex: {
  106807. name: string;
  106808. shader: string;
  106809. };
  106810. }
  106811. declare module BABYLON {
  106812. /** @hidden */
  106813. export var logDepthVertex: {
  106814. name: string;
  106815. shader: string;
  106816. };
  106817. }
  106818. declare module BABYLON {
  106819. /** @hidden */
  106820. export var defaultVertexShader: {
  106821. name: string;
  106822. shader: string;
  106823. };
  106824. }
  106825. declare module BABYLON {
  106826. /** @hidden */
  106827. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106828. MAINUV1: boolean;
  106829. MAINUV2: boolean;
  106830. DIFFUSE: boolean;
  106831. DIFFUSEDIRECTUV: number;
  106832. AMBIENT: boolean;
  106833. AMBIENTDIRECTUV: number;
  106834. OPACITY: boolean;
  106835. OPACITYDIRECTUV: number;
  106836. OPACITYRGB: boolean;
  106837. REFLECTION: boolean;
  106838. EMISSIVE: boolean;
  106839. EMISSIVEDIRECTUV: number;
  106840. SPECULAR: boolean;
  106841. SPECULARDIRECTUV: number;
  106842. BUMP: boolean;
  106843. BUMPDIRECTUV: number;
  106844. PARALLAX: boolean;
  106845. PARALLAXOCCLUSION: boolean;
  106846. SPECULAROVERALPHA: boolean;
  106847. CLIPPLANE: boolean;
  106848. CLIPPLANE2: boolean;
  106849. CLIPPLANE3: boolean;
  106850. CLIPPLANE4: boolean;
  106851. ALPHATEST: boolean;
  106852. DEPTHPREPASS: boolean;
  106853. ALPHAFROMDIFFUSE: boolean;
  106854. POINTSIZE: boolean;
  106855. FOG: boolean;
  106856. SPECULARTERM: boolean;
  106857. DIFFUSEFRESNEL: boolean;
  106858. OPACITYFRESNEL: boolean;
  106859. REFLECTIONFRESNEL: boolean;
  106860. REFRACTIONFRESNEL: boolean;
  106861. EMISSIVEFRESNEL: boolean;
  106862. FRESNEL: boolean;
  106863. NORMAL: boolean;
  106864. UV1: boolean;
  106865. UV2: boolean;
  106866. VERTEXCOLOR: boolean;
  106867. VERTEXALPHA: boolean;
  106868. NUM_BONE_INFLUENCERS: number;
  106869. BonesPerMesh: number;
  106870. BONETEXTURE: boolean;
  106871. INSTANCES: boolean;
  106872. GLOSSINESS: boolean;
  106873. ROUGHNESS: boolean;
  106874. EMISSIVEASILLUMINATION: boolean;
  106875. LINKEMISSIVEWITHDIFFUSE: boolean;
  106876. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106877. LIGHTMAP: boolean;
  106878. LIGHTMAPDIRECTUV: number;
  106879. OBJECTSPACE_NORMALMAP: boolean;
  106880. USELIGHTMAPASSHADOWMAP: boolean;
  106881. REFLECTIONMAP_3D: boolean;
  106882. REFLECTIONMAP_SPHERICAL: boolean;
  106883. REFLECTIONMAP_PLANAR: boolean;
  106884. REFLECTIONMAP_CUBIC: boolean;
  106885. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106886. REFLECTIONMAP_PROJECTION: boolean;
  106887. REFLECTIONMAP_SKYBOX: boolean;
  106888. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106889. REFLECTIONMAP_EXPLICIT: boolean;
  106890. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106891. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106892. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106893. INVERTCUBICMAP: boolean;
  106894. LOGARITHMICDEPTH: boolean;
  106895. REFRACTION: boolean;
  106896. REFRACTIONMAP_3D: boolean;
  106897. REFLECTIONOVERALPHA: boolean;
  106898. TWOSIDEDLIGHTING: boolean;
  106899. SHADOWFLOAT: boolean;
  106900. MORPHTARGETS: boolean;
  106901. MORPHTARGETS_NORMAL: boolean;
  106902. MORPHTARGETS_TANGENT: boolean;
  106903. MORPHTARGETS_UV: boolean;
  106904. NUM_MORPH_INFLUENCERS: number;
  106905. NONUNIFORMSCALING: boolean;
  106906. PREMULTIPLYALPHA: boolean;
  106907. IMAGEPROCESSING: boolean;
  106908. VIGNETTE: boolean;
  106909. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106910. VIGNETTEBLENDMODEOPAQUE: boolean;
  106911. TONEMAPPING: boolean;
  106912. TONEMAPPING_ACES: boolean;
  106913. CONTRAST: boolean;
  106914. COLORCURVES: boolean;
  106915. COLORGRADING: boolean;
  106916. COLORGRADING3D: boolean;
  106917. SAMPLER3DGREENDEPTH: boolean;
  106918. SAMPLER3DBGRMAP: boolean;
  106919. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106920. MULTIVIEW: boolean;
  106921. /**
  106922. * If the reflection texture on this material is in linear color space
  106923. * @hidden
  106924. */
  106925. IS_REFLECTION_LINEAR: boolean;
  106926. /**
  106927. * If the refraction texture on this material is in linear color space
  106928. * @hidden
  106929. */
  106930. IS_REFRACTION_LINEAR: boolean;
  106931. EXPOSURE: boolean;
  106932. constructor();
  106933. setReflectionMode(modeToEnable: string): void;
  106934. }
  106935. /**
  106936. * This is the default material used in Babylon. It is the best trade off between quality
  106937. * and performances.
  106938. * @see http://doc.babylonjs.com/babylon101/materials
  106939. */
  106940. export class StandardMaterial extends PushMaterial {
  106941. private _diffuseTexture;
  106942. /**
  106943. * The basic texture of the material as viewed under a light.
  106944. */
  106945. diffuseTexture: Nullable<BaseTexture>;
  106946. private _ambientTexture;
  106947. /**
  106948. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106949. */
  106950. ambientTexture: Nullable<BaseTexture>;
  106951. private _opacityTexture;
  106952. /**
  106953. * Define the transparency of the material from a texture.
  106954. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106955. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106956. */
  106957. opacityTexture: Nullable<BaseTexture>;
  106958. private _reflectionTexture;
  106959. /**
  106960. * Define the texture used to display the reflection.
  106961. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106962. */
  106963. reflectionTexture: Nullable<BaseTexture>;
  106964. private _emissiveTexture;
  106965. /**
  106966. * Define texture of the material as if self lit.
  106967. * This will be mixed in the final result even in the absence of light.
  106968. */
  106969. emissiveTexture: Nullable<BaseTexture>;
  106970. private _specularTexture;
  106971. /**
  106972. * Define how the color and intensity of the highlight given by the light in the material.
  106973. */
  106974. specularTexture: Nullable<BaseTexture>;
  106975. private _bumpTexture;
  106976. /**
  106977. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  106978. * 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.
  106979. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  106980. */
  106981. bumpTexture: Nullable<BaseTexture>;
  106982. private _lightmapTexture;
  106983. /**
  106984. * Complex lighting can be computationally expensive to compute at runtime.
  106985. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  106986. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  106987. */
  106988. lightmapTexture: Nullable<BaseTexture>;
  106989. private _refractionTexture;
  106990. /**
  106991. * Define the texture used to display the refraction.
  106992. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106993. */
  106994. refractionTexture: Nullable<BaseTexture>;
  106995. /**
  106996. * The color of the material lit by the environmental background lighting.
  106997. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106998. */
  106999. ambientColor: Color3;
  107000. /**
  107001. * The basic color of the material as viewed under a light.
  107002. */
  107003. diffuseColor: Color3;
  107004. /**
  107005. * Define how the color and intensity of the highlight given by the light in the material.
  107006. */
  107007. specularColor: Color3;
  107008. /**
  107009. * Define the color of the material as if self lit.
  107010. * This will be mixed in the final result even in the absence of light.
  107011. */
  107012. emissiveColor: Color3;
  107013. /**
  107014. * Defines how sharp are the highlights in the material.
  107015. * The bigger the value the sharper giving a more glossy feeling to the result.
  107016. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107017. */
  107018. specularPower: number;
  107019. private _useAlphaFromDiffuseTexture;
  107020. /**
  107021. * Does the transparency come from the diffuse texture alpha channel.
  107022. */
  107023. useAlphaFromDiffuseTexture: boolean;
  107024. private _useEmissiveAsIllumination;
  107025. /**
  107026. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107027. */
  107028. useEmissiveAsIllumination: boolean;
  107029. private _linkEmissiveWithDiffuse;
  107030. /**
  107031. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107032. * the emissive level when the final color is close to one.
  107033. */
  107034. linkEmissiveWithDiffuse: boolean;
  107035. private _useSpecularOverAlpha;
  107036. /**
  107037. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107038. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107039. */
  107040. useSpecularOverAlpha: boolean;
  107041. private _useReflectionOverAlpha;
  107042. /**
  107043. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107044. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107045. */
  107046. useReflectionOverAlpha: boolean;
  107047. private _disableLighting;
  107048. /**
  107049. * Does lights from the scene impacts this material.
  107050. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107051. */
  107052. disableLighting: boolean;
  107053. private _useObjectSpaceNormalMap;
  107054. /**
  107055. * Allows using an object space normal map (instead of tangent space).
  107056. */
  107057. useObjectSpaceNormalMap: boolean;
  107058. private _useParallax;
  107059. /**
  107060. * Is parallax enabled or not.
  107061. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107062. */
  107063. useParallax: boolean;
  107064. private _useParallaxOcclusion;
  107065. /**
  107066. * Is parallax occlusion enabled or not.
  107067. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107068. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107069. */
  107070. useParallaxOcclusion: boolean;
  107071. /**
  107072. * 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.
  107073. */
  107074. parallaxScaleBias: number;
  107075. private _roughness;
  107076. /**
  107077. * Helps to define how blurry the reflections should appears in the material.
  107078. */
  107079. roughness: number;
  107080. /**
  107081. * In case of refraction, define the value of the index of refraction.
  107082. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107083. */
  107084. indexOfRefraction: number;
  107085. /**
  107086. * Invert the refraction texture alongside the y axis.
  107087. * It can be useful with procedural textures or probe for instance.
  107088. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107089. */
  107090. invertRefractionY: boolean;
  107091. /**
  107092. * Defines the alpha limits in alpha test mode.
  107093. */
  107094. alphaCutOff: number;
  107095. private _useLightmapAsShadowmap;
  107096. /**
  107097. * In case of light mapping, define whether the map contains light or shadow informations.
  107098. */
  107099. useLightmapAsShadowmap: boolean;
  107100. private _diffuseFresnelParameters;
  107101. /**
  107102. * Define the diffuse fresnel parameters of the material.
  107103. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107104. */
  107105. diffuseFresnelParameters: FresnelParameters;
  107106. private _opacityFresnelParameters;
  107107. /**
  107108. * Define the opacity fresnel parameters of the material.
  107109. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107110. */
  107111. opacityFresnelParameters: FresnelParameters;
  107112. private _reflectionFresnelParameters;
  107113. /**
  107114. * Define the reflection fresnel parameters of the material.
  107115. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107116. */
  107117. reflectionFresnelParameters: FresnelParameters;
  107118. private _refractionFresnelParameters;
  107119. /**
  107120. * Define the refraction fresnel parameters of the material.
  107121. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107122. */
  107123. refractionFresnelParameters: FresnelParameters;
  107124. private _emissiveFresnelParameters;
  107125. /**
  107126. * Define the emissive fresnel parameters of the material.
  107127. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107128. */
  107129. emissiveFresnelParameters: FresnelParameters;
  107130. private _useReflectionFresnelFromSpecular;
  107131. /**
  107132. * If true automatically deducts the fresnels values from the material specularity.
  107133. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107134. */
  107135. useReflectionFresnelFromSpecular: boolean;
  107136. private _useGlossinessFromSpecularMapAlpha;
  107137. /**
  107138. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107139. */
  107140. useGlossinessFromSpecularMapAlpha: boolean;
  107141. private _maxSimultaneousLights;
  107142. /**
  107143. * Defines the maximum number of lights that can be used in the material
  107144. */
  107145. maxSimultaneousLights: number;
  107146. private _invertNormalMapX;
  107147. /**
  107148. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107149. */
  107150. invertNormalMapX: boolean;
  107151. private _invertNormalMapY;
  107152. /**
  107153. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107154. */
  107155. invertNormalMapY: boolean;
  107156. private _twoSidedLighting;
  107157. /**
  107158. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107159. */
  107160. twoSidedLighting: boolean;
  107161. /**
  107162. * Default configuration related to image processing available in the standard Material.
  107163. */
  107164. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107165. /**
  107166. * Gets the image processing configuration used either in this material.
  107167. */
  107168. /**
  107169. * Sets the Default image processing configuration used either in the this material.
  107170. *
  107171. * If sets to null, the scene one is in use.
  107172. */
  107173. imageProcessingConfiguration: ImageProcessingConfiguration;
  107174. /**
  107175. * Keep track of the image processing observer to allow dispose and replace.
  107176. */
  107177. private _imageProcessingObserver;
  107178. /**
  107179. * Attaches a new image processing configuration to the Standard Material.
  107180. * @param configuration
  107181. */
  107182. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107183. /**
  107184. * Gets wether the color curves effect is enabled.
  107185. */
  107186. /**
  107187. * Sets wether the color curves effect is enabled.
  107188. */
  107189. cameraColorCurvesEnabled: boolean;
  107190. /**
  107191. * Gets wether the color grading effect is enabled.
  107192. */
  107193. /**
  107194. * Gets wether the color grading effect is enabled.
  107195. */
  107196. cameraColorGradingEnabled: boolean;
  107197. /**
  107198. * Gets wether tonemapping is enabled or not.
  107199. */
  107200. /**
  107201. * Sets wether tonemapping is enabled or not
  107202. */
  107203. cameraToneMappingEnabled: boolean;
  107204. /**
  107205. * The camera exposure used on this material.
  107206. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107207. * This corresponds to a photographic exposure.
  107208. */
  107209. /**
  107210. * The camera exposure used on this material.
  107211. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107212. * This corresponds to a photographic exposure.
  107213. */
  107214. cameraExposure: number;
  107215. /**
  107216. * Gets The camera contrast used on this material.
  107217. */
  107218. /**
  107219. * Sets The camera contrast used on this material.
  107220. */
  107221. cameraContrast: number;
  107222. /**
  107223. * Gets the Color Grading 2D Lookup Texture.
  107224. */
  107225. /**
  107226. * Sets the Color Grading 2D Lookup Texture.
  107227. */
  107228. cameraColorGradingTexture: Nullable<BaseTexture>;
  107229. /**
  107230. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107231. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107232. * 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;
  107233. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107234. */
  107235. /**
  107236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107238. * 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;
  107239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107240. */
  107241. cameraColorCurves: Nullable<ColorCurves>;
  107242. /**
  107243. * Custom callback helping to override the default shader used in the material.
  107244. */
  107245. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107246. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107247. protected _worldViewProjectionMatrix: Matrix;
  107248. protected _globalAmbientColor: Color3;
  107249. protected _useLogarithmicDepth: boolean;
  107250. protected _rebuildInParallel: boolean;
  107251. /**
  107252. * Instantiates a new standard material.
  107253. * This is the default material used in Babylon. It is the best trade off between quality
  107254. * and performances.
  107255. * @see http://doc.babylonjs.com/babylon101/materials
  107256. * @param name Define the name of the material in the scene
  107257. * @param scene Define the scene the material belong to
  107258. */
  107259. constructor(name: string, scene: Scene);
  107260. /**
  107261. * Gets a boolean indicating that current material needs to register RTT
  107262. */
  107263. readonly hasRenderTargetTextures: boolean;
  107264. /**
  107265. * Gets the current class name of the material e.g. "StandardMaterial"
  107266. * Mainly use in serialization.
  107267. * @returns the class name
  107268. */
  107269. getClassName(): string;
  107270. /**
  107271. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107272. * You can try switching to logarithmic depth.
  107273. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107274. */
  107275. useLogarithmicDepth: boolean;
  107276. /**
  107277. * Specifies if the material will require alpha blending
  107278. * @returns a boolean specifying if alpha blending is needed
  107279. */
  107280. needAlphaBlending(): boolean;
  107281. /**
  107282. * Specifies if this material should be rendered in alpha test mode
  107283. * @returns a boolean specifying if an alpha test is needed.
  107284. */
  107285. needAlphaTesting(): boolean;
  107286. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107287. /**
  107288. * Get the texture used for alpha test purpose.
  107289. * @returns the diffuse texture in case of the standard material.
  107290. */
  107291. getAlphaTestTexture(): Nullable<BaseTexture>;
  107292. /**
  107293. * Get if the submesh is ready to be used and all its information available.
  107294. * Child classes can use it to update shaders
  107295. * @param mesh defines the mesh to check
  107296. * @param subMesh defines which submesh to check
  107297. * @param useInstances specifies that instances should be used
  107298. * @returns a boolean indicating that the submesh is ready or not
  107299. */
  107300. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107301. /**
  107302. * Builds the material UBO layouts.
  107303. * Used internally during the effect preparation.
  107304. */
  107305. buildUniformLayout(): void;
  107306. /**
  107307. * Unbinds the material from the mesh
  107308. */
  107309. unbind(): void;
  107310. /**
  107311. * Binds the submesh to this material by preparing the effect and shader to draw
  107312. * @param world defines the world transformation matrix
  107313. * @param mesh defines the mesh containing the submesh
  107314. * @param subMesh defines the submesh to bind the material to
  107315. */
  107316. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107317. /**
  107318. * Get the list of animatables in the material.
  107319. * @returns the list of animatables object used in the material
  107320. */
  107321. getAnimatables(): IAnimatable[];
  107322. /**
  107323. * Gets the active textures from the material
  107324. * @returns an array of textures
  107325. */
  107326. getActiveTextures(): BaseTexture[];
  107327. /**
  107328. * Specifies if the material uses a texture
  107329. * @param texture defines the texture to check against the material
  107330. * @returns a boolean specifying if the material uses the texture
  107331. */
  107332. hasTexture(texture: BaseTexture): boolean;
  107333. /**
  107334. * Disposes the material
  107335. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107336. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107337. */
  107338. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107339. /**
  107340. * Makes a duplicate of the material, and gives it a new name
  107341. * @param name defines the new name for the duplicated material
  107342. * @returns the cloned material
  107343. */
  107344. clone(name: string): StandardMaterial;
  107345. /**
  107346. * Serializes this material in a JSON representation
  107347. * @returns the serialized material object
  107348. */
  107349. serialize(): any;
  107350. /**
  107351. * Creates a standard material from parsed material data
  107352. * @param source defines the JSON representation of the material
  107353. * @param scene defines the hosting scene
  107354. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107355. * @returns a new standard material
  107356. */
  107357. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107358. /**
  107359. * Are diffuse textures enabled in the application.
  107360. */
  107361. static DiffuseTextureEnabled: boolean;
  107362. /**
  107363. * Are ambient textures enabled in the application.
  107364. */
  107365. static AmbientTextureEnabled: boolean;
  107366. /**
  107367. * Are opacity textures enabled in the application.
  107368. */
  107369. static OpacityTextureEnabled: boolean;
  107370. /**
  107371. * Are reflection textures enabled in the application.
  107372. */
  107373. static ReflectionTextureEnabled: boolean;
  107374. /**
  107375. * Are emissive textures enabled in the application.
  107376. */
  107377. static EmissiveTextureEnabled: boolean;
  107378. /**
  107379. * Are specular textures enabled in the application.
  107380. */
  107381. static SpecularTextureEnabled: boolean;
  107382. /**
  107383. * Are bump textures enabled in the application.
  107384. */
  107385. static BumpTextureEnabled: boolean;
  107386. /**
  107387. * Are lightmap textures enabled in the application.
  107388. */
  107389. static LightmapTextureEnabled: boolean;
  107390. /**
  107391. * Are refraction textures enabled in the application.
  107392. */
  107393. static RefractionTextureEnabled: boolean;
  107394. /**
  107395. * Are color grading textures enabled in the application.
  107396. */
  107397. static ColorGradingTextureEnabled: boolean;
  107398. /**
  107399. * Are fresnels enabled in the application.
  107400. */
  107401. static FresnelEnabled: boolean;
  107402. }
  107403. }
  107404. declare module BABYLON {
  107405. /** @hidden */
  107406. export var imageProcessingPixelShader: {
  107407. name: string;
  107408. shader: string;
  107409. };
  107410. }
  107411. declare module BABYLON {
  107412. /**
  107413. * ImageProcessingPostProcess
  107414. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107415. */
  107416. export class ImageProcessingPostProcess extends PostProcess {
  107417. /**
  107418. * Default configuration related to image processing available in the PBR Material.
  107419. */
  107420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107421. /**
  107422. * Gets the image processing configuration used either in this material.
  107423. */
  107424. /**
  107425. * Sets the Default image processing configuration used either in the this material.
  107426. *
  107427. * If sets to null, the scene one is in use.
  107428. */
  107429. imageProcessingConfiguration: ImageProcessingConfiguration;
  107430. /**
  107431. * Keep track of the image processing observer to allow dispose and replace.
  107432. */
  107433. private _imageProcessingObserver;
  107434. /**
  107435. * Attaches a new image processing configuration to the PBR Material.
  107436. * @param configuration
  107437. */
  107438. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107439. /**
  107440. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107441. */
  107442. /**
  107443. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107444. */
  107445. colorCurves: Nullable<ColorCurves>;
  107446. /**
  107447. * Gets wether the color curves effect is enabled.
  107448. */
  107449. /**
  107450. * Sets wether the color curves effect is enabled.
  107451. */
  107452. colorCurvesEnabled: boolean;
  107453. /**
  107454. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107455. */
  107456. /**
  107457. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107458. */
  107459. colorGradingTexture: Nullable<BaseTexture>;
  107460. /**
  107461. * Gets wether the color grading effect is enabled.
  107462. */
  107463. /**
  107464. * Gets wether the color grading effect is enabled.
  107465. */
  107466. colorGradingEnabled: boolean;
  107467. /**
  107468. * Gets exposure used in the effect.
  107469. */
  107470. /**
  107471. * Sets exposure used in the effect.
  107472. */
  107473. exposure: number;
  107474. /**
  107475. * Gets wether tonemapping is enabled or not.
  107476. */
  107477. /**
  107478. * Sets wether tonemapping is enabled or not
  107479. */
  107480. toneMappingEnabled: boolean;
  107481. /**
  107482. * Gets the type of tone mapping effect.
  107483. */
  107484. /**
  107485. * Sets the type of tone mapping effect.
  107486. */
  107487. toneMappingType: number;
  107488. /**
  107489. * Gets contrast used in the effect.
  107490. */
  107491. /**
  107492. * Sets contrast used in the effect.
  107493. */
  107494. contrast: number;
  107495. /**
  107496. * Gets Vignette stretch size.
  107497. */
  107498. /**
  107499. * Sets Vignette stretch size.
  107500. */
  107501. vignetteStretch: number;
  107502. /**
  107503. * Gets Vignette centre X Offset.
  107504. */
  107505. /**
  107506. * Sets Vignette centre X Offset.
  107507. */
  107508. vignetteCentreX: number;
  107509. /**
  107510. * Gets Vignette centre Y Offset.
  107511. */
  107512. /**
  107513. * Sets Vignette centre Y Offset.
  107514. */
  107515. vignetteCentreY: number;
  107516. /**
  107517. * Gets Vignette weight or intensity of the vignette effect.
  107518. */
  107519. /**
  107520. * Sets Vignette weight or intensity of the vignette effect.
  107521. */
  107522. vignetteWeight: number;
  107523. /**
  107524. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107525. * if vignetteEnabled is set to true.
  107526. */
  107527. /**
  107528. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107529. * if vignetteEnabled is set to true.
  107530. */
  107531. vignetteColor: Color4;
  107532. /**
  107533. * Gets Camera field of view used by the Vignette effect.
  107534. */
  107535. /**
  107536. * Sets Camera field of view used by the Vignette effect.
  107537. */
  107538. vignetteCameraFov: number;
  107539. /**
  107540. * Gets the vignette blend mode allowing different kind of effect.
  107541. */
  107542. /**
  107543. * Sets the vignette blend mode allowing different kind of effect.
  107544. */
  107545. vignetteBlendMode: number;
  107546. /**
  107547. * Gets wether the vignette effect is enabled.
  107548. */
  107549. /**
  107550. * Sets wether the vignette effect is enabled.
  107551. */
  107552. vignetteEnabled: boolean;
  107553. private _fromLinearSpace;
  107554. /**
  107555. * Gets wether the input of the processing is in Gamma or Linear Space.
  107556. */
  107557. /**
  107558. * Sets wether the input of the processing is in Gamma or Linear Space.
  107559. */
  107560. fromLinearSpace: boolean;
  107561. /**
  107562. * Defines cache preventing GC.
  107563. */
  107564. private _defines;
  107565. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107566. /**
  107567. * "ImageProcessingPostProcess"
  107568. * @returns "ImageProcessingPostProcess"
  107569. */
  107570. getClassName(): string;
  107571. protected _updateParameters(): void;
  107572. dispose(camera?: Camera): void;
  107573. }
  107574. }
  107575. declare module BABYLON {
  107576. /**
  107577. * Class containing static functions to help procedurally build meshes
  107578. */
  107579. export class GroundBuilder {
  107580. /**
  107581. * Creates a ground mesh
  107582. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107583. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107585. * @param name defines the name of the mesh
  107586. * @param options defines the options used to create the mesh
  107587. * @param scene defines the hosting scene
  107588. * @returns the ground mesh
  107589. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107590. */
  107591. static CreateGround(name: string, options: {
  107592. width?: number;
  107593. height?: number;
  107594. subdivisions?: number;
  107595. subdivisionsX?: number;
  107596. subdivisionsY?: number;
  107597. updatable?: boolean;
  107598. }, scene: any): Mesh;
  107599. /**
  107600. * Creates a tiled ground mesh
  107601. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107602. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107603. * * 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
  107604. * * 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
  107605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107606. * @param name defines the name of the mesh
  107607. * @param options defines the options used to create the mesh
  107608. * @param scene defines the hosting scene
  107609. * @returns the tiled ground mesh
  107610. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107611. */
  107612. static CreateTiledGround(name: string, options: {
  107613. xmin: number;
  107614. zmin: number;
  107615. xmax: number;
  107616. zmax: number;
  107617. subdivisions?: {
  107618. w: number;
  107619. h: number;
  107620. };
  107621. precision?: {
  107622. w: number;
  107623. h: number;
  107624. };
  107625. updatable?: boolean;
  107626. }, scene?: Nullable<Scene>): Mesh;
  107627. /**
  107628. * Creates a ground mesh from a height map
  107629. * * The parameter `url` sets the URL of the height map image resource.
  107630. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107631. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107632. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107633. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107634. * * 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.
  107635. * * 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).
  107636. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107638. * @param name defines the name of the mesh
  107639. * @param url defines the url to the height map
  107640. * @param options defines the options used to create the mesh
  107641. * @param scene defines the hosting scene
  107642. * @returns the ground mesh
  107643. * @see https://doc.babylonjs.com/babylon101/height_map
  107644. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107645. */
  107646. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107647. width?: number;
  107648. height?: number;
  107649. subdivisions?: number;
  107650. minHeight?: number;
  107651. maxHeight?: number;
  107652. colorFilter?: Color3;
  107653. alphaFilter?: number;
  107654. updatable?: boolean;
  107655. onReady?: (mesh: GroundMesh) => void;
  107656. }, scene?: Nullable<Scene>): GroundMesh;
  107657. }
  107658. }
  107659. declare module BABYLON {
  107660. /**
  107661. * Class containing static functions to help procedurally build meshes
  107662. */
  107663. export class TorusBuilder {
  107664. /**
  107665. * Creates a torus mesh
  107666. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107667. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107668. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107672. * @param name defines the name of the mesh
  107673. * @param options defines the options used to create the mesh
  107674. * @param scene defines the hosting scene
  107675. * @returns the torus mesh
  107676. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107677. */
  107678. static CreateTorus(name: string, options: {
  107679. diameter?: number;
  107680. thickness?: number;
  107681. tessellation?: number;
  107682. updatable?: boolean;
  107683. sideOrientation?: number;
  107684. frontUVs?: Vector4;
  107685. backUVs?: Vector4;
  107686. }, scene: any): Mesh;
  107687. }
  107688. }
  107689. declare module BABYLON {
  107690. /**
  107691. * Class containing static functions to help procedurally build meshes
  107692. */
  107693. export class CylinderBuilder {
  107694. /**
  107695. * Creates a cylinder or a cone mesh
  107696. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107697. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107698. * * 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.
  107699. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107700. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107701. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107702. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107703. * * 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).
  107704. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107705. * * 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).
  107706. * * 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
  107707. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107708. * * 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
  107709. * * 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.
  107710. * * If `enclose` is false, a ring surface is one element.
  107711. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107712. * * 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
  107713. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107714. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107716. * @param name defines the name of the mesh
  107717. * @param options defines the options used to create the mesh
  107718. * @param scene defines the hosting scene
  107719. * @returns the cylinder mesh
  107720. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107721. */
  107722. static CreateCylinder(name: string, options: {
  107723. height?: number;
  107724. diameterTop?: number;
  107725. diameterBottom?: number;
  107726. diameter?: number;
  107727. tessellation?: number;
  107728. subdivisions?: number;
  107729. arc?: number;
  107730. faceColors?: Color4[];
  107731. faceUV?: Vector4[];
  107732. updatable?: boolean;
  107733. hasRings?: boolean;
  107734. enclose?: boolean;
  107735. cap?: number;
  107736. sideOrientation?: number;
  107737. frontUVs?: Vector4;
  107738. backUVs?: Vector4;
  107739. }, scene: any): Mesh;
  107740. }
  107741. }
  107742. declare module BABYLON {
  107743. /**
  107744. * Options to modify the vr teleportation behavior.
  107745. */
  107746. export interface VRTeleportationOptions {
  107747. /**
  107748. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107749. */
  107750. floorMeshName?: string;
  107751. /**
  107752. * A list of meshes to be used as the teleportation floor. (default: empty)
  107753. */
  107754. floorMeshes?: Mesh[];
  107755. }
  107756. /**
  107757. * Options to modify the vr experience helper's behavior.
  107758. */
  107759. export interface VRExperienceHelperOptions extends WebVROptions {
  107760. /**
  107761. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107762. */
  107763. createDeviceOrientationCamera?: boolean;
  107764. /**
  107765. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107766. */
  107767. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107768. /**
  107769. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107770. */
  107771. laserToggle?: boolean;
  107772. /**
  107773. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107774. */
  107775. floorMeshes?: Mesh[];
  107776. /**
  107777. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107778. */
  107779. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107780. }
  107781. /**
  107782. * Event containing information after VR has been entered
  107783. */
  107784. export class OnAfterEnteringVRObservableEvent {
  107785. /**
  107786. * If entering vr was successful
  107787. */
  107788. success: boolean;
  107789. }
  107790. /**
  107791. * Helps to quickly add VR support to an existing scene.
  107792. * See http://doc.babylonjs.com/how_to/webvr_helper
  107793. */
  107794. export class VRExperienceHelper {
  107795. /** Options to modify the vr experience helper's behavior. */
  107796. webVROptions: VRExperienceHelperOptions;
  107797. private _scene;
  107798. private _position;
  107799. private _btnVR;
  107800. private _btnVRDisplayed;
  107801. private _webVRsupported;
  107802. private _webVRready;
  107803. private _webVRrequesting;
  107804. private _webVRpresenting;
  107805. private _hasEnteredVR;
  107806. private _fullscreenVRpresenting;
  107807. private _canvas;
  107808. private _webVRCamera;
  107809. private _vrDeviceOrientationCamera;
  107810. private _deviceOrientationCamera;
  107811. private _existingCamera;
  107812. private _onKeyDown;
  107813. private _onVrDisplayPresentChange;
  107814. private _onVRDisplayChanged;
  107815. private _onVRRequestPresentStart;
  107816. private _onVRRequestPresentComplete;
  107817. /**
  107818. * 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)
  107819. */
  107820. enableGazeEvenWhenNoPointerLock: boolean;
  107821. /**
  107822. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107823. */
  107824. exitVROnDoubleTap: boolean;
  107825. /**
  107826. * Observable raised right before entering VR.
  107827. */
  107828. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107829. /**
  107830. * Observable raised when entering VR has completed.
  107831. */
  107832. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107833. /**
  107834. * Observable raised when exiting VR.
  107835. */
  107836. onExitingVRObservable: Observable<VRExperienceHelper>;
  107837. /**
  107838. * Observable raised when controller mesh is loaded.
  107839. */
  107840. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107841. /** Return this.onEnteringVRObservable
  107842. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107843. */
  107844. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107845. /** Return this.onExitingVRObservable
  107846. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107847. */
  107848. readonly onExitingVR: Observable<VRExperienceHelper>;
  107849. /** Return this.onControllerMeshLoadedObservable
  107850. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107851. */
  107852. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107853. private _rayLength;
  107854. private _useCustomVRButton;
  107855. private _teleportationRequested;
  107856. private _teleportActive;
  107857. private _floorMeshName;
  107858. private _floorMeshesCollection;
  107859. private _rotationAllowed;
  107860. private _teleportBackwardsVector;
  107861. private _teleportationTarget;
  107862. private _isDefaultTeleportationTarget;
  107863. private _postProcessMove;
  107864. private _teleportationFillColor;
  107865. private _teleportationBorderColor;
  107866. private _rotationAngle;
  107867. private _haloCenter;
  107868. private _cameraGazer;
  107869. private _padSensibilityUp;
  107870. private _padSensibilityDown;
  107871. private _leftController;
  107872. private _rightController;
  107873. /**
  107874. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107875. */
  107876. onNewMeshSelected: Observable<AbstractMesh>;
  107877. /**
  107878. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107879. * This observable will provide the mesh and the controller used to select the mesh
  107880. */
  107881. onMeshSelectedWithController: Observable<{
  107882. mesh: AbstractMesh;
  107883. controller: WebVRController;
  107884. }>;
  107885. /**
  107886. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107887. */
  107888. onNewMeshPicked: Observable<PickingInfo>;
  107889. private _circleEase;
  107890. /**
  107891. * Observable raised before camera teleportation
  107892. */
  107893. onBeforeCameraTeleport: Observable<Vector3>;
  107894. /**
  107895. * Observable raised after camera teleportation
  107896. */
  107897. onAfterCameraTeleport: Observable<Vector3>;
  107898. /**
  107899. * Observable raised when current selected mesh gets unselected
  107900. */
  107901. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107902. private _raySelectionPredicate;
  107903. /**
  107904. * To be optionaly changed by user to define custom ray selection
  107905. */
  107906. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107907. /**
  107908. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107909. */
  107910. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107911. /**
  107912. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107913. */
  107914. teleportationEnabled: boolean;
  107915. private _defaultHeight;
  107916. private _teleportationInitialized;
  107917. private _interactionsEnabled;
  107918. private _interactionsRequested;
  107919. private _displayGaze;
  107920. private _displayLaserPointer;
  107921. /**
  107922. * The mesh used to display where the user is going to teleport.
  107923. */
  107924. /**
  107925. * Sets the mesh to be used to display where the user is going to teleport.
  107926. */
  107927. teleportationTarget: Mesh;
  107928. /**
  107929. * 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
  107930. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107931. * See http://doc.babylonjs.com/resources/baking_transformations
  107932. */
  107933. gazeTrackerMesh: Mesh;
  107934. /**
  107935. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107936. */
  107937. updateGazeTrackerScale: boolean;
  107938. /**
  107939. * If the gaze trackers color should be updated when selecting meshes
  107940. */
  107941. updateGazeTrackerColor: boolean;
  107942. /**
  107943. * If the controller laser color should be updated when selecting meshes
  107944. */
  107945. updateControllerLaserColor: boolean;
  107946. /**
  107947. * The gaze tracking mesh corresponding to the left controller
  107948. */
  107949. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  107950. /**
  107951. * The gaze tracking mesh corresponding to the right controller
  107952. */
  107953. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  107954. /**
  107955. * If the ray of the gaze should be displayed.
  107956. */
  107957. /**
  107958. * Sets if the ray of the gaze should be displayed.
  107959. */
  107960. displayGaze: boolean;
  107961. /**
  107962. * If the ray of the LaserPointer should be displayed.
  107963. */
  107964. /**
  107965. * Sets if the ray of the LaserPointer should be displayed.
  107966. */
  107967. displayLaserPointer: boolean;
  107968. /**
  107969. * The deviceOrientationCamera used as the camera when not in VR.
  107970. */
  107971. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  107972. /**
  107973. * Based on the current WebVR support, returns the current VR camera used.
  107974. */
  107975. readonly currentVRCamera: Nullable<Camera>;
  107976. /**
  107977. * The webVRCamera which is used when in VR.
  107978. */
  107979. readonly webVRCamera: WebVRFreeCamera;
  107980. /**
  107981. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  107982. */
  107983. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  107984. /**
  107985. * The html button that is used to trigger entering into VR.
  107986. */
  107987. readonly vrButton: Nullable<HTMLButtonElement>;
  107988. private readonly _teleportationRequestInitiated;
  107989. /**
  107990. * Defines wether or not Pointer lock should be requested when switching to
  107991. * full screen.
  107992. */
  107993. requestPointerLockOnFullScreen: boolean;
  107994. /**
  107995. * Instantiates a VRExperienceHelper.
  107996. * Helps to quickly add VR support to an existing scene.
  107997. * @param scene The scene the VRExperienceHelper belongs to.
  107998. * @param webVROptions Options to modify the vr experience helper's behavior.
  107999. */
  108000. constructor(scene: Scene,
  108001. /** Options to modify the vr experience helper's behavior. */
  108002. webVROptions?: VRExperienceHelperOptions);
  108003. private _onDefaultMeshLoaded;
  108004. private _onResize;
  108005. private _onFullscreenChange;
  108006. /**
  108007. * Gets a value indicating if we are currently in VR mode.
  108008. */
  108009. readonly isInVRMode: boolean;
  108010. private onVrDisplayPresentChange;
  108011. private onVRDisplayChanged;
  108012. private moveButtonToBottomRight;
  108013. private displayVRButton;
  108014. private updateButtonVisibility;
  108015. private _cachedAngularSensibility;
  108016. /**
  108017. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108018. * Otherwise, will use the fullscreen API.
  108019. */
  108020. enterVR(): void;
  108021. /**
  108022. * Attempt to exit VR, or fullscreen.
  108023. */
  108024. exitVR(): void;
  108025. /**
  108026. * The position of the vr experience helper.
  108027. */
  108028. /**
  108029. * Sets the position of the vr experience helper.
  108030. */
  108031. position: Vector3;
  108032. /**
  108033. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108034. */
  108035. enableInteractions(): void;
  108036. private readonly _noControllerIsActive;
  108037. private beforeRender;
  108038. private _isTeleportationFloor;
  108039. /**
  108040. * Adds a floor mesh to be used for teleportation.
  108041. * @param floorMesh the mesh to be used for teleportation.
  108042. */
  108043. addFloorMesh(floorMesh: Mesh): void;
  108044. /**
  108045. * Removes a floor mesh from being used for teleportation.
  108046. * @param floorMesh the mesh to be removed.
  108047. */
  108048. removeFloorMesh(floorMesh: Mesh): void;
  108049. /**
  108050. * Enables interactions and teleportation using the VR controllers and gaze.
  108051. * @param vrTeleportationOptions options to modify teleportation behavior.
  108052. */
  108053. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108054. private _onNewGamepadConnected;
  108055. private _tryEnableInteractionOnController;
  108056. private _onNewGamepadDisconnected;
  108057. private _enableInteractionOnController;
  108058. private _checkTeleportWithRay;
  108059. private _checkRotate;
  108060. private _checkTeleportBackwards;
  108061. private _enableTeleportationOnController;
  108062. private _createTeleportationCircles;
  108063. private _displayTeleportationTarget;
  108064. private _hideTeleportationTarget;
  108065. private _rotateCamera;
  108066. private _moveTeleportationSelectorTo;
  108067. private _workingVector;
  108068. private _workingQuaternion;
  108069. private _workingMatrix;
  108070. /**
  108071. * Teleports the users feet to the desired location
  108072. * @param location The location where the user's feet should be placed
  108073. */
  108074. teleportCamera(location: Vector3): void;
  108075. private _convertNormalToDirectionOfRay;
  108076. private _castRayAndSelectObject;
  108077. private _notifySelectedMeshUnselected;
  108078. /**
  108079. * Sets the color of the laser ray from the vr controllers.
  108080. * @param color new color for the ray.
  108081. */
  108082. changeLaserColor(color: Color3): void;
  108083. /**
  108084. * Sets the color of the ray from the vr headsets gaze.
  108085. * @param color new color for the ray.
  108086. */
  108087. changeGazeColor(color: Color3): void;
  108088. /**
  108089. * Exits VR and disposes of the vr experience helper
  108090. */
  108091. dispose(): void;
  108092. /**
  108093. * Gets the name of the VRExperienceHelper class
  108094. * @returns "VRExperienceHelper"
  108095. */
  108096. getClassName(): string;
  108097. }
  108098. }
  108099. declare module BABYLON {
  108100. /**
  108101. * Manages an XRSession to work with Babylon's engine
  108102. * @see https://doc.babylonjs.com/how_to/webxr
  108103. */
  108104. export class WebXRSessionManager implements IDisposable {
  108105. private scene;
  108106. /**
  108107. * Fires every time a new xrFrame arrives which can be used to update the camera
  108108. */
  108109. onXRFrameObservable: Observable<any>;
  108110. /**
  108111. * Fires when the xr session is ended either by the device or manually done
  108112. */
  108113. onXRSessionEnded: Observable<any>;
  108114. /**
  108115. * Underlying xr session
  108116. */
  108117. session: XRSession;
  108118. /**
  108119. * Type of reference space used when creating the session
  108120. */
  108121. referenceSpace: XRReferenceSpace;
  108122. /** @hidden */
  108123. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108124. /**
  108125. * Current XR frame
  108126. */
  108127. currentFrame: Nullable<XRFrame>;
  108128. private _xrNavigator;
  108129. private baseLayer;
  108130. /**
  108131. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108132. * @param scene The scene which the session should be created for
  108133. */
  108134. constructor(scene: Scene);
  108135. /**
  108136. * Initializes the manager
  108137. * After initialization enterXR can be called to start an XR session
  108138. * @returns Promise which resolves after it is initialized
  108139. */
  108140. initializeAsync(): Promise<void>;
  108141. /**
  108142. * Initializes an xr session
  108143. * @param xrSessionMode mode to initialize
  108144. * @returns a promise which will resolve once the session has been initialized
  108145. */
  108146. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108147. /**
  108148. * Sets the reference space on the xr session
  108149. * @param referenceSpace space to set
  108150. * @returns a promise that will resolve once the reference space has been set
  108151. */
  108152. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108153. /**
  108154. * Updates the render state of the session
  108155. * @param state state to set
  108156. * @returns a promise that resolves once the render state has been updated
  108157. */
  108158. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108159. /**
  108160. * Starts rendering to the xr layer
  108161. * @returns a promise that will resolve once rendering has started
  108162. */
  108163. startRenderingToXRAsync(): Promise<void>;
  108164. /**
  108165. * Stops the xrSession and restores the renderloop
  108166. * @returns Promise which resolves after it exits XR
  108167. */
  108168. exitXRAsync(): Promise<unknown>;
  108169. /**
  108170. * Checks if a session would be supported for the creation options specified
  108171. * @param sessionMode session mode to check if supported eg. immersive-vr
  108172. * @returns true if supported
  108173. */
  108174. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108175. /**
  108176. * @hidden
  108177. * Converts the render layer of xrSession to a render target
  108178. * @param session session to create render target for
  108179. * @param scene scene the new render target should be created for
  108180. */
  108181. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108182. /**
  108183. * Disposes of the session manager
  108184. */
  108185. dispose(): void;
  108186. }
  108187. }
  108188. declare module BABYLON {
  108189. /**
  108190. * WebXR Camera which holds the views for the xrSession
  108191. * @see https://doc.babylonjs.com/how_to/webxr
  108192. */
  108193. export class WebXRCamera extends FreeCamera {
  108194. private static _TmpMatrix;
  108195. /**
  108196. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108197. * @param name the name of the camera
  108198. * @param scene the scene to add the camera to
  108199. */
  108200. constructor(name: string, scene: Scene);
  108201. private _updateNumberOfRigCameras;
  108202. /** @hidden */
  108203. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108204. /**
  108205. * Updates the cameras position from the current pose information of the XR session
  108206. * @param xrSessionManager the session containing pose information
  108207. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108208. */
  108209. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108210. }
  108211. }
  108212. declare module BABYLON {
  108213. /**
  108214. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108215. */
  108216. export class WebXRManagedOutputCanvas implements IDisposable {
  108217. private helper;
  108218. private _canvas;
  108219. /**
  108220. * xrpresent context of the canvas which can be used to display/mirror xr content
  108221. */
  108222. canvasContext: WebGLRenderingContext;
  108223. /**
  108224. * xr layer for the canvas
  108225. */
  108226. xrLayer: Nullable<XRWebGLLayer>;
  108227. /**
  108228. * Initializes the xr layer for the session
  108229. * @param xrSession xr session
  108230. * @returns a promise that will resolve once the XR Layer has been created
  108231. */
  108232. initializeXRLayerAsync(xrSession: any): any;
  108233. /**
  108234. * Initializes the canvas to be added/removed upon entering/exiting xr
  108235. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108236. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108237. */
  108238. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108239. /**
  108240. * Disposes of the object
  108241. */
  108242. dispose(): void;
  108243. private _setManagedOutputCanvas;
  108244. private _addCanvas;
  108245. private _removeCanvas;
  108246. }
  108247. }
  108248. declare module BABYLON {
  108249. /**
  108250. * States of the webXR experience
  108251. */
  108252. export enum WebXRState {
  108253. /**
  108254. * Transitioning to being in XR mode
  108255. */
  108256. ENTERING_XR = 0,
  108257. /**
  108258. * Transitioning to non XR mode
  108259. */
  108260. EXITING_XR = 1,
  108261. /**
  108262. * In XR mode and presenting
  108263. */
  108264. IN_XR = 2,
  108265. /**
  108266. * Not entered XR mode
  108267. */
  108268. NOT_IN_XR = 3
  108269. }
  108270. /**
  108271. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108272. * @see https://doc.babylonjs.com/how_to/webxr
  108273. */
  108274. export class WebXRExperienceHelper implements IDisposable {
  108275. private scene;
  108276. /**
  108277. * 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
  108278. */
  108279. container: AbstractMesh;
  108280. /**
  108281. * Camera used to render xr content
  108282. */
  108283. camera: WebXRCamera;
  108284. /**
  108285. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108286. */
  108287. state: WebXRState;
  108288. private _setState;
  108289. private static _TmpVector;
  108290. /**
  108291. * Fires when the state of the experience helper has changed
  108292. */
  108293. onStateChangedObservable: Observable<WebXRState>;
  108294. /** Session manager used to keep track of xr session */
  108295. sessionManager: WebXRSessionManager;
  108296. private _nonVRCamera;
  108297. private _originalSceneAutoClear;
  108298. private _supported;
  108299. /**
  108300. * Creates the experience helper
  108301. * @param scene the scene to attach the experience helper to
  108302. * @returns a promise for the experience helper
  108303. */
  108304. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108305. /**
  108306. * Creates a WebXRExperienceHelper
  108307. * @param scene The scene the helper should be created in
  108308. */
  108309. private constructor();
  108310. /**
  108311. * Exits XR mode and returns the scene to its original state
  108312. * @returns promise that resolves after xr mode has exited
  108313. */
  108314. exitXRAsync(): Promise<unknown>;
  108315. /**
  108316. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108317. * @param sessionCreationOptions options for the XR session
  108318. * @param referenceSpaceType frame of reference of the XR session
  108319. * @param outputCanvas the output canvas that will be used to enter XR mode
  108320. * @returns promise that resolves after xr mode has entered
  108321. */
  108322. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108323. /**
  108324. * Updates the global position of the camera by moving the camera's container
  108325. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108326. * @param position The desired global position of the camera
  108327. */
  108328. setPositionOfCameraUsingContainer(position: Vector3): void;
  108329. /**
  108330. * Rotates the xr camera by rotating the camera's container around the camera's position
  108331. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108332. * @param rotation the desired quaternion rotation to apply to the camera
  108333. */
  108334. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108335. /**
  108336. * Disposes of the experience helper
  108337. */
  108338. dispose(): void;
  108339. }
  108340. }
  108341. declare module BABYLON {
  108342. /**
  108343. * Button which can be used to enter a different mode of XR
  108344. */
  108345. export class WebXREnterExitUIButton {
  108346. /** button element */
  108347. element: HTMLElement;
  108348. /** XR initialization options for the button */
  108349. sessionMode: XRSessionMode;
  108350. /** Reference space type */
  108351. referenceSpaceType: XRReferenceSpaceType;
  108352. /**
  108353. * Creates a WebXREnterExitUIButton
  108354. * @param element button element
  108355. * @param sessionMode XR initialization session mode
  108356. * @param referenceSpaceType the type of reference space to be used
  108357. */
  108358. constructor(
  108359. /** button element */
  108360. element: HTMLElement,
  108361. /** XR initialization options for the button */
  108362. sessionMode: XRSessionMode,
  108363. /** Reference space type */
  108364. referenceSpaceType: XRReferenceSpaceType);
  108365. /**
  108366. * Overwritable function which can be used to update the button's visuals when the state changes
  108367. * @param activeButton the current active button in the UI
  108368. */
  108369. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108370. }
  108371. /**
  108372. * Options to create the webXR UI
  108373. */
  108374. export class WebXREnterExitUIOptions {
  108375. /**
  108376. * Context to enter xr with
  108377. */
  108378. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108379. /**
  108380. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108381. */
  108382. customButtons?: Array<WebXREnterExitUIButton>;
  108383. }
  108384. /**
  108385. * UI to allow the user to enter/exit XR mode
  108386. */
  108387. export class WebXREnterExitUI implements IDisposable {
  108388. private scene;
  108389. private _overlay;
  108390. private _buttons;
  108391. private _activeButton;
  108392. /**
  108393. * Fired every time the active button is changed.
  108394. *
  108395. * When xr is entered via a button that launches xr that button will be the callback parameter
  108396. *
  108397. * When exiting xr the callback parameter will be null)
  108398. */
  108399. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108400. /**
  108401. * Creates UI to allow the user to enter/exit XR mode
  108402. * @param scene the scene to add the ui to
  108403. * @param helper the xr experience helper to enter/exit xr with
  108404. * @param options options to configure the UI
  108405. * @returns the created ui
  108406. */
  108407. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108408. private constructor();
  108409. private _updateButtons;
  108410. /**
  108411. * Disposes of the object
  108412. */
  108413. dispose(): void;
  108414. }
  108415. }
  108416. declare module BABYLON {
  108417. /**
  108418. * Represents an XR input
  108419. */
  108420. export class WebXRController {
  108421. private scene;
  108422. /** The underlying input source for the controller */
  108423. inputSource: XRInputSource;
  108424. private parentContainer;
  108425. /**
  108426. * 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
  108427. */
  108428. grip?: AbstractMesh;
  108429. /**
  108430. * Pointer which can be used to select objects or attach a visible laser to
  108431. */
  108432. pointer: AbstractMesh;
  108433. /**
  108434. * Event that fires when the controller is removed/disposed
  108435. */
  108436. onDisposeObservable: Observable<{}>;
  108437. private _tmpMatrix;
  108438. private _tmpQuaternion;
  108439. private _tmpVector;
  108440. /**
  108441. * Creates the controller
  108442. * @see https://doc.babylonjs.com/how_to/webxr
  108443. * @param scene the scene which the controller should be associated to
  108444. * @param inputSource the underlying input source for the controller
  108445. * @param parentContainer parent that the controller meshes should be children of
  108446. */
  108447. constructor(scene: Scene,
  108448. /** The underlying input source for the controller */
  108449. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108450. /**
  108451. * Updates the controller pose based on the given XRFrame
  108452. * @param xrFrame xr frame to update the pose with
  108453. * @param referenceSpace reference space to use
  108454. */
  108455. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108456. /**
  108457. * Gets a world space ray coming from the controller
  108458. * @param result the resulting ray
  108459. */
  108460. getWorldPointerRayToRef(result: Ray): void;
  108461. /**
  108462. * Disposes of the object
  108463. */
  108464. dispose(): void;
  108465. }
  108466. }
  108467. declare module BABYLON {
  108468. /**
  108469. * XR input used to track XR inputs such as controllers/rays
  108470. */
  108471. export class WebXRInput implements IDisposable {
  108472. /**
  108473. * Base experience the input listens to
  108474. */
  108475. baseExperience: WebXRExperienceHelper;
  108476. /**
  108477. * XR controllers being tracked
  108478. */
  108479. controllers: Array<WebXRController>;
  108480. private _frameObserver;
  108481. private _stateObserver;
  108482. /**
  108483. * Event when a controller has been connected/added
  108484. */
  108485. onControllerAddedObservable: Observable<WebXRController>;
  108486. /**
  108487. * Event when a controller has been removed/disconnected
  108488. */
  108489. onControllerRemovedObservable: Observable<WebXRController>;
  108490. /**
  108491. * Initializes the WebXRInput
  108492. * @param baseExperience experience helper which the input should be created for
  108493. */
  108494. constructor(
  108495. /**
  108496. * Base experience the input listens to
  108497. */
  108498. baseExperience: WebXRExperienceHelper);
  108499. private _onInputSourcesChange;
  108500. private _addAndRemoveControllers;
  108501. /**
  108502. * Disposes of the object
  108503. */
  108504. dispose(): void;
  108505. }
  108506. }
  108507. declare module BABYLON {
  108508. /**
  108509. * Enables teleportation
  108510. */
  108511. export class WebXRControllerTeleportation {
  108512. private _teleportationFillColor;
  108513. private _teleportationBorderColor;
  108514. private _tmpRay;
  108515. private _tmpVector;
  108516. /**
  108517. * Creates a WebXRControllerTeleportation
  108518. * @param input input manager to add teleportation to
  108519. * @param floorMeshes floormeshes which can be teleported to
  108520. */
  108521. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108522. }
  108523. }
  108524. declare module BABYLON {
  108525. /**
  108526. * Handles pointer input automatically for the pointer of XR controllers
  108527. */
  108528. export class WebXRControllerPointerSelection {
  108529. private static _idCounter;
  108530. private _tmpRay;
  108531. /**
  108532. * Creates a WebXRControllerPointerSelection
  108533. * @param input input manager to setup pointer selection
  108534. */
  108535. constructor(input: WebXRInput);
  108536. private _convertNormalToDirectionOfRay;
  108537. private _updatePointerDistance;
  108538. }
  108539. }
  108540. declare module BABYLON {
  108541. /**
  108542. * Class used to represent data loading progression
  108543. */
  108544. export class SceneLoaderProgressEvent {
  108545. /** defines if data length to load can be evaluated */
  108546. readonly lengthComputable: boolean;
  108547. /** defines the loaded data length */
  108548. readonly loaded: number;
  108549. /** defines the data length to load */
  108550. readonly total: number;
  108551. /**
  108552. * Create a new progress event
  108553. * @param lengthComputable defines if data length to load can be evaluated
  108554. * @param loaded defines the loaded data length
  108555. * @param total defines the data length to load
  108556. */
  108557. constructor(
  108558. /** defines if data length to load can be evaluated */
  108559. lengthComputable: boolean,
  108560. /** defines the loaded data length */
  108561. loaded: number,
  108562. /** defines the data length to load */
  108563. total: number);
  108564. /**
  108565. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108566. * @param event defines the source event
  108567. * @returns a new SceneLoaderProgressEvent
  108568. */
  108569. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108570. }
  108571. /**
  108572. * Interface used by SceneLoader plugins to define supported file extensions
  108573. */
  108574. export interface ISceneLoaderPluginExtensions {
  108575. /**
  108576. * Defines the list of supported extensions
  108577. */
  108578. [extension: string]: {
  108579. isBinary: boolean;
  108580. };
  108581. }
  108582. /**
  108583. * Interface used by SceneLoader plugin factory
  108584. */
  108585. export interface ISceneLoaderPluginFactory {
  108586. /**
  108587. * Defines the name of the factory
  108588. */
  108589. name: string;
  108590. /**
  108591. * Function called to create a new plugin
  108592. * @return the new plugin
  108593. */
  108594. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108595. /**
  108596. * Boolean indicating if the plugin can direct load specific data
  108597. */
  108598. canDirectLoad?: (data: string) => boolean;
  108599. }
  108600. /**
  108601. * Interface used to define a SceneLoader plugin
  108602. */
  108603. export interface ISceneLoaderPlugin {
  108604. /**
  108605. * The friendly name of this plugin.
  108606. */
  108607. name: string;
  108608. /**
  108609. * The file extensions supported by this plugin.
  108610. */
  108611. extensions: string | ISceneLoaderPluginExtensions;
  108612. /**
  108613. * Import meshes into a scene.
  108614. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108615. * @param scene The scene to import into
  108616. * @param data The data to import
  108617. * @param rootUrl The root url for scene and resources
  108618. * @param meshes The meshes array to import into
  108619. * @param particleSystems The particle systems array to import into
  108620. * @param skeletons The skeletons array to import into
  108621. * @param onError The callback when import fails
  108622. * @returns True if successful or false otherwise
  108623. */
  108624. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108625. /**
  108626. * Load into a scene.
  108627. * @param scene The scene to load into
  108628. * @param data The data to import
  108629. * @param rootUrl The root url for scene and resources
  108630. * @param onError The callback when import fails
  108631. * @returns true if successful or false otherwise
  108632. */
  108633. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108634. /**
  108635. * The callback that returns true if the data can be directly loaded.
  108636. */
  108637. canDirectLoad?: (data: string) => boolean;
  108638. /**
  108639. * The callback that allows custom handling of the root url based on the response url.
  108640. */
  108641. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108642. /**
  108643. * Load into an asset container.
  108644. * @param scene The scene to load into
  108645. * @param data The data to import
  108646. * @param rootUrl The root url for scene and resources
  108647. * @param onError The callback when import fails
  108648. * @returns The loaded asset container
  108649. */
  108650. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108651. }
  108652. /**
  108653. * Interface used to define an async SceneLoader plugin
  108654. */
  108655. export interface ISceneLoaderPluginAsync {
  108656. /**
  108657. * The friendly name of this plugin.
  108658. */
  108659. name: string;
  108660. /**
  108661. * The file extensions supported by this plugin.
  108662. */
  108663. extensions: string | ISceneLoaderPluginExtensions;
  108664. /**
  108665. * Import meshes into a scene.
  108666. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108667. * @param scene The scene to import into
  108668. * @param data The data to import
  108669. * @param rootUrl The root url for scene and resources
  108670. * @param onProgress The callback when the load progresses
  108671. * @param fileName Defines the name of the file to load
  108672. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108673. */
  108674. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108675. meshes: AbstractMesh[];
  108676. particleSystems: IParticleSystem[];
  108677. skeletons: Skeleton[];
  108678. animationGroups: AnimationGroup[];
  108679. }>;
  108680. /**
  108681. * Load into a scene.
  108682. * @param scene The scene to load into
  108683. * @param data The data to import
  108684. * @param rootUrl The root url for scene and resources
  108685. * @param onProgress The callback when the load progresses
  108686. * @param fileName Defines the name of the file to load
  108687. * @returns Nothing
  108688. */
  108689. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108690. /**
  108691. * The callback that returns true if the data can be directly loaded.
  108692. */
  108693. canDirectLoad?: (data: string) => boolean;
  108694. /**
  108695. * The callback that allows custom handling of the root url based on the response url.
  108696. */
  108697. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108698. /**
  108699. * Load into an asset container.
  108700. * @param scene The scene to load into
  108701. * @param data The data to import
  108702. * @param rootUrl The root url for scene and resources
  108703. * @param onProgress The callback when the load progresses
  108704. * @param fileName Defines the name of the file to load
  108705. * @returns The loaded asset container
  108706. */
  108707. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108708. }
  108709. /**
  108710. * Class used to load scene from various file formats using registered plugins
  108711. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108712. */
  108713. export class SceneLoader {
  108714. /**
  108715. * No logging while loading
  108716. */
  108717. static readonly NO_LOGGING: number;
  108718. /**
  108719. * Minimal logging while loading
  108720. */
  108721. static readonly MINIMAL_LOGGING: number;
  108722. /**
  108723. * Summary logging while loading
  108724. */
  108725. static readonly SUMMARY_LOGGING: number;
  108726. /**
  108727. * Detailled logging while loading
  108728. */
  108729. static readonly DETAILED_LOGGING: number;
  108730. /**
  108731. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108732. */
  108733. static ForceFullSceneLoadingForIncremental: boolean;
  108734. /**
  108735. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108736. */
  108737. static ShowLoadingScreen: boolean;
  108738. /**
  108739. * Defines the current logging level (while loading the scene)
  108740. * @ignorenaming
  108741. */
  108742. static loggingLevel: number;
  108743. /**
  108744. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108745. */
  108746. static CleanBoneMatrixWeights: boolean;
  108747. /**
  108748. * Event raised when a plugin is used to load a scene
  108749. */
  108750. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108751. private static _registeredPlugins;
  108752. private static _getDefaultPlugin;
  108753. private static _getPluginForExtension;
  108754. private static _getPluginForDirectLoad;
  108755. private static _getPluginForFilename;
  108756. private static _getDirectLoad;
  108757. private static _loadData;
  108758. private static _getFileInfo;
  108759. /**
  108760. * Gets a plugin that can load the given extension
  108761. * @param extension defines the extension to load
  108762. * @returns a plugin or null if none works
  108763. */
  108764. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108765. /**
  108766. * Gets a boolean indicating that the given extension can be loaded
  108767. * @param extension defines the extension to load
  108768. * @returns true if the extension is supported
  108769. */
  108770. static IsPluginForExtensionAvailable(extension: string): boolean;
  108771. /**
  108772. * Adds a new plugin to the list of registered plugins
  108773. * @param plugin defines the plugin to add
  108774. */
  108775. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108776. /**
  108777. * Import meshes into a scene
  108778. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108779. * @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)
  108780. * @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)
  108781. * @param scene the instance of BABYLON.Scene to append to
  108782. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108783. * @param onProgress a callback with a progress event for each file being loaded
  108784. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108785. * @param pluginExtension the extension used to determine the plugin
  108786. * @returns The loaded plugin
  108787. */
  108788. 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>;
  108789. /**
  108790. * Import meshes into a scene
  108791. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108792. * @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)
  108793. * @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)
  108794. * @param scene the instance of BABYLON.Scene to append to
  108795. * @param onProgress a callback with a progress event for each file being loaded
  108796. * @param pluginExtension the extension used to determine the plugin
  108797. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108798. */
  108799. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108800. meshes: AbstractMesh[];
  108801. particleSystems: IParticleSystem[];
  108802. skeletons: Skeleton[];
  108803. animationGroups: AnimationGroup[];
  108804. }>;
  108805. /**
  108806. * Load a scene
  108807. * @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)
  108808. * @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)
  108809. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108810. * @param onSuccess a callback with the scene when import succeeds
  108811. * @param onProgress a callback with a progress event for each file being loaded
  108812. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108813. * @param pluginExtension the extension used to determine the plugin
  108814. * @returns The loaded plugin
  108815. */
  108816. 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>;
  108817. /**
  108818. * Load a scene
  108819. * @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)
  108820. * @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)
  108821. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108822. * @param onProgress a callback with a progress event for each file being loaded
  108823. * @param pluginExtension the extension used to determine the plugin
  108824. * @returns The loaded scene
  108825. */
  108826. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108827. /**
  108828. * Append a scene
  108829. * @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)
  108830. * @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)
  108831. * @param scene is the instance of BABYLON.Scene to append to
  108832. * @param onSuccess a callback with the scene when import succeeds
  108833. * @param onProgress a callback with a progress event for each file being loaded
  108834. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108835. * @param pluginExtension the extension used to determine the plugin
  108836. * @returns The loaded plugin
  108837. */
  108838. 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>;
  108839. /**
  108840. * Append a scene
  108841. * @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)
  108842. * @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)
  108843. * @param scene is the instance of BABYLON.Scene to append to
  108844. * @param onProgress a callback with a progress event for each file being loaded
  108845. * @param pluginExtension the extension used to determine the plugin
  108846. * @returns The given scene
  108847. */
  108848. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108849. /**
  108850. * Load a scene into an asset container
  108851. * @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)
  108852. * @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)
  108853. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108854. * @param onSuccess a callback with the scene when import succeeds
  108855. * @param onProgress a callback with a progress event for each file being loaded
  108856. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108857. * @param pluginExtension the extension used to determine the plugin
  108858. * @returns The loaded plugin
  108859. */
  108860. 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>;
  108861. /**
  108862. * Load a scene into an asset container
  108863. * @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)
  108864. * @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)
  108865. * @param scene is the instance of Scene to append to
  108866. * @param onProgress a callback with a progress event for each file being loaded
  108867. * @param pluginExtension the extension used to determine the plugin
  108868. * @returns The loaded asset container
  108869. */
  108870. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108871. }
  108872. }
  108873. declare module BABYLON {
  108874. /**
  108875. * Generic Controller
  108876. */
  108877. export class GenericController extends WebVRController {
  108878. /**
  108879. * Base Url for the controller model.
  108880. */
  108881. static readonly MODEL_BASE_URL: string;
  108882. /**
  108883. * File name for the controller model.
  108884. */
  108885. static readonly MODEL_FILENAME: string;
  108886. /**
  108887. * Creates a new GenericController from a gamepad
  108888. * @param vrGamepad the gamepad that the controller should be created from
  108889. */
  108890. constructor(vrGamepad: any);
  108891. /**
  108892. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108893. * @param scene scene in which to add meshes
  108894. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108895. */
  108896. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108897. /**
  108898. * Called once for each button that changed state since the last frame
  108899. * @param buttonIdx Which button index changed
  108900. * @param state New state of the button
  108901. * @param changes Which properties on the state changed since last frame
  108902. */
  108903. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108904. }
  108905. }
  108906. declare module BABYLON {
  108907. /**
  108908. * Defines the WindowsMotionController object that the state of the windows motion controller
  108909. */
  108910. export class WindowsMotionController extends WebVRController {
  108911. /**
  108912. * The base url used to load the left and right controller models
  108913. */
  108914. static MODEL_BASE_URL: string;
  108915. /**
  108916. * The name of the left controller model file
  108917. */
  108918. static MODEL_LEFT_FILENAME: string;
  108919. /**
  108920. * The name of the right controller model file
  108921. */
  108922. static MODEL_RIGHT_FILENAME: string;
  108923. /**
  108924. * The controller name prefix for this controller type
  108925. */
  108926. static readonly GAMEPAD_ID_PREFIX: string;
  108927. /**
  108928. * The controller id pattern for this controller type
  108929. */
  108930. private static readonly GAMEPAD_ID_PATTERN;
  108931. private _loadedMeshInfo;
  108932. private readonly _mapping;
  108933. /**
  108934. * Fired when the trackpad on this controller is clicked
  108935. */
  108936. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108937. /**
  108938. * Fired when the trackpad on this controller is modified
  108939. */
  108940. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108941. /**
  108942. * The current x and y values of this controller's trackpad
  108943. */
  108944. trackpad: StickValues;
  108945. /**
  108946. * Creates a new WindowsMotionController from a gamepad
  108947. * @param vrGamepad the gamepad that the controller should be created from
  108948. */
  108949. constructor(vrGamepad: any);
  108950. /**
  108951. * Fired when the trigger on this controller is modified
  108952. */
  108953. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108954. /**
  108955. * Fired when the menu button on this controller is modified
  108956. */
  108957. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108958. /**
  108959. * Fired when the grip button on this controller is modified
  108960. */
  108961. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108962. /**
  108963. * Fired when the thumbstick button on this controller is modified
  108964. */
  108965. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108966. /**
  108967. * Fired when the touchpad button on this controller is modified
  108968. */
  108969. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108970. /**
  108971. * Fired when the touchpad values on this controller are modified
  108972. */
  108973. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  108974. private _updateTrackpad;
  108975. /**
  108976. * Called once per frame by the engine.
  108977. */
  108978. update(): void;
  108979. /**
  108980. * Called once for each button that changed state since the last frame
  108981. * @param buttonIdx Which button index changed
  108982. * @param state New state of the button
  108983. * @param changes Which properties on the state changed since last frame
  108984. */
  108985. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108986. /**
  108987. * Moves the buttons on the controller mesh based on their current state
  108988. * @param buttonName the name of the button to move
  108989. * @param buttonValue the value of the button which determines the buttons new position
  108990. */
  108991. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108992. /**
  108993. * Moves the axis on the controller mesh based on its current state
  108994. * @param axis the index of the axis
  108995. * @param axisValue the value of the axis which determines the meshes new position
  108996. * @hidden
  108997. */
  108998. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108999. /**
  109000. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109001. * @param scene scene in which to add meshes
  109002. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109003. */
  109004. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109005. /**
  109006. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109007. * can be transformed by button presses and axes values, based on this._mapping.
  109008. *
  109009. * @param scene scene in which the meshes exist
  109010. * @param meshes list of meshes that make up the controller model to process
  109011. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109012. */
  109013. private processModel;
  109014. private createMeshInfo;
  109015. /**
  109016. * Gets the ray of the controller in the direction the controller is pointing
  109017. * @param length the length the resulting ray should be
  109018. * @returns a ray in the direction the controller is pointing
  109019. */
  109020. getForwardRay(length?: number): Ray;
  109021. /**
  109022. * Disposes of the controller
  109023. */
  109024. dispose(): void;
  109025. }
  109026. }
  109027. declare module BABYLON {
  109028. /**
  109029. * Oculus Touch Controller
  109030. */
  109031. export class OculusTouchController extends WebVRController {
  109032. /**
  109033. * Base Url for the controller model.
  109034. */
  109035. static MODEL_BASE_URL: string;
  109036. /**
  109037. * File name for the left controller model.
  109038. */
  109039. static MODEL_LEFT_FILENAME: string;
  109040. /**
  109041. * File name for the right controller model.
  109042. */
  109043. static MODEL_RIGHT_FILENAME: string;
  109044. /**
  109045. * Base Url for the Quest controller model.
  109046. */
  109047. static QUEST_MODEL_BASE_URL: string;
  109048. /**
  109049. * @hidden
  109050. * If the controllers are running on a device that needs the updated Quest controller models
  109051. */
  109052. static _IsQuest: boolean;
  109053. /**
  109054. * Fired when the secondary trigger on this controller is modified
  109055. */
  109056. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109057. /**
  109058. * Fired when the thumb rest on this controller is modified
  109059. */
  109060. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109061. /**
  109062. * Creates a new OculusTouchController from a gamepad
  109063. * @param vrGamepad the gamepad that the controller should be created from
  109064. */
  109065. constructor(vrGamepad: any);
  109066. /**
  109067. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109068. * @param scene scene in which to add meshes
  109069. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109070. */
  109071. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109072. /**
  109073. * Fired when the A button on this controller is modified
  109074. */
  109075. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109076. /**
  109077. * Fired when the B button on this controller is modified
  109078. */
  109079. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109080. /**
  109081. * Fired when the X button on this controller is modified
  109082. */
  109083. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109084. /**
  109085. * Fired when the Y button on this controller is modified
  109086. */
  109087. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109088. /**
  109089. * Called once for each button that changed state since the last frame
  109090. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109091. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109092. * 2) secondary trigger (same)
  109093. * 3) A (right) X (left), touch, pressed = value
  109094. * 4) B / Y
  109095. * 5) thumb rest
  109096. * @param buttonIdx Which button index changed
  109097. * @param state New state of the button
  109098. * @param changes Which properties on the state changed since last frame
  109099. */
  109100. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109101. }
  109102. }
  109103. declare module BABYLON {
  109104. /**
  109105. * Vive Controller
  109106. */
  109107. export class ViveController extends WebVRController {
  109108. /**
  109109. * Base Url for the controller model.
  109110. */
  109111. static MODEL_BASE_URL: string;
  109112. /**
  109113. * File name for the controller model.
  109114. */
  109115. static MODEL_FILENAME: string;
  109116. /**
  109117. * Creates a new ViveController from a gamepad
  109118. * @param vrGamepad the gamepad that the controller should be created from
  109119. */
  109120. constructor(vrGamepad: any);
  109121. /**
  109122. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109123. * @param scene scene in which to add meshes
  109124. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109125. */
  109126. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109127. /**
  109128. * Fired when the left button on this controller is modified
  109129. */
  109130. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109131. /**
  109132. * Fired when the right button on this controller is modified
  109133. */
  109134. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109135. /**
  109136. * Fired when the menu button on this controller is modified
  109137. */
  109138. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109139. /**
  109140. * Called once for each button that changed state since the last frame
  109141. * Vive mapping:
  109142. * 0: touchpad
  109143. * 1: trigger
  109144. * 2: left AND right buttons
  109145. * 3: menu button
  109146. * @param buttonIdx Which button index changed
  109147. * @param state New state of the button
  109148. * @param changes Which properties on the state changed since last frame
  109149. */
  109150. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109151. }
  109152. }
  109153. declare module BABYLON {
  109154. /**
  109155. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109156. */
  109157. export class WebXRControllerModelLoader {
  109158. /**
  109159. * Creates the WebXRControllerModelLoader
  109160. * @param input xr input that creates the controllers
  109161. */
  109162. constructor(input: WebXRInput);
  109163. }
  109164. }
  109165. declare module BABYLON {
  109166. /**
  109167. * Contains an array of blocks representing the octree
  109168. */
  109169. export interface IOctreeContainer<T> {
  109170. /**
  109171. * Blocks within the octree
  109172. */
  109173. blocks: Array<OctreeBlock<T>>;
  109174. }
  109175. /**
  109176. * Class used to store a cell in an octree
  109177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109178. */
  109179. export class OctreeBlock<T> {
  109180. /**
  109181. * Gets the content of the current block
  109182. */
  109183. entries: T[];
  109184. /**
  109185. * Gets the list of block children
  109186. */
  109187. blocks: Array<OctreeBlock<T>>;
  109188. private _depth;
  109189. private _maxDepth;
  109190. private _capacity;
  109191. private _minPoint;
  109192. private _maxPoint;
  109193. private _boundingVectors;
  109194. private _creationFunc;
  109195. /**
  109196. * Creates a new block
  109197. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109198. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109199. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109200. * @param depth defines the current depth of this block in the octree
  109201. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109202. * @param creationFunc defines a callback to call when an element is added to the block
  109203. */
  109204. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109205. /**
  109206. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109207. */
  109208. readonly capacity: number;
  109209. /**
  109210. * Gets the minimum vector (in world space) of the block's bounding box
  109211. */
  109212. readonly minPoint: Vector3;
  109213. /**
  109214. * Gets the maximum vector (in world space) of the block's bounding box
  109215. */
  109216. readonly maxPoint: Vector3;
  109217. /**
  109218. * Add a new element to this block
  109219. * @param entry defines the element to add
  109220. */
  109221. addEntry(entry: T): void;
  109222. /**
  109223. * Remove an element from this block
  109224. * @param entry defines the element to remove
  109225. */
  109226. removeEntry(entry: T): void;
  109227. /**
  109228. * Add an array of elements to this block
  109229. * @param entries defines the array of elements to add
  109230. */
  109231. addEntries(entries: T[]): void;
  109232. /**
  109233. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109234. * @param frustumPlanes defines the frustum planes to test
  109235. * @param selection defines the array to store current content if selection is positive
  109236. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109237. */
  109238. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109239. /**
  109240. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109241. * @param sphereCenter defines the bounding sphere center
  109242. * @param sphereRadius defines the bounding sphere radius
  109243. * @param selection defines the array to store current content if selection is positive
  109244. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109245. */
  109246. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109247. /**
  109248. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109249. * @param ray defines the ray to test with
  109250. * @param selection defines the array to store current content if selection is positive
  109251. */
  109252. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109253. /**
  109254. * Subdivide the content into child blocks (this block will then be empty)
  109255. */
  109256. createInnerBlocks(): void;
  109257. /**
  109258. * @hidden
  109259. */
  109260. 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;
  109261. }
  109262. }
  109263. declare module BABYLON {
  109264. /**
  109265. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109266. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109267. */
  109268. export class Octree<T> {
  109269. /** 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.) */
  109270. maxDepth: number;
  109271. /**
  109272. * Blocks within the octree containing objects
  109273. */
  109274. blocks: Array<OctreeBlock<T>>;
  109275. /**
  109276. * Content stored in the octree
  109277. */
  109278. dynamicContent: T[];
  109279. private _maxBlockCapacity;
  109280. private _selectionContent;
  109281. private _creationFunc;
  109282. /**
  109283. * Creates a octree
  109284. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109285. * @param creationFunc function to be used to instatiate the octree
  109286. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109287. * @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.)
  109288. */
  109289. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109290. /** 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.) */
  109291. maxDepth?: number);
  109292. /**
  109293. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109294. * @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);
  109295. * @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);
  109296. * @param entries meshes to be added to the octree blocks
  109297. */
  109298. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109299. /**
  109300. * Adds a mesh to the octree
  109301. * @param entry Mesh to add to the octree
  109302. */
  109303. addMesh(entry: T): void;
  109304. /**
  109305. * Remove an element from the octree
  109306. * @param entry defines the element to remove
  109307. */
  109308. removeMesh(entry: T): void;
  109309. /**
  109310. * Selects an array of meshes within the frustum
  109311. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109312. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109313. * @returns array of meshes within the frustum
  109314. */
  109315. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109316. /**
  109317. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109318. * @param sphereCenter defines the bounding sphere center
  109319. * @param sphereRadius defines the bounding sphere radius
  109320. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109321. * @returns an array of objects that intersect the sphere
  109322. */
  109323. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109324. /**
  109325. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109326. * @param ray defines the ray to test with
  109327. * @returns array of intersected objects
  109328. */
  109329. intersectsRay(ray: Ray): SmartArray<T>;
  109330. /**
  109331. * Adds a mesh into the octree block if it intersects the block
  109332. */
  109333. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109334. /**
  109335. * Adds a submesh into the octree block if it intersects the block
  109336. */
  109337. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109338. }
  109339. }
  109340. declare module BABYLON {
  109341. interface Scene {
  109342. /**
  109343. * @hidden
  109344. * Backing Filed
  109345. */
  109346. _selectionOctree: Octree<AbstractMesh>;
  109347. /**
  109348. * Gets the octree used to boost mesh selection (picking)
  109349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109350. */
  109351. selectionOctree: Octree<AbstractMesh>;
  109352. /**
  109353. * Creates or updates the octree used to boost selection (picking)
  109354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109355. * @param maxCapacity defines the maximum capacity per leaf
  109356. * @param maxDepth defines the maximum depth of the octree
  109357. * @returns an octree of AbstractMesh
  109358. */
  109359. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109360. }
  109361. interface AbstractMesh {
  109362. /**
  109363. * @hidden
  109364. * Backing Field
  109365. */
  109366. _submeshesOctree: Octree<SubMesh>;
  109367. /**
  109368. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109369. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109370. * @param maxCapacity defines the maximum size of each block (64 by default)
  109371. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109372. * @returns the new octree
  109373. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109374. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109375. */
  109376. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109377. }
  109378. /**
  109379. * Defines the octree scene component responsible to manage any octrees
  109380. * in a given scene.
  109381. */
  109382. export class OctreeSceneComponent {
  109383. /**
  109384. * The component name help to identify the component in the list of scene components.
  109385. */
  109386. readonly name: string;
  109387. /**
  109388. * The scene the component belongs to.
  109389. */
  109390. scene: Scene;
  109391. /**
  109392. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109393. */
  109394. readonly checksIsEnabled: boolean;
  109395. /**
  109396. * Creates a new instance of the component for the given scene
  109397. * @param scene Defines the scene to register the component in
  109398. */
  109399. constructor(scene: Scene);
  109400. /**
  109401. * Registers the component in a given scene
  109402. */
  109403. register(): void;
  109404. /**
  109405. * Return the list of active meshes
  109406. * @returns the list of active meshes
  109407. */
  109408. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109409. /**
  109410. * Return the list of active sub meshes
  109411. * @param mesh The mesh to get the candidates sub meshes from
  109412. * @returns the list of active sub meshes
  109413. */
  109414. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109415. private _tempRay;
  109416. /**
  109417. * Return the list of sub meshes intersecting with a given local ray
  109418. * @param mesh defines the mesh to find the submesh for
  109419. * @param localRay defines the ray in local space
  109420. * @returns the list of intersecting sub meshes
  109421. */
  109422. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109423. /**
  109424. * Return the list of sub meshes colliding with a collider
  109425. * @param mesh defines the mesh to find the submesh for
  109426. * @param collider defines the collider to evaluate the collision against
  109427. * @returns the list of colliding sub meshes
  109428. */
  109429. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109430. /**
  109431. * Rebuilds the elements related to this component in case of
  109432. * context lost for instance.
  109433. */
  109434. rebuild(): void;
  109435. /**
  109436. * Disposes the component and the associated ressources.
  109437. */
  109438. dispose(): void;
  109439. }
  109440. }
  109441. declare module BABYLON {
  109442. /**
  109443. * Renders a layer on top of an existing scene
  109444. */
  109445. export class UtilityLayerRenderer implements IDisposable {
  109446. /** the original scene that will be rendered on top of */
  109447. originalScene: Scene;
  109448. private _pointerCaptures;
  109449. private _lastPointerEvents;
  109450. private static _DefaultUtilityLayer;
  109451. private static _DefaultKeepDepthUtilityLayer;
  109452. private _sharedGizmoLight;
  109453. private _renderCamera;
  109454. /**
  109455. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109456. * @returns the camera that is used when rendering the utility layer
  109457. */
  109458. getRenderCamera(): Nullable<Camera>;
  109459. /**
  109460. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109461. * @param cam the camera that should be used when rendering the utility layer
  109462. */
  109463. setRenderCamera(cam: Nullable<Camera>): void;
  109464. /**
  109465. * @hidden
  109466. * Light which used by gizmos to get light shading
  109467. */
  109468. _getSharedGizmoLight(): HemisphericLight;
  109469. /**
  109470. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109471. */
  109472. pickUtilitySceneFirst: boolean;
  109473. /**
  109474. * 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)
  109475. */
  109476. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109477. /**
  109478. * 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)
  109479. */
  109480. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109481. /**
  109482. * The scene that is rendered on top of the original scene
  109483. */
  109484. utilityLayerScene: Scene;
  109485. /**
  109486. * If the utility layer should automatically be rendered on top of existing scene
  109487. */
  109488. shouldRender: boolean;
  109489. /**
  109490. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109491. */
  109492. onlyCheckPointerDownEvents: boolean;
  109493. /**
  109494. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109495. */
  109496. processAllEvents: boolean;
  109497. /**
  109498. * Observable raised when the pointer move from the utility layer scene to the main scene
  109499. */
  109500. onPointerOutObservable: Observable<number>;
  109501. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109502. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109503. private _afterRenderObserver;
  109504. private _sceneDisposeObserver;
  109505. private _originalPointerObserver;
  109506. /**
  109507. * Instantiates a UtilityLayerRenderer
  109508. * @param originalScene the original scene that will be rendered on top of
  109509. * @param handleEvents boolean indicating if the utility layer should handle events
  109510. */
  109511. constructor(
  109512. /** the original scene that will be rendered on top of */
  109513. originalScene: Scene, handleEvents?: boolean);
  109514. private _notifyObservers;
  109515. /**
  109516. * Renders the utility layers scene on top of the original scene
  109517. */
  109518. render(): void;
  109519. /**
  109520. * Disposes of the renderer
  109521. */
  109522. dispose(): void;
  109523. private _updateCamera;
  109524. }
  109525. }
  109526. declare module BABYLON {
  109527. /**
  109528. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109529. */
  109530. export class Gizmo implements IDisposable {
  109531. /** The utility layer the gizmo will be added to */
  109532. gizmoLayer: UtilityLayerRenderer;
  109533. /**
  109534. * The root mesh of the gizmo
  109535. */
  109536. _rootMesh: Mesh;
  109537. private _attachedMesh;
  109538. /**
  109539. * Ratio for the scale of the gizmo (Default: 1)
  109540. */
  109541. scaleRatio: number;
  109542. /**
  109543. * If a custom mesh has been set (Default: false)
  109544. */
  109545. protected _customMeshSet: boolean;
  109546. /**
  109547. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109548. * * When set, interactions will be enabled
  109549. */
  109550. attachedMesh: Nullable<AbstractMesh>;
  109551. /**
  109552. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109553. * @param mesh The mesh to replace the default mesh of the gizmo
  109554. */
  109555. setCustomMesh(mesh: Mesh): void;
  109556. /**
  109557. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109558. */
  109559. updateGizmoRotationToMatchAttachedMesh: boolean;
  109560. /**
  109561. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109562. */
  109563. updateGizmoPositionToMatchAttachedMesh: boolean;
  109564. /**
  109565. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109566. */
  109567. updateScale: boolean;
  109568. protected _interactionsEnabled: boolean;
  109569. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109570. private _beforeRenderObserver;
  109571. private _tempVector;
  109572. /**
  109573. * Creates a gizmo
  109574. * @param gizmoLayer The utility layer the gizmo will be added to
  109575. */
  109576. constructor(
  109577. /** The utility layer the gizmo will be added to */
  109578. gizmoLayer?: UtilityLayerRenderer);
  109579. /**
  109580. * Updates the gizmo to match the attached mesh's position/rotation
  109581. */
  109582. protected _update(): void;
  109583. /**
  109584. * Disposes of the gizmo
  109585. */
  109586. dispose(): void;
  109587. }
  109588. }
  109589. declare module BABYLON {
  109590. /**
  109591. * Single plane drag gizmo
  109592. */
  109593. export class PlaneDragGizmo extends Gizmo {
  109594. /**
  109595. * Drag behavior responsible for the gizmos dragging interactions
  109596. */
  109597. dragBehavior: PointerDragBehavior;
  109598. private _pointerObserver;
  109599. /**
  109600. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109601. */
  109602. snapDistance: number;
  109603. /**
  109604. * Event that fires each time the gizmo snaps to a new location.
  109605. * * snapDistance is the the change in distance
  109606. */
  109607. onSnapObservable: Observable<{
  109608. snapDistance: number;
  109609. }>;
  109610. private _plane;
  109611. private _coloredMaterial;
  109612. private _hoverMaterial;
  109613. private _isEnabled;
  109614. private _parent;
  109615. /** @hidden */
  109616. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109617. /** @hidden */
  109618. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109619. /**
  109620. * Creates a PlaneDragGizmo
  109621. * @param gizmoLayer The utility layer the gizmo will be added to
  109622. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109623. * @param color The color of the gizmo
  109624. */
  109625. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109626. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109627. /**
  109628. * If the gizmo is enabled
  109629. */
  109630. isEnabled: boolean;
  109631. /**
  109632. * Disposes of the gizmo
  109633. */
  109634. dispose(): void;
  109635. }
  109636. }
  109637. declare module BABYLON {
  109638. /**
  109639. * Gizmo that enables dragging a mesh along 3 axis
  109640. */
  109641. export class PositionGizmo extends Gizmo {
  109642. /**
  109643. * Internal gizmo used for interactions on the x axis
  109644. */
  109645. xGizmo: AxisDragGizmo;
  109646. /**
  109647. * Internal gizmo used for interactions on the y axis
  109648. */
  109649. yGizmo: AxisDragGizmo;
  109650. /**
  109651. * Internal gizmo used for interactions on the z axis
  109652. */
  109653. zGizmo: AxisDragGizmo;
  109654. /**
  109655. * Internal gizmo used for interactions on the yz plane
  109656. */
  109657. xPlaneGizmo: PlaneDragGizmo;
  109658. /**
  109659. * Internal gizmo used for interactions on the xz plane
  109660. */
  109661. yPlaneGizmo: PlaneDragGizmo;
  109662. /**
  109663. * Internal gizmo used for interactions on the xy plane
  109664. */
  109665. zPlaneGizmo: PlaneDragGizmo;
  109666. /**
  109667. * private variables
  109668. */
  109669. private _meshAttached;
  109670. private _updateGizmoRotationToMatchAttachedMesh;
  109671. private _snapDistance;
  109672. private _scaleRatio;
  109673. /** Fires an event when any of it's sub gizmos are dragged */
  109674. onDragStartObservable: Observable<unknown>;
  109675. /** Fires an event when any of it's sub gizmos are released from dragging */
  109676. onDragEndObservable: Observable<unknown>;
  109677. /**
  109678. * If set to true, planar drag is enabled
  109679. */
  109680. private _planarGizmoEnabled;
  109681. attachedMesh: Nullable<AbstractMesh>;
  109682. /**
  109683. * Creates a PositionGizmo
  109684. * @param gizmoLayer The utility layer the gizmo will be added to
  109685. */
  109686. constructor(gizmoLayer?: UtilityLayerRenderer);
  109687. /**
  109688. * If the planar drag gizmo is enabled
  109689. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109690. */
  109691. planarGizmoEnabled: boolean;
  109692. updateGizmoRotationToMatchAttachedMesh: boolean;
  109693. /**
  109694. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109695. */
  109696. snapDistance: number;
  109697. /**
  109698. * Ratio for the scale of the gizmo (Default: 1)
  109699. */
  109700. scaleRatio: number;
  109701. /**
  109702. * Disposes of the gizmo
  109703. */
  109704. dispose(): void;
  109705. /**
  109706. * CustomMeshes are not supported by this gizmo
  109707. * @param mesh The mesh to replace the default mesh of the gizmo
  109708. */
  109709. setCustomMesh(mesh: Mesh): void;
  109710. }
  109711. }
  109712. declare module BABYLON {
  109713. /**
  109714. * Single axis drag gizmo
  109715. */
  109716. export class AxisDragGizmo extends Gizmo {
  109717. /**
  109718. * Drag behavior responsible for the gizmos dragging interactions
  109719. */
  109720. dragBehavior: PointerDragBehavior;
  109721. private _pointerObserver;
  109722. /**
  109723. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109724. */
  109725. snapDistance: number;
  109726. /**
  109727. * Event that fires each time the gizmo snaps to a new location.
  109728. * * snapDistance is the the change in distance
  109729. */
  109730. onSnapObservable: Observable<{
  109731. snapDistance: number;
  109732. }>;
  109733. private _isEnabled;
  109734. private _parent;
  109735. private _arrow;
  109736. private _coloredMaterial;
  109737. private _hoverMaterial;
  109738. /** @hidden */
  109739. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109740. /** @hidden */
  109741. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109742. /**
  109743. * Creates an AxisDragGizmo
  109744. * @param gizmoLayer The utility layer the gizmo will be added to
  109745. * @param dragAxis The axis which the gizmo will be able to drag on
  109746. * @param color The color of the gizmo
  109747. */
  109748. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109749. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109750. /**
  109751. * If the gizmo is enabled
  109752. */
  109753. isEnabled: boolean;
  109754. /**
  109755. * Disposes of the gizmo
  109756. */
  109757. dispose(): void;
  109758. }
  109759. }
  109760. declare module BABYLON.Debug {
  109761. /**
  109762. * The Axes viewer will show 3 axes in a specific point in space
  109763. */
  109764. export class AxesViewer {
  109765. private _xAxis;
  109766. private _yAxis;
  109767. private _zAxis;
  109768. private _scaleLinesFactor;
  109769. private _instanced;
  109770. /**
  109771. * Gets the hosting scene
  109772. */
  109773. scene: Scene;
  109774. /**
  109775. * Gets or sets a number used to scale line length
  109776. */
  109777. scaleLines: number;
  109778. /** Gets the node hierarchy used to render x-axis */
  109779. readonly xAxis: TransformNode;
  109780. /** Gets the node hierarchy used to render y-axis */
  109781. readonly yAxis: TransformNode;
  109782. /** Gets the node hierarchy used to render z-axis */
  109783. readonly zAxis: TransformNode;
  109784. /**
  109785. * Creates a new AxesViewer
  109786. * @param scene defines the hosting scene
  109787. * @param scaleLines defines a number used to scale line length (1 by default)
  109788. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109789. * @param xAxis defines the node hierarchy used to render the x-axis
  109790. * @param yAxis defines the node hierarchy used to render the y-axis
  109791. * @param zAxis defines the node hierarchy used to render the z-axis
  109792. */
  109793. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109794. /**
  109795. * Force the viewer to update
  109796. * @param position defines the position of the viewer
  109797. * @param xaxis defines the x axis of the viewer
  109798. * @param yaxis defines the y axis of the viewer
  109799. * @param zaxis defines the z axis of the viewer
  109800. */
  109801. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109802. /**
  109803. * Creates an instance of this axes viewer.
  109804. * @returns a new axes viewer with instanced meshes
  109805. */
  109806. createInstance(): AxesViewer;
  109807. /** Releases resources */
  109808. dispose(): void;
  109809. private static _SetRenderingGroupId;
  109810. }
  109811. }
  109812. declare module BABYLON.Debug {
  109813. /**
  109814. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109815. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109816. */
  109817. export class BoneAxesViewer extends AxesViewer {
  109818. /**
  109819. * Gets or sets the target mesh where to display the axes viewer
  109820. */
  109821. mesh: Nullable<Mesh>;
  109822. /**
  109823. * Gets or sets the target bone where to display the axes viewer
  109824. */
  109825. bone: Nullable<Bone>;
  109826. /** Gets current position */
  109827. pos: Vector3;
  109828. /** Gets direction of X axis */
  109829. xaxis: Vector3;
  109830. /** Gets direction of Y axis */
  109831. yaxis: Vector3;
  109832. /** Gets direction of Z axis */
  109833. zaxis: Vector3;
  109834. /**
  109835. * Creates a new BoneAxesViewer
  109836. * @param scene defines the hosting scene
  109837. * @param bone defines the target bone
  109838. * @param mesh defines the target mesh
  109839. * @param scaleLines defines a scaling factor for line length (1 by default)
  109840. */
  109841. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109842. /**
  109843. * Force the viewer to update
  109844. */
  109845. update(): void;
  109846. /** Releases resources */
  109847. dispose(): void;
  109848. }
  109849. }
  109850. declare module BABYLON {
  109851. /**
  109852. * Interface used to define scene explorer extensibility option
  109853. */
  109854. export interface IExplorerExtensibilityOption {
  109855. /**
  109856. * Define the option label
  109857. */
  109858. label: string;
  109859. /**
  109860. * Defines the action to execute on click
  109861. */
  109862. action: (entity: any) => void;
  109863. }
  109864. /**
  109865. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109866. */
  109867. export interface IExplorerExtensibilityGroup {
  109868. /**
  109869. * Defines a predicate to test if a given type mut be extended
  109870. */
  109871. predicate: (entity: any) => boolean;
  109872. /**
  109873. * Gets the list of options added to a type
  109874. */
  109875. entries: IExplorerExtensibilityOption[];
  109876. }
  109877. /**
  109878. * Interface used to define the options to use to create the Inspector
  109879. */
  109880. export interface IInspectorOptions {
  109881. /**
  109882. * Display in overlay mode (default: false)
  109883. */
  109884. overlay?: boolean;
  109885. /**
  109886. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109887. */
  109888. globalRoot?: HTMLElement;
  109889. /**
  109890. * Display the Scene explorer
  109891. */
  109892. showExplorer?: boolean;
  109893. /**
  109894. * Display the property inspector
  109895. */
  109896. showInspector?: boolean;
  109897. /**
  109898. * Display in embed mode (both panes on the right)
  109899. */
  109900. embedMode?: boolean;
  109901. /**
  109902. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109903. */
  109904. handleResize?: boolean;
  109905. /**
  109906. * Allow the panes to popup (default: true)
  109907. */
  109908. enablePopup?: boolean;
  109909. /**
  109910. * Allow the panes to be closed by users (default: true)
  109911. */
  109912. enableClose?: boolean;
  109913. /**
  109914. * Optional list of extensibility entries
  109915. */
  109916. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109917. /**
  109918. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109919. */
  109920. inspectorURL?: string;
  109921. }
  109922. interface Scene {
  109923. /**
  109924. * @hidden
  109925. * Backing field
  109926. */
  109927. _debugLayer: DebugLayer;
  109928. /**
  109929. * Gets the debug layer (aka Inspector) associated with the scene
  109930. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109931. */
  109932. debugLayer: DebugLayer;
  109933. }
  109934. /**
  109935. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109936. * what is happening in your scene
  109937. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109938. */
  109939. export class DebugLayer {
  109940. /**
  109941. * Define the url to get the inspector script from.
  109942. * By default it uses the babylonjs CDN.
  109943. * @ignoreNaming
  109944. */
  109945. static InspectorURL: string;
  109946. private _scene;
  109947. private BJSINSPECTOR;
  109948. private _onPropertyChangedObservable?;
  109949. /**
  109950. * Observable triggered when a property is changed through the inspector.
  109951. */
  109952. readonly onPropertyChangedObservable: any;
  109953. /**
  109954. * Instantiates a new debug layer.
  109955. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109956. * what is happening in your scene
  109957. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109958. * @param scene Defines the scene to inspect
  109959. */
  109960. constructor(scene: Scene);
  109961. /** Creates the inspector window. */
  109962. private _createInspector;
  109963. /**
  109964. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  109965. * @param entity defines the entity to select
  109966. * @param lineContainerTitle defines the specific block to highlight
  109967. */
  109968. select(entity: any, lineContainerTitle?: string): void;
  109969. /** Get the inspector from bundle or global */
  109970. private _getGlobalInspector;
  109971. /**
  109972. * Get if the inspector is visible or not.
  109973. * @returns true if visible otherwise, false
  109974. */
  109975. isVisible(): boolean;
  109976. /**
  109977. * Hide the inspector and close its window.
  109978. */
  109979. hide(): void;
  109980. /**
  109981. * Launch the debugLayer.
  109982. * @param config Define the configuration of the inspector
  109983. * @return a promise fulfilled when the debug layer is visible
  109984. */
  109985. show(config?: IInspectorOptions): Promise<DebugLayer>;
  109986. }
  109987. }
  109988. declare module BABYLON {
  109989. /**
  109990. * Class containing static functions to help procedurally build meshes
  109991. */
  109992. export class BoxBuilder {
  109993. /**
  109994. * Creates a box mesh
  109995. * * The parameter `size` sets the size (float) of each box side (default 1)
  109996. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109997. * * 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)
  109998. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110002. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110003. * @param name defines the name of the mesh
  110004. * @param options defines the options used to create the mesh
  110005. * @param scene defines the hosting scene
  110006. * @returns the box mesh
  110007. */
  110008. static CreateBox(name: string, options: {
  110009. size?: number;
  110010. width?: number;
  110011. height?: number;
  110012. depth?: number;
  110013. faceUV?: Vector4[];
  110014. faceColors?: Color4[];
  110015. sideOrientation?: number;
  110016. frontUVs?: Vector4;
  110017. backUVs?: Vector4;
  110018. wrap?: boolean;
  110019. topBaseAt?: number;
  110020. bottomBaseAt?: number;
  110021. updatable?: boolean;
  110022. }, scene?: Nullable<Scene>): Mesh;
  110023. }
  110024. }
  110025. declare module BABYLON {
  110026. /**
  110027. * Class containing static functions to help procedurally build meshes
  110028. */
  110029. export class SphereBuilder {
  110030. /**
  110031. * Creates a sphere mesh
  110032. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110033. * * 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`)
  110034. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110035. * * 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
  110036. * * 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)
  110037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110040. * @param name defines the name of the mesh
  110041. * @param options defines the options used to create the mesh
  110042. * @param scene defines the hosting scene
  110043. * @returns the sphere mesh
  110044. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110045. */
  110046. static CreateSphere(name: string, options: {
  110047. segments?: number;
  110048. diameter?: number;
  110049. diameterX?: number;
  110050. diameterY?: number;
  110051. diameterZ?: number;
  110052. arc?: number;
  110053. slice?: number;
  110054. sideOrientation?: number;
  110055. frontUVs?: Vector4;
  110056. backUVs?: Vector4;
  110057. updatable?: boolean;
  110058. }, scene?: Nullable<Scene>): Mesh;
  110059. }
  110060. }
  110061. declare module BABYLON.Debug {
  110062. /**
  110063. * Used to show the physics impostor around the specific mesh
  110064. */
  110065. export class PhysicsViewer {
  110066. /** @hidden */
  110067. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110068. /** @hidden */
  110069. protected _meshes: Array<Nullable<AbstractMesh>>;
  110070. /** @hidden */
  110071. protected _scene: Nullable<Scene>;
  110072. /** @hidden */
  110073. protected _numMeshes: number;
  110074. /** @hidden */
  110075. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110076. private _renderFunction;
  110077. private _utilityLayer;
  110078. private _debugBoxMesh;
  110079. private _debugSphereMesh;
  110080. private _debugCylinderMesh;
  110081. private _debugMaterial;
  110082. private _debugMeshMeshes;
  110083. /**
  110084. * Creates a new PhysicsViewer
  110085. * @param scene defines the hosting scene
  110086. */
  110087. constructor(scene: Scene);
  110088. /** @hidden */
  110089. protected _updateDebugMeshes(): void;
  110090. /**
  110091. * Renders a specified physic impostor
  110092. * @param impostor defines the impostor to render
  110093. * @param targetMesh defines the mesh represented by the impostor
  110094. * @returns the new debug mesh used to render the impostor
  110095. */
  110096. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110097. /**
  110098. * Hides a specified physic impostor
  110099. * @param impostor defines the impostor to hide
  110100. */
  110101. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110102. private _getDebugMaterial;
  110103. private _getDebugBoxMesh;
  110104. private _getDebugSphereMesh;
  110105. private _getDebugCylinderMesh;
  110106. private _getDebugMeshMesh;
  110107. private _getDebugMesh;
  110108. /** Releases all resources */
  110109. dispose(): void;
  110110. }
  110111. }
  110112. declare module BABYLON {
  110113. /**
  110114. * Class containing static functions to help procedurally build meshes
  110115. */
  110116. export class LinesBuilder {
  110117. /**
  110118. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110119. * * 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
  110120. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110121. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110122. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110123. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110124. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110125. * * 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
  110126. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110128. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110129. * @param name defines the name of the new line system
  110130. * @param options defines the options used to create the line system
  110131. * @param scene defines the hosting scene
  110132. * @returns a new line system mesh
  110133. */
  110134. static CreateLineSystem(name: string, options: {
  110135. lines: Vector3[][];
  110136. updatable?: boolean;
  110137. instance?: Nullable<LinesMesh>;
  110138. colors?: Nullable<Color4[][]>;
  110139. useVertexAlpha?: boolean;
  110140. }, scene: Nullable<Scene>): LinesMesh;
  110141. /**
  110142. * Creates a line mesh
  110143. * 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
  110144. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110145. * * The parameter `points` is an array successive Vector3
  110146. * * 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
  110147. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110148. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110149. * * When updating an instance, remember that only point positions can change, not the number of points
  110150. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110151. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110152. * @param name defines the name of the new line system
  110153. * @param options defines the options used to create the line system
  110154. * @param scene defines the hosting scene
  110155. * @returns a new line mesh
  110156. */
  110157. static CreateLines(name: string, options: {
  110158. points: Vector3[];
  110159. updatable?: boolean;
  110160. instance?: Nullable<LinesMesh>;
  110161. colors?: Color4[];
  110162. useVertexAlpha?: boolean;
  110163. }, scene?: Nullable<Scene>): LinesMesh;
  110164. /**
  110165. * Creates a dashed line mesh
  110166. * * 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
  110167. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110168. * * The parameter `points` is an array successive Vector3
  110169. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110170. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110171. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110172. * * 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
  110173. * * When updating an instance, remember that only point positions can change, not the number of points
  110174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110175. * @param name defines the name of the mesh
  110176. * @param options defines the options used to create the mesh
  110177. * @param scene defines the hosting scene
  110178. * @returns the dashed line mesh
  110179. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110180. */
  110181. static CreateDashedLines(name: string, options: {
  110182. points: Vector3[];
  110183. dashSize?: number;
  110184. gapSize?: number;
  110185. dashNb?: number;
  110186. updatable?: boolean;
  110187. instance?: LinesMesh;
  110188. }, scene?: Nullable<Scene>): LinesMesh;
  110189. }
  110190. }
  110191. declare module BABYLON {
  110192. /**
  110193. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110194. * in order to better appreciate the issue one might have.
  110195. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110196. */
  110197. export class RayHelper {
  110198. /**
  110199. * Defines the ray we are currently tryin to visualize.
  110200. */
  110201. ray: Nullable<Ray>;
  110202. private _renderPoints;
  110203. private _renderLine;
  110204. private _renderFunction;
  110205. private _scene;
  110206. private _updateToMeshFunction;
  110207. private _attachedToMesh;
  110208. private _meshSpaceDirection;
  110209. private _meshSpaceOrigin;
  110210. /**
  110211. * Helper function to create a colored helper in a scene in one line.
  110212. * @param ray Defines the ray we are currently tryin to visualize
  110213. * @param scene Defines the scene the ray is used in
  110214. * @param color Defines the color we want to see the ray in
  110215. * @returns The newly created ray helper.
  110216. */
  110217. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110218. /**
  110219. * Instantiate a new ray helper.
  110220. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110221. * in order to better appreciate the issue one might have.
  110222. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110223. * @param ray Defines the ray we are currently tryin to visualize
  110224. */
  110225. constructor(ray: Ray);
  110226. /**
  110227. * Shows the ray we are willing to debug.
  110228. * @param scene Defines the scene the ray needs to be rendered in
  110229. * @param color Defines the color the ray needs to be rendered in
  110230. */
  110231. show(scene: Scene, color?: Color3): void;
  110232. /**
  110233. * Hides the ray we are debugging.
  110234. */
  110235. hide(): void;
  110236. private _render;
  110237. /**
  110238. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110239. * @param mesh Defines the mesh we want the helper attached to
  110240. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110241. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110242. * @param length Defines the length of the ray
  110243. */
  110244. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110245. /**
  110246. * Detach the ray helper from the mesh it has previously been attached to.
  110247. */
  110248. detachFromMesh(): void;
  110249. private _updateToMesh;
  110250. /**
  110251. * Dispose the helper and release its associated resources.
  110252. */
  110253. dispose(): void;
  110254. }
  110255. }
  110256. declare module BABYLON.Debug {
  110257. /**
  110258. * Class used to render a debug view of a given skeleton
  110259. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110260. */
  110261. export class SkeletonViewer {
  110262. /** defines the skeleton to render */
  110263. skeleton: Skeleton;
  110264. /** defines the mesh attached to the skeleton */
  110265. mesh: AbstractMesh;
  110266. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110267. autoUpdateBonesMatrices: boolean;
  110268. /** defines the rendering group id to use with the viewer */
  110269. renderingGroupId: number;
  110270. /** Gets or sets the color used to render the skeleton */
  110271. color: Color3;
  110272. private _scene;
  110273. private _debugLines;
  110274. private _debugMesh;
  110275. private _isEnabled;
  110276. private _renderFunction;
  110277. private _utilityLayer;
  110278. /**
  110279. * Returns the mesh used to render the bones
  110280. */
  110281. readonly debugMesh: Nullable<LinesMesh>;
  110282. /**
  110283. * Creates a new SkeletonViewer
  110284. * @param skeleton defines the skeleton to render
  110285. * @param mesh defines the mesh attached to the skeleton
  110286. * @param scene defines the hosting scene
  110287. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110288. * @param renderingGroupId defines the rendering group id to use with the viewer
  110289. */
  110290. constructor(
  110291. /** defines the skeleton to render */
  110292. skeleton: Skeleton,
  110293. /** defines the mesh attached to the skeleton */
  110294. mesh: AbstractMesh, scene: Scene,
  110295. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110296. autoUpdateBonesMatrices?: boolean,
  110297. /** defines the rendering group id to use with the viewer */
  110298. renderingGroupId?: number);
  110299. /** Gets or sets a boolean indicating if the viewer is enabled */
  110300. isEnabled: boolean;
  110301. private _getBonePosition;
  110302. private _getLinesForBonesWithLength;
  110303. private _getLinesForBonesNoLength;
  110304. /** Update the viewer to sync with current skeleton state */
  110305. update(): void;
  110306. /** Release associated resources */
  110307. dispose(): void;
  110308. }
  110309. }
  110310. declare module BABYLON {
  110311. /**
  110312. * Options to create the null engine
  110313. */
  110314. export class NullEngineOptions {
  110315. /**
  110316. * Render width (Default: 512)
  110317. */
  110318. renderWidth: number;
  110319. /**
  110320. * Render height (Default: 256)
  110321. */
  110322. renderHeight: number;
  110323. /**
  110324. * Texture size (Default: 512)
  110325. */
  110326. textureSize: number;
  110327. /**
  110328. * If delta time between frames should be constant
  110329. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110330. */
  110331. deterministicLockstep: boolean;
  110332. /**
  110333. * Maximum about of steps between frames (Default: 4)
  110334. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110335. */
  110336. lockstepMaxSteps: number;
  110337. }
  110338. /**
  110339. * The null engine class provides support for headless version of babylon.js.
  110340. * This can be used in server side scenario or for testing purposes
  110341. */
  110342. export class NullEngine extends Engine {
  110343. private _options;
  110344. /**
  110345. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110346. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110347. * @returns true if engine is in deterministic lock step mode
  110348. */
  110349. isDeterministicLockStep(): boolean;
  110350. /**
  110351. * Gets the max steps when engine is running in deterministic lock step
  110352. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110353. * @returns the max steps
  110354. */
  110355. getLockstepMaxSteps(): number;
  110356. /**
  110357. * Gets the current hardware scaling level.
  110358. * By default the hardware scaling level is computed from the window device ratio.
  110359. * 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.
  110360. * @returns a number indicating the current hardware scaling level
  110361. */
  110362. getHardwareScalingLevel(): number;
  110363. constructor(options?: NullEngineOptions);
  110364. /**
  110365. * Creates a vertex buffer
  110366. * @param vertices the data for the vertex buffer
  110367. * @returns the new WebGL static buffer
  110368. */
  110369. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110370. /**
  110371. * Creates a new index buffer
  110372. * @param indices defines the content of the index buffer
  110373. * @param updatable defines if the index buffer must be updatable
  110374. * @returns a new webGL buffer
  110375. */
  110376. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110377. /**
  110378. * Clear the current render buffer or the current render target (if any is set up)
  110379. * @param color defines the color to use
  110380. * @param backBuffer defines if the back buffer must be cleared
  110381. * @param depth defines if the depth buffer must be cleared
  110382. * @param stencil defines if the stencil buffer must be cleared
  110383. */
  110384. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110385. /**
  110386. * Gets the current render width
  110387. * @param useScreen defines if screen size must be used (or the current render target if any)
  110388. * @returns a number defining the current render width
  110389. */
  110390. getRenderWidth(useScreen?: boolean): number;
  110391. /**
  110392. * Gets the current render height
  110393. * @param useScreen defines if screen size must be used (or the current render target if any)
  110394. * @returns a number defining the current render height
  110395. */
  110396. getRenderHeight(useScreen?: boolean): number;
  110397. /**
  110398. * Set the WebGL's viewport
  110399. * @param viewport defines the viewport element to be used
  110400. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110401. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110402. */
  110403. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110404. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110405. /**
  110406. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110407. * @param pipelineContext defines the pipeline context to use
  110408. * @param uniformsNames defines the list of uniform names
  110409. * @returns an array of webGL uniform locations
  110410. */
  110411. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110412. /**
  110413. * Gets the lsit of active attributes for a given webGL program
  110414. * @param pipelineContext defines the pipeline context to use
  110415. * @param attributesNames defines the list of attribute names to get
  110416. * @returns an array of indices indicating the offset of each attribute
  110417. */
  110418. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110419. /**
  110420. * Binds an effect to the webGL context
  110421. * @param effect defines the effect to bind
  110422. */
  110423. bindSamplers(effect: Effect): void;
  110424. /**
  110425. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110426. * @param effect defines the effect to activate
  110427. */
  110428. enableEffect(effect: Effect): void;
  110429. /**
  110430. * Set various states to the webGL context
  110431. * @param culling defines backface culling state
  110432. * @param zOffset defines the value to apply to zOffset (0 by default)
  110433. * @param force defines if states must be applied even if cache is up to date
  110434. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110435. */
  110436. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110437. /**
  110438. * Set the value of an uniform to an array of int32
  110439. * @param uniform defines the webGL uniform location where to store the value
  110440. * @param array defines the array of int32 to store
  110441. */
  110442. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110443. /**
  110444. * Set the value of an uniform to an array of int32 (stored as vec2)
  110445. * @param uniform defines the webGL uniform location where to store the value
  110446. * @param array defines the array of int32 to store
  110447. */
  110448. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110449. /**
  110450. * Set the value of an uniform to an array of int32 (stored as vec3)
  110451. * @param uniform defines the webGL uniform location where to store the value
  110452. * @param array defines the array of int32 to store
  110453. */
  110454. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110455. /**
  110456. * Set the value of an uniform to an array of int32 (stored as vec4)
  110457. * @param uniform defines the webGL uniform location where to store the value
  110458. * @param array defines the array of int32 to store
  110459. */
  110460. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110461. /**
  110462. * Set the value of an uniform to an array of float32
  110463. * @param uniform defines the webGL uniform location where to store the value
  110464. * @param array defines the array of float32 to store
  110465. */
  110466. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110467. /**
  110468. * Set the value of an uniform to an array of float32 (stored as vec2)
  110469. * @param uniform defines the webGL uniform location where to store the value
  110470. * @param array defines the array of float32 to store
  110471. */
  110472. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110473. /**
  110474. * Set the value of an uniform to an array of float32 (stored as vec3)
  110475. * @param uniform defines the webGL uniform location where to store the value
  110476. * @param array defines the array of float32 to store
  110477. */
  110478. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110479. /**
  110480. * Set the value of an uniform to an array of float32 (stored as vec4)
  110481. * @param uniform defines the webGL uniform location where to store the value
  110482. * @param array defines the array of float32 to store
  110483. */
  110484. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110485. /**
  110486. * Set the value of an uniform to an array of number
  110487. * @param uniform defines the webGL uniform location where to store the value
  110488. * @param array defines the array of number to store
  110489. */
  110490. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110491. /**
  110492. * Set the value of an uniform to an array of number (stored as vec2)
  110493. * @param uniform defines the webGL uniform location where to store the value
  110494. * @param array defines the array of number to store
  110495. */
  110496. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110497. /**
  110498. * Set the value of an uniform to an array of number (stored as vec3)
  110499. * @param uniform defines the webGL uniform location where to store the value
  110500. * @param array defines the array of number to store
  110501. */
  110502. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110503. /**
  110504. * Set the value of an uniform to an array of number (stored as vec4)
  110505. * @param uniform defines the webGL uniform location where to store the value
  110506. * @param array defines the array of number to store
  110507. */
  110508. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110509. /**
  110510. * Set the value of an uniform to an array of float32 (stored as matrices)
  110511. * @param uniform defines the webGL uniform location where to store the value
  110512. * @param matrices defines the array of float32 to store
  110513. */
  110514. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110515. /**
  110516. * Set the value of an uniform to a matrix (3x3)
  110517. * @param uniform defines the webGL uniform location where to store the value
  110518. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110519. */
  110520. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110521. /**
  110522. * Set the value of an uniform to a matrix (2x2)
  110523. * @param uniform defines the webGL uniform location where to store the value
  110524. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110525. */
  110526. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110527. /**
  110528. * Set the value of an uniform to a number (float)
  110529. * @param uniform defines the webGL uniform location where to store the value
  110530. * @param value defines the float number to store
  110531. */
  110532. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110533. /**
  110534. * Set the value of an uniform to a vec2
  110535. * @param uniform defines the webGL uniform location where to store the value
  110536. * @param x defines the 1st component of the value
  110537. * @param y defines the 2nd component of the value
  110538. */
  110539. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110540. /**
  110541. * Set the value of an uniform to a vec3
  110542. * @param uniform defines the webGL uniform location where to store the value
  110543. * @param x defines the 1st component of the value
  110544. * @param y defines the 2nd component of the value
  110545. * @param z defines the 3rd component of the value
  110546. */
  110547. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110548. /**
  110549. * Set the value of an uniform to a boolean
  110550. * @param uniform defines the webGL uniform location where to store the value
  110551. * @param bool defines the boolean to store
  110552. */
  110553. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110554. /**
  110555. * Set the value of an uniform to a vec4
  110556. * @param uniform defines the webGL uniform location where to store the value
  110557. * @param x defines the 1st component of the value
  110558. * @param y defines the 2nd component of the value
  110559. * @param z defines the 3rd component of the value
  110560. * @param w defines the 4th component of the value
  110561. */
  110562. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110563. /**
  110564. * Sets the current alpha mode
  110565. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110566. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110567. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110568. */
  110569. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110570. /**
  110571. * Bind webGl buffers directly to the webGL context
  110572. * @param vertexBuffers defines the vertex buffer to bind
  110573. * @param indexBuffer defines the index buffer to bind
  110574. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110575. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110576. * @param effect defines the effect associated with the vertex buffer
  110577. */
  110578. bindBuffers(vertexBuffers: {
  110579. [key: string]: VertexBuffer;
  110580. }, indexBuffer: DataBuffer, effect: Effect): void;
  110581. /**
  110582. * Force the entire cache to be cleared
  110583. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110584. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110585. */
  110586. wipeCaches(bruteForce?: boolean): void;
  110587. /**
  110588. * Send a draw order
  110589. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110590. * @param indexStart defines the starting index
  110591. * @param indexCount defines the number of index to draw
  110592. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110593. */
  110594. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110595. /**
  110596. * Draw a list of indexed primitives
  110597. * @param fillMode defines the primitive to use
  110598. * @param indexStart defines the starting index
  110599. * @param indexCount defines the number of index to draw
  110600. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110601. */
  110602. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110603. /**
  110604. * Draw a list of unindexed primitives
  110605. * @param fillMode defines the primitive to use
  110606. * @param verticesStart defines the index of first vertex to draw
  110607. * @param verticesCount defines the count of vertices to draw
  110608. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110609. */
  110610. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110611. /** @hidden */
  110612. _createTexture(): WebGLTexture;
  110613. /** @hidden */
  110614. _releaseTexture(texture: InternalTexture): void;
  110615. /**
  110616. * Usually called from Texture.ts.
  110617. * Passed information to create a WebGLTexture
  110618. * @param urlArg defines a value which contains one of the following:
  110619. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110620. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110621. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110622. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110623. * @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)
  110624. * @param scene needed for loading to the correct scene
  110625. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110626. * @param onLoad optional callback to be called upon successful completion
  110627. * @param onError optional callback to be called upon failure
  110628. * @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
  110629. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110630. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110631. * @param forcedExtension defines the extension to use to pick the right loader
  110632. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110633. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110634. */
  110635. 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;
  110636. /**
  110637. * Creates a new render target texture
  110638. * @param size defines the size of the texture
  110639. * @param options defines the options used to create the texture
  110640. * @returns a new render target texture stored in an InternalTexture
  110641. */
  110642. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110643. /**
  110644. * Update the sampling mode of a given texture
  110645. * @param samplingMode defines the required sampling mode
  110646. * @param texture defines the texture to update
  110647. */
  110648. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110649. /**
  110650. * Binds the frame buffer to the specified texture.
  110651. * @param texture The texture to render to or null for the default canvas
  110652. * @param faceIndex The face of the texture to render to in case of cube texture
  110653. * @param requiredWidth The width of the target to render to
  110654. * @param requiredHeight The height of the target to render to
  110655. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110656. * @param depthStencilTexture The depth stencil texture to use to render
  110657. * @param lodLevel defines le lod level to bind to the frame buffer
  110658. */
  110659. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110660. /**
  110661. * Unbind the current render target texture from the webGL context
  110662. * @param texture defines the render target texture to unbind
  110663. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110664. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110665. */
  110666. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110667. /**
  110668. * Creates a dynamic vertex buffer
  110669. * @param vertices the data for the dynamic vertex buffer
  110670. * @returns the new WebGL dynamic buffer
  110671. */
  110672. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110673. /**
  110674. * Update the content of a dynamic texture
  110675. * @param texture defines the texture to update
  110676. * @param canvas defines the canvas containing the source
  110677. * @param invertY defines if data must be stored with Y axis inverted
  110678. * @param premulAlpha defines if alpha is stored as premultiplied
  110679. * @param format defines the format of the data
  110680. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110681. */
  110682. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110683. /**
  110684. * Gets a boolean indicating if all created effects are ready
  110685. * @returns true if all effects are ready
  110686. */
  110687. areAllEffectsReady(): boolean;
  110688. /**
  110689. * @hidden
  110690. * Get the current error code of the webGL context
  110691. * @returns the error code
  110692. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110693. */
  110694. getError(): number;
  110695. /** @hidden */
  110696. _getUnpackAlignement(): number;
  110697. /** @hidden */
  110698. _unpackFlipY(value: boolean): void;
  110699. /**
  110700. * Update a dynamic index buffer
  110701. * @param indexBuffer defines the target index buffer
  110702. * @param indices defines the data to update
  110703. * @param offset defines the offset in the target index buffer where update should start
  110704. */
  110705. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110706. /**
  110707. * Updates a dynamic vertex buffer.
  110708. * @param vertexBuffer the vertex buffer to update
  110709. * @param vertices the data used to update the vertex buffer
  110710. * @param byteOffset the byte offset of the data (optional)
  110711. * @param byteLength the byte length of the data (optional)
  110712. */
  110713. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110714. /** @hidden */
  110715. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110716. /** @hidden */
  110717. _bindTexture(channel: number, texture: InternalTexture): void;
  110718. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110719. /**
  110720. * 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
  110721. */
  110722. releaseEffects(): void;
  110723. displayLoadingUI(): void;
  110724. hideLoadingUI(): void;
  110725. /** @hidden */
  110726. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110727. /** @hidden */
  110728. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110729. /** @hidden */
  110730. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110731. /** @hidden */
  110732. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110733. }
  110734. }
  110735. declare module BABYLON {
  110736. /** @hidden */
  110737. export class _OcclusionDataStorage {
  110738. /** @hidden */
  110739. occlusionInternalRetryCounter: number;
  110740. /** @hidden */
  110741. isOcclusionQueryInProgress: boolean;
  110742. /** @hidden */
  110743. isOccluded: boolean;
  110744. /** @hidden */
  110745. occlusionRetryCount: number;
  110746. /** @hidden */
  110747. occlusionType: number;
  110748. /** @hidden */
  110749. occlusionQueryAlgorithmType: number;
  110750. }
  110751. interface Engine {
  110752. /**
  110753. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110754. * @return the new query
  110755. */
  110756. createQuery(): WebGLQuery;
  110757. /**
  110758. * Delete and release a webGL query
  110759. * @param query defines the query to delete
  110760. * @return the current engine
  110761. */
  110762. deleteQuery(query: WebGLQuery): Engine;
  110763. /**
  110764. * Check if a given query has resolved and got its value
  110765. * @param query defines the query to check
  110766. * @returns true if the query got its value
  110767. */
  110768. isQueryResultAvailable(query: WebGLQuery): boolean;
  110769. /**
  110770. * Gets the value of a given query
  110771. * @param query defines the query to check
  110772. * @returns the value of the query
  110773. */
  110774. getQueryResult(query: WebGLQuery): number;
  110775. /**
  110776. * Initiates an occlusion query
  110777. * @param algorithmType defines the algorithm to use
  110778. * @param query defines the query to use
  110779. * @returns the current engine
  110780. * @see http://doc.babylonjs.com/features/occlusionquery
  110781. */
  110782. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110783. /**
  110784. * Ends an occlusion query
  110785. * @see http://doc.babylonjs.com/features/occlusionquery
  110786. * @param algorithmType defines the algorithm to use
  110787. * @returns the current engine
  110788. */
  110789. endOcclusionQuery(algorithmType: number): Engine;
  110790. /**
  110791. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110792. * Please note that only one query can be issued at a time
  110793. * @returns a time token used to track the time span
  110794. */
  110795. startTimeQuery(): Nullable<_TimeToken>;
  110796. /**
  110797. * Ends a time query
  110798. * @param token defines the token used to measure the time span
  110799. * @returns the time spent (in ns)
  110800. */
  110801. endTimeQuery(token: _TimeToken): int;
  110802. /** @hidden */
  110803. _currentNonTimestampToken: Nullable<_TimeToken>;
  110804. /** @hidden */
  110805. _createTimeQuery(): WebGLQuery;
  110806. /** @hidden */
  110807. _deleteTimeQuery(query: WebGLQuery): void;
  110808. /** @hidden */
  110809. _getGlAlgorithmType(algorithmType: number): number;
  110810. /** @hidden */
  110811. _getTimeQueryResult(query: WebGLQuery): any;
  110812. /** @hidden */
  110813. _getTimeQueryAvailability(query: WebGLQuery): any;
  110814. }
  110815. interface AbstractMesh {
  110816. /**
  110817. * Backing filed
  110818. * @hidden
  110819. */
  110820. __occlusionDataStorage: _OcclusionDataStorage;
  110821. /**
  110822. * Access property
  110823. * @hidden
  110824. */
  110825. _occlusionDataStorage: _OcclusionDataStorage;
  110826. /**
  110827. * 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.
  110828. * The default value is -1 which means don't break the query and wait till the result
  110829. * @see http://doc.babylonjs.com/features/occlusionquery
  110830. */
  110831. occlusionRetryCount: number;
  110832. /**
  110833. * 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:
  110834. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110835. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110836. * * 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.
  110837. * @see http://doc.babylonjs.com/features/occlusionquery
  110838. */
  110839. occlusionType: number;
  110840. /**
  110841. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110842. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110843. * * 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.
  110844. * @see http://doc.babylonjs.com/features/occlusionquery
  110845. */
  110846. occlusionQueryAlgorithmType: number;
  110847. /**
  110848. * 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
  110849. * @see http://doc.babylonjs.com/features/occlusionquery
  110850. */
  110851. isOccluded: boolean;
  110852. /**
  110853. * Flag to check the progress status of the query
  110854. * @see http://doc.babylonjs.com/features/occlusionquery
  110855. */
  110856. isOcclusionQueryInProgress: boolean;
  110857. }
  110858. }
  110859. declare module BABYLON {
  110860. /** @hidden */
  110861. export var _forceTransformFeedbackToBundle: boolean;
  110862. interface Engine {
  110863. /**
  110864. * Creates a webGL transform feedback object
  110865. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110866. * @returns the webGL transform feedback object
  110867. */
  110868. createTransformFeedback(): WebGLTransformFeedback;
  110869. /**
  110870. * Delete a webGL transform feedback object
  110871. * @param value defines the webGL transform feedback object to delete
  110872. */
  110873. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110874. /**
  110875. * Bind a webGL transform feedback object to the webgl context
  110876. * @param value defines the webGL transform feedback object to bind
  110877. */
  110878. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110879. /**
  110880. * Begins a transform feedback operation
  110881. * @param usePoints defines if points or triangles must be used
  110882. */
  110883. beginTransformFeedback(usePoints: boolean): void;
  110884. /**
  110885. * Ends a transform feedback operation
  110886. */
  110887. endTransformFeedback(): void;
  110888. /**
  110889. * Specify the varyings to use with transform feedback
  110890. * @param program defines the associated webGL program
  110891. * @param value defines the list of strings representing the varying names
  110892. */
  110893. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110894. /**
  110895. * Bind a webGL buffer for a transform feedback operation
  110896. * @param value defines the webGL buffer to bind
  110897. */
  110898. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110899. }
  110900. }
  110901. declare module BABYLON {
  110902. /**
  110903. * Creation options of the multi render target texture.
  110904. */
  110905. export interface IMultiRenderTargetOptions {
  110906. /**
  110907. * Define if the texture needs to create mip maps after render.
  110908. */
  110909. generateMipMaps?: boolean;
  110910. /**
  110911. * Define the types of all the draw buffers we want to create
  110912. */
  110913. types?: number[];
  110914. /**
  110915. * Define the sampling modes of all the draw buffers we want to create
  110916. */
  110917. samplingModes?: number[];
  110918. /**
  110919. * Define if a depth buffer is required
  110920. */
  110921. generateDepthBuffer?: boolean;
  110922. /**
  110923. * Define if a stencil buffer is required
  110924. */
  110925. generateStencilBuffer?: boolean;
  110926. /**
  110927. * Define if a depth texture is required instead of a depth buffer
  110928. */
  110929. generateDepthTexture?: boolean;
  110930. /**
  110931. * Define the number of desired draw buffers
  110932. */
  110933. textureCount?: number;
  110934. /**
  110935. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110936. */
  110937. doNotChangeAspectRatio?: boolean;
  110938. /**
  110939. * Define the default type of the buffers we are creating
  110940. */
  110941. defaultType?: number;
  110942. }
  110943. /**
  110944. * A multi render target, like a render target provides the ability to render to a texture.
  110945. * Unlike the render target, it can render to several draw buffers in one draw.
  110946. * This is specially interesting in deferred rendering or for any effects requiring more than
  110947. * just one color from a single pass.
  110948. */
  110949. export class MultiRenderTarget extends RenderTargetTexture {
  110950. private _internalTextures;
  110951. private _textures;
  110952. private _multiRenderTargetOptions;
  110953. /**
  110954. * Get if draw buffers are currently supported by the used hardware and browser.
  110955. */
  110956. readonly isSupported: boolean;
  110957. /**
  110958. * Get the list of textures generated by the multi render target.
  110959. */
  110960. readonly textures: Texture[];
  110961. /**
  110962. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  110963. */
  110964. readonly depthTexture: Texture;
  110965. /**
  110966. * Set the wrapping mode on U of all the textures we are rendering to.
  110967. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110968. */
  110969. wrapU: number;
  110970. /**
  110971. * Set the wrapping mode on V of all the textures we are rendering to.
  110972. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  110973. */
  110974. wrapV: number;
  110975. /**
  110976. * Instantiate a new multi render target texture.
  110977. * A multi render target, like a render target provides the ability to render to a texture.
  110978. * Unlike the render target, it can render to several draw buffers in one draw.
  110979. * This is specially interesting in deferred rendering or for any effects requiring more than
  110980. * just one color from a single pass.
  110981. * @param name Define the name of the texture
  110982. * @param size Define the size of the buffers to render to
  110983. * @param count Define the number of target we are rendering into
  110984. * @param scene Define the scene the texture belongs to
  110985. * @param options Define the options used to create the multi render target
  110986. */
  110987. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  110988. /** @hidden */
  110989. _rebuild(): void;
  110990. private _createInternalTextures;
  110991. private _createTextures;
  110992. /**
  110993. * Define the number of samples used if MSAA is enabled.
  110994. */
  110995. samples: number;
  110996. /**
  110997. * Resize all the textures in the multi render target.
  110998. * Be carrefull as it will recreate all the data in the new texture.
  110999. * @param size Define the new size
  111000. */
  111001. resize(size: any): void;
  111002. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111003. /**
  111004. * Dispose the render targets and their associated resources
  111005. */
  111006. dispose(): void;
  111007. /**
  111008. * Release all the underlying texture used as draw buffers.
  111009. */
  111010. releaseInternalTextures(): void;
  111011. }
  111012. }
  111013. declare module BABYLON {
  111014. interface ThinEngine {
  111015. /**
  111016. * Unbind a list of render target textures from the webGL context
  111017. * This is used only when drawBuffer extension or webGL2 are active
  111018. * @param textures defines the render target textures to unbind
  111019. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111020. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111021. */
  111022. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111023. /**
  111024. * Create a multi render target texture
  111025. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111026. * @param size defines the size of the texture
  111027. * @param options defines the creation options
  111028. * @returns the cube texture as an InternalTexture
  111029. */
  111030. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111031. /**
  111032. * Update the sample count for a given multiple render target texture
  111033. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111034. * @param textures defines the textures to update
  111035. * @param samples defines the sample count to set
  111036. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111037. */
  111038. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111039. }
  111040. }
  111041. declare module BABYLON {
  111042. /** @hidden */
  111043. export var rgbdEncodePixelShader: {
  111044. name: string;
  111045. shader: string;
  111046. };
  111047. }
  111048. declare module BABYLON {
  111049. /** @hidden */
  111050. export var rgbdDecodePixelShader: {
  111051. name: string;
  111052. shader: string;
  111053. };
  111054. }
  111055. declare module BABYLON {
  111056. /**
  111057. * Raw texture data and descriptor sufficient for WebGL texture upload
  111058. */
  111059. export interface EnvironmentTextureInfo {
  111060. /**
  111061. * Version of the environment map
  111062. */
  111063. version: number;
  111064. /**
  111065. * Width of image
  111066. */
  111067. width: number;
  111068. /**
  111069. * Irradiance information stored in the file.
  111070. */
  111071. irradiance: any;
  111072. /**
  111073. * Specular information stored in the file.
  111074. */
  111075. specular: any;
  111076. }
  111077. /**
  111078. * Defines One Image in the file. It requires only the position in the file
  111079. * as well as the length.
  111080. */
  111081. interface BufferImageData {
  111082. /**
  111083. * Length of the image data.
  111084. */
  111085. length: number;
  111086. /**
  111087. * Position of the data from the null terminator delimiting the end of the JSON.
  111088. */
  111089. position: number;
  111090. }
  111091. /**
  111092. * Defines the specular data enclosed in the file.
  111093. * This corresponds to the version 1 of the data.
  111094. */
  111095. export interface EnvironmentTextureSpecularInfoV1 {
  111096. /**
  111097. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111098. */
  111099. specularDataPosition?: number;
  111100. /**
  111101. * This contains all the images data needed to reconstruct the cubemap.
  111102. */
  111103. mipmaps: Array<BufferImageData>;
  111104. /**
  111105. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111106. */
  111107. lodGenerationScale: number;
  111108. }
  111109. /**
  111110. * Sets of helpers addressing the serialization and deserialization of environment texture
  111111. * stored in a BabylonJS env file.
  111112. * Those files are usually stored as .env files.
  111113. */
  111114. export class EnvironmentTextureTools {
  111115. /**
  111116. * Magic number identifying the env file.
  111117. */
  111118. private static _MagicBytes;
  111119. /**
  111120. * Gets the environment info from an env file.
  111121. * @param data The array buffer containing the .env bytes.
  111122. * @returns the environment file info (the json header) if successfully parsed.
  111123. */
  111124. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111125. /**
  111126. * Creates an environment texture from a loaded cube texture.
  111127. * @param texture defines the cube texture to convert in env file
  111128. * @return a promise containing the environment data if succesfull.
  111129. */
  111130. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111131. /**
  111132. * Creates a JSON representation of the spherical data.
  111133. * @param texture defines the texture containing the polynomials
  111134. * @return the JSON representation of the spherical info
  111135. */
  111136. private static _CreateEnvTextureIrradiance;
  111137. /**
  111138. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111139. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111140. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111141. * @return the views described by info providing access to the underlying buffer
  111142. */
  111143. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111144. /**
  111145. * Uploads the texture info contained in the env file to the GPU.
  111146. * @param texture defines the internal texture to upload to
  111147. * @param arrayBuffer defines the buffer cotaining the data to load
  111148. * @param info defines the texture info retrieved through the GetEnvInfo method
  111149. * @returns a promise
  111150. */
  111151. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111152. /**
  111153. * Uploads the levels of image data to the GPU.
  111154. * @param texture defines the internal texture to upload to
  111155. * @param imageData defines the array buffer views of image data [mipmap][face]
  111156. * @returns a promise
  111157. */
  111158. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111159. /**
  111160. * Uploads spherical polynomials information to the texture.
  111161. * @param texture defines the texture we are trying to upload the information to
  111162. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111163. */
  111164. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111165. /** @hidden */
  111166. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111167. }
  111168. }
  111169. declare module BABYLON {
  111170. /**
  111171. * Contains position and normal vectors for a vertex
  111172. */
  111173. export class PositionNormalVertex {
  111174. /** the position of the vertex (defaut: 0,0,0) */
  111175. position: Vector3;
  111176. /** the normal of the vertex (defaut: 0,1,0) */
  111177. normal: Vector3;
  111178. /**
  111179. * Creates a PositionNormalVertex
  111180. * @param position the position of the vertex (defaut: 0,0,0)
  111181. * @param normal the normal of the vertex (defaut: 0,1,0)
  111182. */
  111183. constructor(
  111184. /** the position of the vertex (defaut: 0,0,0) */
  111185. position?: Vector3,
  111186. /** the normal of the vertex (defaut: 0,1,0) */
  111187. normal?: Vector3);
  111188. /**
  111189. * Clones the PositionNormalVertex
  111190. * @returns the cloned PositionNormalVertex
  111191. */
  111192. clone(): PositionNormalVertex;
  111193. }
  111194. /**
  111195. * Contains position, normal and uv vectors for a vertex
  111196. */
  111197. export class PositionNormalTextureVertex {
  111198. /** the position of the vertex (defaut: 0,0,0) */
  111199. position: Vector3;
  111200. /** the normal of the vertex (defaut: 0,1,0) */
  111201. normal: Vector3;
  111202. /** the uv of the vertex (default: 0,0) */
  111203. uv: Vector2;
  111204. /**
  111205. * Creates a PositionNormalTextureVertex
  111206. * @param position the position of the vertex (defaut: 0,0,0)
  111207. * @param normal the normal of the vertex (defaut: 0,1,0)
  111208. * @param uv the uv of the vertex (default: 0,0)
  111209. */
  111210. constructor(
  111211. /** the position of the vertex (defaut: 0,0,0) */
  111212. position?: Vector3,
  111213. /** the normal of the vertex (defaut: 0,1,0) */
  111214. normal?: Vector3,
  111215. /** the uv of the vertex (default: 0,0) */
  111216. uv?: Vector2);
  111217. /**
  111218. * Clones the PositionNormalTextureVertex
  111219. * @returns the cloned PositionNormalTextureVertex
  111220. */
  111221. clone(): PositionNormalTextureVertex;
  111222. }
  111223. }
  111224. declare module BABYLON {
  111225. /** @hidden */
  111226. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111227. private _genericAttributeLocation;
  111228. private _varyingLocationCount;
  111229. private _varyingLocationMap;
  111230. private _replacements;
  111231. private _textureCount;
  111232. private _uniforms;
  111233. lineProcessor(line: string): string;
  111234. attributeProcessor(attribute: string): string;
  111235. varyingProcessor(varying: string, isFragment: boolean): string;
  111236. uniformProcessor(uniform: string): string;
  111237. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111238. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111239. }
  111240. }
  111241. declare module BABYLON {
  111242. /**
  111243. * Container for accessors for natively-stored mesh data buffers.
  111244. */
  111245. class NativeDataBuffer extends DataBuffer {
  111246. /**
  111247. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111248. */
  111249. nativeIndexBuffer?: any;
  111250. /**
  111251. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111252. */
  111253. nativeVertexBuffer?: any;
  111254. }
  111255. /** @hidden */
  111256. export class NativeEngine extends Engine {
  111257. private readonly _native;
  111258. getHardwareScalingLevel(): number;
  111259. constructor();
  111260. /**
  111261. * Can be used to override the current requestAnimationFrame requester.
  111262. * @hidden
  111263. */
  111264. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111265. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111266. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111267. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111268. recordVertexArrayObject(vertexBuffers: {
  111269. [key: string]: VertexBuffer;
  111270. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111271. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111272. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111273. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111274. /**
  111275. * Draw a list of indexed primitives
  111276. * @param fillMode defines the primitive to use
  111277. * @param indexStart defines the starting index
  111278. * @param indexCount defines the number of index to draw
  111279. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111280. */
  111281. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111282. /**
  111283. * Draw a list of unindexed primitives
  111284. * @param fillMode defines the primitive to use
  111285. * @param verticesStart defines the index of first vertex to draw
  111286. * @param verticesCount defines the count of vertices to draw
  111287. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111288. */
  111289. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111290. createPipelineContext(): IPipelineContext;
  111291. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111292. /** @hidden */
  111293. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111294. /** @hidden */
  111295. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111296. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111297. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111298. protected _setProgram(program: WebGLProgram): void;
  111299. _releaseEffect(effect: Effect): void;
  111300. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111301. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111302. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111303. bindSamplers(effect: Effect): void;
  111304. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111305. getRenderWidth(useScreen?: boolean): number;
  111306. getRenderHeight(useScreen?: boolean): number;
  111307. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111308. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111309. /**
  111310. * Set the z offset to apply to current rendering
  111311. * @param value defines the offset to apply
  111312. */
  111313. setZOffset(value: number): void;
  111314. /**
  111315. * Gets the current value of the zOffset
  111316. * @returns the current zOffset state
  111317. */
  111318. getZOffset(): number;
  111319. /**
  111320. * Enable or disable depth buffering
  111321. * @param enable defines the state to set
  111322. */
  111323. setDepthBuffer(enable: boolean): void;
  111324. /**
  111325. * Gets a boolean indicating if depth writing is enabled
  111326. * @returns the current depth writing state
  111327. */
  111328. getDepthWrite(): boolean;
  111329. /**
  111330. * Enable or disable depth writing
  111331. * @param enable defines the state to set
  111332. */
  111333. setDepthWrite(enable: boolean): void;
  111334. /**
  111335. * Enable or disable color writing
  111336. * @param enable defines the state to set
  111337. */
  111338. setColorWrite(enable: boolean): void;
  111339. /**
  111340. * Gets a boolean indicating if color writing is enabled
  111341. * @returns the current color writing state
  111342. */
  111343. getColorWrite(): boolean;
  111344. /**
  111345. * Sets alpha constants used by some alpha blending modes
  111346. * @param r defines the red component
  111347. * @param g defines the green component
  111348. * @param b defines the blue component
  111349. * @param a defines the alpha component
  111350. */
  111351. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111352. /**
  111353. * Sets the current alpha mode
  111354. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111355. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111356. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111357. */
  111358. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111359. /**
  111360. * Gets the current alpha mode
  111361. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111362. * @returns the current alpha mode
  111363. */
  111364. getAlphaMode(): number;
  111365. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111366. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111367. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111368. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111369. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111370. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111371. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111372. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111373. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111374. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111375. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111376. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111377. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111378. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111379. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111380. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111381. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111382. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111383. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111384. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111385. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111386. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111387. wipeCaches(bruteForce?: boolean): void;
  111388. _createTexture(): WebGLTexture;
  111389. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111390. /**
  111391. * Usually called from BABYLON.Texture.ts.
  111392. * Passed information to create a WebGLTexture
  111393. * @param urlArg defines a value which contains one of the following:
  111394. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111395. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111396. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111397. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111398. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111399. * @param scene needed for loading to the correct scene
  111400. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111401. * @param onLoad optional callback to be called upon successful completion
  111402. * @param onError optional callback to be called upon failure
  111403. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111404. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111405. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111406. * @param forcedExtension defines the extension to use to pick the right loader
  111407. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111408. */
  111409. 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;
  111410. /**
  111411. * Creates a cube texture
  111412. * @param rootUrl defines the url where the files to load is located
  111413. * @param scene defines the current scene
  111414. * @param files defines the list of files to load (1 per face)
  111415. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111416. * @param onLoad defines an optional callback raised when the texture is loaded
  111417. * @param onError defines an optional callback raised if there is an issue to load the texture
  111418. * @param format defines the format of the data
  111419. * @param forcedExtension defines the extension to use to pick the right loader
  111420. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111421. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111422. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111423. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111424. * @returns the cube texture as an InternalTexture
  111425. */
  111426. 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;
  111427. private _getSamplingFilter;
  111428. private static _GetNativeTextureFormat;
  111429. createRenderTargetTexture(size: number | {
  111430. width: number;
  111431. height: number;
  111432. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111433. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111434. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111435. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111436. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111437. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111438. /**
  111439. * Updates a dynamic vertex buffer.
  111440. * @param vertexBuffer the vertex buffer to update
  111441. * @param data the data used to update the vertex buffer
  111442. * @param byteOffset the byte offset of the data (optional)
  111443. * @param byteLength the byte length of the data (optional)
  111444. */
  111445. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111446. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111447. private _updateAnisotropicLevel;
  111448. private _getAddressMode;
  111449. /** @hidden */
  111450. _bindTexture(channel: number, texture: InternalTexture): void;
  111451. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111452. releaseEffects(): void;
  111453. /** @hidden */
  111454. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111455. /** @hidden */
  111456. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111457. /** @hidden */
  111458. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111459. /** @hidden */
  111460. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111461. }
  111462. }
  111463. declare module BABYLON {
  111464. /**
  111465. * Gather the list of clipboard event types as constants.
  111466. */
  111467. export class ClipboardEventTypes {
  111468. /**
  111469. * The clipboard event is fired when a copy command is active (pressed).
  111470. */
  111471. static readonly COPY: number;
  111472. /**
  111473. * The clipboard event is fired when a cut command is active (pressed).
  111474. */
  111475. static readonly CUT: number;
  111476. /**
  111477. * The clipboard event is fired when a paste command is active (pressed).
  111478. */
  111479. static readonly PASTE: number;
  111480. }
  111481. /**
  111482. * This class is used to store clipboard related info for the onClipboardObservable event.
  111483. */
  111484. export class ClipboardInfo {
  111485. /**
  111486. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111487. */
  111488. type: number;
  111489. /**
  111490. * Defines the related dom event
  111491. */
  111492. event: ClipboardEvent;
  111493. /**
  111494. *Creates an instance of ClipboardInfo.
  111495. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111496. * @param event Defines the related dom event
  111497. */
  111498. constructor(
  111499. /**
  111500. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111501. */
  111502. type: number,
  111503. /**
  111504. * Defines the related dom event
  111505. */
  111506. event: ClipboardEvent);
  111507. /**
  111508. * Get the clipboard event's type from the keycode.
  111509. * @param keyCode Defines the keyCode for the current keyboard event.
  111510. * @return {number}
  111511. */
  111512. static GetTypeFromCharacter(keyCode: number): number;
  111513. }
  111514. }
  111515. declare module BABYLON {
  111516. /**
  111517. * Google Daydream controller
  111518. */
  111519. export class DaydreamController extends WebVRController {
  111520. /**
  111521. * Base Url for the controller model.
  111522. */
  111523. static MODEL_BASE_URL: string;
  111524. /**
  111525. * File name for the controller model.
  111526. */
  111527. static MODEL_FILENAME: string;
  111528. /**
  111529. * Gamepad Id prefix used to identify Daydream Controller.
  111530. */
  111531. static readonly GAMEPAD_ID_PREFIX: string;
  111532. /**
  111533. * Creates a new DaydreamController from a gamepad
  111534. * @param vrGamepad the gamepad that the controller should be created from
  111535. */
  111536. constructor(vrGamepad: any);
  111537. /**
  111538. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111539. * @param scene scene in which to add meshes
  111540. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111541. */
  111542. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111543. /**
  111544. * Called once for each button that changed state since the last frame
  111545. * @param buttonIdx Which button index changed
  111546. * @param state New state of the button
  111547. * @param changes Which properties on the state changed since last frame
  111548. */
  111549. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111550. }
  111551. }
  111552. declare module BABYLON {
  111553. /**
  111554. * Gear VR Controller
  111555. */
  111556. export class GearVRController extends WebVRController {
  111557. /**
  111558. * Base Url for the controller model.
  111559. */
  111560. static MODEL_BASE_URL: string;
  111561. /**
  111562. * File name for the controller model.
  111563. */
  111564. static MODEL_FILENAME: string;
  111565. /**
  111566. * Gamepad Id prefix used to identify this controller.
  111567. */
  111568. static readonly GAMEPAD_ID_PREFIX: string;
  111569. private readonly _buttonIndexToObservableNameMap;
  111570. /**
  111571. * Creates a new GearVRController from a gamepad
  111572. * @param vrGamepad the gamepad that the controller should be created from
  111573. */
  111574. constructor(vrGamepad: any);
  111575. /**
  111576. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111577. * @param scene scene in which to add meshes
  111578. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111579. */
  111580. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111581. /**
  111582. * Called once for each button that changed state since the last frame
  111583. * @param buttonIdx Which button index changed
  111584. * @param state New state of the button
  111585. * @param changes Which properties on the state changed since last frame
  111586. */
  111587. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111588. }
  111589. }
  111590. declare module BABYLON {
  111591. /**
  111592. * Class containing static functions to help procedurally build meshes
  111593. */
  111594. export class PolyhedronBuilder {
  111595. /**
  111596. * Creates a polyhedron mesh
  111597. * * 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
  111598. * * The parameter `size` (positive float, default 1) sets the polygon size
  111599. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111600. * * 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`
  111601. * * 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
  111602. * * 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)`)
  111603. * * 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
  111604. * * 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
  111605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111606. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111608. * @param name defines the name of the mesh
  111609. * @param options defines the options used to create the mesh
  111610. * @param scene defines the hosting scene
  111611. * @returns the polyhedron mesh
  111612. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111613. */
  111614. static CreatePolyhedron(name: string, options: {
  111615. type?: number;
  111616. size?: number;
  111617. sizeX?: number;
  111618. sizeY?: number;
  111619. sizeZ?: number;
  111620. custom?: any;
  111621. faceUV?: Vector4[];
  111622. faceColors?: Color4[];
  111623. flat?: boolean;
  111624. updatable?: boolean;
  111625. sideOrientation?: number;
  111626. frontUVs?: Vector4;
  111627. backUVs?: Vector4;
  111628. }, scene?: Nullable<Scene>): Mesh;
  111629. }
  111630. }
  111631. declare module BABYLON {
  111632. /**
  111633. * Gizmo that enables scaling a mesh along 3 axis
  111634. */
  111635. export class ScaleGizmo extends Gizmo {
  111636. /**
  111637. * Internal gizmo used for interactions on the x axis
  111638. */
  111639. xGizmo: AxisScaleGizmo;
  111640. /**
  111641. * Internal gizmo used for interactions on the y axis
  111642. */
  111643. yGizmo: AxisScaleGizmo;
  111644. /**
  111645. * Internal gizmo used for interactions on the z axis
  111646. */
  111647. zGizmo: AxisScaleGizmo;
  111648. /**
  111649. * Internal gizmo used to scale all axis equally
  111650. */
  111651. uniformScaleGizmo: AxisScaleGizmo;
  111652. private _meshAttached;
  111653. private _updateGizmoRotationToMatchAttachedMesh;
  111654. private _snapDistance;
  111655. private _scaleRatio;
  111656. private _uniformScalingMesh;
  111657. private _octahedron;
  111658. /** Fires an event when any of it's sub gizmos are dragged */
  111659. onDragStartObservable: Observable<unknown>;
  111660. /** Fires an event when any of it's sub gizmos are released from dragging */
  111661. onDragEndObservable: Observable<unknown>;
  111662. attachedMesh: Nullable<AbstractMesh>;
  111663. /**
  111664. * Creates a ScaleGizmo
  111665. * @param gizmoLayer The utility layer the gizmo will be added to
  111666. */
  111667. constructor(gizmoLayer?: UtilityLayerRenderer);
  111668. updateGizmoRotationToMatchAttachedMesh: boolean;
  111669. /**
  111670. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111671. */
  111672. snapDistance: number;
  111673. /**
  111674. * Ratio for the scale of the gizmo (Default: 1)
  111675. */
  111676. scaleRatio: number;
  111677. /**
  111678. * Disposes of the gizmo
  111679. */
  111680. dispose(): void;
  111681. }
  111682. }
  111683. declare module BABYLON {
  111684. /**
  111685. * Single axis scale gizmo
  111686. */
  111687. export class AxisScaleGizmo extends Gizmo {
  111688. /**
  111689. * Drag behavior responsible for the gizmos dragging interactions
  111690. */
  111691. dragBehavior: PointerDragBehavior;
  111692. private _pointerObserver;
  111693. /**
  111694. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111695. */
  111696. snapDistance: number;
  111697. /**
  111698. * Event that fires each time the gizmo snaps to a new location.
  111699. * * snapDistance is the the change in distance
  111700. */
  111701. onSnapObservable: Observable<{
  111702. snapDistance: number;
  111703. }>;
  111704. /**
  111705. * If the scaling operation should be done on all axis (default: false)
  111706. */
  111707. uniformScaling: boolean;
  111708. private _isEnabled;
  111709. private _parent;
  111710. private _arrow;
  111711. private _coloredMaterial;
  111712. private _hoverMaterial;
  111713. /**
  111714. * Creates an AxisScaleGizmo
  111715. * @param gizmoLayer The utility layer the gizmo will be added to
  111716. * @param dragAxis The axis which the gizmo will be able to scale on
  111717. * @param color The color of the gizmo
  111718. */
  111719. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111720. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111721. /**
  111722. * If the gizmo is enabled
  111723. */
  111724. isEnabled: boolean;
  111725. /**
  111726. * Disposes of the gizmo
  111727. */
  111728. dispose(): void;
  111729. /**
  111730. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111731. * @param mesh The mesh to replace the default mesh of the gizmo
  111732. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111733. */
  111734. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111735. }
  111736. }
  111737. declare module BABYLON {
  111738. /**
  111739. * Bounding box gizmo
  111740. */
  111741. export class BoundingBoxGizmo extends Gizmo {
  111742. private _lineBoundingBox;
  111743. private _rotateSpheresParent;
  111744. private _scaleBoxesParent;
  111745. private _boundingDimensions;
  111746. private _renderObserver;
  111747. private _pointerObserver;
  111748. private _scaleDragSpeed;
  111749. private _tmpQuaternion;
  111750. private _tmpVector;
  111751. private _tmpRotationMatrix;
  111752. /**
  111753. * 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)
  111754. */
  111755. ignoreChildren: boolean;
  111756. /**
  111757. * 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)
  111758. */
  111759. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111760. /**
  111761. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111762. */
  111763. rotationSphereSize: number;
  111764. /**
  111765. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111766. */
  111767. scaleBoxSize: number;
  111768. /**
  111769. * 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)
  111770. */
  111771. fixedDragMeshScreenSize: boolean;
  111772. /**
  111773. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111774. */
  111775. fixedDragMeshScreenSizeDistanceFactor: number;
  111776. /**
  111777. * Fired when a rotation sphere or scale box is dragged
  111778. */
  111779. onDragStartObservable: Observable<{}>;
  111780. /**
  111781. * Fired when a scale box is dragged
  111782. */
  111783. onScaleBoxDragObservable: Observable<{}>;
  111784. /**
  111785. * Fired when a scale box drag is ended
  111786. */
  111787. onScaleBoxDragEndObservable: Observable<{}>;
  111788. /**
  111789. * Fired when a rotation sphere is dragged
  111790. */
  111791. onRotationSphereDragObservable: Observable<{}>;
  111792. /**
  111793. * Fired when a rotation sphere drag is ended
  111794. */
  111795. onRotationSphereDragEndObservable: Observable<{}>;
  111796. /**
  111797. * 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)
  111798. */
  111799. scalePivot: Nullable<Vector3>;
  111800. /**
  111801. * Mesh used as a pivot to rotate the attached mesh
  111802. */
  111803. private _anchorMesh;
  111804. private _existingMeshScale;
  111805. private _dragMesh;
  111806. private pointerDragBehavior;
  111807. private coloredMaterial;
  111808. private hoverColoredMaterial;
  111809. /**
  111810. * Sets the color of the bounding box gizmo
  111811. * @param color the color to set
  111812. */
  111813. setColor(color: Color3): void;
  111814. /**
  111815. * Creates an BoundingBoxGizmo
  111816. * @param gizmoLayer The utility layer the gizmo will be added to
  111817. * @param color The color of the gizmo
  111818. */
  111819. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111820. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111821. private _selectNode;
  111822. /**
  111823. * Updates the bounding box information for the Gizmo
  111824. */
  111825. updateBoundingBox(): void;
  111826. private _updateRotationSpheres;
  111827. private _updateScaleBoxes;
  111828. /**
  111829. * Enables rotation on the specified axis and disables rotation on the others
  111830. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111831. */
  111832. setEnabledRotationAxis(axis: string): void;
  111833. /**
  111834. * Enables/disables scaling
  111835. * @param enable if scaling should be enabled
  111836. */
  111837. setEnabledScaling(enable: boolean): void;
  111838. private _updateDummy;
  111839. /**
  111840. * Enables a pointer drag behavior on the bounding box of the gizmo
  111841. */
  111842. enableDragBehavior(): void;
  111843. /**
  111844. * Disposes of the gizmo
  111845. */
  111846. dispose(): void;
  111847. /**
  111848. * 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)
  111849. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  111850. * @returns the bounding box mesh with the passed in mesh as a child
  111851. */
  111852. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  111853. /**
  111854. * CustomMeshes are not supported by this gizmo
  111855. * @param mesh The mesh to replace the default mesh of the gizmo
  111856. */
  111857. setCustomMesh(mesh: Mesh): void;
  111858. }
  111859. }
  111860. declare module BABYLON {
  111861. /**
  111862. * Single plane rotation gizmo
  111863. */
  111864. export class PlaneRotationGizmo extends Gizmo {
  111865. /**
  111866. * Drag behavior responsible for the gizmos dragging interactions
  111867. */
  111868. dragBehavior: PointerDragBehavior;
  111869. private _pointerObserver;
  111870. /**
  111871. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  111872. */
  111873. snapDistance: number;
  111874. /**
  111875. * Event that fires each time the gizmo snaps to a new location.
  111876. * * snapDistance is the the change in distance
  111877. */
  111878. onSnapObservable: Observable<{
  111879. snapDistance: number;
  111880. }>;
  111881. private _isEnabled;
  111882. private _parent;
  111883. /**
  111884. * Creates a PlaneRotationGizmo
  111885. * @param gizmoLayer The utility layer the gizmo will be added to
  111886. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  111887. * @param color The color of the gizmo
  111888. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111889. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111890. */
  111891. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  111892. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111893. /**
  111894. * If the gizmo is enabled
  111895. */
  111896. isEnabled: boolean;
  111897. /**
  111898. * Disposes of the gizmo
  111899. */
  111900. dispose(): void;
  111901. }
  111902. }
  111903. declare module BABYLON {
  111904. /**
  111905. * Gizmo that enables rotating a mesh along 3 axis
  111906. */
  111907. export class RotationGizmo extends Gizmo {
  111908. /**
  111909. * Internal gizmo used for interactions on the x axis
  111910. */
  111911. xGizmo: PlaneRotationGizmo;
  111912. /**
  111913. * Internal gizmo used for interactions on the y axis
  111914. */
  111915. yGizmo: PlaneRotationGizmo;
  111916. /**
  111917. * Internal gizmo used for interactions on the z axis
  111918. */
  111919. zGizmo: PlaneRotationGizmo;
  111920. /** Fires an event when any of it's sub gizmos are dragged */
  111921. onDragStartObservable: Observable<unknown>;
  111922. /** Fires an event when any of it's sub gizmos are released from dragging */
  111923. onDragEndObservable: Observable<unknown>;
  111924. private _meshAttached;
  111925. attachedMesh: Nullable<AbstractMesh>;
  111926. /**
  111927. * Creates a RotationGizmo
  111928. * @param gizmoLayer The utility layer the gizmo will be added to
  111929. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111930. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111931. */
  111932. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  111933. updateGizmoRotationToMatchAttachedMesh: boolean;
  111934. /**
  111935. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111936. */
  111937. snapDistance: number;
  111938. /**
  111939. * Ratio for the scale of the gizmo (Default: 1)
  111940. */
  111941. scaleRatio: number;
  111942. /**
  111943. * Disposes of the gizmo
  111944. */
  111945. dispose(): void;
  111946. /**
  111947. * CustomMeshes are not supported by this gizmo
  111948. * @param mesh The mesh to replace the default mesh of the gizmo
  111949. */
  111950. setCustomMesh(mesh: Mesh): void;
  111951. }
  111952. }
  111953. declare module BABYLON {
  111954. /**
  111955. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  111956. */
  111957. export class GizmoManager implements IDisposable {
  111958. private scene;
  111959. /**
  111960. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  111961. */
  111962. gizmos: {
  111963. positionGizmo: Nullable<PositionGizmo>;
  111964. rotationGizmo: Nullable<RotationGizmo>;
  111965. scaleGizmo: Nullable<ScaleGizmo>;
  111966. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  111967. };
  111968. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  111969. clearGizmoOnEmptyPointerEvent: boolean;
  111970. /** Fires an event when the manager is attached to a mesh */
  111971. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  111972. private _gizmosEnabled;
  111973. private _pointerObserver;
  111974. private _attachedMesh;
  111975. private _boundingBoxColor;
  111976. private _defaultUtilityLayer;
  111977. private _defaultKeepDepthUtilityLayer;
  111978. /**
  111979. * When bounding box gizmo is enabled, this can be used to track drag/end events
  111980. */
  111981. boundingBoxDragBehavior: SixDofDragBehavior;
  111982. /**
  111983. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  111984. */
  111985. attachableMeshes: Nullable<Array<AbstractMesh>>;
  111986. /**
  111987. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  111988. */
  111989. usePointerToAttachGizmos: boolean;
  111990. /**
  111991. * Utility layer that the bounding box gizmo belongs to
  111992. */
  111993. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  111994. /**
  111995. * Utility layer that all gizmos besides bounding box belong to
  111996. */
  111997. readonly utilityLayer: UtilityLayerRenderer;
  111998. /**
  111999. * Instatiates a gizmo manager
  112000. * @param scene the scene to overlay the gizmos on top of
  112001. */
  112002. constructor(scene: Scene);
  112003. /**
  112004. * Attaches a set of gizmos to the specified mesh
  112005. * @param mesh The mesh the gizmo's should be attached to
  112006. */
  112007. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112008. /**
  112009. * If the position gizmo is enabled
  112010. */
  112011. positionGizmoEnabled: boolean;
  112012. /**
  112013. * If the rotation gizmo is enabled
  112014. */
  112015. rotationGizmoEnabled: boolean;
  112016. /**
  112017. * If the scale gizmo is enabled
  112018. */
  112019. scaleGizmoEnabled: boolean;
  112020. /**
  112021. * If the boundingBox gizmo is enabled
  112022. */
  112023. boundingBoxGizmoEnabled: boolean;
  112024. /**
  112025. * Disposes of the gizmo manager
  112026. */
  112027. dispose(): void;
  112028. }
  112029. }
  112030. declare module BABYLON {
  112031. /**
  112032. * A directional light is defined by a direction (what a surprise!).
  112033. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112034. * 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.
  112035. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112036. */
  112037. export class DirectionalLight extends ShadowLight {
  112038. private _shadowFrustumSize;
  112039. /**
  112040. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112041. */
  112042. /**
  112043. * Specifies a fix frustum size for the shadow generation.
  112044. */
  112045. shadowFrustumSize: number;
  112046. private _shadowOrthoScale;
  112047. /**
  112048. * Gets the shadow projection scale against the optimal computed one.
  112049. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112050. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112051. */
  112052. /**
  112053. * Sets the shadow projection scale against the optimal computed one.
  112054. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112055. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112056. */
  112057. shadowOrthoScale: number;
  112058. /**
  112059. * Automatically compute the projection matrix to best fit (including all the casters)
  112060. * on each frame.
  112061. */
  112062. autoUpdateExtends: boolean;
  112063. private _orthoLeft;
  112064. private _orthoRight;
  112065. private _orthoTop;
  112066. private _orthoBottom;
  112067. /**
  112068. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112069. * The directional light is emitted from everywhere in the given direction.
  112070. * It can cast shadows.
  112071. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112072. * @param name The friendly name of the light
  112073. * @param direction The direction of the light
  112074. * @param scene The scene the light belongs to
  112075. */
  112076. constructor(name: string, direction: Vector3, scene: Scene);
  112077. /**
  112078. * Returns the string "DirectionalLight".
  112079. * @return The class name
  112080. */
  112081. getClassName(): string;
  112082. /**
  112083. * Returns the integer 1.
  112084. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112085. */
  112086. getTypeID(): number;
  112087. /**
  112088. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112089. * Returns the DirectionalLight Shadow projection matrix.
  112090. */
  112091. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112092. /**
  112093. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112094. * Returns the DirectionalLight Shadow projection matrix.
  112095. */
  112096. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112097. /**
  112098. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112099. * Returns the DirectionalLight Shadow projection matrix.
  112100. */
  112101. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112102. protected _buildUniformLayout(): void;
  112103. /**
  112104. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112105. * @param effect The effect to update
  112106. * @param lightIndex The index of the light in the effect to update
  112107. * @returns The directional light
  112108. */
  112109. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112110. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112111. /**
  112112. * Gets the minZ used for shadow according to both the scene and the light.
  112113. *
  112114. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112115. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112116. * @param activeCamera The camera we are returning the min for
  112117. * @returns the depth min z
  112118. */
  112119. getDepthMinZ(activeCamera: Camera): number;
  112120. /**
  112121. * Gets the maxZ used for shadow according to both the scene and the light.
  112122. *
  112123. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112124. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112125. * @param activeCamera The camera we are returning the max for
  112126. * @returns the depth max z
  112127. */
  112128. getDepthMaxZ(activeCamera: Camera): number;
  112129. /**
  112130. * Prepares the list of defines specific to the light type.
  112131. * @param defines the list of defines
  112132. * @param lightIndex defines the index of the light for the effect
  112133. */
  112134. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112135. }
  112136. }
  112137. declare module BABYLON {
  112138. /**
  112139. * Class containing static functions to help procedurally build meshes
  112140. */
  112141. export class HemisphereBuilder {
  112142. /**
  112143. * Creates a hemisphere mesh
  112144. * @param name defines the name of the mesh
  112145. * @param options defines the options used to create the mesh
  112146. * @param scene defines the hosting scene
  112147. * @returns the hemisphere mesh
  112148. */
  112149. static CreateHemisphere(name: string, options: {
  112150. segments?: number;
  112151. diameter?: number;
  112152. sideOrientation?: number;
  112153. }, scene: any): Mesh;
  112154. }
  112155. }
  112156. declare module BABYLON {
  112157. /**
  112158. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112159. * These values define a cone of light starting from the position, emitting toward the direction.
  112160. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112161. * and the exponent defines the speed of the decay of the light with distance (reach).
  112162. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112163. */
  112164. export class SpotLight extends ShadowLight {
  112165. private _angle;
  112166. private _innerAngle;
  112167. private _cosHalfAngle;
  112168. private _lightAngleScale;
  112169. private _lightAngleOffset;
  112170. /**
  112171. * Gets the cone angle of the spot light in Radians.
  112172. */
  112173. /**
  112174. * Sets the cone angle of the spot light in Radians.
  112175. */
  112176. angle: number;
  112177. /**
  112178. * Only used in gltf falloff mode, this defines the angle where
  112179. * the directional falloff will start before cutting at angle which could be seen
  112180. * as outer angle.
  112181. */
  112182. /**
  112183. * Only used in gltf falloff mode, this defines the angle where
  112184. * the directional falloff will start before cutting at angle which could be seen
  112185. * as outer angle.
  112186. */
  112187. innerAngle: number;
  112188. private _shadowAngleScale;
  112189. /**
  112190. * Allows scaling the angle of the light for shadow generation only.
  112191. */
  112192. /**
  112193. * Allows scaling the angle of the light for shadow generation only.
  112194. */
  112195. shadowAngleScale: number;
  112196. /**
  112197. * The light decay speed with the distance from the emission spot.
  112198. */
  112199. exponent: number;
  112200. private _projectionTextureMatrix;
  112201. /**
  112202. * Allows reading the projecton texture
  112203. */
  112204. readonly projectionTextureMatrix: Matrix;
  112205. protected _projectionTextureLightNear: number;
  112206. /**
  112207. * Gets the near clip of the Spotlight for texture projection.
  112208. */
  112209. /**
  112210. * Sets the near clip of the Spotlight for texture projection.
  112211. */
  112212. projectionTextureLightNear: number;
  112213. protected _projectionTextureLightFar: number;
  112214. /**
  112215. * Gets the far clip of the Spotlight for texture projection.
  112216. */
  112217. /**
  112218. * Sets the far clip of the Spotlight for texture projection.
  112219. */
  112220. projectionTextureLightFar: number;
  112221. protected _projectionTextureUpDirection: Vector3;
  112222. /**
  112223. * Gets the Up vector of the Spotlight for texture projection.
  112224. */
  112225. /**
  112226. * Sets the Up vector of the Spotlight for texture projection.
  112227. */
  112228. projectionTextureUpDirection: Vector3;
  112229. private _projectionTexture;
  112230. /**
  112231. * Gets the projection texture of the light.
  112232. */
  112233. /**
  112234. * Sets the projection texture of the light.
  112235. */
  112236. projectionTexture: Nullable<BaseTexture>;
  112237. private _projectionTextureViewLightDirty;
  112238. private _projectionTextureProjectionLightDirty;
  112239. private _projectionTextureDirty;
  112240. private _projectionTextureViewTargetVector;
  112241. private _projectionTextureViewLightMatrix;
  112242. private _projectionTextureProjectionLightMatrix;
  112243. private _projectionTextureScalingMatrix;
  112244. /**
  112245. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112246. * It can cast shadows.
  112247. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112248. * @param name The light friendly name
  112249. * @param position The position of the spot light in the scene
  112250. * @param direction The direction of the light in the scene
  112251. * @param angle The cone angle of the light in Radians
  112252. * @param exponent The light decay speed with the distance from the emission spot
  112253. * @param scene The scene the lights belongs to
  112254. */
  112255. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112256. /**
  112257. * Returns the string "SpotLight".
  112258. * @returns the class name
  112259. */
  112260. getClassName(): string;
  112261. /**
  112262. * Returns the integer 2.
  112263. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112264. */
  112265. getTypeID(): number;
  112266. /**
  112267. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112268. */
  112269. protected _setDirection(value: Vector3): void;
  112270. /**
  112271. * Overrides the position setter to recompute the projection texture view light Matrix.
  112272. */
  112273. protected _setPosition(value: Vector3): void;
  112274. /**
  112275. * 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.
  112276. * Returns the SpotLight.
  112277. */
  112278. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112279. protected _computeProjectionTextureViewLightMatrix(): void;
  112280. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112281. /**
  112282. * Main function for light texture projection matrix computing.
  112283. */
  112284. protected _computeProjectionTextureMatrix(): void;
  112285. protected _buildUniformLayout(): void;
  112286. private _computeAngleValues;
  112287. /**
  112288. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112289. * @param effect The effect to update
  112290. * @param lightIndex The index of the light in the effect to update
  112291. * @returns The spot light
  112292. */
  112293. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112294. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112295. /**
  112296. * Disposes the light and the associated resources.
  112297. */
  112298. dispose(): void;
  112299. /**
  112300. * Prepares the list of defines specific to the light type.
  112301. * @param defines the list of defines
  112302. * @param lightIndex defines the index of the light for the effect
  112303. */
  112304. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112305. }
  112306. }
  112307. declare module BABYLON {
  112308. /**
  112309. * Gizmo that enables viewing a light
  112310. */
  112311. export class LightGizmo extends Gizmo {
  112312. private _lightMesh;
  112313. private _material;
  112314. private cachedPosition;
  112315. private cachedForward;
  112316. /**
  112317. * Creates a LightGizmo
  112318. * @param gizmoLayer The utility layer the gizmo will be added to
  112319. */
  112320. constructor(gizmoLayer?: UtilityLayerRenderer);
  112321. private _light;
  112322. /**
  112323. * The light that the gizmo is attached to
  112324. */
  112325. light: Nullable<Light>;
  112326. /**
  112327. * Gets the material used to render the light gizmo
  112328. */
  112329. readonly material: StandardMaterial;
  112330. /**
  112331. * @hidden
  112332. * Updates the gizmo to match the attached mesh's position/rotation
  112333. */
  112334. protected _update(): void;
  112335. private static _Scale;
  112336. /**
  112337. * Creates the lines for a light mesh
  112338. */
  112339. private static _createLightLines;
  112340. /**
  112341. * Disposes of the light gizmo
  112342. */
  112343. dispose(): void;
  112344. private static _CreateHemisphericLightMesh;
  112345. private static _CreatePointLightMesh;
  112346. private static _CreateSpotLightMesh;
  112347. private static _CreateDirectionalLightMesh;
  112348. }
  112349. }
  112350. declare module BABYLON {
  112351. /** @hidden */
  112352. export var backgroundFragmentDeclaration: {
  112353. name: string;
  112354. shader: string;
  112355. };
  112356. }
  112357. declare module BABYLON {
  112358. /** @hidden */
  112359. export var backgroundUboDeclaration: {
  112360. name: string;
  112361. shader: string;
  112362. };
  112363. }
  112364. declare module BABYLON {
  112365. /** @hidden */
  112366. export var backgroundPixelShader: {
  112367. name: string;
  112368. shader: string;
  112369. };
  112370. }
  112371. declare module BABYLON {
  112372. /** @hidden */
  112373. export var backgroundVertexDeclaration: {
  112374. name: string;
  112375. shader: string;
  112376. };
  112377. }
  112378. declare module BABYLON {
  112379. /** @hidden */
  112380. export var backgroundVertexShader: {
  112381. name: string;
  112382. shader: string;
  112383. };
  112384. }
  112385. declare module BABYLON {
  112386. /**
  112387. * Background material used to create an efficient environement around your scene.
  112388. */
  112389. export class BackgroundMaterial extends PushMaterial {
  112390. /**
  112391. * Standard reflectance value at parallel view angle.
  112392. */
  112393. static StandardReflectance0: number;
  112394. /**
  112395. * Standard reflectance value at grazing angle.
  112396. */
  112397. static StandardReflectance90: number;
  112398. protected _primaryColor: Color3;
  112399. /**
  112400. * Key light Color (multiply against the environement texture)
  112401. */
  112402. primaryColor: Color3;
  112403. protected __perceptualColor: Nullable<Color3>;
  112404. /**
  112405. * Experimental Internal Use Only.
  112406. *
  112407. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112408. * This acts as a helper to set the primary color to a more "human friendly" value.
  112409. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112410. * output color as close as possible from the chosen value.
  112411. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112412. * part of lighting setup.)
  112413. */
  112414. _perceptualColor: Nullable<Color3>;
  112415. protected _primaryColorShadowLevel: float;
  112416. /**
  112417. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112418. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112419. */
  112420. primaryColorShadowLevel: float;
  112421. protected _primaryColorHighlightLevel: float;
  112422. /**
  112423. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112424. * The primary color is used at the level chosen to define what the white area would look.
  112425. */
  112426. primaryColorHighlightLevel: float;
  112427. protected _reflectionTexture: Nullable<BaseTexture>;
  112428. /**
  112429. * Reflection Texture used in the material.
  112430. * Should be author in a specific way for the best result (refer to the documentation).
  112431. */
  112432. reflectionTexture: Nullable<BaseTexture>;
  112433. protected _reflectionBlur: float;
  112434. /**
  112435. * Reflection Texture level of blur.
  112436. *
  112437. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112438. * texture twice.
  112439. */
  112440. reflectionBlur: float;
  112441. protected _diffuseTexture: Nullable<BaseTexture>;
  112442. /**
  112443. * Diffuse Texture used in the material.
  112444. * Should be author in a specific way for the best result (refer to the documentation).
  112445. */
  112446. diffuseTexture: Nullable<BaseTexture>;
  112447. protected _shadowLights: Nullable<IShadowLight[]>;
  112448. /**
  112449. * Specify the list of lights casting shadow on the material.
  112450. * All scene shadow lights will be included if null.
  112451. */
  112452. shadowLights: Nullable<IShadowLight[]>;
  112453. protected _shadowLevel: float;
  112454. /**
  112455. * Helps adjusting the shadow to a softer level if required.
  112456. * 0 means black shadows and 1 means no shadows.
  112457. */
  112458. shadowLevel: float;
  112459. protected _sceneCenter: Vector3;
  112460. /**
  112461. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112462. * It is usually zero but might be interesting to modify according to your setup.
  112463. */
  112464. sceneCenter: Vector3;
  112465. protected _opacityFresnel: boolean;
  112466. /**
  112467. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112468. * This helps ensuring a nice transition when the camera goes under the ground.
  112469. */
  112470. opacityFresnel: boolean;
  112471. protected _reflectionFresnel: boolean;
  112472. /**
  112473. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112474. * This helps adding a mirror texture on the ground.
  112475. */
  112476. reflectionFresnel: boolean;
  112477. protected _reflectionFalloffDistance: number;
  112478. /**
  112479. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112480. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112481. */
  112482. reflectionFalloffDistance: number;
  112483. protected _reflectionAmount: number;
  112484. /**
  112485. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112486. */
  112487. reflectionAmount: number;
  112488. protected _reflectionReflectance0: number;
  112489. /**
  112490. * This specifies the weight of the reflection at grazing angle.
  112491. */
  112492. reflectionReflectance0: number;
  112493. protected _reflectionReflectance90: number;
  112494. /**
  112495. * This specifies the weight of the reflection at a perpendicular point of view.
  112496. */
  112497. reflectionReflectance90: number;
  112498. /**
  112499. * Sets the reflection reflectance fresnel values according to the default standard
  112500. * empirically know to work well :-)
  112501. */
  112502. reflectionStandardFresnelWeight: number;
  112503. protected _useRGBColor: boolean;
  112504. /**
  112505. * Helps to directly use the maps channels instead of their level.
  112506. */
  112507. useRGBColor: boolean;
  112508. protected _enableNoise: boolean;
  112509. /**
  112510. * This helps reducing the banding effect that could occur on the background.
  112511. */
  112512. enableNoise: boolean;
  112513. /**
  112514. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112515. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112516. * Recommended to be keep at 1.0 except for special cases.
  112517. */
  112518. fovMultiplier: number;
  112519. private _fovMultiplier;
  112520. /**
  112521. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112522. */
  112523. useEquirectangularFOV: boolean;
  112524. private _maxSimultaneousLights;
  112525. /**
  112526. * Number of Simultaneous lights allowed on the material.
  112527. */
  112528. maxSimultaneousLights: int;
  112529. /**
  112530. * Default configuration related to image processing available in the Background Material.
  112531. */
  112532. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112533. /**
  112534. * Keep track of the image processing observer to allow dispose and replace.
  112535. */
  112536. private _imageProcessingObserver;
  112537. /**
  112538. * Attaches a new image processing configuration to the PBR Material.
  112539. * @param configuration (if null the scene configuration will be use)
  112540. */
  112541. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112542. /**
  112543. * Gets the image processing configuration used either in this material.
  112544. */
  112545. /**
  112546. * Sets the Default image processing configuration used either in the this material.
  112547. *
  112548. * If sets to null, the scene one is in use.
  112549. */
  112550. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112551. /**
  112552. * Gets wether the color curves effect is enabled.
  112553. */
  112554. /**
  112555. * Sets wether the color curves effect is enabled.
  112556. */
  112557. cameraColorCurvesEnabled: boolean;
  112558. /**
  112559. * Gets wether the color grading effect is enabled.
  112560. */
  112561. /**
  112562. * Gets wether the color grading effect is enabled.
  112563. */
  112564. cameraColorGradingEnabled: boolean;
  112565. /**
  112566. * Gets wether tonemapping is enabled or not.
  112567. */
  112568. /**
  112569. * Sets wether tonemapping is enabled or not
  112570. */
  112571. cameraToneMappingEnabled: boolean;
  112572. /**
  112573. * The camera exposure used on this material.
  112574. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112575. * This corresponds to a photographic exposure.
  112576. */
  112577. /**
  112578. * The camera exposure used on this material.
  112579. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112580. * This corresponds to a photographic exposure.
  112581. */
  112582. cameraExposure: float;
  112583. /**
  112584. * Gets The camera contrast used on this material.
  112585. */
  112586. /**
  112587. * Sets The camera contrast used on this material.
  112588. */
  112589. cameraContrast: float;
  112590. /**
  112591. * Gets the Color Grading 2D Lookup Texture.
  112592. */
  112593. /**
  112594. * Sets the Color Grading 2D Lookup Texture.
  112595. */
  112596. cameraColorGradingTexture: Nullable<BaseTexture>;
  112597. /**
  112598. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112599. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112600. * 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;
  112601. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112602. */
  112603. /**
  112604. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112605. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112606. * 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;
  112607. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112608. */
  112609. cameraColorCurves: Nullable<ColorCurves>;
  112610. /**
  112611. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112612. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112613. */
  112614. switchToBGR: boolean;
  112615. private _renderTargets;
  112616. private _reflectionControls;
  112617. private _white;
  112618. private _primaryShadowColor;
  112619. private _primaryHighlightColor;
  112620. /**
  112621. * Instantiates a Background Material in the given scene
  112622. * @param name The friendly name of the material
  112623. * @param scene The scene to add the material to
  112624. */
  112625. constructor(name: string, scene: Scene);
  112626. /**
  112627. * Gets a boolean indicating that current material needs to register RTT
  112628. */
  112629. readonly hasRenderTargetTextures: boolean;
  112630. /**
  112631. * The entire material has been created in order to prevent overdraw.
  112632. * @returns false
  112633. */
  112634. needAlphaTesting(): boolean;
  112635. /**
  112636. * The entire material has been created in order to prevent overdraw.
  112637. * @returns true if blending is enable
  112638. */
  112639. needAlphaBlending(): boolean;
  112640. /**
  112641. * Checks wether the material is ready to be rendered for a given mesh.
  112642. * @param mesh The mesh to render
  112643. * @param subMesh The submesh to check against
  112644. * @param useInstances Specify wether or not the material is used with instances
  112645. * @returns true if all the dependencies are ready (Textures, Effects...)
  112646. */
  112647. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112648. /**
  112649. * Compute the primary color according to the chosen perceptual color.
  112650. */
  112651. private _computePrimaryColorFromPerceptualColor;
  112652. /**
  112653. * Compute the highlights and shadow colors according to their chosen levels.
  112654. */
  112655. private _computePrimaryColors;
  112656. /**
  112657. * Build the uniform buffer used in the material.
  112658. */
  112659. buildUniformLayout(): void;
  112660. /**
  112661. * Unbind the material.
  112662. */
  112663. unbind(): void;
  112664. /**
  112665. * Bind only the world matrix to the material.
  112666. * @param world The world matrix to bind.
  112667. */
  112668. bindOnlyWorldMatrix(world: Matrix): void;
  112669. /**
  112670. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112671. * @param world The world matrix to bind.
  112672. * @param subMesh The submesh to bind for.
  112673. */
  112674. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112675. /**
  112676. * Checks to see if a texture is used in the material.
  112677. * @param texture - Base texture to use.
  112678. * @returns - Boolean specifying if a texture is used in the material.
  112679. */
  112680. hasTexture(texture: BaseTexture): boolean;
  112681. /**
  112682. * Dispose the material.
  112683. * @param forceDisposeEffect Force disposal of the associated effect.
  112684. * @param forceDisposeTextures Force disposal of the associated textures.
  112685. */
  112686. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112687. /**
  112688. * Clones the material.
  112689. * @param name The cloned name.
  112690. * @returns The cloned material.
  112691. */
  112692. clone(name: string): BackgroundMaterial;
  112693. /**
  112694. * Serializes the current material to its JSON representation.
  112695. * @returns The JSON representation.
  112696. */
  112697. serialize(): any;
  112698. /**
  112699. * Gets the class name of the material
  112700. * @returns "BackgroundMaterial"
  112701. */
  112702. getClassName(): string;
  112703. /**
  112704. * Parse a JSON input to create back a background material.
  112705. * @param source The JSON data to parse
  112706. * @param scene The scene to create the parsed material in
  112707. * @param rootUrl The root url of the assets the material depends upon
  112708. * @returns the instantiated BackgroundMaterial.
  112709. */
  112710. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112711. }
  112712. }
  112713. declare module BABYLON {
  112714. /**
  112715. * Represents the different options available during the creation of
  112716. * a Environment helper.
  112717. *
  112718. * This can control the default ground, skybox and image processing setup of your scene.
  112719. */
  112720. export interface IEnvironmentHelperOptions {
  112721. /**
  112722. * Specifies wether or not to create a ground.
  112723. * True by default.
  112724. */
  112725. createGround: boolean;
  112726. /**
  112727. * Specifies the ground size.
  112728. * 15 by default.
  112729. */
  112730. groundSize: number;
  112731. /**
  112732. * The texture used on the ground for the main color.
  112733. * Comes from the BabylonJS CDN by default.
  112734. *
  112735. * Remarks: Can be either a texture or a url.
  112736. */
  112737. groundTexture: string | BaseTexture;
  112738. /**
  112739. * The color mixed in the ground texture by default.
  112740. * BabylonJS clearColor by default.
  112741. */
  112742. groundColor: Color3;
  112743. /**
  112744. * Specifies the ground opacity.
  112745. * 1 by default.
  112746. */
  112747. groundOpacity: number;
  112748. /**
  112749. * Enables the ground to receive shadows.
  112750. * True by default.
  112751. */
  112752. enableGroundShadow: boolean;
  112753. /**
  112754. * Helps preventing the shadow to be fully black on the ground.
  112755. * 0.5 by default.
  112756. */
  112757. groundShadowLevel: number;
  112758. /**
  112759. * Creates a mirror texture attach to the ground.
  112760. * false by default.
  112761. */
  112762. enableGroundMirror: boolean;
  112763. /**
  112764. * Specifies the ground mirror size ratio.
  112765. * 0.3 by default as the default kernel is 64.
  112766. */
  112767. groundMirrorSizeRatio: number;
  112768. /**
  112769. * Specifies the ground mirror blur kernel size.
  112770. * 64 by default.
  112771. */
  112772. groundMirrorBlurKernel: number;
  112773. /**
  112774. * Specifies the ground mirror visibility amount.
  112775. * 1 by default
  112776. */
  112777. groundMirrorAmount: number;
  112778. /**
  112779. * Specifies the ground mirror reflectance weight.
  112780. * This uses the standard weight of the background material to setup the fresnel effect
  112781. * of the mirror.
  112782. * 1 by default.
  112783. */
  112784. groundMirrorFresnelWeight: number;
  112785. /**
  112786. * Specifies the ground mirror Falloff distance.
  112787. * This can helps reducing the size of the reflection.
  112788. * 0 by Default.
  112789. */
  112790. groundMirrorFallOffDistance: number;
  112791. /**
  112792. * Specifies the ground mirror texture type.
  112793. * Unsigned Int by Default.
  112794. */
  112795. groundMirrorTextureType: number;
  112796. /**
  112797. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112798. * the shown objects.
  112799. */
  112800. groundYBias: number;
  112801. /**
  112802. * Specifies wether or not to create a skybox.
  112803. * True by default.
  112804. */
  112805. createSkybox: boolean;
  112806. /**
  112807. * Specifies the skybox size.
  112808. * 20 by default.
  112809. */
  112810. skyboxSize: number;
  112811. /**
  112812. * The texture used on the skybox for the main color.
  112813. * Comes from the BabylonJS CDN by default.
  112814. *
  112815. * Remarks: Can be either a texture or a url.
  112816. */
  112817. skyboxTexture: string | BaseTexture;
  112818. /**
  112819. * The color mixed in the skybox texture by default.
  112820. * BabylonJS clearColor by default.
  112821. */
  112822. skyboxColor: Color3;
  112823. /**
  112824. * The background rotation around the Y axis of the scene.
  112825. * This helps aligning the key lights of your scene with the background.
  112826. * 0 by default.
  112827. */
  112828. backgroundYRotation: number;
  112829. /**
  112830. * Compute automatically the size of the elements to best fit with the scene.
  112831. */
  112832. sizeAuto: boolean;
  112833. /**
  112834. * Default position of the rootMesh if autoSize is not true.
  112835. */
  112836. rootPosition: Vector3;
  112837. /**
  112838. * Sets up the image processing in the scene.
  112839. * true by default.
  112840. */
  112841. setupImageProcessing: boolean;
  112842. /**
  112843. * The texture used as your environment texture in the scene.
  112844. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  112845. *
  112846. * Remarks: Can be either a texture or a url.
  112847. */
  112848. environmentTexture: string | BaseTexture;
  112849. /**
  112850. * The value of the exposure to apply to the scene.
  112851. * 0.6 by default if setupImageProcessing is true.
  112852. */
  112853. cameraExposure: number;
  112854. /**
  112855. * The value of the contrast to apply to the scene.
  112856. * 1.6 by default if setupImageProcessing is true.
  112857. */
  112858. cameraContrast: number;
  112859. /**
  112860. * Specifies wether or not tonemapping should be enabled in the scene.
  112861. * true by default if setupImageProcessing is true.
  112862. */
  112863. toneMappingEnabled: boolean;
  112864. }
  112865. /**
  112866. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  112867. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  112868. * It also helps with the default setup of your imageProcessing configuration.
  112869. */
  112870. export class EnvironmentHelper {
  112871. /**
  112872. * Default ground texture URL.
  112873. */
  112874. private static _groundTextureCDNUrl;
  112875. /**
  112876. * Default skybox texture URL.
  112877. */
  112878. private static _skyboxTextureCDNUrl;
  112879. /**
  112880. * Default environment texture URL.
  112881. */
  112882. private static _environmentTextureCDNUrl;
  112883. /**
  112884. * Creates the default options for the helper.
  112885. */
  112886. private static _getDefaultOptions;
  112887. private _rootMesh;
  112888. /**
  112889. * Gets the root mesh created by the helper.
  112890. */
  112891. readonly rootMesh: Mesh;
  112892. private _skybox;
  112893. /**
  112894. * Gets the skybox created by the helper.
  112895. */
  112896. readonly skybox: Nullable<Mesh>;
  112897. private _skyboxTexture;
  112898. /**
  112899. * Gets the skybox texture created by the helper.
  112900. */
  112901. readonly skyboxTexture: Nullable<BaseTexture>;
  112902. private _skyboxMaterial;
  112903. /**
  112904. * Gets the skybox material created by the helper.
  112905. */
  112906. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  112907. private _ground;
  112908. /**
  112909. * Gets the ground mesh created by the helper.
  112910. */
  112911. readonly ground: Nullable<Mesh>;
  112912. private _groundTexture;
  112913. /**
  112914. * Gets the ground texture created by the helper.
  112915. */
  112916. readonly groundTexture: Nullable<BaseTexture>;
  112917. private _groundMirror;
  112918. /**
  112919. * Gets the ground mirror created by the helper.
  112920. */
  112921. readonly groundMirror: Nullable<MirrorTexture>;
  112922. /**
  112923. * Gets the ground mirror render list to helps pushing the meshes
  112924. * you wish in the ground reflection.
  112925. */
  112926. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  112927. private _groundMaterial;
  112928. /**
  112929. * Gets the ground material created by the helper.
  112930. */
  112931. readonly groundMaterial: Nullable<BackgroundMaterial>;
  112932. /**
  112933. * Stores the creation options.
  112934. */
  112935. private readonly _scene;
  112936. private _options;
  112937. /**
  112938. * This observable will be notified with any error during the creation of the environment,
  112939. * mainly texture creation errors.
  112940. */
  112941. onErrorObservable: Observable<{
  112942. message?: string;
  112943. exception?: any;
  112944. }>;
  112945. /**
  112946. * constructor
  112947. * @param options Defines the options we want to customize the helper
  112948. * @param scene The scene to add the material to
  112949. */
  112950. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  112951. /**
  112952. * Updates the background according to the new options
  112953. * @param options
  112954. */
  112955. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  112956. /**
  112957. * Sets the primary color of all the available elements.
  112958. * @param color the main color to affect to the ground and the background
  112959. */
  112960. setMainColor(color: Color3): void;
  112961. /**
  112962. * Setup the image processing according to the specified options.
  112963. */
  112964. private _setupImageProcessing;
  112965. /**
  112966. * Setup the environment texture according to the specified options.
  112967. */
  112968. private _setupEnvironmentTexture;
  112969. /**
  112970. * Setup the background according to the specified options.
  112971. */
  112972. private _setupBackground;
  112973. /**
  112974. * Get the scene sizes according to the setup.
  112975. */
  112976. private _getSceneSize;
  112977. /**
  112978. * Setup the ground according to the specified options.
  112979. */
  112980. private _setupGround;
  112981. /**
  112982. * Setup the ground material according to the specified options.
  112983. */
  112984. private _setupGroundMaterial;
  112985. /**
  112986. * Setup the ground diffuse texture according to the specified options.
  112987. */
  112988. private _setupGroundDiffuseTexture;
  112989. /**
  112990. * Setup the ground mirror texture according to the specified options.
  112991. */
  112992. private _setupGroundMirrorTexture;
  112993. /**
  112994. * Setup the ground to receive the mirror texture.
  112995. */
  112996. private _setupMirrorInGroundMaterial;
  112997. /**
  112998. * Setup the skybox according to the specified options.
  112999. */
  113000. private _setupSkybox;
  113001. /**
  113002. * Setup the skybox material according to the specified options.
  113003. */
  113004. private _setupSkyboxMaterial;
  113005. /**
  113006. * Setup the skybox reflection texture according to the specified options.
  113007. */
  113008. private _setupSkyboxReflectionTexture;
  113009. private _errorHandler;
  113010. /**
  113011. * Dispose all the elements created by the Helper.
  113012. */
  113013. dispose(): void;
  113014. }
  113015. }
  113016. declare module BABYLON {
  113017. /**
  113018. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113019. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113020. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113021. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113022. */
  113023. export class PhotoDome extends TransformNode {
  113024. /**
  113025. * Define the image as a Monoscopic panoramic 360 image.
  113026. */
  113027. static readonly MODE_MONOSCOPIC: number;
  113028. /**
  113029. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113030. */
  113031. static readonly MODE_TOPBOTTOM: number;
  113032. /**
  113033. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113034. */
  113035. static readonly MODE_SIDEBYSIDE: number;
  113036. private _useDirectMapping;
  113037. /**
  113038. * The texture being displayed on the sphere
  113039. */
  113040. protected _photoTexture: Texture;
  113041. /**
  113042. * Gets or sets the texture being displayed on the sphere
  113043. */
  113044. photoTexture: Texture;
  113045. /**
  113046. * Observable raised when an error occured while loading the 360 image
  113047. */
  113048. onLoadErrorObservable: Observable<string>;
  113049. /**
  113050. * The skybox material
  113051. */
  113052. protected _material: BackgroundMaterial;
  113053. /**
  113054. * The surface used for the skybox
  113055. */
  113056. protected _mesh: Mesh;
  113057. /**
  113058. * Gets the mesh used for the skybox.
  113059. */
  113060. readonly mesh: Mesh;
  113061. /**
  113062. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113063. * Also see the options.resolution property.
  113064. */
  113065. fovMultiplier: number;
  113066. private _imageMode;
  113067. /**
  113068. * Gets or set the current video mode for the video. It can be:
  113069. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113070. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113071. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113072. */
  113073. imageMode: number;
  113074. /**
  113075. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113076. * @param name Element's name, child elements will append suffixes for their own names.
  113077. * @param urlsOfPhoto defines the url of the photo to display
  113078. * @param options defines an object containing optional or exposed sub element properties
  113079. * @param onError defines a callback called when an error occured while loading the texture
  113080. */
  113081. constructor(name: string, urlOfPhoto: string, options: {
  113082. resolution?: number;
  113083. size?: number;
  113084. useDirectMapping?: boolean;
  113085. faceForward?: boolean;
  113086. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113087. private _onBeforeCameraRenderObserver;
  113088. private _changeImageMode;
  113089. /**
  113090. * Releases resources associated with this node.
  113091. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113092. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113093. */
  113094. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113095. }
  113096. }
  113097. declare module BABYLON {
  113098. /**
  113099. * Class used to host RGBD texture specific utilities
  113100. */
  113101. export class RGBDTextureTools {
  113102. /**
  113103. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113104. * @param texture the texture to expand.
  113105. */
  113106. static ExpandRGBDTexture(texture: Texture): void;
  113107. }
  113108. }
  113109. declare module BABYLON {
  113110. /**
  113111. * Class used to host texture specific utilities
  113112. */
  113113. export class BRDFTextureTools {
  113114. /**
  113115. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113116. * @param scene defines the hosting scene
  113117. * @returns the environment BRDF texture
  113118. */
  113119. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113120. private static _environmentBRDFBase64Texture;
  113121. }
  113122. }
  113123. declare module BABYLON {
  113124. /**
  113125. * @hidden
  113126. */
  113127. export interface IMaterialClearCoatDefines {
  113128. CLEARCOAT: boolean;
  113129. CLEARCOAT_DEFAULTIOR: boolean;
  113130. CLEARCOAT_TEXTURE: boolean;
  113131. CLEARCOAT_TEXTUREDIRECTUV: number;
  113132. CLEARCOAT_BUMP: boolean;
  113133. CLEARCOAT_BUMPDIRECTUV: number;
  113134. CLEARCOAT_TINT: boolean;
  113135. CLEARCOAT_TINT_TEXTURE: boolean;
  113136. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113137. /** @hidden */
  113138. _areTexturesDirty: boolean;
  113139. }
  113140. /**
  113141. * Define the code related to the clear coat parameters of the pbr material.
  113142. */
  113143. export class PBRClearCoatConfiguration {
  113144. /**
  113145. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113146. * The default fits with a polyurethane material.
  113147. */
  113148. private static readonly _DefaultIndexOfRefraction;
  113149. private _isEnabled;
  113150. /**
  113151. * Defines if the clear coat is enabled in the material.
  113152. */
  113153. isEnabled: boolean;
  113154. /**
  113155. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113156. */
  113157. intensity: number;
  113158. /**
  113159. * Defines the clear coat layer roughness.
  113160. */
  113161. roughness: number;
  113162. private _indexOfRefraction;
  113163. /**
  113164. * Defines the index of refraction of the clear coat.
  113165. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113166. * The default fits with a polyurethane material.
  113167. * Changing the default value is more performance intensive.
  113168. */
  113169. indexOfRefraction: number;
  113170. private _texture;
  113171. /**
  113172. * Stores the clear coat values in a texture.
  113173. */
  113174. texture: Nullable<BaseTexture>;
  113175. private _bumpTexture;
  113176. /**
  113177. * Define the clear coat specific bump texture.
  113178. */
  113179. bumpTexture: Nullable<BaseTexture>;
  113180. private _isTintEnabled;
  113181. /**
  113182. * Defines if the clear coat tint is enabled in the material.
  113183. */
  113184. isTintEnabled: boolean;
  113185. /**
  113186. * Defines the clear coat tint of the material.
  113187. * This is only use if tint is enabled
  113188. */
  113189. tintColor: Color3;
  113190. /**
  113191. * Defines the distance at which the tint color should be found in the
  113192. * clear coat media.
  113193. * This is only use if tint is enabled
  113194. */
  113195. tintColorAtDistance: number;
  113196. /**
  113197. * Defines the clear coat layer thickness.
  113198. * This is only use if tint is enabled
  113199. */
  113200. tintThickness: number;
  113201. private _tintTexture;
  113202. /**
  113203. * Stores the clear tint values in a texture.
  113204. * rgb is tint
  113205. * a is a thickness factor
  113206. */
  113207. tintTexture: Nullable<BaseTexture>;
  113208. /** @hidden */
  113209. private _internalMarkAllSubMeshesAsTexturesDirty;
  113210. /** @hidden */
  113211. _markAllSubMeshesAsTexturesDirty(): void;
  113212. /**
  113213. * Instantiate a new istance of clear coat configuration.
  113214. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113215. */
  113216. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113217. /**
  113218. * Gets wehter the submesh is ready to be used or not.
  113219. * @param defines the list of "defines" to update.
  113220. * @param scene defines the scene the material belongs to.
  113221. * @param engine defines the engine the material belongs to.
  113222. * @param disableBumpMap defines wether the material disables bump or not.
  113223. * @returns - boolean indicating that the submesh is ready or not.
  113224. */
  113225. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113226. /**
  113227. * Checks to see if a texture is used in the material.
  113228. * @param defines the list of "defines" to update.
  113229. * @param scene defines the scene to the material belongs to.
  113230. */
  113231. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113232. /**
  113233. * Binds the material data.
  113234. * @param uniformBuffer defines the Uniform buffer to fill in.
  113235. * @param scene defines the scene the material belongs to.
  113236. * @param engine defines the engine the material belongs to.
  113237. * @param disableBumpMap defines wether the material disables bump or not.
  113238. * @param isFrozen defines wether the material is frozen or not.
  113239. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113240. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113241. */
  113242. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113243. /**
  113244. * Checks to see if a texture is used in the material.
  113245. * @param texture - Base texture to use.
  113246. * @returns - Boolean specifying if a texture is used in the material.
  113247. */
  113248. hasTexture(texture: BaseTexture): boolean;
  113249. /**
  113250. * Returns an array of the actively used textures.
  113251. * @param activeTextures Array of BaseTextures
  113252. */
  113253. getActiveTextures(activeTextures: BaseTexture[]): void;
  113254. /**
  113255. * Returns the animatable textures.
  113256. * @param animatables Array of animatable textures.
  113257. */
  113258. getAnimatables(animatables: IAnimatable[]): void;
  113259. /**
  113260. * Disposes the resources of the material.
  113261. * @param forceDisposeTextures - Forces the disposal of all textures.
  113262. */
  113263. dispose(forceDisposeTextures?: boolean): void;
  113264. /**
  113265. * Get the current class name of the texture useful for serialization or dynamic coding.
  113266. * @returns "PBRClearCoatConfiguration"
  113267. */
  113268. getClassName(): string;
  113269. /**
  113270. * Add fallbacks to the effect fallbacks list.
  113271. * @param defines defines the Base texture to use.
  113272. * @param fallbacks defines the current fallback list.
  113273. * @param currentRank defines the current fallback rank.
  113274. * @returns the new fallback rank.
  113275. */
  113276. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113277. /**
  113278. * Add the required uniforms to the current list.
  113279. * @param uniforms defines the current uniform list.
  113280. */
  113281. static AddUniforms(uniforms: string[]): void;
  113282. /**
  113283. * Add the required samplers to the current list.
  113284. * @param samplers defines the current sampler list.
  113285. */
  113286. static AddSamplers(samplers: string[]): void;
  113287. /**
  113288. * Add the required uniforms to the current buffer.
  113289. * @param uniformBuffer defines the current uniform buffer.
  113290. */
  113291. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113292. /**
  113293. * Makes a duplicate of the current configuration into another one.
  113294. * @param clearCoatConfiguration define the config where to copy the info
  113295. */
  113296. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113297. /**
  113298. * Serializes this clear coat configuration.
  113299. * @returns - An object with the serialized config.
  113300. */
  113301. serialize(): any;
  113302. /**
  113303. * Parses a anisotropy Configuration from a serialized object.
  113304. * @param source - Serialized object.
  113305. * @param scene Defines the scene we are parsing for
  113306. * @param rootUrl Defines the rootUrl to load from
  113307. */
  113308. parse(source: any, scene: Scene, rootUrl: string): void;
  113309. }
  113310. }
  113311. declare module BABYLON {
  113312. /**
  113313. * @hidden
  113314. */
  113315. export interface IMaterialAnisotropicDefines {
  113316. ANISOTROPIC: boolean;
  113317. ANISOTROPIC_TEXTURE: boolean;
  113318. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113319. MAINUV1: boolean;
  113320. _areTexturesDirty: boolean;
  113321. _needUVs: boolean;
  113322. }
  113323. /**
  113324. * Define the code related to the anisotropic parameters of the pbr material.
  113325. */
  113326. export class PBRAnisotropicConfiguration {
  113327. private _isEnabled;
  113328. /**
  113329. * Defines if the anisotropy is enabled in the material.
  113330. */
  113331. isEnabled: boolean;
  113332. /**
  113333. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113334. */
  113335. intensity: number;
  113336. /**
  113337. * Defines if the effect is along the tangents, bitangents or in between.
  113338. * By default, the effect is "strectching" the highlights along the tangents.
  113339. */
  113340. direction: Vector2;
  113341. private _texture;
  113342. /**
  113343. * Stores the anisotropy values in a texture.
  113344. * rg is direction (like normal from -1 to 1)
  113345. * b is a intensity
  113346. */
  113347. texture: Nullable<BaseTexture>;
  113348. /** @hidden */
  113349. private _internalMarkAllSubMeshesAsTexturesDirty;
  113350. /** @hidden */
  113351. _markAllSubMeshesAsTexturesDirty(): void;
  113352. /**
  113353. * Instantiate a new istance of anisotropy configuration.
  113354. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113355. */
  113356. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113357. /**
  113358. * Specifies that the submesh is ready to be used.
  113359. * @param defines the list of "defines" to update.
  113360. * @param scene defines the scene the material belongs to.
  113361. * @returns - boolean indicating that the submesh is ready or not.
  113362. */
  113363. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113364. /**
  113365. * Checks to see if a texture is used in the material.
  113366. * @param defines the list of "defines" to update.
  113367. * @param mesh the mesh we are preparing the defines for.
  113368. * @param scene defines the scene the material belongs to.
  113369. */
  113370. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113371. /**
  113372. * Binds the material data.
  113373. * @param uniformBuffer defines the Uniform buffer to fill in.
  113374. * @param scene defines the scene the material belongs to.
  113375. * @param isFrozen defines wether the material is frozen or not.
  113376. */
  113377. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113378. /**
  113379. * Checks to see if a texture is used in the material.
  113380. * @param texture - Base texture to use.
  113381. * @returns - Boolean specifying if a texture is used in the material.
  113382. */
  113383. hasTexture(texture: BaseTexture): boolean;
  113384. /**
  113385. * Returns an array of the actively used textures.
  113386. * @param activeTextures Array of BaseTextures
  113387. */
  113388. getActiveTextures(activeTextures: BaseTexture[]): void;
  113389. /**
  113390. * Returns the animatable textures.
  113391. * @param animatables Array of animatable textures.
  113392. */
  113393. getAnimatables(animatables: IAnimatable[]): void;
  113394. /**
  113395. * Disposes the resources of the material.
  113396. * @param forceDisposeTextures - Forces the disposal of all textures.
  113397. */
  113398. dispose(forceDisposeTextures?: boolean): void;
  113399. /**
  113400. * Get the current class name of the texture useful for serialization or dynamic coding.
  113401. * @returns "PBRAnisotropicConfiguration"
  113402. */
  113403. getClassName(): string;
  113404. /**
  113405. * Add fallbacks to the effect fallbacks list.
  113406. * @param defines defines the Base texture to use.
  113407. * @param fallbacks defines the current fallback list.
  113408. * @param currentRank defines the current fallback rank.
  113409. * @returns the new fallback rank.
  113410. */
  113411. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113412. /**
  113413. * Add the required uniforms to the current list.
  113414. * @param uniforms defines the current uniform list.
  113415. */
  113416. static AddUniforms(uniforms: string[]): void;
  113417. /**
  113418. * Add the required uniforms to the current buffer.
  113419. * @param uniformBuffer defines the current uniform buffer.
  113420. */
  113421. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113422. /**
  113423. * Add the required samplers to the current list.
  113424. * @param samplers defines the current sampler list.
  113425. */
  113426. static AddSamplers(samplers: string[]): void;
  113427. /**
  113428. * Makes a duplicate of the current configuration into another one.
  113429. * @param anisotropicConfiguration define the config where to copy the info
  113430. */
  113431. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113432. /**
  113433. * Serializes this anisotropy configuration.
  113434. * @returns - An object with the serialized config.
  113435. */
  113436. serialize(): any;
  113437. /**
  113438. * Parses a anisotropy Configuration from a serialized object.
  113439. * @param source - Serialized object.
  113440. * @param scene Defines the scene we are parsing for
  113441. * @param rootUrl Defines the rootUrl to load from
  113442. */
  113443. parse(source: any, scene: Scene, rootUrl: string): void;
  113444. }
  113445. }
  113446. declare module BABYLON {
  113447. /**
  113448. * @hidden
  113449. */
  113450. export interface IMaterialBRDFDefines {
  113451. BRDF_V_HEIGHT_CORRELATED: boolean;
  113452. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113453. SPHERICAL_HARMONICS: boolean;
  113454. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113455. /** @hidden */
  113456. _areMiscDirty: boolean;
  113457. }
  113458. /**
  113459. * Define the code related to the BRDF parameters of the pbr material.
  113460. */
  113461. export class PBRBRDFConfiguration {
  113462. /**
  113463. * Default value used for the energy conservation.
  113464. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113465. */
  113466. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113467. /**
  113468. * Default value used for the Smith Visibility Height Correlated mode.
  113469. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113470. */
  113471. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113472. /**
  113473. * Default value used for the IBL diffuse part.
  113474. * This can help switching back to the polynomials mode globally which is a tiny bit
  113475. * less GPU intensive at the drawback of a lower quality.
  113476. */
  113477. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113478. /**
  113479. * Default value used for activating energy conservation for the specular workflow.
  113480. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113481. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113482. */
  113483. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113484. private _useEnergyConservation;
  113485. /**
  113486. * Defines if the material uses energy conservation.
  113487. */
  113488. useEnergyConservation: boolean;
  113489. private _useSmithVisibilityHeightCorrelated;
  113490. /**
  113491. * LEGACY Mode set to false
  113492. * Defines if the material uses height smith correlated visibility term.
  113493. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113494. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113495. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113496. * Not relying on height correlated will also disable energy conservation.
  113497. */
  113498. useSmithVisibilityHeightCorrelated: boolean;
  113499. private _useSphericalHarmonics;
  113500. /**
  113501. * LEGACY Mode set to false
  113502. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113503. * diffuse part of the IBL.
  113504. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113505. * to the ground truth.
  113506. */
  113507. useSphericalHarmonics: boolean;
  113508. private _useSpecularGlossinessInputEnergyConservation;
  113509. /**
  113510. * Defines if the material uses energy conservation, when the specular workflow is active.
  113511. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113512. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113513. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113514. */
  113515. useSpecularGlossinessInputEnergyConservation: boolean;
  113516. /** @hidden */
  113517. private _internalMarkAllSubMeshesAsMiscDirty;
  113518. /** @hidden */
  113519. _markAllSubMeshesAsMiscDirty(): void;
  113520. /**
  113521. * Instantiate a new istance of clear coat configuration.
  113522. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113523. */
  113524. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113525. /**
  113526. * Checks to see if a texture is used in the material.
  113527. * @param defines the list of "defines" to update.
  113528. */
  113529. prepareDefines(defines: IMaterialBRDFDefines): void;
  113530. /**
  113531. * Get the current class name of the texture useful for serialization or dynamic coding.
  113532. * @returns "PBRClearCoatConfiguration"
  113533. */
  113534. getClassName(): string;
  113535. /**
  113536. * Makes a duplicate of the current configuration into another one.
  113537. * @param brdfConfiguration define the config where to copy the info
  113538. */
  113539. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113540. /**
  113541. * Serializes this BRDF configuration.
  113542. * @returns - An object with the serialized config.
  113543. */
  113544. serialize(): any;
  113545. /**
  113546. * Parses a anisotropy Configuration from a serialized object.
  113547. * @param source - Serialized object.
  113548. * @param scene Defines the scene we are parsing for
  113549. * @param rootUrl Defines the rootUrl to load from
  113550. */
  113551. parse(source: any, scene: Scene, rootUrl: string): void;
  113552. }
  113553. }
  113554. declare module BABYLON {
  113555. /**
  113556. * @hidden
  113557. */
  113558. export interface IMaterialSheenDefines {
  113559. SHEEN: boolean;
  113560. SHEEN_TEXTURE: boolean;
  113561. SHEEN_TEXTUREDIRECTUV: number;
  113562. SHEEN_LINKWITHALBEDO: boolean;
  113563. /** @hidden */
  113564. _areTexturesDirty: boolean;
  113565. }
  113566. /**
  113567. * Define the code related to the Sheen parameters of the pbr material.
  113568. */
  113569. export class PBRSheenConfiguration {
  113570. private _isEnabled;
  113571. /**
  113572. * Defines if the material uses sheen.
  113573. */
  113574. isEnabled: boolean;
  113575. private _linkSheenWithAlbedo;
  113576. /**
  113577. * Defines if the sheen is linked to the sheen color.
  113578. */
  113579. linkSheenWithAlbedo: boolean;
  113580. /**
  113581. * Defines the sheen intensity.
  113582. */
  113583. intensity: number;
  113584. /**
  113585. * Defines the sheen color.
  113586. */
  113587. color: Color3;
  113588. private _texture;
  113589. /**
  113590. * Stores the sheen tint values in a texture.
  113591. * rgb is tint
  113592. * a is a intensity
  113593. */
  113594. texture: Nullable<BaseTexture>;
  113595. /** @hidden */
  113596. private _internalMarkAllSubMeshesAsTexturesDirty;
  113597. /** @hidden */
  113598. _markAllSubMeshesAsTexturesDirty(): void;
  113599. /**
  113600. * Instantiate a new istance of clear coat configuration.
  113601. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113602. */
  113603. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113604. /**
  113605. * Specifies that the submesh is ready to be used.
  113606. * @param defines the list of "defines" to update.
  113607. * @param scene defines the scene the material belongs to.
  113608. * @returns - boolean indicating that the submesh is ready or not.
  113609. */
  113610. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113611. /**
  113612. * Checks to see if a texture is used in the material.
  113613. * @param defines the list of "defines" to update.
  113614. * @param scene defines the scene the material belongs to.
  113615. */
  113616. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113617. /**
  113618. * Binds the material data.
  113619. * @param uniformBuffer defines the Uniform buffer to fill in.
  113620. * @param scene defines the scene the material belongs to.
  113621. * @param isFrozen defines wether the material is frozen or not.
  113622. */
  113623. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113624. /**
  113625. * Checks to see if a texture is used in the material.
  113626. * @param texture - Base texture to use.
  113627. * @returns - Boolean specifying if a texture is used in the material.
  113628. */
  113629. hasTexture(texture: BaseTexture): boolean;
  113630. /**
  113631. * Returns an array of the actively used textures.
  113632. * @param activeTextures Array of BaseTextures
  113633. */
  113634. getActiveTextures(activeTextures: BaseTexture[]): void;
  113635. /**
  113636. * Returns the animatable textures.
  113637. * @param animatables Array of animatable textures.
  113638. */
  113639. getAnimatables(animatables: IAnimatable[]): void;
  113640. /**
  113641. * Disposes the resources of the material.
  113642. * @param forceDisposeTextures - Forces the disposal of all textures.
  113643. */
  113644. dispose(forceDisposeTextures?: boolean): void;
  113645. /**
  113646. * Get the current class name of the texture useful for serialization or dynamic coding.
  113647. * @returns "PBRSheenConfiguration"
  113648. */
  113649. getClassName(): string;
  113650. /**
  113651. * Add fallbacks to the effect fallbacks list.
  113652. * @param defines defines the Base texture to use.
  113653. * @param fallbacks defines the current fallback list.
  113654. * @param currentRank defines the current fallback rank.
  113655. * @returns the new fallback rank.
  113656. */
  113657. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113658. /**
  113659. * Add the required uniforms to the current list.
  113660. * @param uniforms defines the current uniform list.
  113661. */
  113662. static AddUniforms(uniforms: string[]): void;
  113663. /**
  113664. * Add the required uniforms to the current buffer.
  113665. * @param uniformBuffer defines the current uniform buffer.
  113666. */
  113667. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113668. /**
  113669. * Add the required samplers to the current list.
  113670. * @param samplers defines the current sampler list.
  113671. */
  113672. static AddSamplers(samplers: string[]): void;
  113673. /**
  113674. * Makes a duplicate of the current configuration into another one.
  113675. * @param sheenConfiguration define the config where to copy the info
  113676. */
  113677. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113678. /**
  113679. * Serializes this BRDF configuration.
  113680. * @returns - An object with the serialized config.
  113681. */
  113682. serialize(): any;
  113683. /**
  113684. * Parses a anisotropy Configuration from a serialized object.
  113685. * @param source - Serialized object.
  113686. * @param scene Defines the scene we are parsing for
  113687. * @param rootUrl Defines the rootUrl to load from
  113688. */
  113689. parse(source: any, scene: Scene, rootUrl: string): void;
  113690. }
  113691. }
  113692. declare module BABYLON {
  113693. /**
  113694. * @hidden
  113695. */
  113696. export interface IMaterialSubSurfaceDefines {
  113697. SUBSURFACE: boolean;
  113698. SS_REFRACTION: boolean;
  113699. SS_TRANSLUCENCY: boolean;
  113700. SS_SCATERRING: boolean;
  113701. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113702. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113703. SS_REFRACTIONMAP_3D: boolean;
  113704. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113705. SS_LODINREFRACTIONALPHA: boolean;
  113706. SS_GAMMAREFRACTION: boolean;
  113707. SS_RGBDREFRACTION: boolean;
  113708. SS_LINEARSPECULARREFRACTION: boolean;
  113709. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113710. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113711. /** @hidden */
  113712. _areTexturesDirty: boolean;
  113713. }
  113714. /**
  113715. * Define the code related to the sub surface parameters of the pbr material.
  113716. */
  113717. export class PBRSubSurfaceConfiguration {
  113718. private _isRefractionEnabled;
  113719. /**
  113720. * Defines if the refraction is enabled in the material.
  113721. */
  113722. isRefractionEnabled: boolean;
  113723. private _isTranslucencyEnabled;
  113724. /**
  113725. * Defines if the translucency is enabled in the material.
  113726. */
  113727. isTranslucencyEnabled: boolean;
  113728. private _isScatteringEnabled;
  113729. /**
  113730. * Defines the refraction intensity of the material.
  113731. * The refraction when enabled replaces the Diffuse part of the material.
  113732. * The intensity helps transitionning between diffuse and refraction.
  113733. */
  113734. refractionIntensity: number;
  113735. /**
  113736. * Defines the translucency intensity of the material.
  113737. * When translucency has been enabled, this defines how much of the "translucency"
  113738. * is addded to the diffuse part of the material.
  113739. */
  113740. translucencyIntensity: number;
  113741. /**
  113742. * Defines the scattering intensity of the material.
  113743. * When scattering has been enabled, this defines how much of the "scattered light"
  113744. * is addded to the diffuse part of the material.
  113745. */
  113746. scatteringIntensity: number;
  113747. private _thicknessTexture;
  113748. /**
  113749. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113750. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113751. * 0 would mean minimumThickness
  113752. * 1 would mean maximumThickness
  113753. * The other channels might be use as a mask to vary the different effects intensity.
  113754. */
  113755. thicknessTexture: Nullable<BaseTexture>;
  113756. private _refractionTexture;
  113757. /**
  113758. * Defines the texture to use for refraction.
  113759. */
  113760. refractionTexture: Nullable<BaseTexture>;
  113761. private _indexOfRefraction;
  113762. /**
  113763. * Defines the index of refraction used in the material.
  113764. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113765. */
  113766. indexOfRefraction: number;
  113767. private _invertRefractionY;
  113768. /**
  113769. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113770. */
  113771. invertRefractionY: boolean;
  113772. private _linkRefractionWithTransparency;
  113773. /**
  113774. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113775. * Materials half opaque for instance using refraction could benefit from this control.
  113776. */
  113777. linkRefractionWithTransparency: boolean;
  113778. /**
  113779. * Defines the minimum thickness stored in the thickness map.
  113780. * If no thickness map is defined, this value will be used to simulate thickness.
  113781. */
  113782. minimumThickness: number;
  113783. /**
  113784. * Defines the maximum thickness stored in the thickness map.
  113785. */
  113786. maximumThickness: number;
  113787. /**
  113788. * Defines the volume tint of the material.
  113789. * This is used for both translucency and scattering.
  113790. */
  113791. tintColor: Color3;
  113792. /**
  113793. * Defines the distance at which the tint color should be found in the media.
  113794. * This is used for refraction only.
  113795. */
  113796. tintColorAtDistance: number;
  113797. /**
  113798. * Defines how far each channel transmit through the media.
  113799. * It is defined as a color to simplify it selection.
  113800. */
  113801. diffusionDistance: Color3;
  113802. private _useMaskFromThicknessTexture;
  113803. /**
  113804. * Stores the intensity of the different subsurface effects in the thickness texture.
  113805. * * the green channel is the translucency intensity.
  113806. * * the blue channel is the scattering intensity.
  113807. * * the alpha channel is the refraction intensity.
  113808. */
  113809. useMaskFromThicknessTexture: boolean;
  113810. /** @hidden */
  113811. private _internalMarkAllSubMeshesAsTexturesDirty;
  113812. /** @hidden */
  113813. _markAllSubMeshesAsTexturesDirty(): void;
  113814. /**
  113815. * Instantiate a new istance of sub surface configuration.
  113816. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113817. */
  113818. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113819. /**
  113820. * Gets wehter the submesh is ready to be used or not.
  113821. * @param defines the list of "defines" to update.
  113822. * @param scene defines the scene the material belongs to.
  113823. * @returns - boolean indicating that the submesh is ready or not.
  113824. */
  113825. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113826. /**
  113827. * Checks to see if a texture is used in the material.
  113828. * @param defines the list of "defines" to update.
  113829. * @param scene defines the scene to the material belongs to.
  113830. */
  113831. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113832. /**
  113833. * Binds the material data.
  113834. * @param uniformBuffer defines the Uniform buffer to fill in.
  113835. * @param scene defines the scene the material belongs to.
  113836. * @param engine defines the engine the material belongs to.
  113837. * @param isFrozen defines wether the material is frozen or not.
  113838. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113839. */
  113840. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113841. /**
  113842. * Unbinds the material from the mesh.
  113843. * @param activeEffect defines the effect that should be unbound from.
  113844. * @returns true if unbound, otherwise false
  113845. */
  113846. unbind(activeEffect: Effect): boolean;
  113847. /**
  113848. * Returns the texture used for refraction or null if none is used.
  113849. * @param scene defines the scene the material belongs to.
  113850. * @returns - Refraction texture if present. If no refraction texture and refraction
  113851. * is linked with transparency, returns environment texture. Otherwise, returns null.
  113852. */
  113853. private _getRefractionTexture;
  113854. /**
  113855. * Returns true if alpha blending should be disabled.
  113856. */
  113857. readonly disableAlphaBlending: boolean;
  113858. /**
  113859. * Fills the list of render target textures.
  113860. * @param renderTargets the list of render targets to update
  113861. */
  113862. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  113863. /**
  113864. * Checks to see if a texture is used in the material.
  113865. * @param texture - Base texture to use.
  113866. * @returns - Boolean specifying if a texture is used in the material.
  113867. */
  113868. hasTexture(texture: BaseTexture): boolean;
  113869. /**
  113870. * Gets a boolean indicating that current material needs to register RTT
  113871. * @returns true if this uses a render target otherwise false.
  113872. */
  113873. hasRenderTargetTextures(): boolean;
  113874. /**
  113875. * Returns an array of the actively used textures.
  113876. * @param activeTextures Array of BaseTextures
  113877. */
  113878. getActiveTextures(activeTextures: BaseTexture[]): void;
  113879. /**
  113880. * Returns the animatable textures.
  113881. * @param animatables Array of animatable textures.
  113882. */
  113883. getAnimatables(animatables: IAnimatable[]): void;
  113884. /**
  113885. * Disposes the resources of the material.
  113886. * @param forceDisposeTextures - Forces the disposal of all textures.
  113887. */
  113888. dispose(forceDisposeTextures?: boolean): void;
  113889. /**
  113890. * Get the current class name of the texture useful for serialization or dynamic coding.
  113891. * @returns "PBRSubSurfaceConfiguration"
  113892. */
  113893. getClassName(): string;
  113894. /**
  113895. * Add fallbacks to the effect fallbacks list.
  113896. * @param defines defines the Base texture to use.
  113897. * @param fallbacks defines the current fallback list.
  113898. * @param currentRank defines the current fallback rank.
  113899. * @returns the new fallback rank.
  113900. */
  113901. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113902. /**
  113903. * Add the required uniforms to the current list.
  113904. * @param uniforms defines the current uniform list.
  113905. */
  113906. static AddUniforms(uniforms: string[]): void;
  113907. /**
  113908. * Add the required samplers to the current list.
  113909. * @param samplers defines the current sampler list.
  113910. */
  113911. static AddSamplers(samplers: string[]): void;
  113912. /**
  113913. * Add the required uniforms to the current buffer.
  113914. * @param uniformBuffer defines the current uniform buffer.
  113915. */
  113916. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113917. /**
  113918. * Makes a duplicate of the current configuration into another one.
  113919. * @param configuration define the config where to copy the info
  113920. */
  113921. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  113922. /**
  113923. * Serializes this Sub Surface configuration.
  113924. * @returns - An object with the serialized config.
  113925. */
  113926. serialize(): any;
  113927. /**
  113928. * Parses a anisotropy Configuration from a serialized object.
  113929. * @param source - Serialized object.
  113930. * @param scene Defines the scene we are parsing for
  113931. * @param rootUrl Defines the rootUrl to load from
  113932. */
  113933. parse(source: any, scene: Scene, rootUrl: string): void;
  113934. }
  113935. }
  113936. declare module BABYLON {
  113937. /** @hidden */
  113938. export var pbrFragmentDeclaration: {
  113939. name: string;
  113940. shader: string;
  113941. };
  113942. }
  113943. declare module BABYLON {
  113944. /** @hidden */
  113945. export var pbrUboDeclaration: {
  113946. name: string;
  113947. shader: string;
  113948. };
  113949. }
  113950. declare module BABYLON {
  113951. /** @hidden */
  113952. export var pbrFragmentExtraDeclaration: {
  113953. name: string;
  113954. shader: string;
  113955. };
  113956. }
  113957. declare module BABYLON {
  113958. /** @hidden */
  113959. export var pbrFragmentSamplersDeclaration: {
  113960. name: string;
  113961. shader: string;
  113962. };
  113963. }
  113964. declare module BABYLON {
  113965. /** @hidden */
  113966. export var pbrHelperFunctions: {
  113967. name: string;
  113968. shader: string;
  113969. };
  113970. }
  113971. declare module BABYLON {
  113972. /** @hidden */
  113973. export var harmonicsFunctions: {
  113974. name: string;
  113975. shader: string;
  113976. };
  113977. }
  113978. declare module BABYLON {
  113979. /** @hidden */
  113980. export var pbrDirectLightingSetupFunctions: {
  113981. name: string;
  113982. shader: string;
  113983. };
  113984. }
  113985. declare module BABYLON {
  113986. /** @hidden */
  113987. export var pbrDirectLightingFalloffFunctions: {
  113988. name: string;
  113989. shader: string;
  113990. };
  113991. }
  113992. declare module BABYLON {
  113993. /** @hidden */
  113994. export var pbrBRDFFunctions: {
  113995. name: string;
  113996. shader: string;
  113997. };
  113998. }
  113999. declare module BABYLON {
  114000. /** @hidden */
  114001. export var pbrDirectLightingFunctions: {
  114002. name: string;
  114003. shader: string;
  114004. };
  114005. }
  114006. declare module BABYLON {
  114007. /** @hidden */
  114008. export var pbrIBLFunctions: {
  114009. name: string;
  114010. shader: string;
  114011. };
  114012. }
  114013. declare module BABYLON {
  114014. /** @hidden */
  114015. export var pbrDebug: {
  114016. name: string;
  114017. shader: string;
  114018. };
  114019. }
  114020. declare module BABYLON {
  114021. /** @hidden */
  114022. export var pbrPixelShader: {
  114023. name: string;
  114024. shader: string;
  114025. };
  114026. }
  114027. declare module BABYLON {
  114028. /** @hidden */
  114029. export var pbrVertexDeclaration: {
  114030. name: string;
  114031. shader: string;
  114032. };
  114033. }
  114034. declare module BABYLON {
  114035. /** @hidden */
  114036. export var pbrVertexShader: {
  114037. name: string;
  114038. shader: string;
  114039. };
  114040. }
  114041. declare module BABYLON {
  114042. /**
  114043. * Manages the defines for the PBR Material.
  114044. * @hidden
  114045. */
  114046. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114047. PBR: boolean;
  114048. MAINUV1: boolean;
  114049. MAINUV2: boolean;
  114050. UV1: boolean;
  114051. UV2: boolean;
  114052. ALBEDO: boolean;
  114053. ALBEDODIRECTUV: number;
  114054. VERTEXCOLOR: boolean;
  114055. AMBIENT: boolean;
  114056. AMBIENTDIRECTUV: number;
  114057. AMBIENTINGRAYSCALE: boolean;
  114058. OPACITY: boolean;
  114059. VERTEXALPHA: boolean;
  114060. OPACITYDIRECTUV: number;
  114061. OPACITYRGB: boolean;
  114062. ALPHATEST: boolean;
  114063. DEPTHPREPASS: boolean;
  114064. ALPHABLEND: boolean;
  114065. ALPHAFROMALBEDO: boolean;
  114066. ALPHATESTVALUE: string;
  114067. SPECULAROVERALPHA: boolean;
  114068. RADIANCEOVERALPHA: boolean;
  114069. ALPHAFRESNEL: boolean;
  114070. LINEARALPHAFRESNEL: boolean;
  114071. PREMULTIPLYALPHA: boolean;
  114072. EMISSIVE: boolean;
  114073. EMISSIVEDIRECTUV: number;
  114074. REFLECTIVITY: boolean;
  114075. REFLECTIVITYDIRECTUV: number;
  114076. SPECULARTERM: boolean;
  114077. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114078. MICROSURFACEAUTOMATIC: boolean;
  114079. LODBASEDMICROSFURACE: boolean;
  114080. MICROSURFACEMAP: boolean;
  114081. MICROSURFACEMAPDIRECTUV: number;
  114082. METALLICWORKFLOW: boolean;
  114083. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114084. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114085. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114086. AOSTOREINMETALMAPRED: boolean;
  114087. ENVIRONMENTBRDF: boolean;
  114088. ENVIRONMENTBRDF_RGBD: boolean;
  114089. NORMAL: boolean;
  114090. TANGENT: boolean;
  114091. BUMP: boolean;
  114092. BUMPDIRECTUV: number;
  114093. OBJECTSPACE_NORMALMAP: boolean;
  114094. PARALLAX: boolean;
  114095. PARALLAXOCCLUSION: boolean;
  114096. NORMALXYSCALE: boolean;
  114097. LIGHTMAP: boolean;
  114098. LIGHTMAPDIRECTUV: number;
  114099. USELIGHTMAPASSHADOWMAP: boolean;
  114100. GAMMALIGHTMAP: boolean;
  114101. RGBDLIGHTMAP: boolean;
  114102. REFLECTION: boolean;
  114103. REFLECTIONMAP_3D: boolean;
  114104. REFLECTIONMAP_SPHERICAL: boolean;
  114105. REFLECTIONMAP_PLANAR: boolean;
  114106. REFLECTIONMAP_CUBIC: boolean;
  114107. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114108. REFLECTIONMAP_PROJECTION: boolean;
  114109. REFLECTIONMAP_SKYBOX: boolean;
  114110. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114111. REFLECTIONMAP_EXPLICIT: boolean;
  114112. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114113. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114114. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114115. INVERTCUBICMAP: boolean;
  114116. USESPHERICALFROMREFLECTIONMAP: boolean;
  114117. USEIRRADIANCEMAP: boolean;
  114118. SPHERICAL_HARMONICS: boolean;
  114119. USESPHERICALINVERTEX: boolean;
  114120. REFLECTIONMAP_OPPOSITEZ: boolean;
  114121. LODINREFLECTIONALPHA: boolean;
  114122. GAMMAREFLECTION: boolean;
  114123. RGBDREFLECTION: boolean;
  114124. LINEARSPECULARREFLECTION: boolean;
  114125. RADIANCEOCCLUSION: boolean;
  114126. HORIZONOCCLUSION: boolean;
  114127. INSTANCES: boolean;
  114128. NUM_BONE_INFLUENCERS: number;
  114129. BonesPerMesh: number;
  114130. BONETEXTURE: boolean;
  114131. NONUNIFORMSCALING: boolean;
  114132. MORPHTARGETS: boolean;
  114133. MORPHTARGETS_NORMAL: boolean;
  114134. MORPHTARGETS_TANGENT: boolean;
  114135. MORPHTARGETS_UV: boolean;
  114136. NUM_MORPH_INFLUENCERS: number;
  114137. IMAGEPROCESSING: boolean;
  114138. VIGNETTE: boolean;
  114139. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114140. VIGNETTEBLENDMODEOPAQUE: boolean;
  114141. TONEMAPPING: boolean;
  114142. TONEMAPPING_ACES: boolean;
  114143. CONTRAST: boolean;
  114144. COLORCURVES: boolean;
  114145. COLORGRADING: boolean;
  114146. COLORGRADING3D: boolean;
  114147. SAMPLER3DGREENDEPTH: boolean;
  114148. SAMPLER3DBGRMAP: boolean;
  114149. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114150. EXPOSURE: boolean;
  114151. MULTIVIEW: boolean;
  114152. USEPHYSICALLIGHTFALLOFF: boolean;
  114153. USEGLTFLIGHTFALLOFF: boolean;
  114154. TWOSIDEDLIGHTING: boolean;
  114155. SHADOWFLOAT: boolean;
  114156. CLIPPLANE: boolean;
  114157. CLIPPLANE2: boolean;
  114158. CLIPPLANE3: boolean;
  114159. CLIPPLANE4: boolean;
  114160. POINTSIZE: boolean;
  114161. FOG: boolean;
  114162. LOGARITHMICDEPTH: boolean;
  114163. FORCENORMALFORWARD: boolean;
  114164. SPECULARAA: boolean;
  114165. CLEARCOAT: boolean;
  114166. CLEARCOAT_DEFAULTIOR: boolean;
  114167. CLEARCOAT_TEXTURE: boolean;
  114168. CLEARCOAT_TEXTUREDIRECTUV: number;
  114169. CLEARCOAT_BUMP: boolean;
  114170. CLEARCOAT_BUMPDIRECTUV: number;
  114171. CLEARCOAT_TINT: boolean;
  114172. CLEARCOAT_TINT_TEXTURE: boolean;
  114173. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114174. ANISOTROPIC: boolean;
  114175. ANISOTROPIC_TEXTURE: boolean;
  114176. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114177. BRDF_V_HEIGHT_CORRELATED: boolean;
  114178. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114179. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114180. SHEEN: boolean;
  114181. SHEEN_TEXTURE: boolean;
  114182. SHEEN_TEXTUREDIRECTUV: number;
  114183. SHEEN_LINKWITHALBEDO: boolean;
  114184. SUBSURFACE: boolean;
  114185. SS_REFRACTION: boolean;
  114186. SS_TRANSLUCENCY: boolean;
  114187. SS_SCATERRING: boolean;
  114188. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114189. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114190. SS_REFRACTIONMAP_3D: boolean;
  114191. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114192. SS_LODINREFRACTIONALPHA: boolean;
  114193. SS_GAMMAREFRACTION: boolean;
  114194. SS_RGBDREFRACTION: boolean;
  114195. SS_LINEARSPECULARREFRACTION: boolean;
  114196. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114197. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114198. UNLIT: boolean;
  114199. DEBUGMODE: number;
  114200. /**
  114201. * Initializes the PBR Material defines.
  114202. */
  114203. constructor();
  114204. /**
  114205. * Resets the PBR Material defines.
  114206. */
  114207. reset(): void;
  114208. }
  114209. /**
  114210. * The Physically based material base class of BJS.
  114211. *
  114212. * This offers the main features of a standard PBR material.
  114213. * For more information, please refer to the documentation :
  114214. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114215. */
  114216. export abstract class PBRBaseMaterial extends PushMaterial {
  114217. /**
  114218. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114219. */
  114220. static readonly PBRMATERIAL_OPAQUE: number;
  114221. /**
  114222. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114223. */
  114224. static readonly PBRMATERIAL_ALPHATEST: number;
  114225. /**
  114226. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114227. */
  114228. static readonly PBRMATERIAL_ALPHABLEND: number;
  114229. /**
  114230. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114231. * They are also discarded below the alpha cutoff threshold to improve performances.
  114232. */
  114233. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114234. /**
  114235. * Defines the default value of how much AO map is occluding the analytical lights
  114236. * (point spot...).
  114237. */
  114238. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114239. /**
  114240. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114241. */
  114242. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114243. /**
  114244. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114245. * to enhance interoperability with other engines.
  114246. */
  114247. static readonly LIGHTFALLOFF_GLTF: number;
  114248. /**
  114249. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114250. * to enhance interoperability with other materials.
  114251. */
  114252. static readonly LIGHTFALLOFF_STANDARD: number;
  114253. /**
  114254. * Intensity of the direct lights e.g. the four lights available in your scene.
  114255. * This impacts both the direct diffuse and specular highlights.
  114256. */
  114257. protected _directIntensity: number;
  114258. /**
  114259. * Intensity of the emissive part of the material.
  114260. * This helps controlling the emissive effect without modifying the emissive color.
  114261. */
  114262. protected _emissiveIntensity: number;
  114263. /**
  114264. * Intensity of the environment e.g. how much the environment will light the object
  114265. * either through harmonics for rough material or through the refelction for shiny ones.
  114266. */
  114267. protected _environmentIntensity: number;
  114268. /**
  114269. * This is a special control allowing the reduction of the specular highlights coming from the
  114270. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114271. */
  114272. protected _specularIntensity: number;
  114273. /**
  114274. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114275. */
  114276. private _lightingInfos;
  114277. /**
  114278. * Debug Control allowing disabling the bump map on this material.
  114279. */
  114280. protected _disableBumpMap: boolean;
  114281. /**
  114282. * AKA Diffuse Texture in standard nomenclature.
  114283. */
  114284. protected _albedoTexture: Nullable<BaseTexture>;
  114285. /**
  114286. * AKA Occlusion Texture in other nomenclature.
  114287. */
  114288. protected _ambientTexture: Nullable<BaseTexture>;
  114289. /**
  114290. * AKA Occlusion Texture Intensity in other nomenclature.
  114291. */
  114292. protected _ambientTextureStrength: number;
  114293. /**
  114294. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114295. * 1 means it completely occludes it
  114296. * 0 mean it has no impact
  114297. */
  114298. protected _ambientTextureImpactOnAnalyticalLights: number;
  114299. /**
  114300. * Stores the alpha values in a texture.
  114301. */
  114302. protected _opacityTexture: Nullable<BaseTexture>;
  114303. /**
  114304. * Stores the reflection values in a texture.
  114305. */
  114306. protected _reflectionTexture: Nullable<BaseTexture>;
  114307. /**
  114308. * Stores the emissive values in a texture.
  114309. */
  114310. protected _emissiveTexture: Nullable<BaseTexture>;
  114311. /**
  114312. * AKA Specular texture in other nomenclature.
  114313. */
  114314. protected _reflectivityTexture: Nullable<BaseTexture>;
  114315. /**
  114316. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114317. */
  114318. protected _metallicTexture: Nullable<BaseTexture>;
  114319. /**
  114320. * Specifies the metallic scalar of the metallic/roughness workflow.
  114321. * Can also be used to scale the metalness values of the metallic texture.
  114322. */
  114323. protected _metallic: Nullable<number>;
  114324. /**
  114325. * Specifies the roughness scalar of the metallic/roughness workflow.
  114326. * Can also be used to scale the roughness values of the metallic texture.
  114327. */
  114328. protected _roughness: Nullable<number>;
  114329. /**
  114330. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114331. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114332. */
  114333. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114334. /**
  114335. * Stores surface normal data used to displace a mesh in a texture.
  114336. */
  114337. protected _bumpTexture: Nullable<BaseTexture>;
  114338. /**
  114339. * Stores the pre-calculated light information of a mesh in a texture.
  114340. */
  114341. protected _lightmapTexture: Nullable<BaseTexture>;
  114342. /**
  114343. * The color of a material in ambient lighting.
  114344. */
  114345. protected _ambientColor: Color3;
  114346. /**
  114347. * AKA Diffuse Color in other nomenclature.
  114348. */
  114349. protected _albedoColor: Color3;
  114350. /**
  114351. * AKA Specular Color in other nomenclature.
  114352. */
  114353. protected _reflectivityColor: Color3;
  114354. /**
  114355. * The color applied when light is reflected from a material.
  114356. */
  114357. protected _reflectionColor: Color3;
  114358. /**
  114359. * The color applied when light is emitted from a material.
  114360. */
  114361. protected _emissiveColor: Color3;
  114362. /**
  114363. * AKA Glossiness in other nomenclature.
  114364. */
  114365. protected _microSurface: number;
  114366. /**
  114367. * Specifies that the material will use the light map as a show map.
  114368. */
  114369. protected _useLightmapAsShadowmap: boolean;
  114370. /**
  114371. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114372. * makes the reflect vector face the model (under horizon).
  114373. */
  114374. protected _useHorizonOcclusion: boolean;
  114375. /**
  114376. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114377. * too much the area relying on ambient texture to define their ambient occlusion.
  114378. */
  114379. protected _useRadianceOcclusion: boolean;
  114380. /**
  114381. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114382. */
  114383. protected _useAlphaFromAlbedoTexture: boolean;
  114384. /**
  114385. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114386. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114387. */
  114388. protected _useSpecularOverAlpha: boolean;
  114389. /**
  114390. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114391. */
  114392. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114393. /**
  114394. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114395. */
  114396. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114397. /**
  114398. * Specifies if the metallic texture contains the roughness information in its green channel.
  114399. */
  114400. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114401. /**
  114402. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114403. */
  114404. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114405. /**
  114406. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114407. */
  114408. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114409. /**
  114410. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114411. */
  114412. protected _useAmbientInGrayScale: boolean;
  114413. /**
  114414. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114415. * The material will try to infer what glossiness each pixel should be.
  114416. */
  114417. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114418. /**
  114419. * Defines the falloff type used in this material.
  114420. * It by default is Physical.
  114421. */
  114422. protected _lightFalloff: number;
  114423. /**
  114424. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114425. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114426. */
  114427. protected _useRadianceOverAlpha: boolean;
  114428. /**
  114429. * Allows using an object space normal map (instead of tangent space).
  114430. */
  114431. protected _useObjectSpaceNormalMap: boolean;
  114432. /**
  114433. * Allows using the bump map in parallax mode.
  114434. */
  114435. protected _useParallax: boolean;
  114436. /**
  114437. * Allows using the bump map in parallax occlusion mode.
  114438. */
  114439. protected _useParallaxOcclusion: boolean;
  114440. /**
  114441. * Controls the scale bias of the parallax mode.
  114442. */
  114443. protected _parallaxScaleBias: number;
  114444. /**
  114445. * If sets to true, disables all the lights affecting the material.
  114446. */
  114447. protected _disableLighting: boolean;
  114448. /**
  114449. * Number of Simultaneous lights allowed on the material.
  114450. */
  114451. protected _maxSimultaneousLights: number;
  114452. /**
  114453. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114454. */
  114455. protected _invertNormalMapX: boolean;
  114456. /**
  114457. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114458. */
  114459. protected _invertNormalMapY: boolean;
  114460. /**
  114461. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114462. */
  114463. protected _twoSidedLighting: boolean;
  114464. /**
  114465. * Defines the alpha limits in alpha test mode.
  114466. */
  114467. protected _alphaCutOff: number;
  114468. /**
  114469. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114470. */
  114471. protected _forceAlphaTest: boolean;
  114472. /**
  114473. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114474. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114475. */
  114476. protected _useAlphaFresnel: boolean;
  114477. /**
  114478. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114479. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114480. */
  114481. protected _useLinearAlphaFresnel: boolean;
  114482. /**
  114483. * The transparency mode of the material.
  114484. */
  114485. protected _transparencyMode: Nullable<number>;
  114486. /**
  114487. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114488. * from cos thetav and roughness:
  114489. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114490. */
  114491. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114492. /**
  114493. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114494. */
  114495. protected _forceIrradianceInFragment: boolean;
  114496. /**
  114497. * Force normal to face away from face.
  114498. */
  114499. protected _forceNormalForward: boolean;
  114500. /**
  114501. * Enables specular anti aliasing in the PBR shader.
  114502. * It will both interacts on the Geometry for analytical and IBL lighting.
  114503. * It also prefilter the roughness map based on the bump values.
  114504. */
  114505. protected _enableSpecularAntiAliasing: boolean;
  114506. /**
  114507. * Default configuration related to image processing available in the PBR Material.
  114508. */
  114509. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114510. /**
  114511. * Keep track of the image processing observer to allow dispose and replace.
  114512. */
  114513. private _imageProcessingObserver;
  114514. /**
  114515. * Attaches a new image processing configuration to the PBR Material.
  114516. * @param configuration
  114517. */
  114518. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114519. /**
  114520. * Stores the available render targets.
  114521. */
  114522. private _renderTargets;
  114523. /**
  114524. * Sets the global ambient color for the material used in lighting calculations.
  114525. */
  114526. private _globalAmbientColor;
  114527. /**
  114528. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114529. */
  114530. private _useLogarithmicDepth;
  114531. /**
  114532. * If set to true, no lighting calculations will be applied.
  114533. */
  114534. private _unlit;
  114535. private _debugMode;
  114536. /**
  114537. * @hidden
  114538. * This is reserved for the inspector.
  114539. * Defines the material debug mode.
  114540. * It helps seeing only some components of the material while troubleshooting.
  114541. */
  114542. debugMode: number;
  114543. /**
  114544. * @hidden
  114545. * This is reserved for the inspector.
  114546. * Specify from where on screen the debug mode should start.
  114547. * The value goes from -1 (full screen) to 1 (not visible)
  114548. * It helps with side by side comparison against the final render
  114549. * This defaults to -1
  114550. */
  114551. private debugLimit;
  114552. /**
  114553. * @hidden
  114554. * This is reserved for the inspector.
  114555. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114556. * You can use the factor to better multiply the final value.
  114557. */
  114558. private debugFactor;
  114559. /**
  114560. * Defines the clear coat layer parameters for the material.
  114561. */
  114562. readonly clearCoat: PBRClearCoatConfiguration;
  114563. /**
  114564. * Defines the anisotropic parameters for the material.
  114565. */
  114566. readonly anisotropy: PBRAnisotropicConfiguration;
  114567. /**
  114568. * Defines the BRDF parameters for the material.
  114569. */
  114570. readonly brdf: PBRBRDFConfiguration;
  114571. /**
  114572. * Defines the Sheen parameters for the material.
  114573. */
  114574. readonly sheen: PBRSheenConfiguration;
  114575. /**
  114576. * Defines the SubSurface parameters for the material.
  114577. */
  114578. readonly subSurface: PBRSubSurfaceConfiguration;
  114579. /**
  114580. * Custom callback helping to override the default shader used in the material.
  114581. */
  114582. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114583. protected _rebuildInParallel: boolean;
  114584. /**
  114585. * Instantiates a new PBRMaterial instance.
  114586. *
  114587. * @param name The material name
  114588. * @param scene The scene the material will be use in.
  114589. */
  114590. constructor(name: string, scene: Scene);
  114591. /**
  114592. * Gets a boolean indicating that current material needs to register RTT
  114593. */
  114594. readonly hasRenderTargetTextures: boolean;
  114595. /**
  114596. * Gets the name of the material class.
  114597. */
  114598. getClassName(): string;
  114599. /**
  114600. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114601. */
  114602. /**
  114603. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114604. */
  114605. useLogarithmicDepth: boolean;
  114606. /**
  114607. * Gets the current transparency mode.
  114608. */
  114609. /**
  114610. * Sets the transparency mode of the material.
  114611. *
  114612. * | Value | Type | Description |
  114613. * | ----- | ----------------------------------- | ----------- |
  114614. * | 0 | OPAQUE | |
  114615. * | 1 | ALPHATEST | |
  114616. * | 2 | ALPHABLEND | |
  114617. * | 3 | ALPHATESTANDBLEND | |
  114618. *
  114619. */
  114620. transparencyMode: Nullable<number>;
  114621. /**
  114622. * Returns true if alpha blending should be disabled.
  114623. */
  114624. private readonly _disableAlphaBlending;
  114625. /**
  114626. * Specifies whether or not this material should be rendered in alpha blend mode.
  114627. */
  114628. needAlphaBlending(): boolean;
  114629. /**
  114630. * Specifies if the mesh will require alpha blending.
  114631. * @param mesh - BJS mesh.
  114632. */
  114633. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114634. /**
  114635. * Specifies whether or not this material should be rendered in alpha test mode.
  114636. */
  114637. needAlphaTesting(): boolean;
  114638. /**
  114639. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114640. */
  114641. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114642. /**
  114643. * Gets the texture used for the alpha test.
  114644. */
  114645. getAlphaTestTexture(): Nullable<BaseTexture>;
  114646. /**
  114647. * Specifies that the submesh is ready to be used.
  114648. * @param mesh - BJS mesh.
  114649. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114650. * @param useInstances - Specifies that instances should be used.
  114651. * @returns - boolean indicating that the submesh is ready or not.
  114652. */
  114653. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114654. /**
  114655. * Specifies if the material uses metallic roughness workflow.
  114656. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114657. */
  114658. isMetallicWorkflow(): boolean;
  114659. private _prepareEffect;
  114660. private _prepareDefines;
  114661. /**
  114662. * Force shader compilation
  114663. */
  114664. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114665. clipPlane: boolean;
  114666. }>): void;
  114667. /**
  114668. * Initializes the uniform buffer layout for the shader.
  114669. */
  114670. buildUniformLayout(): void;
  114671. /**
  114672. * Unbinds the material from the mesh
  114673. */
  114674. unbind(): void;
  114675. /**
  114676. * Binds the submesh data.
  114677. * @param world - The world matrix.
  114678. * @param mesh - The BJS mesh.
  114679. * @param subMesh - A submesh of the BJS mesh.
  114680. */
  114681. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114682. /**
  114683. * Returns the animatable textures.
  114684. * @returns - Array of animatable textures.
  114685. */
  114686. getAnimatables(): IAnimatable[];
  114687. /**
  114688. * Returns the texture used for reflections.
  114689. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114690. */
  114691. private _getReflectionTexture;
  114692. /**
  114693. * Returns an array of the actively used textures.
  114694. * @returns - Array of BaseTextures
  114695. */
  114696. getActiveTextures(): BaseTexture[];
  114697. /**
  114698. * Checks to see if a texture is used in the material.
  114699. * @param texture - Base texture to use.
  114700. * @returns - Boolean specifying if a texture is used in the material.
  114701. */
  114702. hasTexture(texture: BaseTexture): boolean;
  114703. /**
  114704. * Disposes the resources of the material.
  114705. * @param forceDisposeEffect - Forces the disposal of effects.
  114706. * @param forceDisposeTextures - Forces the disposal of all textures.
  114707. */
  114708. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114709. }
  114710. }
  114711. declare module BABYLON {
  114712. /**
  114713. * The Physically based material of BJS.
  114714. *
  114715. * This offers the main features of a standard PBR material.
  114716. * For more information, please refer to the documentation :
  114717. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114718. */
  114719. export class PBRMaterial extends PBRBaseMaterial {
  114720. /**
  114721. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114722. */
  114723. static readonly PBRMATERIAL_OPAQUE: number;
  114724. /**
  114725. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114726. */
  114727. static readonly PBRMATERIAL_ALPHATEST: number;
  114728. /**
  114729. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114730. */
  114731. static readonly PBRMATERIAL_ALPHABLEND: number;
  114732. /**
  114733. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114734. * They are also discarded below the alpha cutoff threshold to improve performances.
  114735. */
  114736. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114737. /**
  114738. * Defines the default value of how much AO map is occluding the analytical lights
  114739. * (point spot...).
  114740. */
  114741. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114742. /**
  114743. * Intensity of the direct lights e.g. the four lights available in your scene.
  114744. * This impacts both the direct diffuse and specular highlights.
  114745. */
  114746. directIntensity: number;
  114747. /**
  114748. * Intensity of the emissive part of the material.
  114749. * This helps controlling the emissive effect without modifying the emissive color.
  114750. */
  114751. emissiveIntensity: number;
  114752. /**
  114753. * Intensity of the environment e.g. how much the environment will light the object
  114754. * either through harmonics for rough material or through the refelction for shiny ones.
  114755. */
  114756. environmentIntensity: number;
  114757. /**
  114758. * This is a special control allowing the reduction of the specular highlights coming from the
  114759. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114760. */
  114761. specularIntensity: number;
  114762. /**
  114763. * Debug Control allowing disabling the bump map on this material.
  114764. */
  114765. disableBumpMap: boolean;
  114766. /**
  114767. * AKA Diffuse Texture in standard nomenclature.
  114768. */
  114769. albedoTexture: BaseTexture;
  114770. /**
  114771. * AKA Occlusion Texture in other nomenclature.
  114772. */
  114773. ambientTexture: BaseTexture;
  114774. /**
  114775. * AKA Occlusion Texture Intensity in other nomenclature.
  114776. */
  114777. ambientTextureStrength: number;
  114778. /**
  114779. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114780. * 1 means it completely occludes it
  114781. * 0 mean it has no impact
  114782. */
  114783. ambientTextureImpactOnAnalyticalLights: number;
  114784. /**
  114785. * Stores the alpha values in a texture.
  114786. */
  114787. opacityTexture: BaseTexture;
  114788. /**
  114789. * Stores the reflection values in a texture.
  114790. */
  114791. reflectionTexture: Nullable<BaseTexture>;
  114792. /**
  114793. * Stores the emissive values in a texture.
  114794. */
  114795. emissiveTexture: BaseTexture;
  114796. /**
  114797. * AKA Specular texture in other nomenclature.
  114798. */
  114799. reflectivityTexture: BaseTexture;
  114800. /**
  114801. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114802. */
  114803. metallicTexture: BaseTexture;
  114804. /**
  114805. * Specifies the metallic scalar of the metallic/roughness workflow.
  114806. * Can also be used to scale the metalness values of the metallic texture.
  114807. */
  114808. metallic: Nullable<number>;
  114809. /**
  114810. * Specifies the roughness scalar of the metallic/roughness workflow.
  114811. * Can also be used to scale the roughness values of the metallic texture.
  114812. */
  114813. roughness: Nullable<number>;
  114814. /**
  114815. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114816. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114817. */
  114818. microSurfaceTexture: BaseTexture;
  114819. /**
  114820. * Stores surface normal data used to displace a mesh in a texture.
  114821. */
  114822. bumpTexture: BaseTexture;
  114823. /**
  114824. * Stores the pre-calculated light information of a mesh in a texture.
  114825. */
  114826. lightmapTexture: BaseTexture;
  114827. /**
  114828. * Stores the refracted light information in a texture.
  114829. */
  114830. refractionTexture: Nullable<BaseTexture>;
  114831. /**
  114832. * The color of a material in ambient lighting.
  114833. */
  114834. ambientColor: Color3;
  114835. /**
  114836. * AKA Diffuse Color in other nomenclature.
  114837. */
  114838. albedoColor: Color3;
  114839. /**
  114840. * AKA Specular Color in other nomenclature.
  114841. */
  114842. reflectivityColor: Color3;
  114843. /**
  114844. * The color reflected from the material.
  114845. */
  114846. reflectionColor: Color3;
  114847. /**
  114848. * The color emitted from the material.
  114849. */
  114850. emissiveColor: Color3;
  114851. /**
  114852. * AKA Glossiness in other nomenclature.
  114853. */
  114854. microSurface: number;
  114855. /**
  114856. * source material index of refraction (IOR)' / 'destination material IOR.
  114857. */
  114858. indexOfRefraction: number;
  114859. /**
  114860. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114861. */
  114862. invertRefractionY: boolean;
  114863. /**
  114864. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114865. * Materials half opaque for instance using refraction could benefit from this control.
  114866. */
  114867. linkRefractionWithTransparency: boolean;
  114868. /**
  114869. * If true, the light map contains occlusion information instead of lighting info.
  114870. */
  114871. useLightmapAsShadowmap: boolean;
  114872. /**
  114873. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114874. */
  114875. useAlphaFromAlbedoTexture: boolean;
  114876. /**
  114877. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114878. */
  114879. forceAlphaTest: boolean;
  114880. /**
  114881. * Defines the alpha limits in alpha test mode.
  114882. */
  114883. alphaCutOff: number;
  114884. /**
  114885. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  114886. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114887. */
  114888. useSpecularOverAlpha: boolean;
  114889. /**
  114890. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114891. */
  114892. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114893. /**
  114894. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114895. */
  114896. useRoughnessFromMetallicTextureAlpha: boolean;
  114897. /**
  114898. * Specifies if the metallic texture contains the roughness information in its green channel.
  114899. */
  114900. useRoughnessFromMetallicTextureGreen: boolean;
  114901. /**
  114902. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114903. */
  114904. useMetallnessFromMetallicTextureBlue: boolean;
  114905. /**
  114906. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114907. */
  114908. useAmbientOcclusionFromMetallicTextureRed: boolean;
  114909. /**
  114910. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114911. */
  114912. useAmbientInGrayScale: boolean;
  114913. /**
  114914. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114915. * The material will try to infer what glossiness each pixel should be.
  114916. */
  114917. useAutoMicroSurfaceFromReflectivityMap: boolean;
  114918. /**
  114919. * BJS is using an harcoded light falloff based on a manually sets up range.
  114920. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114921. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114922. */
  114923. /**
  114924. * BJS is using an harcoded light falloff based on a manually sets up range.
  114925. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  114926. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  114927. */
  114928. usePhysicalLightFalloff: boolean;
  114929. /**
  114930. * In order to support the falloff compatibility with gltf, a special mode has been added
  114931. * to reproduce the gltf light falloff.
  114932. */
  114933. /**
  114934. * In order to support the falloff compatibility with gltf, a special mode has been added
  114935. * to reproduce the gltf light falloff.
  114936. */
  114937. useGLTFLightFalloff: boolean;
  114938. /**
  114939. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114940. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114941. */
  114942. useRadianceOverAlpha: boolean;
  114943. /**
  114944. * Allows using an object space normal map (instead of tangent space).
  114945. */
  114946. useObjectSpaceNormalMap: boolean;
  114947. /**
  114948. * Allows using the bump map in parallax mode.
  114949. */
  114950. useParallax: boolean;
  114951. /**
  114952. * Allows using the bump map in parallax occlusion mode.
  114953. */
  114954. useParallaxOcclusion: boolean;
  114955. /**
  114956. * Controls the scale bias of the parallax mode.
  114957. */
  114958. parallaxScaleBias: number;
  114959. /**
  114960. * If sets to true, disables all the lights affecting the material.
  114961. */
  114962. disableLighting: boolean;
  114963. /**
  114964. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114965. */
  114966. forceIrradianceInFragment: boolean;
  114967. /**
  114968. * Number of Simultaneous lights allowed on the material.
  114969. */
  114970. maxSimultaneousLights: number;
  114971. /**
  114972. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114973. */
  114974. invertNormalMapX: boolean;
  114975. /**
  114976. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114977. */
  114978. invertNormalMapY: boolean;
  114979. /**
  114980. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114981. */
  114982. twoSidedLighting: boolean;
  114983. /**
  114984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114985. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114986. */
  114987. useAlphaFresnel: boolean;
  114988. /**
  114989. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114990. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114991. */
  114992. useLinearAlphaFresnel: boolean;
  114993. /**
  114994. * Let user defines the brdf lookup texture used for IBL.
  114995. * A default 8bit version is embedded but you could point at :
  114996. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  114997. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  114998. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  114999. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115000. */
  115001. environmentBRDFTexture: Nullable<BaseTexture>;
  115002. /**
  115003. * Force normal to face away from face.
  115004. */
  115005. forceNormalForward: boolean;
  115006. /**
  115007. * Enables specular anti aliasing in the PBR shader.
  115008. * It will both interacts on the Geometry for analytical and IBL lighting.
  115009. * It also prefilter the roughness map based on the bump values.
  115010. */
  115011. enableSpecularAntiAliasing: boolean;
  115012. /**
  115013. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115014. * makes the reflect vector face the model (under horizon).
  115015. */
  115016. useHorizonOcclusion: boolean;
  115017. /**
  115018. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115019. * too much the area relying on ambient texture to define their ambient occlusion.
  115020. */
  115021. useRadianceOcclusion: boolean;
  115022. /**
  115023. * If set to true, no lighting calculations will be applied.
  115024. */
  115025. unlit: boolean;
  115026. /**
  115027. * Gets the image processing configuration used either in this material.
  115028. */
  115029. /**
  115030. * Sets the Default image processing configuration used either in the this material.
  115031. *
  115032. * If sets to null, the scene one is in use.
  115033. */
  115034. imageProcessingConfiguration: ImageProcessingConfiguration;
  115035. /**
  115036. * Gets wether the color curves effect is enabled.
  115037. */
  115038. /**
  115039. * Sets wether the color curves effect is enabled.
  115040. */
  115041. cameraColorCurvesEnabled: boolean;
  115042. /**
  115043. * Gets wether the color grading effect is enabled.
  115044. */
  115045. /**
  115046. * Gets wether the color grading effect is enabled.
  115047. */
  115048. cameraColorGradingEnabled: boolean;
  115049. /**
  115050. * Gets wether tonemapping is enabled or not.
  115051. */
  115052. /**
  115053. * Sets wether tonemapping is enabled or not
  115054. */
  115055. cameraToneMappingEnabled: boolean;
  115056. /**
  115057. * The camera exposure used on this material.
  115058. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115059. * This corresponds to a photographic exposure.
  115060. */
  115061. /**
  115062. * The camera exposure used on this material.
  115063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115064. * This corresponds to a photographic exposure.
  115065. */
  115066. cameraExposure: number;
  115067. /**
  115068. * Gets The camera contrast used on this material.
  115069. */
  115070. /**
  115071. * Sets The camera contrast used on this material.
  115072. */
  115073. cameraContrast: number;
  115074. /**
  115075. * Gets the Color Grading 2D Lookup Texture.
  115076. */
  115077. /**
  115078. * Sets the Color Grading 2D Lookup Texture.
  115079. */
  115080. cameraColorGradingTexture: Nullable<BaseTexture>;
  115081. /**
  115082. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115083. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115084. * 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;
  115085. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115086. */
  115087. /**
  115088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115090. * 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;
  115091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115092. */
  115093. cameraColorCurves: Nullable<ColorCurves>;
  115094. /**
  115095. * Instantiates a new PBRMaterial instance.
  115096. *
  115097. * @param name The material name
  115098. * @param scene The scene the material will be use in.
  115099. */
  115100. constructor(name: string, scene: Scene);
  115101. /**
  115102. * Returns the name of this material class.
  115103. */
  115104. getClassName(): string;
  115105. /**
  115106. * Makes a duplicate of the current material.
  115107. * @param name - name to use for the new material.
  115108. */
  115109. clone(name: string): PBRMaterial;
  115110. /**
  115111. * Serializes this PBR Material.
  115112. * @returns - An object with the serialized material.
  115113. */
  115114. serialize(): any;
  115115. /**
  115116. * Parses a PBR Material from a serialized object.
  115117. * @param source - Serialized object.
  115118. * @param scene - BJS scene instance.
  115119. * @param rootUrl - url for the scene object
  115120. * @returns - PBRMaterial
  115121. */
  115122. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115123. }
  115124. }
  115125. declare module BABYLON {
  115126. /**
  115127. * Direct draw surface info
  115128. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115129. */
  115130. export interface DDSInfo {
  115131. /**
  115132. * Width of the texture
  115133. */
  115134. width: number;
  115135. /**
  115136. * Width of the texture
  115137. */
  115138. height: number;
  115139. /**
  115140. * Number of Mipmaps for the texture
  115141. * @see https://en.wikipedia.org/wiki/Mipmap
  115142. */
  115143. mipmapCount: number;
  115144. /**
  115145. * If the textures format is a known fourCC format
  115146. * @see https://www.fourcc.org/
  115147. */
  115148. isFourCC: boolean;
  115149. /**
  115150. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115151. */
  115152. isRGB: boolean;
  115153. /**
  115154. * If the texture is a lumincance format
  115155. */
  115156. isLuminance: boolean;
  115157. /**
  115158. * If this is a cube texture
  115159. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115160. */
  115161. isCube: boolean;
  115162. /**
  115163. * If the texture is a compressed format eg. FOURCC_DXT1
  115164. */
  115165. isCompressed: boolean;
  115166. /**
  115167. * The dxgiFormat of the texture
  115168. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115169. */
  115170. dxgiFormat: number;
  115171. /**
  115172. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115173. */
  115174. textureType: number;
  115175. /**
  115176. * Sphericle polynomial created for the dds texture
  115177. */
  115178. sphericalPolynomial?: SphericalPolynomial;
  115179. }
  115180. /**
  115181. * Class used to provide DDS decompression tools
  115182. */
  115183. export class DDSTools {
  115184. /**
  115185. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115186. */
  115187. static StoreLODInAlphaChannel: boolean;
  115188. /**
  115189. * Gets DDS information from an array buffer
  115190. * @param arrayBuffer defines the array buffer to read data from
  115191. * @returns the DDS information
  115192. */
  115193. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115194. private static _FloatView;
  115195. private static _Int32View;
  115196. private static _ToHalfFloat;
  115197. private static _FromHalfFloat;
  115198. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115199. private static _GetHalfFloatRGBAArrayBuffer;
  115200. private static _GetFloatRGBAArrayBuffer;
  115201. private static _GetFloatAsUIntRGBAArrayBuffer;
  115202. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115203. private static _GetRGBAArrayBuffer;
  115204. private static _ExtractLongWordOrder;
  115205. private static _GetRGBArrayBuffer;
  115206. private static _GetLuminanceArrayBuffer;
  115207. /**
  115208. * Uploads DDS Levels to a Babylon Texture
  115209. * @hidden
  115210. */
  115211. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115212. }
  115213. interface ThinEngine {
  115214. /**
  115215. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115216. * @param rootUrl defines the url where the file to load is located
  115217. * @param scene defines the current scene
  115218. * @param lodScale defines scale to apply to the mip map selection
  115219. * @param lodOffset defines offset to apply to the mip map selection
  115220. * @param onLoad defines an optional callback raised when the texture is loaded
  115221. * @param onError defines an optional callback raised if there is an issue to load the texture
  115222. * @param format defines the format of the data
  115223. * @param forcedExtension defines the extension to use to pick the right loader
  115224. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115225. * @returns the cube texture as an InternalTexture
  115226. */
  115227. 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;
  115228. }
  115229. }
  115230. declare module BABYLON {
  115231. /**
  115232. * Implementation of the DDS Texture Loader.
  115233. * @hidden
  115234. */
  115235. export class _DDSTextureLoader implements IInternalTextureLoader {
  115236. /**
  115237. * Defines wether the loader supports cascade loading the different faces.
  115238. */
  115239. readonly supportCascades: boolean;
  115240. /**
  115241. * This returns if the loader support the current file information.
  115242. * @param extension defines the file extension of the file being loaded
  115243. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115244. * @param fallback defines the fallback internal texture if any
  115245. * @param isBase64 defines whether the texture is encoded as a base64
  115246. * @param isBuffer defines whether the texture data are stored as a buffer
  115247. * @returns true if the loader can load the specified file
  115248. */
  115249. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115250. /**
  115251. * Transform the url before loading if required.
  115252. * @param rootUrl the url of the texture
  115253. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115254. * @returns the transformed texture
  115255. */
  115256. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115257. /**
  115258. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115259. * @param rootUrl the url of the texture
  115260. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115261. * @returns the fallback texture
  115262. */
  115263. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115264. /**
  115265. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115266. * @param data contains the texture data
  115267. * @param texture defines the BabylonJS internal texture
  115268. * @param createPolynomials will be true if polynomials have been requested
  115269. * @param onLoad defines the callback to trigger once the texture is ready
  115270. * @param onError defines the callback to trigger in case of error
  115271. */
  115272. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115273. /**
  115274. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115275. * @param data contains the texture data
  115276. * @param texture defines the BabylonJS internal texture
  115277. * @param callback defines the method to call once ready to upload
  115278. */
  115279. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115280. }
  115281. }
  115282. declare module BABYLON {
  115283. /**
  115284. * Implementation of the ENV Texture Loader.
  115285. * @hidden
  115286. */
  115287. export class _ENVTextureLoader implements IInternalTextureLoader {
  115288. /**
  115289. * Defines wether the loader supports cascade loading the different faces.
  115290. */
  115291. readonly supportCascades: boolean;
  115292. /**
  115293. * This returns if the loader support the current file information.
  115294. * @param extension defines the file extension of the file being loaded
  115295. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115296. * @param fallback defines the fallback internal texture if any
  115297. * @param isBase64 defines whether the texture is encoded as a base64
  115298. * @param isBuffer defines whether the texture data are stored as a buffer
  115299. * @returns true if the loader can load the specified file
  115300. */
  115301. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115302. /**
  115303. * Transform the url before loading if required.
  115304. * @param rootUrl the url of the texture
  115305. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115306. * @returns the transformed texture
  115307. */
  115308. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115309. /**
  115310. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115311. * @param rootUrl the url of the texture
  115312. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115313. * @returns the fallback texture
  115314. */
  115315. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115316. /**
  115317. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115318. * @param data contains the texture data
  115319. * @param texture defines the BabylonJS internal texture
  115320. * @param createPolynomials will be true if polynomials have been requested
  115321. * @param onLoad defines the callback to trigger once the texture is ready
  115322. * @param onError defines the callback to trigger in case of error
  115323. */
  115324. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115325. /**
  115326. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115327. * @param data contains the texture data
  115328. * @param texture defines the BabylonJS internal texture
  115329. * @param callback defines the method to call once ready to upload
  115330. */
  115331. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115332. }
  115333. }
  115334. declare module BABYLON {
  115335. /**
  115336. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115337. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115338. */
  115339. export class KhronosTextureContainer {
  115340. /** contents of the KTX container file */
  115341. arrayBuffer: any;
  115342. private static HEADER_LEN;
  115343. private static COMPRESSED_2D;
  115344. private static COMPRESSED_3D;
  115345. private static TEX_2D;
  115346. private static TEX_3D;
  115347. /**
  115348. * Gets the openGL type
  115349. */
  115350. glType: number;
  115351. /**
  115352. * Gets the openGL type size
  115353. */
  115354. glTypeSize: number;
  115355. /**
  115356. * Gets the openGL format
  115357. */
  115358. glFormat: number;
  115359. /**
  115360. * Gets the openGL internal format
  115361. */
  115362. glInternalFormat: number;
  115363. /**
  115364. * Gets the base internal format
  115365. */
  115366. glBaseInternalFormat: number;
  115367. /**
  115368. * Gets image width in pixel
  115369. */
  115370. pixelWidth: number;
  115371. /**
  115372. * Gets image height in pixel
  115373. */
  115374. pixelHeight: number;
  115375. /**
  115376. * Gets image depth in pixels
  115377. */
  115378. pixelDepth: number;
  115379. /**
  115380. * Gets the number of array elements
  115381. */
  115382. numberOfArrayElements: number;
  115383. /**
  115384. * Gets the number of faces
  115385. */
  115386. numberOfFaces: number;
  115387. /**
  115388. * Gets the number of mipmap levels
  115389. */
  115390. numberOfMipmapLevels: number;
  115391. /**
  115392. * Gets the bytes of key value data
  115393. */
  115394. bytesOfKeyValueData: number;
  115395. /**
  115396. * Gets the load type
  115397. */
  115398. loadType: number;
  115399. /**
  115400. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115401. */
  115402. isInvalid: boolean;
  115403. /**
  115404. * Creates a new KhronosTextureContainer
  115405. * @param arrayBuffer contents of the KTX container file
  115406. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115407. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115408. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115409. */
  115410. constructor(
  115411. /** contents of the KTX container file */
  115412. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115413. /**
  115414. * Uploads KTX content to a Babylon Texture.
  115415. * It is assumed that the texture has already been created & is currently bound
  115416. * @hidden
  115417. */
  115418. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115419. private _upload2DCompressedLevels;
  115420. }
  115421. }
  115422. declare module BABYLON {
  115423. /**
  115424. * Implementation of the KTX Texture Loader.
  115425. * @hidden
  115426. */
  115427. export class _KTXTextureLoader implements IInternalTextureLoader {
  115428. /**
  115429. * Defines wether the loader supports cascade loading the different faces.
  115430. */
  115431. readonly supportCascades: boolean;
  115432. /**
  115433. * This returns if the loader support the current file information.
  115434. * @param extension defines the file extension of the file being loaded
  115435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115436. * @param fallback defines the fallback internal texture if any
  115437. * @param isBase64 defines whether the texture is encoded as a base64
  115438. * @param isBuffer defines whether the texture data are stored as a buffer
  115439. * @returns true if the loader can load the specified file
  115440. */
  115441. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115442. /**
  115443. * Transform the url before loading if required.
  115444. * @param rootUrl the url of the texture
  115445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115446. * @returns the transformed texture
  115447. */
  115448. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115449. /**
  115450. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115451. * @param rootUrl the url of the texture
  115452. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115453. * @returns the fallback texture
  115454. */
  115455. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115456. /**
  115457. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115458. * @param data contains the texture data
  115459. * @param texture defines the BabylonJS internal texture
  115460. * @param createPolynomials will be true if polynomials have been requested
  115461. * @param onLoad defines the callback to trigger once the texture is ready
  115462. * @param onError defines the callback to trigger in case of error
  115463. */
  115464. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115465. /**
  115466. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115467. * @param data contains the texture data
  115468. * @param texture defines the BabylonJS internal texture
  115469. * @param callback defines the method to call once ready to upload
  115470. */
  115471. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115472. }
  115473. }
  115474. declare module BABYLON {
  115475. /**
  115476. * Options for the default xr helper
  115477. */
  115478. export class WebXRDefaultExperienceOptions {
  115479. /**
  115480. * Floor meshes that should be used for teleporting
  115481. */
  115482. floorMeshes: Array<AbstractMesh>;
  115483. }
  115484. /**
  115485. * Default experience which provides a similar setup to the previous webVRExperience
  115486. */
  115487. export class WebXRDefaultExperience {
  115488. /**
  115489. * Base experience
  115490. */
  115491. baseExperience: WebXRExperienceHelper;
  115492. /**
  115493. * Input experience extension
  115494. */
  115495. input: WebXRInput;
  115496. /**
  115497. * Loads the controller models
  115498. */
  115499. controllerModelLoader: WebXRControllerModelLoader;
  115500. /**
  115501. * Enables laser pointer and selection
  115502. */
  115503. pointerSelection: WebXRControllerPointerSelection;
  115504. /**
  115505. * Enables teleportation
  115506. */
  115507. teleportation: WebXRControllerTeleportation;
  115508. /**
  115509. * Enables ui for enetering/exiting xr
  115510. */
  115511. enterExitUI: WebXREnterExitUI;
  115512. /**
  115513. * Default output canvas xr should render to
  115514. */
  115515. outputCanvas: WebXRManagedOutputCanvas;
  115516. /**
  115517. * Creates the default xr experience
  115518. * @param scene scene
  115519. * @param options options for basic configuration
  115520. * @returns resulting WebXRDefaultExperience
  115521. */
  115522. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115523. private constructor();
  115524. /**
  115525. * DIsposes of the experience helper
  115526. */
  115527. dispose(): void;
  115528. }
  115529. }
  115530. declare module BABYLON {
  115531. /** @hidden */
  115532. export var _forceSceneHelpersToBundle: boolean;
  115533. interface Scene {
  115534. /**
  115535. * Creates a default light for the scene.
  115536. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115537. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115538. */
  115539. createDefaultLight(replace?: boolean): void;
  115540. /**
  115541. * Creates a default camera for the scene.
  115542. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115543. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115544. * @param replace has default false, when true replaces the active camera in the scene
  115545. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115546. */
  115547. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115548. /**
  115549. * Creates a default camera and a default light.
  115550. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115551. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115552. * @param replace has the default false, when true replaces the active camera/light in the scene
  115553. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115554. */
  115555. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115556. /**
  115557. * Creates a new sky box
  115558. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115559. * @param environmentTexture defines the texture to use as environment texture
  115560. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115561. * @param scale defines the overall scale of the skybox
  115562. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115563. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115564. * @returns a new mesh holding the sky box
  115565. */
  115566. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115567. /**
  115568. * Creates a new environment
  115569. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115570. * @param options defines the options you can use to configure the environment
  115571. * @returns the new EnvironmentHelper
  115572. */
  115573. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115574. /**
  115575. * Creates a new VREXperienceHelper
  115576. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115577. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115578. * @returns a new VREXperienceHelper
  115579. */
  115580. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115581. /**
  115582. * Creates a new WebXRDefaultExperience
  115583. * @see http://doc.babylonjs.com/how_to/webxr
  115584. * @param options experience options
  115585. * @returns a promise for a new WebXRDefaultExperience
  115586. */
  115587. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115588. }
  115589. }
  115590. declare module BABYLON {
  115591. /**
  115592. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115593. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115594. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115595. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115596. */
  115597. export class VideoDome extends TransformNode {
  115598. /**
  115599. * Define the video source as a Monoscopic panoramic 360 video.
  115600. */
  115601. static readonly MODE_MONOSCOPIC: number;
  115602. /**
  115603. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115604. */
  115605. static readonly MODE_TOPBOTTOM: number;
  115606. /**
  115607. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115608. */
  115609. static readonly MODE_SIDEBYSIDE: number;
  115610. private _halfDome;
  115611. private _useDirectMapping;
  115612. /**
  115613. * The video texture being displayed on the sphere
  115614. */
  115615. protected _videoTexture: VideoTexture;
  115616. /**
  115617. * Gets the video texture being displayed on the sphere
  115618. */
  115619. readonly videoTexture: VideoTexture;
  115620. /**
  115621. * The skybox material
  115622. */
  115623. protected _material: BackgroundMaterial;
  115624. /**
  115625. * The surface used for the skybox
  115626. */
  115627. protected _mesh: Mesh;
  115628. /**
  115629. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115630. */
  115631. private _halfDomeMask;
  115632. /**
  115633. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115634. * Also see the options.resolution property.
  115635. */
  115636. fovMultiplier: number;
  115637. private _videoMode;
  115638. /**
  115639. * Gets or set the current video mode for the video. It can be:
  115640. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115641. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115642. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115643. */
  115644. videoMode: number;
  115645. /**
  115646. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115647. *
  115648. */
  115649. /**
  115650. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115651. */
  115652. halfDome: boolean;
  115653. /**
  115654. * Oberserver used in Stereoscopic VR Mode.
  115655. */
  115656. private _onBeforeCameraRenderObserver;
  115657. /**
  115658. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115659. * @param name Element's name, child elements will append suffixes for their own names.
  115660. * @param urlsOrVideo defines the url(s) or the video element to use
  115661. * @param options An object containing optional or exposed sub element properties
  115662. */
  115663. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115664. resolution?: number;
  115665. clickToPlay?: boolean;
  115666. autoPlay?: boolean;
  115667. loop?: boolean;
  115668. size?: number;
  115669. poster?: string;
  115670. faceForward?: boolean;
  115671. useDirectMapping?: boolean;
  115672. halfDomeMode?: boolean;
  115673. }, scene: Scene);
  115674. private _changeVideoMode;
  115675. /**
  115676. * Releases resources associated with this node.
  115677. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115678. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115679. */
  115680. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115681. }
  115682. }
  115683. declare module BABYLON {
  115684. /**
  115685. * This class can be used to get instrumentation data from a Babylon engine
  115686. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115687. */
  115688. export class EngineInstrumentation implements IDisposable {
  115689. /**
  115690. * Define the instrumented engine.
  115691. */
  115692. engine: Engine;
  115693. private _captureGPUFrameTime;
  115694. private _gpuFrameTimeToken;
  115695. private _gpuFrameTime;
  115696. private _captureShaderCompilationTime;
  115697. private _shaderCompilationTime;
  115698. private _onBeginFrameObserver;
  115699. private _onEndFrameObserver;
  115700. private _onBeforeShaderCompilationObserver;
  115701. private _onAfterShaderCompilationObserver;
  115702. /**
  115703. * Gets the perf counter used for GPU frame time
  115704. */
  115705. readonly gpuFrameTimeCounter: PerfCounter;
  115706. /**
  115707. * Gets the GPU frame time capture status
  115708. */
  115709. /**
  115710. * Enable or disable the GPU frame time capture
  115711. */
  115712. captureGPUFrameTime: boolean;
  115713. /**
  115714. * Gets the perf counter used for shader compilation time
  115715. */
  115716. readonly shaderCompilationTimeCounter: PerfCounter;
  115717. /**
  115718. * Gets the shader compilation time capture status
  115719. */
  115720. /**
  115721. * Enable or disable the shader compilation time capture
  115722. */
  115723. captureShaderCompilationTime: boolean;
  115724. /**
  115725. * Instantiates a new engine instrumentation.
  115726. * This class can be used to get instrumentation data from a Babylon engine
  115727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115728. * @param engine Defines the engine to instrument
  115729. */
  115730. constructor(
  115731. /**
  115732. * Define the instrumented engine.
  115733. */
  115734. engine: Engine);
  115735. /**
  115736. * Dispose and release associated resources.
  115737. */
  115738. dispose(): void;
  115739. }
  115740. }
  115741. declare module BABYLON {
  115742. /**
  115743. * This class can be used to get instrumentation data from a Babylon engine
  115744. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115745. */
  115746. export class SceneInstrumentation implements IDisposable {
  115747. /**
  115748. * Defines the scene to instrument
  115749. */
  115750. scene: Scene;
  115751. private _captureActiveMeshesEvaluationTime;
  115752. private _activeMeshesEvaluationTime;
  115753. private _captureRenderTargetsRenderTime;
  115754. private _renderTargetsRenderTime;
  115755. private _captureFrameTime;
  115756. private _frameTime;
  115757. private _captureRenderTime;
  115758. private _renderTime;
  115759. private _captureInterFrameTime;
  115760. private _interFrameTime;
  115761. private _captureParticlesRenderTime;
  115762. private _particlesRenderTime;
  115763. private _captureSpritesRenderTime;
  115764. private _spritesRenderTime;
  115765. private _capturePhysicsTime;
  115766. private _physicsTime;
  115767. private _captureAnimationsTime;
  115768. private _animationsTime;
  115769. private _captureCameraRenderTime;
  115770. private _cameraRenderTime;
  115771. private _onBeforeActiveMeshesEvaluationObserver;
  115772. private _onAfterActiveMeshesEvaluationObserver;
  115773. private _onBeforeRenderTargetsRenderObserver;
  115774. private _onAfterRenderTargetsRenderObserver;
  115775. private _onAfterRenderObserver;
  115776. private _onBeforeDrawPhaseObserver;
  115777. private _onAfterDrawPhaseObserver;
  115778. private _onBeforeAnimationsObserver;
  115779. private _onBeforeParticlesRenderingObserver;
  115780. private _onAfterParticlesRenderingObserver;
  115781. private _onBeforeSpritesRenderingObserver;
  115782. private _onAfterSpritesRenderingObserver;
  115783. private _onBeforePhysicsObserver;
  115784. private _onAfterPhysicsObserver;
  115785. private _onAfterAnimationsObserver;
  115786. private _onBeforeCameraRenderObserver;
  115787. private _onAfterCameraRenderObserver;
  115788. /**
  115789. * Gets the perf counter used for active meshes evaluation time
  115790. */
  115791. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115792. /**
  115793. * Gets the active meshes evaluation time capture status
  115794. */
  115795. /**
  115796. * Enable or disable the active meshes evaluation time capture
  115797. */
  115798. captureActiveMeshesEvaluationTime: boolean;
  115799. /**
  115800. * Gets the perf counter used for render targets render time
  115801. */
  115802. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115803. /**
  115804. * Gets the render targets render time capture status
  115805. */
  115806. /**
  115807. * Enable or disable the render targets render time capture
  115808. */
  115809. captureRenderTargetsRenderTime: boolean;
  115810. /**
  115811. * Gets the perf counter used for particles render time
  115812. */
  115813. readonly particlesRenderTimeCounter: PerfCounter;
  115814. /**
  115815. * Gets the particles render time capture status
  115816. */
  115817. /**
  115818. * Enable or disable the particles render time capture
  115819. */
  115820. captureParticlesRenderTime: boolean;
  115821. /**
  115822. * Gets the perf counter used for sprites render time
  115823. */
  115824. readonly spritesRenderTimeCounter: PerfCounter;
  115825. /**
  115826. * Gets the sprites render time capture status
  115827. */
  115828. /**
  115829. * Enable or disable the sprites render time capture
  115830. */
  115831. captureSpritesRenderTime: boolean;
  115832. /**
  115833. * Gets the perf counter used for physics time
  115834. */
  115835. readonly physicsTimeCounter: PerfCounter;
  115836. /**
  115837. * Gets the physics time capture status
  115838. */
  115839. /**
  115840. * Enable or disable the physics time capture
  115841. */
  115842. capturePhysicsTime: boolean;
  115843. /**
  115844. * Gets the perf counter used for animations time
  115845. */
  115846. readonly animationsTimeCounter: PerfCounter;
  115847. /**
  115848. * Gets the animations time capture status
  115849. */
  115850. /**
  115851. * Enable or disable the animations time capture
  115852. */
  115853. captureAnimationsTime: boolean;
  115854. /**
  115855. * Gets the perf counter used for frame time capture
  115856. */
  115857. readonly frameTimeCounter: PerfCounter;
  115858. /**
  115859. * Gets the frame time capture status
  115860. */
  115861. /**
  115862. * Enable or disable the frame time capture
  115863. */
  115864. captureFrameTime: boolean;
  115865. /**
  115866. * Gets the perf counter used for inter-frames time capture
  115867. */
  115868. readonly interFrameTimeCounter: PerfCounter;
  115869. /**
  115870. * Gets the inter-frames time capture status
  115871. */
  115872. /**
  115873. * Enable or disable the inter-frames time capture
  115874. */
  115875. captureInterFrameTime: boolean;
  115876. /**
  115877. * Gets the perf counter used for render time capture
  115878. */
  115879. readonly renderTimeCounter: PerfCounter;
  115880. /**
  115881. * Gets the render time capture status
  115882. */
  115883. /**
  115884. * Enable or disable the render time capture
  115885. */
  115886. captureRenderTime: boolean;
  115887. /**
  115888. * Gets the perf counter used for camera render time capture
  115889. */
  115890. readonly cameraRenderTimeCounter: PerfCounter;
  115891. /**
  115892. * Gets the camera render time capture status
  115893. */
  115894. /**
  115895. * Enable or disable the camera render time capture
  115896. */
  115897. captureCameraRenderTime: boolean;
  115898. /**
  115899. * Gets the perf counter used for draw calls
  115900. */
  115901. readonly drawCallsCounter: PerfCounter;
  115902. /**
  115903. * Instantiates a new scene instrumentation.
  115904. * This class can be used to get instrumentation data from a Babylon engine
  115905. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115906. * @param scene Defines the scene to instrument
  115907. */
  115908. constructor(
  115909. /**
  115910. * Defines the scene to instrument
  115911. */
  115912. scene: Scene);
  115913. /**
  115914. * Dispose and release associated resources.
  115915. */
  115916. dispose(): void;
  115917. }
  115918. }
  115919. declare module BABYLON {
  115920. /** @hidden */
  115921. export var glowMapGenerationPixelShader: {
  115922. name: string;
  115923. shader: string;
  115924. };
  115925. }
  115926. declare module BABYLON {
  115927. /** @hidden */
  115928. export var glowMapGenerationVertexShader: {
  115929. name: string;
  115930. shader: string;
  115931. };
  115932. }
  115933. declare module BABYLON {
  115934. /**
  115935. * Effect layer options. This helps customizing the behaviour
  115936. * of the effect layer.
  115937. */
  115938. export interface IEffectLayerOptions {
  115939. /**
  115940. * Multiplication factor apply to the canvas size to compute the render target size
  115941. * used to generated the objects (the smaller the faster).
  115942. */
  115943. mainTextureRatio: number;
  115944. /**
  115945. * Enforces a fixed size texture to ensure effect stability across devices.
  115946. */
  115947. mainTextureFixedSize?: number;
  115948. /**
  115949. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  115950. */
  115951. alphaBlendingMode: number;
  115952. /**
  115953. * The camera attached to the layer.
  115954. */
  115955. camera: Nullable<Camera>;
  115956. /**
  115957. * The rendering group to draw the layer in.
  115958. */
  115959. renderingGroupId: number;
  115960. }
  115961. /**
  115962. * The effect layer Helps adding post process effect blended with the main pass.
  115963. *
  115964. * This can be for instance use to generate glow or higlight effects on the scene.
  115965. *
  115966. * The effect layer class can not be used directly and is intented to inherited from to be
  115967. * customized per effects.
  115968. */
  115969. export abstract class EffectLayer {
  115970. private _vertexBuffers;
  115971. private _indexBuffer;
  115972. private _cachedDefines;
  115973. private _effectLayerMapGenerationEffect;
  115974. private _effectLayerOptions;
  115975. private _mergeEffect;
  115976. protected _scene: Scene;
  115977. protected _engine: Engine;
  115978. protected _maxSize: number;
  115979. protected _mainTextureDesiredSize: ISize;
  115980. protected _mainTexture: RenderTargetTexture;
  115981. protected _shouldRender: boolean;
  115982. protected _postProcesses: PostProcess[];
  115983. protected _textures: BaseTexture[];
  115984. protected _emissiveTextureAndColor: {
  115985. texture: Nullable<BaseTexture>;
  115986. color: Color4;
  115987. };
  115988. /**
  115989. * The name of the layer
  115990. */
  115991. name: string;
  115992. /**
  115993. * The clear color of the texture used to generate the glow map.
  115994. */
  115995. neutralColor: Color4;
  115996. /**
  115997. * Specifies wether the highlight layer is enabled or not.
  115998. */
  115999. isEnabled: boolean;
  116000. /**
  116001. * Gets the camera attached to the layer.
  116002. */
  116003. readonly camera: Nullable<Camera>;
  116004. /**
  116005. * Gets the rendering group id the layer should render in.
  116006. */
  116007. renderingGroupId: number;
  116008. /**
  116009. * An event triggered when the effect layer has been disposed.
  116010. */
  116011. onDisposeObservable: Observable<EffectLayer>;
  116012. /**
  116013. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116014. */
  116015. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116016. /**
  116017. * An event triggered when the generated texture is being merged in the scene.
  116018. */
  116019. onBeforeComposeObservable: Observable<EffectLayer>;
  116020. /**
  116021. * An event triggered when the generated texture has been merged in the scene.
  116022. */
  116023. onAfterComposeObservable: Observable<EffectLayer>;
  116024. /**
  116025. * An event triggered when the efffect layer changes its size.
  116026. */
  116027. onSizeChangedObservable: Observable<EffectLayer>;
  116028. /** @hidden */
  116029. static _SceneComponentInitialization: (scene: Scene) => void;
  116030. /**
  116031. * Instantiates a new effect Layer and references it in the scene.
  116032. * @param name The name of the layer
  116033. * @param scene The scene to use the layer in
  116034. */
  116035. constructor(
  116036. /** The Friendly of the effect in the scene */
  116037. name: string, scene: Scene);
  116038. /**
  116039. * Get the effect name of the layer.
  116040. * @return The effect name
  116041. */
  116042. abstract getEffectName(): string;
  116043. /**
  116044. * Checks for the readiness of the element composing the layer.
  116045. * @param subMesh the mesh to check for
  116046. * @param useInstances specify wether or not to use instances to render the mesh
  116047. * @return true if ready otherwise, false
  116048. */
  116049. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116050. /**
  116051. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116052. * @returns true if the effect requires stencil during the main canvas render pass.
  116053. */
  116054. abstract needStencil(): boolean;
  116055. /**
  116056. * Create the merge effect. This is the shader use to blit the information back
  116057. * to the main canvas at the end of the scene rendering.
  116058. * @returns The effect containing the shader used to merge the effect on the main canvas
  116059. */
  116060. protected abstract _createMergeEffect(): Effect;
  116061. /**
  116062. * Creates the render target textures and post processes used in the effect layer.
  116063. */
  116064. protected abstract _createTextureAndPostProcesses(): void;
  116065. /**
  116066. * Implementation specific of rendering the generating effect on the main canvas.
  116067. * @param effect The effect used to render through
  116068. */
  116069. protected abstract _internalRender(effect: Effect): void;
  116070. /**
  116071. * Sets the required values for both the emissive texture and and the main color.
  116072. */
  116073. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116074. /**
  116075. * Free any resources and references associated to a mesh.
  116076. * Internal use
  116077. * @param mesh The mesh to free.
  116078. */
  116079. abstract _disposeMesh(mesh: Mesh): void;
  116080. /**
  116081. * Serializes this layer (Glow or Highlight for example)
  116082. * @returns a serialized layer object
  116083. */
  116084. abstract serialize?(): any;
  116085. /**
  116086. * Initializes the effect layer with the required options.
  116087. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116088. */
  116089. protected _init(options: Partial<IEffectLayerOptions>): void;
  116090. /**
  116091. * Generates the index buffer of the full screen quad blending to the main canvas.
  116092. */
  116093. private _generateIndexBuffer;
  116094. /**
  116095. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116096. */
  116097. private _generateVertexBuffer;
  116098. /**
  116099. * Sets the main texture desired size which is the closest power of two
  116100. * of the engine canvas size.
  116101. */
  116102. private _setMainTextureSize;
  116103. /**
  116104. * Creates the main texture for the effect layer.
  116105. */
  116106. protected _createMainTexture(): void;
  116107. /**
  116108. * Adds specific effects defines.
  116109. * @param defines The defines to add specifics to.
  116110. */
  116111. protected _addCustomEffectDefines(defines: string[]): void;
  116112. /**
  116113. * Checks for the readiness of the element composing the layer.
  116114. * @param subMesh the mesh to check for
  116115. * @param useInstances specify wether or not to use instances to render the mesh
  116116. * @param emissiveTexture the associated emissive texture used to generate the glow
  116117. * @return true if ready otherwise, false
  116118. */
  116119. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116120. /**
  116121. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116122. */
  116123. render(): void;
  116124. /**
  116125. * Determine if a given mesh will be used in the current effect.
  116126. * @param mesh mesh to test
  116127. * @returns true if the mesh will be used
  116128. */
  116129. hasMesh(mesh: AbstractMesh): boolean;
  116130. /**
  116131. * Returns true if the layer contains information to display, otherwise false.
  116132. * @returns true if the glow layer should be rendered
  116133. */
  116134. shouldRender(): boolean;
  116135. /**
  116136. * Returns true if the mesh should render, otherwise false.
  116137. * @param mesh The mesh to render
  116138. * @returns true if it should render otherwise false
  116139. */
  116140. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116141. /**
  116142. * Returns true if the mesh can be rendered, otherwise false.
  116143. * @param mesh The mesh to render
  116144. * @param material The material used on the mesh
  116145. * @returns true if it can be rendered otherwise false
  116146. */
  116147. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116148. /**
  116149. * Returns true if the mesh should render, otherwise false.
  116150. * @param mesh The mesh to render
  116151. * @returns true if it should render otherwise false
  116152. */
  116153. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116154. /**
  116155. * Renders the submesh passed in parameter to the generation map.
  116156. */
  116157. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116158. /**
  116159. * Rebuild the required buffers.
  116160. * @hidden Internal use only.
  116161. */
  116162. _rebuild(): void;
  116163. /**
  116164. * Dispose only the render target textures and post process.
  116165. */
  116166. private _disposeTextureAndPostProcesses;
  116167. /**
  116168. * Dispose the highlight layer and free resources.
  116169. */
  116170. dispose(): void;
  116171. /**
  116172. * Gets the class name of the effect layer
  116173. * @returns the string with the class name of the effect layer
  116174. */
  116175. getClassName(): string;
  116176. /**
  116177. * Creates an effect layer from parsed effect layer data
  116178. * @param parsedEffectLayer defines effect layer data
  116179. * @param scene defines the current scene
  116180. * @param rootUrl defines the root URL containing the effect layer information
  116181. * @returns a parsed effect Layer
  116182. */
  116183. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116184. }
  116185. }
  116186. declare module BABYLON {
  116187. interface AbstractScene {
  116188. /**
  116189. * The list of effect layers (highlights/glow) added to the scene
  116190. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116191. * @see http://doc.babylonjs.com/how_to/glow_layer
  116192. */
  116193. effectLayers: Array<EffectLayer>;
  116194. /**
  116195. * Removes the given effect layer from this scene.
  116196. * @param toRemove defines the effect layer to remove
  116197. * @returns the index of the removed effect layer
  116198. */
  116199. removeEffectLayer(toRemove: EffectLayer): number;
  116200. /**
  116201. * Adds the given effect layer to this scene
  116202. * @param newEffectLayer defines the effect layer to add
  116203. */
  116204. addEffectLayer(newEffectLayer: EffectLayer): void;
  116205. }
  116206. /**
  116207. * Defines the layer scene component responsible to manage any effect layers
  116208. * in a given scene.
  116209. */
  116210. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116211. /**
  116212. * The component name helpfull to identify the component in the list of scene components.
  116213. */
  116214. readonly name: string;
  116215. /**
  116216. * The scene the component belongs to.
  116217. */
  116218. scene: Scene;
  116219. private _engine;
  116220. private _renderEffects;
  116221. private _needStencil;
  116222. private _previousStencilState;
  116223. /**
  116224. * Creates a new instance of the component for the given scene
  116225. * @param scene Defines the scene to register the component in
  116226. */
  116227. constructor(scene: Scene);
  116228. /**
  116229. * Registers the component in a given scene
  116230. */
  116231. register(): void;
  116232. /**
  116233. * Rebuilds the elements related to this component in case of
  116234. * context lost for instance.
  116235. */
  116236. rebuild(): void;
  116237. /**
  116238. * Serializes the component data to the specified json object
  116239. * @param serializationObject The object to serialize to
  116240. */
  116241. serialize(serializationObject: any): void;
  116242. /**
  116243. * Adds all the elements from the container to the scene
  116244. * @param container the container holding the elements
  116245. */
  116246. addFromContainer(container: AbstractScene): void;
  116247. /**
  116248. * Removes all the elements in the container from the scene
  116249. * @param container contains the elements to remove
  116250. * @param dispose if the removed element should be disposed (default: false)
  116251. */
  116252. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116253. /**
  116254. * Disposes the component and the associated ressources.
  116255. */
  116256. dispose(): void;
  116257. private _isReadyForMesh;
  116258. private _renderMainTexture;
  116259. private _setStencil;
  116260. private _setStencilBack;
  116261. private _draw;
  116262. private _drawCamera;
  116263. private _drawRenderingGroup;
  116264. }
  116265. }
  116266. declare module BABYLON {
  116267. /** @hidden */
  116268. export var glowMapMergePixelShader: {
  116269. name: string;
  116270. shader: string;
  116271. };
  116272. }
  116273. declare module BABYLON {
  116274. /** @hidden */
  116275. export var glowMapMergeVertexShader: {
  116276. name: string;
  116277. shader: string;
  116278. };
  116279. }
  116280. declare module BABYLON {
  116281. interface AbstractScene {
  116282. /**
  116283. * Return a the first highlight layer of the scene with a given name.
  116284. * @param name The name of the highlight layer to look for.
  116285. * @return The highlight layer if found otherwise null.
  116286. */
  116287. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116288. }
  116289. /**
  116290. * Glow layer options. This helps customizing the behaviour
  116291. * of the glow layer.
  116292. */
  116293. export interface IGlowLayerOptions {
  116294. /**
  116295. * Multiplication factor apply to the canvas size to compute the render target size
  116296. * used to generated the glowing objects (the smaller the faster).
  116297. */
  116298. mainTextureRatio: number;
  116299. /**
  116300. * Enforces a fixed size texture to ensure resize independant blur.
  116301. */
  116302. mainTextureFixedSize?: number;
  116303. /**
  116304. * How big is the kernel of the blur texture.
  116305. */
  116306. blurKernelSize: number;
  116307. /**
  116308. * The camera attached to the layer.
  116309. */
  116310. camera: Nullable<Camera>;
  116311. /**
  116312. * Enable MSAA by chosing the number of samples.
  116313. */
  116314. mainTextureSamples?: number;
  116315. /**
  116316. * The rendering group to draw the layer in.
  116317. */
  116318. renderingGroupId: number;
  116319. }
  116320. /**
  116321. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116322. *
  116323. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116324. * glowy meshes to your scene.
  116325. *
  116326. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116327. */
  116328. export class GlowLayer extends EffectLayer {
  116329. /**
  116330. * Effect Name of the layer.
  116331. */
  116332. static readonly EffectName: string;
  116333. /**
  116334. * The default blur kernel size used for the glow.
  116335. */
  116336. static DefaultBlurKernelSize: number;
  116337. /**
  116338. * The default texture size ratio used for the glow.
  116339. */
  116340. static DefaultTextureRatio: number;
  116341. /**
  116342. * Sets the kernel size of the blur.
  116343. */
  116344. /**
  116345. * Gets the kernel size of the blur.
  116346. */
  116347. blurKernelSize: number;
  116348. /**
  116349. * Sets the glow intensity.
  116350. */
  116351. /**
  116352. * Gets the glow intensity.
  116353. */
  116354. intensity: number;
  116355. private _options;
  116356. private _intensity;
  116357. private _horizontalBlurPostprocess1;
  116358. private _verticalBlurPostprocess1;
  116359. private _horizontalBlurPostprocess2;
  116360. private _verticalBlurPostprocess2;
  116361. private _blurTexture1;
  116362. private _blurTexture2;
  116363. private _postProcesses1;
  116364. private _postProcesses2;
  116365. private _includedOnlyMeshes;
  116366. private _excludedMeshes;
  116367. /**
  116368. * Callback used to let the user override the color selection on a per mesh basis
  116369. */
  116370. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116371. /**
  116372. * Callback used to let the user override the texture selection on a per mesh basis
  116373. */
  116374. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116375. /**
  116376. * Instantiates a new glow Layer and references it to the scene.
  116377. * @param name The name of the layer
  116378. * @param scene The scene to use the layer in
  116379. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116380. */
  116381. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116382. /**
  116383. * Get the effect name of the layer.
  116384. * @return The effect name
  116385. */
  116386. getEffectName(): string;
  116387. /**
  116388. * Create the merge effect. This is the shader use to blit the information back
  116389. * to the main canvas at the end of the scene rendering.
  116390. */
  116391. protected _createMergeEffect(): Effect;
  116392. /**
  116393. * Creates the render target textures and post processes used in the glow layer.
  116394. */
  116395. protected _createTextureAndPostProcesses(): void;
  116396. /**
  116397. * Checks for the readiness of the element composing the layer.
  116398. * @param subMesh the mesh to check for
  116399. * @param useInstances specify wether or not to use instances to render the mesh
  116400. * @param emissiveTexture the associated emissive texture used to generate the glow
  116401. * @return true if ready otherwise, false
  116402. */
  116403. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116404. /**
  116405. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116406. */
  116407. needStencil(): boolean;
  116408. /**
  116409. * Returns true if the mesh can be rendered, otherwise false.
  116410. * @param mesh The mesh to render
  116411. * @param material The material used on the mesh
  116412. * @returns true if it can be rendered otherwise false
  116413. */
  116414. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116415. /**
  116416. * Implementation specific of rendering the generating effect on the main canvas.
  116417. * @param effect The effect used to render through
  116418. */
  116419. protected _internalRender(effect: Effect): void;
  116420. /**
  116421. * Sets the required values for both the emissive texture and and the main color.
  116422. */
  116423. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116424. /**
  116425. * Returns true if the mesh should render, otherwise false.
  116426. * @param mesh The mesh to render
  116427. * @returns true if it should render otherwise false
  116428. */
  116429. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116430. /**
  116431. * Adds specific effects defines.
  116432. * @param defines The defines to add specifics to.
  116433. */
  116434. protected _addCustomEffectDefines(defines: string[]): void;
  116435. /**
  116436. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116437. * @param mesh The mesh to exclude from the glow layer
  116438. */
  116439. addExcludedMesh(mesh: Mesh): void;
  116440. /**
  116441. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116442. * @param mesh The mesh to remove
  116443. */
  116444. removeExcludedMesh(mesh: Mesh): void;
  116445. /**
  116446. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116447. * @param mesh The mesh to include in the glow layer
  116448. */
  116449. addIncludedOnlyMesh(mesh: Mesh): void;
  116450. /**
  116451. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116452. * @param mesh The mesh to remove
  116453. */
  116454. removeIncludedOnlyMesh(mesh: Mesh): void;
  116455. /**
  116456. * Determine if a given mesh will be used in the glow layer
  116457. * @param mesh The mesh to test
  116458. * @returns true if the mesh will be highlighted by the current glow layer
  116459. */
  116460. hasMesh(mesh: AbstractMesh): boolean;
  116461. /**
  116462. * Free any resources and references associated to a mesh.
  116463. * Internal use
  116464. * @param mesh The mesh to free.
  116465. * @hidden
  116466. */
  116467. _disposeMesh(mesh: Mesh): void;
  116468. /**
  116469. * Gets the class name of the effect layer
  116470. * @returns the string with the class name of the effect layer
  116471. */
  116472. getClassName(): string;
  116473. /**
  116474. * Serializes this glow layer
  116475. * @returns a serialized glow layer object
  116476. */
  116477. serialize(): any;
  116478. /**
  116479. * Creates a Glow Layer from parsed glow layer data
  116480. * @param parsedGlowLayer defines glow layer data
  116481. * @param scene defines the current scene
  116482. * @param rootUrl defines the root URL containing the glow layer information
  116483. * @returns a parsed Glow Layer
  116484. */
  116485. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116486. }
  116487. }
  116488. declare module BABYLON {
  116489. /** @hidden */
  116490. export var glowBlurPostProcessPixelShader: {
  116491. name: string;
  116492. shader: string;
  116493. };
  116494. }
  116495. declare module BABYLON {
  116496. interface AbstractScene {
  116497. /**
  116498. * Return a the first highlight layer of the scene with a given name.
  116499. * @param name The name of the highlight layer to look for.
  116500. * @return The highlight layer if found otherwise null.
  116501. */
  116502. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116503. }
  116504. /**
  116505. * Highlight layer options. This helps customizing the behaviour
  116506. * of the highlight layer.
  116507. */
  116508. export interface IHighlightLayerOptions {
  116509. /**
  116510. * Multiplication factor apply to the canvas size to compute the render target size
  116511. * used to generated the glowing objects (the smaller the faster).
  116512. */
  116513. mainTextureRatio: number;
  116514. /**
  116515. * Enforces a fixed size texture to ensure resize independant blur.
  116516. */
  116517. mainTextureFixedSize?: number;
  116518. /**
  116519. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116520. * of the picture to blur (the smaller the faster).
  116521. */
  116522. blurTextureSizeRatio: number;
  116523. /**
  116524. * How big in texel of the blur texture is the vertical blur.
  116525. */
  116526. blurVerticalSize: number;
  116527. /**
  116528. * How big in texel of the blur texture is the horizontal blur.
  116529. */
  116530. blurHorizontalSize: number;
  116531. /**
  116532. * Alpha blending mode used to apply the blur. Default is combine.
  116533. */
  116534. alphaBlendingMode: number;
  116535. /**
  116536. * The camera attached to the layer.
  116537. */
  116538. camera: Nullable<Camera>;
  116539. /**
  116540. * Should we display highlight as a solid stroke?
  116541. */
  116542. isStroke?: boolean;
  116543. /**
  116544. * The rendering group to draw the layer in.
  116545. */
  116546. renderingGroupId: number;
  116547. }
  116548. /**
  116549. * The highlight layer Helps adding a glow effect around a mesh.
  116550. *
  116551. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116552. * glowy meshes to your scene.
  116553. *
  116554. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116555. */
  116556. export class HighlightLayer extends EffectLayer {
  116557. name: string;
  116558. /**
  116559. * Effect Name of the highlight layer.
  116560. */
  116561. static readonly EffectName: string;
  116562. /**
  116563. * The neutral color used during the preparation of the glow effect.
  116564. * This is black by default as the blend operation is a blend operation.
  116565. */
  116566. static NeutralColor: Color4;
  116567. /**
  116568. * Stencil value used for glowing meshes.
  116569. */
  116570. static GlowingMeshStencilReference: number;
  116571. /**
  116572. * Stencil value used for the other meshes in the scene.
  116573. */
  116574. static NormalMeshStencilReference: number;
  116575. /**
  116576. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116577. */
  116578. innerGlow: boolean;
  116579. /**
  116580. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116581. */
  116582. outerGlow: boolean;
  116583. /**
  116584. * Specifies the horizontal size of the blur.
  116585. */
  116586. /**
  116587. * Gets the horizontal size of the blur.
  116588. */
  116589. blurHorizontalSize: number;
  116590. /**
  116591. * Specifies the vertical size of the blur.
  116592. */
  116593. /**
  116594. * Gets the vertical size of the blur.
  116595. */
  116596. blurVerticalSize: number;
  116597. /**
  116598. * An event triggered when the highlight layer is being blurred.
  116599. */
  116600. onBeforeBlurObservable: Observable<HighlightLayer>;
  116601. /**
  116602. * An event triggered when the highlight layer has been blurred.
  116603. */
  116604. onAfterBlurObservable: Observable<HighlightLayer>;
  116605. private _instanceGlowingMeshStencilReference;
  116606. private _options;
  116607. private _downSamplePostprocess;
  116608. private _horizontalBlurPostprocess;
  116609. private _verticalBlurPostprocess;
  116610. private _blurTexture;
  116611. private _meshes;
  116612. private _excludedMeshes;
  116613. /**
  116614. * Instantiates a new highlight Layer and references it to the scene..
  116615. * @param name The name of the layer
  116616. * @param scene The scene to use the layer in
  116617. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116618. */
  116619. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116620. /**
  116621. * Get the effect name of the layer.
  116622. * @return The effect name
  116623. */
  116624. getEffectName(): string;
  116625. /**
  116626. * Create the merge effect. This is the shader use to blit the information back
  116627. * to the main canvas at the end of the scene rendering.
  116628. */
  116629. protected _createMergeEffect(): Effect;
  116630. /**
  116631. * Creates the render target textures and post processes used in the highlight layer.
  116632. */
  116633. protected _createTextureAndPostProcesses(): void;
  116634. /**
  116635. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116636. */
  116637. needStencil(): boolean;
  116638. /**
  116639. * Checks for the readiness of the element composing the layer.
  116640. * @param subMesh the mesh to check for
  116641. * @param useInstances specify wether or not to use instances to render the mesh
  116642. * @param emissiveTexture the associated emissive texture used to generate the glow
  116643. * @return true if ready otherwise, false
  116644. */
  116645. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116646. /**
  116647. * Implementation specific of rendering the generating effect on the main canvas.
  116648. * @param effect The effect used to render through
  116649. */
  116650. protected _internalRender(effect: Effect): void;
  116651. /**
  116652. * Returns true if the layer contains information to display, otherwise false.
  116653. */
  116654. shouldRender(): boolean;
  116655. /**
  116656. * Returns true if the mesh should render, otherwise false.
  116657. * @param mesh The mesh to render
  116658. * @returns true if it should render otherwise false
  116659. */
  116660. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116661. /**
  116662. * Sets the required values for both the emissive texture and and the main color.
  116663. */
  116664. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116665. /**
  116666. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116667. * @param mesh The mesh to exclude from the highlight layer
  116668. */
  116669. addExcludedMesh(mesh: Mesh): void;
  116670. /**
  116671. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116672. * @param mesh The mesh to highlight
  116673. */
  116674. removeExcludedMesh(mesh: Mesh): void;
  116675. /**
  116676. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116677. * @param mesh mesh to test
  116678. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116679. */
  116680. hasMesh(mesh: AbstractMesh): boolean;
  116681. /**
  116682. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116683. * @param mesh The mesh to highlight
  116684. * @param color The color of the highlight
  116685. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116686. */
  116687. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116688. /**
  116689. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116690. * @param mesh The mesh to highlight
  116691. */
  116692. removeMesh(mesh: Mesh): void;
  116693. /**
  116694. * Force the stencil to the normal expected value for none glowing parts
  116695. */
  116696. private _defaultStencilReference;
  116697. /**
  116698. * Free any resources and references associated to a mesh.
  116699. * Internal use
  116700. * @param mesh The mesh to free.
  116701. * @hidden
  116702. */
  116703. _disposeMesh(mesh: Mesh): void;
  116704. /**
  116705. * Dispose the highlight layer and free resources.
  116706. */
  116707. dispose(): void;
  116708. /**
  116709. * Gets the class name of the effect layer
  116710. * @returns the string with the class name of the effect layer
  116711. */
  116712. getClassName(): string;
  116713. /**
  116714. * Serializes this Highlight layer
  116715. * @returns a serialized Highlight layer object
  116716. */
  116717. serialize(): any;
  116718. /**
  116719. * Creates a Highlight layer from parsed Highlight layer data
  116720. * @param parsedHightlightLayer defines the Highlight layer data
  116721. * @param scene defines the current scene
  116722. * @param rootUrl defines the root URL containing the Highlight layer information
  116723. * @returns a parsed Highlight layer
  116724. */
  116725. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116726. }
  116727. }
  116728. declare module BABYLON {
  116729. interface AbstractScene {
  116730. /**
  116731. * The list of layers (background and foreground) of the scene
  116732. */
  116733. layers: Array<Layer>;
  116734. }
  116735. /**
  116736. * Defines the layer scene component responsible to manage any layers
  116737. * in a given scene.
  116738. */
  116739. export class LayerSceneComponent implements ISceneComponent {
  116740. /**
  116741. * The component name helpfull to identify the component in the list of scene components.
  116742. */
  116743. readonly name: string;
  116744. /**
  116745. * The scene the component belongs to.
  116746. */
  116747. scene: Scene;
  116748. private _engine;
  116749. /**
  116750. * Creates a new instance of the component for the given scene
  116751. * @param scene Defines the scene to register the component in
  116752. */
  116753. constructor(scene: Scene);
  116754. /**
  116755. * Registers the component in a given scene
  116756. */
  116757. register(): void;
  116758. /**
  116759. * Rebuilds the elements related to this component in case of
  116760. * context lost for instance.
  116761. */
  116762. rebuild(): void;
  116763. /**
  116764. * Disposes the component and the associated ressources.
  116765. */
  116766. dispose(): void;
  116767. private _draw;
  116768. private _drawCameraPredicate;
  116769. private _drawCameraBackground;
  116770. private _drawCameraForeground;
  116771. private _drawRenderTargetPredicate;
  116772. private _drawRenderTargetBackground;
  116773. private _drawRenderTargetForeground;
  116774. /**
  116775. * Adds all the elements from the container to the scene
  116776. * @param container the container holding the elements
  116777. */
  116778. addFromContainer(container: AbstractScene): void;
  116779. /**
  116780. * Removes all the elements in the container from the scene
  116781. * @param container contains the elements to remove
  116782. * @param dispose if the removed element should be disposed (default: false)
  116783. */
  116784. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116785. }
  116786. }
  116787. declare module BABYLON {
  116788. /** @hidden */
  116789. export var layerPixelShader: {
  116790. name: string;
  116791. shader: string;
  116792. };
  116793. }
  116794. declare module BABYLON {
  116795. /** @hidden */
  116796. export var layerVertexShader: {
  116797. name: string;
  116798. shader: string;
  116799. };
  116800. }
  116801. declare module BABYLON {
  116802. /**
  116803. * This represents a full screen 2d layer.
  116804. * This can be useful to display a picture in the background of your scene for instance.
  116805. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116806. */
  116807. export class Layer {
  116808. /**
  116809. * Define the name of the layer.
  116810. */
  116811. name: string;
  116812. /**
  116813. * Define the texture the layer should display.
  116814. */
  116815. texture: Nullable<Texture>;
  116816. /**
  116817. * Is the layer in background or foreground.
  116818. */
  116819. isBackground: boolean;
  116820. /**
  116821. * Define the color of the layer (instead of texture).
  116822. */
  116823. color: Color4;
  116824. /**
  116825. * Define the scale of the layer in order to zoom in out of the texture.
  116826. */
  116827. scale: Vector2;
  116828. /**
  116829. * Define an offset for the layer in order to shift the texture.
  116830. */
  116831. offset: Vector2;
  116832. /**
  116833. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116834. */
  116835. alphaBlendingMode: number;
  116836. /**
  116837. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116838. * Alpha test will not mix with the background color in case of transparency.
  116839. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116840. */
  116841. alphaTest: boolean;
  116842. /**
  116843. * Define a mask to restrict the layer to only some of the scene cameras.
  116844. */
  116845. layerMask: number;
  116846. /**
  116847. * Define the list of render target the layer is visible into.
  116848. */
  116849. renderTargetTextures: RenderTargetTexture[];
  116850. /**
  116851. * Define if the layer is only used in renderTarget or if it also
  116852. * renders in the main frame buffer of the canvas.
  116853. */
  116854. renderOnlyInRenderTargetTextures: boolean;
  116855. private _scene;
  116856. private _vertexBuffers;
  116857. private _indexBuffer;
  116858. private _effect;
  116859. private _alphaTestEffect;
  116860. /**
  116861. * An event triggered when the layer is disposed.
  116862. */
  116863. onDisposeObservable: Observable<Layer>;
  116864. private _onDisposeObserver;
  116865. /**
  116866. * Back compatibility with callback before the onDisposeObservable existed.
  116867. * The set callback will be triggered when the layer has been disposed.
  116868. */
  116869. onDispose: () => void;
  116870. /**
  116871. * An event triggered before rendering the scene
  116872. */
  116873. onBeforeRenderObservable: Observable<Layer>;
  116874. private _onBeforeRenderObserver;
  116875. /**
  116876. * Back compatibility with callback before the onBeforeRenderObservable existed.
  116877. * The set callback will be triggered just before rendering the layer.
  116878. */
  116879. onBeforeRender: () => void;
  116880. /**
  116881. * An event triggered after rendering the scene
  116882. */
  116883. onAfterRenderObservable: Observable<Layer>;
  116884. private _onAfterRenderObserver;
  116885. /**
  116886. * Back compatibility with callback before the onAfterRenderObservable existed.
  116887. * The set callback will be triggered just after rendering the layer.
  116888. */
  116889. onAfterRender: () => void;
  116890. /**
  116891. * Instantiates a new layer.
  116892. * This represents a full screen 2d layer.
  116893. * This can be useful to display a picture in the background of your scene for instance.
  116894. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116895. * @param name Define the name of the layer in the scene
  116896. * @param imgUrl Define the url of the texture to display in the layer
  116897. * @param scene Define the scene the layer belongs to
  116898. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  116899. * @param color Defines a color for the layer
  116900. */
  116901. constructor(
  116902. /**
  116903. * Define the name of the layer.
  116904. */
  116905. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  116906. private _createIndexBuffer;
  116907. /** @hidden */
  116908. _rebuild(): void;
  116909. /**
  116910. * Renders the layer in the scene.
  116911. */
  116912. render(): void;
  116913. /**
  116914. * Disposes and releases the associated ressources.
  116915. */
  116916. dispose(): void;
  116917. }
  116918. }
  116919. declare module BABYLON {
  116920. /** @hidden */
  116921. export var lensFlarePixelShader: {
  116922. name: string;
  116923. shader: string;
  116924. };
  116925. }
  116926. declare module BABYLON {
  116927. /** @hidden */
  116928. export var lensFlareVertexShader: {
  116929. name: string;
  116930. shader: string;
  116931. };
  116932. }
  116933. declare module BABYLON {
  116934. /**
  116935. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116936. * It is usually composed of several `lensFlare`.
  116937. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116938. */
  116939. export class LensFlareSystem {
  116940. /**
  116941. * Define the name of the lens flare system
  116942. */
  116943. name: string;
  116944. /**
  116945. * List of lens flares used in this system.
  116946. */
  116947. lensFlares: LensFlare[];
  116948. /**
  116949. * Define a limit from the border the lens flare can be visible.
  116950. */
  116951. borderLimit: number;
  116952. /**
  116953. * Define a viewport border we do not want to see the lens flare in.
  116954. */
  116955. viewportBorder: number;
  116956. /**
  116957. * Define a predicate which could limit the list of meshes able to occlude the effect.
  116958. */
  116959. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  116960. /**
  116961. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  116962. */
  116963. layerMask: number;
  116964. /**
  116965. * Define the id of the lens flare system in the scene.
  116966. * (equal to name by default)
  116967. */
  116968. id: string;
  116969. private _scene;
  116970. private _emitter;
  116971. private _vertexBuffers;
  116972. private _indexBuffer;
  116973. private _effect;
  116974. private _positionX;
  116975. private _positionY;
  116976. private _isEnabled;
  116977. /** @hidden */
  116978. static _SceneComponentInitialization: (scene: Scene) => void;
  116979. /**
  116980. * Instantiates a lens flare system.
  116981. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  116982. * It is usually composed of several `lensFlare`.
  116983. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116984. * @param name Define the name of the lens flare system in the scene
  116985. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  116986. * @param scene Define the scene the lens flare system belongs to
  116987. */
  116988. constructor(
  116989. /**
  116990. * Define the name of the lens flare system
  116991. */
  116992. name: string, emitter: any, scene: Scene);
  116993. /**
  116994. * Define if the lens flare system is enabled.
  116995. */
  116996. isEnabled: boolean;
  116997. /**
  116998. * Get the scene the effects belongs to.
  116999. * @returns the scene holding the lens flare system
  117000. */
  117001. getScene(): Scene;
  117002. /**
  117003. * Get the emitter of the lens flare system.
  117004. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117005. * @returns the emitter of the lens flare system
  117006. */
  117007. getEmitter(): any;
  117008. /**
  117009. * Set the emitter of the lens flare system.
  117010. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117011. * @param newEmitter Define the new emitter of the system
  117012. */
  117013. setEmitter(newEmitter: any): void;
  117014. /**
  117015. * Get the lens flare system emitter position.
  117016. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117017. * @returns the position
  117018. */
  117019. getEmitterPosition(): Vector3;
  117020. /**
  117021. * @hidden
  117022. */
  117023. computeEffectivePosition(globalViewport: Viewport): boolean;
  117024. /** @hidden */
  117025. _isVisible(): boolean;
  117026. /**
  117027. * @hidden
  117028. */
  117029. render(): boolean;
  117030. /**
  117031. * Dispose and release the lens flare with its associated resources.
  117032. */
  117033. dispose(): void;
  117034. /**
  117035. * Parse a lens flare system from a JSON repressentation
  117036. * @param parsedLensFlareSystem Define the JSON to parse
  117037. * @param scene Define the scene the parsed system should be instantiated in
  117038. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117039. * @returns the parsed system
  117040. */
  117041. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117042. /**
  117043. * Serialize the current Lens Flare System into a JSON representation.
  117044. * @returns the serialized JSON
  117045. */
  117046. serialize(): any;
  117047. }
  117048. }
  117049. declare module BABYLON {
  117050. /**
  117051. * This represents one of the lens effect in a `lensFlareSystem`.
  117052. * It controls one of the indiviual texture used in the effect.
  117053. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117054. */
  117055. export class LensFlare {
  117056. /**
  117057. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117058. */
  117059. size: number;
  117060. /**
  117061. * 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.
  117062. */
  117063. position: number;
  117064. /**
  117065. * Define the lens color.
  117066. */
  117067. color: Color3;
  117068. /**
  117069. * Define the lens texture.
  117070. */
  117071. texture: Nullable<Texture>;
  117072. /**
  117073. * Define the alpha mode to render this particular lens.
  117074. */
  117075. alphaMode: number;
  117076. private _system;
  117077. /**
  117078. * Creates a new Lens Flare.
  117079. * This represents one of the lens effect in a `lensFlareSystem`.
  117080. * It controls one of the indiviual texture used in the effect.
  117081. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117082. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117083. * @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.
  117084. * @param color Define the lens color
  117085. * @param imgUrl Define the lens texture url
  117086. * @param system Define the `lensFlareSystem` this flare is part of
  117087. * @returns The newly created Lens Flare
  117088. */
  117089. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117090. /**
  117091. * Instantiates a new Lens Flare.
  117092. * This represents one of the lens effect in a `lensFlareSystem`.
  117093. * It controls one of the indiviual texture used in the effect.
  117094. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117095. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117096. * @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.
  117097. * @param color Define the lens color
  117098. * @param imgUrl Define the lens texture url
  117099. * @param system Define the `lensFlareSystem` this flare is part of
  117100. */
  117101. constructor(
  117102. /**
  117103. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117104. */
  117105. size: number,
  117106. /**
  117107. * 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.
  117108. */
  117109. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117110. /**
  117111. * Dispose and release the lens flare with its associated resources.
  117112. */
  117113. dispose(): void;
  117114. }
  117115. }
  117116. declare module BABYLON {
  117117. interface AbstractScene {
  117118. /**
  117119. * The list of lens flare system added to the scene
  117120. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117121. */
  117122. lensFlareSystems: Array<LensFlareSystem>;
  117123. /**
  117124. * Removes the given lens flare system from this scene.
  117125. * @param toRemove The lens flare system to remove
  117126. * @returns The index of the removed lens flare system
  117127. */
  117128. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117129. /**
  117130. * Adds the given lens flare system to this scene
  117131. * @param newLensFlareSystem The lens flare system to add
  117132. */
  117133. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117134. /**
  117135. * Gets a lens flare system using its name
  117136. * @param name defines the name to look for
  117137. * @returns the lens flare system or null if not found
  117138. */
  117139. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117140. /**
  117141. * Gets a lens flare system using its id
  117142. * @param id defines the id to look for
  117143. * @returns the lens flare system or null if not found
  117144. */
  117145. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117146. }
  117147. /**
  117148. * Defines the lens flare scene component responsible to manage any lens flares
  117149. * in a given scene.
  117150. */
  117151. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117152. /**
  117153. * The component name helpfull to identify the component in the list of scene components.
  117154. */
  117155. readonly name: string;
  117156. /**
  117157. * The scene the component belongs to.
  117158. */
  117159. scene: Scene;
  117160. /**
  117161. * Creates a new instance of the component for the given scene
  117162. * @param scene Defines the scene to register the component in
  117163. */
  117164. constructor(scene: Scene);
  117165. /**
  117166. * Registers the component in a given scene
  117167. */
  117168. register(): void;
  117169. /**
  117170. * Rebuilds the elements related to this component in case of
  117171. * context lost for instance.
  117172. */
  117173. rebuild(): void;
  117174. /**
  117175. * Adds all the elements from the container to the scene
  117176. * @param container the container holding the elements
  117177. */
  117178. addFromContainer(container: AbstractScene): void;
  117179. /**
  117180. * Removes all the elements in the container from the scene
  117181. * @param container contains the elements to remove
  117182. * @param dispose if the removed element should be disposed (default: false)
  117183. */
  117184. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117185. /**
  117186. * Serializes the component data to the specified json object
  117187. * @param serializationObject The object to serialize to
  117188. */
  117189. serialize(serializationObject: any): void;
  117190. /**
  117191. * Disposes the component and the associated ressources.
  117192. */
  117193. dispose(): void;
  117194. private _draw;
  117195. }
  117196. }
  117197. declare module BABYLON {
  117198. /**
  117199. * Defines the shadow generator component responsible to manage any shadow generators
  117200. * in a given scene.
  117201. */
  117202. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117203. /**
  117204. * The component name helpfull to identify the component in the list of scene components.
  117205. */
  117206. readonly name: string;
  117207. /**
  117208. * The scene the component belongs to.
  117209. */
  117210. scene: Scene;
  117211. /**
  117212. * Creates a new instance of the component for the given scene
  117213. * @param scene Defines the scene to register the component in
  117214. */
  117215. constructor(scene: Scene);
  117216. /**
  117217. * Registers the component in a given scene
  117218. */
  117219. register(): void;
  117220. /**
  117221. * Rebuilds the elements related to this component in case of
  117222. * context lost for instance.
  117223. */
  117224. rebuild(): void;
  117225. /**
  117226. * Serializes the component data to the specified json object
  117227. * @param serializationObject The object to serialize to
  117228. */
  117229. serialize(serializationObject: any): void;
  117230. /**
  117231. * Adds all the elements from the container to the scene
  117232. * @param container the container holding the elements
  117233. */
  117234. addFromContainer(container: AbstractScene): void;
  117235. /**
  117236. * Removes all the elements in the container from the scene
  117237. * @param container contains the elements to remove
  117238. * @param dispose if the removed element should be disposed (default: false)
  117239. */
  117240. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117241. /**
  117242. * Rebuilds the elements related to this component in case of
  117243. * context lost for instance.
  117244. */
  117245. dispose(): void;
  117246. private _gatherRenderTargets;
  117247. }
  117248. }
  117249. declare module BABYLON {
  117250. /**
  117251. * A point light is a light defined by an unique point in world space.
  117252. * The light is emitted in every direction from this point.
  117253. * A good example of a point light is a standard light bulb.
  117254. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117255. */
  117256. export class PointLight extends ShadowLight {
  117257. private _shadowAngle;
  117258. /**
  117259. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117260. * This specifies what angle the shadow will use to be created.
  117261. *
  117262. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117263. */
  117264. /**
  117265. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117266. * This specifies what angle the shadow will use to be created.
  117267. *
  117268. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117269. */
  117270. shadowAngle: number;
  117271. /**
  117272. * Gets the direction if it has been set.
  117273. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117274. */
  117275. /**
  117276. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117277. */
  117278. direction: Vector3;
  117279. /**
  117280. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117281. * A PointLight emits the light in every direction.
  117282. * It can cast shadows.
  117283. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117284. * ```javascript
  117285. * var pointLight = new PointLight("pl", camera.position, scene);
  117286. * ```
  117287. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117288. * @param name The light friendly name
  117289. * @param position The position of the point light in the scene
  117290. * @param scene The scene the lights belongs to
  117291. */
  117292. constructor(name: string, position: Vector3, scene: Scene);
  117293. /**
  117294. * Returns the string "PointLight"
  117295. * @returns the class name
  117296. */
  117297. getClassName(): string;
  117298. /**
  117299. * Returns the integer 0.
  117300. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117301. */
  117302. getTypeID(): number;
  117303. /**
  117304. * Specifies wether or not the shadowmap should be a cube texture.
  117305. * @returns true if the shadowmap needs to be a cube texture.
  117306. */
  117307. needCube(): boolean;
  117308. /**
  117309. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117310. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117311. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117312. */
  117313. getShadowDirection(faceIndex?: number): Vector3;
  117314. /**
  117315. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117316. * - fov = PI / 2
  117317. * - aspect ratio : 1.0
  117318. * - z-near and far equal to the active camera minZ and maxZ.
  117319. * Returns the PointLight.
  117320. */
  117321. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117322. protected _buildUniformLayout(): void;
  117323. /**
  117324. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117325. * @param effect The effect to update
  117326. * @param lightIndex The index of the light in the effect to update
  117327. * @returns The point light
  117328. */
  117329. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117330. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117331. /**
  117332. * Prepares the list of defines specific to the light type.
  117333. * @param defines the list of defines
  117334. * @param lightIndex defines the index of the light for the effect
  117335. */
  117336. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117337. }
  117338. }
  117339. declare module BABYLON {
  117340. /**
  117341. * Header information of HDR texture files.
  117342. */
  117343. export interface HDRInfo {
  117344. /**
  117345. * The height of the texture in pixels.
  117346. */
  117347. height: number;
  117348. /**
  117349. * The width of the texture in pixels.
  117350. */
  117351. width: number;
  117352. /**
  117353. * The index of the beginning of the data in the binary file.
  117354. */
  117355. dataPosition: number;
  117356. }
  117357. /**
  117358. * This groups tools to convert HDR texture to native colors array.
  117359. */
  117360. export class HDRTools {
  117361. private static Ldexp;
  117362. private static Rgbe2float;
  117363. private static readStringLine;
  117364. /**
  117365. * Reads header information from an RGBE texture stored in a native array.
  117366. * More information on this format are available here:
  117367. * https://en.wikipedia.org/wiki/RGBE_image_format
  117368. *
  117369. * @param uint8array The binary file stored in native array.
  117370. * @return The header information.
  117371. */
  117372. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117373. /**
  117374. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117375. * This RGBE texture needs to store the information as a panorama.
  117376. *
  117377. * More information on this format are available here:
  117378. * https://en.wikipedia.org/wiki/RGBE_image_format
  117379. *
  117380. * @param buffer The binary file stored in an array buffer.
  117381. * @param size The expected size of the extracted cubemap.
  117382. * @return The Cube Map information.
  117383. */
  117384. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117385. /**
  117386. * Returns the pixels data extracted from an RGBE texture.
  117387. * This pixels will be stored left to right up to down in the R G B order in one array.
  117388. *
  117389. * More information on this format are available here:
  117390. * https://en.wikipedia.org/wiki/RGBE_image_format
  117391. *
  117392. * @param uint8array The binary file stored in an array buffer.
  117393. * @param hdrInfo The header information of the file.
  117394. * @return The pixels data in RGB right to left up to down order.
  117395. */
  117396. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117397. private static RGBE_ReadPixels_RLE;
  117398. }
  117399. }
  117400. declare module BABYLON {
  117401. /**
  117402. * This represents a texture coming from an HDR input.
  117403. *
  117404. * The only supported format is currently panorama picture stored in RGBE format.
  117405. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117406. */
  117407. export class HDRCubeTexture extends BaseTexture {
  117408. private static _facesMapping;
  117409. private _generateHarmonics;
  117410. private _noMipmap;
  117411. private _textureMatrix;
  117412. private _size;
  117413. private _onLoad;
  117414. private _onError;
  117415. /**
  117416. * The texture URL.
  117417. */
  117418. url: string;
  117419. /**
  117420. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117421. */
  117422. coordinatesMode: number;
  117423. protected _isBlocking: boolean;
  117424. /**
  117425. * Sets wether or not the texture is blocking during loading.
  117426. */
  117427. /**
  117428. * Gets wether or not the texture is blocking during loading.
  117429. */
  117430. isBlocking: boolean;
  117431. protected _rotationY: number;
  117432. /**
  117433. * Sets texture matrix rotation angle around Y axis in radians.
  117434. */
  117435. /**
  117436. * Gets texture matrix rotation angle around Y axis radians.
  117437. */
  117438. rotationY: number;
  117439. /**
  117440. * Gets or sets the center of the bounding box associated with the cube texture
  117441. * It must define where the camera used to render the texture was set
  117442. */
  117443. boundingBoxPosition: Vector3;
  117444. private _boundingBoxSize;
  117445. /**
  117446. * Gets or sets the size of the bounding box associated with the cube texture
  117447. * When defined, the cubemap will switch to local mode
  117448. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117449. * @example https://www.babylonjs-playground.com/#RNASML
  117450. */
  117451. boundingBoxSize: Vector3;
  117452. /**
  117453. * Instantiates an HDRTexture from the following parameters.
  117454. *
  117455. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117456. * @param scene The scene the texture will be used in
  117457. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117458. * @param noMipmap Forces to not generate the mipmap if true
  117459. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117460. * @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)
  117461. * @param reserved Reserved flag for internal use.
  117462. */
  117463. 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>);
  117464. /**
  117465. * Get the current class name of the texture useful for serialization or dynamic coding.
  117466. * @returns "HDRCubeTexture"
  117467. */
  117468. getClassName(): string;
  117469. /**
  117470. * Occurs when the file is raw .hdr file.
  117471. */
  117472. private loadTexture;
  117473. clone(): HDRCubeTexture;
  117474. delayLoad(): void;
  117475. /**
  117476. * Get the texture reflection matrix used to rotate/transform the reflection.
  117477. * @returns the reflection matrix
  117478. */
  117479. getReflectionTextureMatrix(): Matrix;
  117480. /**
  117481. * Set the texture reflection matrix used to rotate/transform the reflection.
  117482. * @param value Define the reflection matrix to set
  117483. */
  117484. setReflectionTextureMatrix(value: Matrix): void;
  117485. /**
  117486. * Parses a JSON representation of an HDR Texture in order to create the texture
  117487. * @param parsedTexture Define the JSON representation
  117488. * @param scene Define the scene the texture should be created in
  117489. * @param rootUrl Define the root url in case we need to load relative dependencies
  117490. * @returns the newly created texture after parsing
  117491. */
  117492. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117493. serialize(): any;
  117494. }
  117495. }
  117496. declare module BABYLON {
  117497. /**
  117498. * Class used to control physics engine
  117499. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117500. */
  117501. export class PhysicsEngine implements IPhysicsEngine {
  117502. private _physicsPlugin;
  117503. /**
  117504. * Global value used to control the smallest number supported by the simulation
  117505. */
  117506. static Epsilon: number;
  117507. private _impostors;
  117508. private _joints;
  117509. /**
  117510. * Gets the gravity vector used by the simulation
  117511. */
  117512. gravity: Vector3;
  117513. /**
  117514. * Factory used to create the default physics plugin.
  117515. * @returns The default physics plugin
  117516. */
  117517. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117518. /**
  117519. * Creates a new Physics Engine
  117520. * @param gravity defines the gravity vector used by the simulation
  117521. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117522. */
  117523. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117524. /**
  117525. * Sets the gravity vector used by the simulation
  117526. * @param gravity defines the gravity vector to use
  117527. */
  117528. setGravity(gravity: Vector3): void;
  117529. /**
  117530. * Set the time step of the physics engine.
  117531. * Default is 1/60.
  117532. * To slow it down, enter 1/600 for example.
  117533. * To speed it up, 1/30
  117534. * @param newTimeStep defines the new timestep to apply to this world.
  117535. */
  117536. setTimeStep(newTimeStep?: number): void;
  117537. /**
  117538. * Get the time step of the physics engine.
  117539. * @returns the current time step
  117540. */
  117541. getTimeStep(): number;
  117542. /**
  117543. * Release all resources
  117544. */
  117545. dispose(): void;
  117546. /**
  117547. * Gets the name of the current physics plugin
  117548. * @returns the name of the plugin
  117549. */
  117550. getPhysicsPluginName(): string;
  117551. /**
  117552. * Adding a new impostor for the impostor tracking.
  117553. * This will be done by the impostor itself.
  117554. * @param impostor the impostor to add
  117555. */
  117556. addImpostor(impostor: PhysicsImpostor): void;
  117557. /**
  117558. * Remove an impostor from the engine.
  117559. * This impostor and its mesh will not longer be updated by the physics engine.
  117560. * @param impostor the impostor to remove
  117561. */
  117562. removeImpostor(impostor: PhysicsImpostor): void;
  117563. /**
  117564. * Add a joint to the physics engine
  117565. * @param mainImpostor defines the main impostor to which the joint is added.
  117566. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117567. * @param joint defines the joint that will connect both impostors.
  117568. */
  117569. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117570. /**
  117571. * Removes a joint from the simulation
  117572. * @param mainImpostor defines the impostor used with the joint
  117573. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117574. * @param joint defines the joint to remove
  117575. */
  117576. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117577. /**
  117578. * Called by the scene. No need to call it.
  117579. * @param delta defines the timespam between frames
  117580. */
  117581. _step(delta: number): void;
  117582. /**
  117583. * Gets the current plugin used to run the simulation
  117584. * @returns current plugin
  117585. */
  117586. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117587. /**
  117588. * Gets the list of physic impostors
  117589. * @returns an array of PhysicsImpostor
  117590. */
  117591. getImpostors(): Array<PhysicsImpostor>;
  117592. /**
  117593. * Gets the impostor for a physics enabled object
  117594. * @param object defines the object impersonated by the impostor
  117595. * @returns the PhysicsImpostor or null if not found
  117596. */
  117597. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117598. /**
  117599. * Gets the impostor for a physics body object
  117600. * @param body defines physics body used by the impostor
  117601. * @returns the PhysicsImpostor or null if not found
  117602. */
  117603. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117604. /**
  117605. * Does a raycast in the physics world
  117606. * @param from when should the ray start?
  117607. * @param to when should the ray end?
  117608. * @returns PhysicsRaycastResult
  117609. */
  117610. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117611. }
  117612. }
  117613. declare module BABYLON {
  117614. /** @hidden */
  117615. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117616. private _useDeltaForWorldStep;
  117617. world: any;
  117618. name: string;
  117619. private _physicsMaterials;
  117620. private _fixedTimeStep;
  117621. private _cannonRaycastResult;
  117622. private _raycastResult;
  117623. private _physicsBodysToRemoveAfterStep;
  117624. BJSCANNON: any;
  117625. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117626. setGravity(gravity: Vector3): void;
  117627. setTimeStep(timeStep: number): void;
  117628. getTimeStep(): number;
  117629. executeStep(delta: number): void;
  117630. private _removeMarkedPhysicsBodiesFromWorld;
  117631. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117632. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117633. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117634. private _processChildMeshes;
  117635. removePhysicsBody(impostor: PhysicsImpostor): void;
  117636. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117637. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117638. private _addMaterial;
  117639. private _checkWithEpsilon;
  117640. private _createShape;
  117641. private _createHeightmap;
  117642. private _minus90X;
  117643. private _plus90X;
  117644. private _tmpPosition;
  117645. private _tmpDeltaPosition;
  117646. private _tmpUnityRotation;
  117647. private _updatePhysicsBodyTransformation;
  117648. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117649. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117650. isSupported(): boolean;
  117651. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117652. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117653. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117654. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117655. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117656. getBodyMass(impostor: PhysicsImpostor): number;
  117657. getBodyFriction(impostor: PhysicsImpostor): number;
  117658. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117659. getBodyRestitution(impostor: PhysicsImpostor): number;
  117660. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117661. sleepBody(impostor: PhysicsImpostor): void;
  117662. wakeUpBody(impostor: PhysicsImpostor): void;
  117663. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117664. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117665. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117666. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117667. getRadius(impostor: PhysicsImpostor): number;
  117668. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117669. dispose(): void;
  117670. private _extendNamespace;
  117671. /**
  117672. * Does a raycast in the physics world
  117673. * @param from when should the ray start?
  117674. * @param to when should the ray end?
  117675. * @returns PhysicsRaycastResult
  117676. */
  117677. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117678. }
  117679. }
  117680. declare module BABYLON {
  117681. /** @hidden */
  117682. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117683. world: any;
  117684. name: string;
  117685. BJSOIMO: any;
  117686. private _raycastResult;
  117687. constructor(iterations?: number, oimoInjection?: any);
  117688. setGravity(gravity: Vector3): void;
  117689. setTimeStep(timeStep: number): void;
  117690. getTimeStep(): number;
  117691. private _tmpImpostorsArray;
  117692. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117693. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117694. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117695. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117696. private _tmpPositionVector;
  117697. removePhysicsBody(impostor: PhysicsImpostor): void;
  117698. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117699. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117700. isSupported(): boolean;
  117701. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117702. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117703. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117704. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117705. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117706. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117707. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117708. getBodyMass(impostor: PhysicsImpostor): number;
  117709. getBodyFriction(impostor: PhysicsImpostor): number;
  117710. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117711. getBodyRestitution(impostor: PhysicsImpostor): number;
  117712. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117713. sleepBody(impostor: PhysicsImpostor): void;
  117714. wakeUpBody(impostor: PhysicsImpostor): void;
  117715. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117716. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117717. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117718. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117719. getRadius(impostor: PhysicsImpostor): number;
  117720. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117721. dispose(): void;
  117722. /**
  117723. * Does a raycast in the physics world
  117724. * @param from when should the ray start?
  117725. * @param to when should the ray end?
  117726. * @returns PhysicsRaycastResult
  117727. */
  117728. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117729. }
  117730. }
  117731. declare module BABYLON {
  117732. /**
  117733. * Class containing static functions to help procedurally build meshes
  117734. */
  117735. export class RibbonBuilder {
  117736. /**
  117737. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117738. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117739. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117740. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117741. * * 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
  117742. * * 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
  117743. * * 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
  117744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117747. * * 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
  117748. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117749. * * 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
  117750. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117752. * @param name defines the name of the mesh
  117753. * @param options defines the options used to create the mesh
  117754. * @param scene defines the hosting scene
  117755. * @returns the ribbon mesh
  117756. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117757. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117758. */
  117759. static CreateRibbon(name: string, options: {
  117760. pathArray: Vector3[][];
  117761. closeArray?: boolean;
  117762. closePath?: boolean;
  117763. offset?: number;
  117764. updatable?: boolean;
  117765. sideOrientation?: number;
  117766. frontUVs?: Vector4;
  117767. backUVs?: Vector4;
  117768. instance?: Mesh;
  117769. invertUV?: boolean;
  117770. uvs?: Vector2[];
  117771. colors?: Color4[];
  117772. }, scene?: Nullable<Scene>): Mesh;
  117773. }
  117774. }
  117775. declare module BABYLON {
  117776. /**
  117777. * Class containing static functions to help procedurally build meshes
  117778. */
  117779. export class ShapeBuilder {
  117780. /**
  117781. * 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.
  117782. * * 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.
  117783. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117784. * * 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.
  117785. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117786. * * 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
  117787. * * 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
  117788. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117791. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117793. * @param name defines the name of the mesh
  117794. * @param options defines the options used to create the mesh
  117795. * @param scene defines the hosting scene
  117796. * @returns the extruded shape mesh
  117797. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117799. */
  117800. static ExtrudeShape(name: string, options: {
  117801. shape: Vector3[];
  117802. path: Vector3[];
  117803. scale?: number;
  117804. rotation?: number;
  117805. cap?: number;
  117806. updatable?: boolean;
  117807. sideOrientation?: number;
  117808. frontUVs?: Vector4;
  117809. backUVs?: Vector4;
  117810. instance?: Mesh;
  117811. invertUV?: boolean;
  117812. }, scene?: Nullable<Scene>): Mesh;
  117813. /**
  117814. * Creates an custom extruded shape mesh.
  117815. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117816. * * 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.
  117817. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117818. * * 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
  117819. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117820. * * 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
  117821. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117822. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117823. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117824. * * 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
  117825. * * 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
  117826. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117827. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117829. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117831. * @param name defines the name of the mesh
  117832. * @param options defines the options used to create the mesh
  117833. * @param scene defines the hosting scene
  117834. * @returns the custom extruded shape mesh
  117835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117836. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117838. */
  117839. static ExtrudeShapeCustom(name: string, options: {
  117840. shape: Vector3[];
  117841. path: Vector3[];
  117842. scaleFunction?: any;
  117843. rotationFunction?: any;
  117844. ribbonCloseArray?: boolean;
  117845. ribbonClosePath?: boolean;
  117846. cap?: number;
  117847. updatable?: boolean;
  117848. sideOrientation?: number;
  117849. frontUVs?: Vector4;
  117850. backUVs?: Vector4;
  117851. instance?: Mesh;
  117852. invertUV?: boolean;
  117853. }, scene?: Nullable<Scene>): Mesh;
  117854. private static _ExtrudeShapeGeneric;
  117855. }
  117856. }
  117857. declare module BABYLON {
  117858. /**
  117859. * AmmoJS Physics plugin
  117860. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117861. * @see https://github.com/kripken/ammo.js/
  117862. */
  117863. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  117864. private _useDeltaForWorldStep;
  117865. /**
  117866. * Reference to the Ammo library
  117867. */
  117868. bjsAMMO: any;
  117869. /**
  117870. * Created ammoJS world which physics bodies are added to
  117871. */
  117872. world: any;
  117873. /**
  117874. * Name of the plugin
  117875. */
  117876. name: string;
  117877. private _timeStep;
  117878. private _fixedTimeStep;
  117879. private _maxSteps;
  117880. private _tmpQuaternion;
  117881. private _tmpAmmoTransform;
  117882. private _tmpAmmoQuaternion;
  117883. private _tmpAmmoConcreteContactResultCallback;
  117884. private _collisionConfiguration;
  117885. private _dispatcher;
  117886. private _overlappingPairCache;
  117887. private _solver;
  117888. private _softBodySolver;
  117889. private _tmpAmmoVectorA;
  117890. private _tmpAmmoVectorB;
  117891. private _tmpAmmoVectorC;
  117892. private _tmpAmmoVectorD;
  117893. private _tmpContactCallbackResult;
  117894. private _tmpAmmoVectorRCA;
  117895. private _tmpAmmoVectorRCB;
  117896. private _raycastResult;
  117897. private static readonly DISABLE_COLLISION_FLAG;
  117898. private static readonly KINEMATIC_FLAG;
  117899. private static readonly DISABLE_DEACTIVATION_FLAG;
  117900. /**
  117901. * Initializes the ammoJS plugin
  117902. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  117903. * @param ammoInjection can be used to inject your own ammo reference
  117904. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  117905. */
  117906. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  117907. /**
  117908. * Sets the gravity of the physics world (m/(s^2))
  117909. * @param gravity Gravity to set
  117910. */
  117911. setGravity(gravity: Vector3): void;
  117912. /**
  117913. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  117914. * @param timeStep timestep to use in seconds
  117915. */
  117916. setTimeStep(timeStep: number): void;
  117917. /**
  117918. * 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)
  117919. * @param fixedTimeStep fixedTimeStep to use in seconds
  117920. */
  117921. setFixedTimeStep(fixedTimeStep: number): void;
  117922. /**
  117923. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  117924. * @param maxSteps the maximum number of steps by the physics engine per frame
  117925. */
  117926. setMaxSteps(maxSteps: number): void;
  117927. /**
  117928. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  117929. * @returns the current timestep in seconds
  117930. */
  117931. getTimeStep(): number;
  117932. private _isImpostorInContact;
  117933. private _isImpostorPairInContact;
  117934. private _stepSimulation;
  117935. /**
  117936. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  117937. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  117938. * After the step the babylon meshes are set to the position of the physics imposters
  117939. * @param delta amount of time to step forward
  117940. * @param impostors array of imposters to update before/after the step
  117941. */
  117942. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117943. /**
  117944. * Update babylon mesh to match physics world object
  117945. * @param impostor imposter to match
  117946. */
  117947. private _afterSoftStep;
  117948. /**
  117949. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117950. * @param impostor imposter to match
  117951. */
  117952. private _ropeStep;
  117953. /**
  117954. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  117955. * @param impostor imposter to match
  117956. */
  117957. private _softbodyOrClothStep;
  117958. private _tmpVector;
  117959. private _tmpMatrix;
  117960. /**
  117961. * Applies an impulse on the imposter
  117962. * @param impostor imposter to apply impulse to
  117963. * @param force amount of force to be applied to the imposter
  117964. * @param contactPoint the location to apply the impulse on the imposter
  117965. */
  117966. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117967. /**
  117968. * Applies a force on the imposter
  117969. * @param impostor imposter to apply force
  117970. * @param force amount of force to be applied to the imposter
  117971. * @param contactPoint the location to apply the force on the imposter
  117972. */
  117973. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117974. /**
  117975. * Creates a physics body using the plugin
  117976. * @param impostor the imposter to create the physics body on
  117977. */
  117978. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117979. /**
  117980. * Removes the physics body from the imposter and disposes of the body's memory
  117981. * @param impostor imposter to remove the physics body from
  117982. */
  117983. removePhysicsBody(impostor: PhysicsImpostor): void;
  117984. /**
  117985. * Generates a joint
  117986. * @param impostorJoint the imposter joint to create the joint with
  117987. */
  117988. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117989. /**
  117990. * Removes a joint
  117991. * @param impostorJoint the imposter joint to remove the joint from
  117992. */
  117993. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117994. private _addMeshVerts;
  117995. /**
  117996. * Initialise the soft body vertices to match its object's (mesh) vertices
  117997. * Softbody vertices (nodes) are in world space and to match this
  117998. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  117999. * @param impostor to create the softbody for
  118000. */
  118001. private _softVertexData;
  118002. /**
  118003. * Create an impostor's soft body
  118004. * @param impostor to create the softbody for
  118005. */
  118006. private _createSoftbody;
  118007. /**
  118008. * Create cloth for an impostor
  118009. * @param impostor to create the softbody for
  118010. */
  118011. private _createCloth;
  118012. /**
  118013. * Create rope for an impostor
  118014. * @param impostor to create the softbody for
  118015. */
  118016. private _createRope;
  118017. private _addHullVerts;
  118018. private _createShape;
  118019. /**
  118020. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118021. * @param impostor imposter containing the physics body and babylon object
  118022. */
  118023. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118024. /**
  118025. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118026. * @param impostor imposter containing the physics body and babylon object
  118027. * @param newPosition new position
  118028. * @param newRotation new rotation
  118029. */
  118030. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118031. /**
  118032. * If this plugin is supported
  118033. * @returns true if its supported
  118034. */
  118035. isSupported(): boolean;
  118036. /**
  118037. * Sets the linear velocity of the physics body
  118038. * @param impostor imposter to set the velocity on
  118039. * @param velocity velocity to set
  118040. */
  118041. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118042. /**
  118043. * Sets the angular velocity of the physics body
  118044. * @param impostor imposter to set the velocity on
  118045. * @param velocity velocity to set
  118046. */
  118047. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118048. /**
  118049. * gets the linear velocity
  118050. * @param impostor imposter to get linear velocity from
  118051. * @returns linear velocity
  118052. */
  118053. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118054. /**
  118055. * gets the angular velocity
  118056. * @param impostor imposter to get angular velocity from
  118057. * @returns angular velocity
  118058. */
  118059. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118060. /**
  118061. * Sets the mass of physics body
  118062. * @param impostor imposter to set the mass on
  118063. * @param mass mass to set
  118064. */
  118065. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118066. /**
  118067. * Gets the mass of the physics body
  118068. * @param impostor imposter to get the mass from
  118069. * @returns mass
  118070. */
  118071. getBodyMass(impostor: PhysicsImpostor): number;
  118072. /**
  118073. * Gets friction of the impostor
  118074. * @param impostor impostor to get friction from
  118075. * @returns friction value
  118076. */
  118077. getBodyFriction(impostor: PhysicsImpostor): number;
  118078. /**
  118079. * Sets friction of the impostor
  118080. * @param impostor impostor to set friction on
  118081. * @param friction friction value
  118082. */
  118083. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118084. /**
  118085. * Gets restitution of the impostor
  118086. * @param impostor impostor to get restitution from
  118087. * @returns restitution value
  118088. */
  118089. getBodyRestitution(impostor: PhysicsImpostor): number;
  118090. /**
  118091. * Sets resitution of the impostor
  118092. * @param impostor impostor to set resitution on
  118093. * @param restitution resitution value
  118094. */
  118095. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118096. /**
  118097. * Gets pressure inside the impostor
  118098. * @param impostor impostor to get pressure from
  118099. * @returns pressure value
  118100. */
  118101. getBodyPressure(impostor: PhysicsImpostor): number;
  118102. /**
  118103. * Sets pressure inside a soft body impostor
  118104. * Cloth and rope must remain 0 pressure
  118105. * @param impostor impostor to set pressure on
  118106. * @param pressure pressure value
  118107. */
  118108. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118109. /**
  118110. * Gets stiffness of the impostor
  118111. * @param impostor impostor to get stiffness from
  118112. * @returns pressure value
  118113. */
  118114. getBodyStiffness(impostor: PhysicsImpostor): number;
  118115. /**
  118116. * Sets stiffness of the impostor
  118117. * @param impostor impostor to set stiffness on
  118118. * @param stiffness stiffness value from 0 to 1
  118119. */
  118120. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118121. /**
  118122. * Gets velocityIterations of the impostor
  118123. * @param impostor impostor to get velocity iterations from
  118124. * @returns velocityIterations value
  118125. */
  118126. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118127. /**
  118128. * Sets velocityIterations of the impostor
  118129. * @param impostor impostor to set velocity iterations on
  118130. * @param velocityIterations velocityIterations value
  118131. */
  118132. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118133. /**
  118134. * Gets positionIterations of the impostor
  118135. * @param impostor impostor to get position iterations from
  118136. * @returns positionIterations value
  118137. */
  118138. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118139. /**
  118140. * Sets positionIterations of the impostor
  118141. * @param impostor impostor to set position on
  118142. * @param positionIterations positionIterations value
  118143. */
  118144. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118145. /**
  118146. * Append an anchor to a cloth object
  118147. * @param impostor is the cloth impostor to add anchor to
  118148. * @param otherImpostor is the rigid impostor to anchor to
  118149. * @param width ratio across width from 0 to 1
  118150. * @param height ratio up height from 0 to 1
  118151. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118152. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118153. */
  118154. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118155. /**
  118156. * Append an hook to a rope object
  118157. * @param impostor is the rope impostor to add hook to
  118158. * @param otherImpostor is the rigid impostor to hook to
  118159. * @param length ratio along the rope from 0 to 1
  118160. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118161. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118162. */
  118163. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118164. /**
  118165. * Sleeps the physics body and stops it from being active
  118166. * @param impostor impostor to sleep
  118167. */
  118168. sleepBody(impostor: PhysicsImpostor): void;
  118169. /**
  118170. * Activates the physics body
  118171. * @param impostor impostor to activate
  118172. */
  118173. wakeUpBody(impostor: PhysicsImpostor): void;
  118174. /**
  118175. * Updates the distance parameters of the joint
  118176. * @param joint joint to update
  118177. * @param maxDistance maximum distance of the joint
  118178. * @param minDistance minimum distance of the joint
  118179. */
  118180. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118181. /**
  118182. * Sets a motor on the joint
  118183. * @param joint joint to set motor on
  118184. * @param speed speed of the motor
  118185. * @param maxForce maximum force of the motor
  118186. * @param motorIndex index of the motor
  118187. */
  118188. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118189. /**
  118190. * Sets the motors limit
  118191. * @param joint joint to set limit on
  118192. * @param upperLimit upper limit
  118193. * @param lowerLimit lower limit
  118194. */
  118195. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118196. /**
  118197. * Syncs the position and rotation of a mesh with the impostor
  118198. * @param mesh mesh to sync
  118199. * @param impostor impostor to update the mesh with
  118200. */
  118201. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118202. /**
  118203. * Gets the radius of the impostor
  118204. * @param impostor impostor to get radius from
  118205. * @returns the radius
  118206. */
  118207. getRadius(impostor: PhysicsImpostor): number;
  118208. /**
  118209. * Gets the box size of the impostor
  118210. * @param impostor impostor to get box size from
  118211. * @param result the resulting box size
  118212. */
  118213. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118214. /**
  118215. * Disposes of the impostor
  118216. */
  118217. dispose(): void;
  118218. /**
  118219. * Does a raycast in the physics world
  118220. * @param from when should the ray start?
  118221. * @param to when should the ray end?
  118222. * @returns PhysicsRaycastResult
  118223. */
  118224. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118225. }
  118226. }
  118227. declare module BABYLON {
  118228. interface AbstractScene {
  118229. /**
  118230. * The list of reflection probes added to the scene
  118231. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118232. */
  118233. reflectionProbes: Array<ReflectionProbe>;
  118234. /**
  118235. * Removes the given reflection probe from this scene.
  118236. * @param toRemove The reflection probe to remove
  118237. * @returns The index of the removed reflection probe
  118238. */
  118239. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118240. /**
  118241. * Adds the given reflection probe to this scene.
  118242. * @param newReflectionProbe The reflection probe to add
  118243. */
  118244. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118245. }
  118246. /**
  118247. * Class used to generate realtime reflection / refraction cube textures
  118248. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118249. */
  118250. export class ReflectionProbe {
  118251. /** defines the name of the probe */
  118252. name: string;
  118253. private _scene;
  118254. private _renderTargetTexture;
  118255. private _projectionMatrix;
  118256. private _viewMatrix;
  118257. private _target;
  118258. private _add;
  118259. private _attachedMesh;
  118260. private _invertYAxis;
  118261. /** Gets or sets probe position (center of the cube map) */
  118262. position: Vector3;
  118263. /**
  118264. * Creates a new reflection probe
  118265. * @param name defines the name of the probe
  118266. * @param size defines the texture resolution (for each face)
  118267. * @param scene defines the hosting scene
  118268. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118269. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118270. */
  118271. constructor(
  118272. /** defines the name of the probe */
  118273. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118274. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118275. samples: number;
  118276. /** Gets or sets the refresh rate to use (on every frame by default) */
  118277. refreshRate: number;
  118278. /**
  118279. * Gets the hosting scene
  118280. * @returns a Scene
  118281. */
  118282. getScene(): Scene;
  118283. /** Gets the internal CubeTexture used to render to */
  118284. readonly cubeTexture: RenderTargetTexture;
  118285. /** Gets the list of meshes to render */
  118286. readonly renderList: Nullable<AbstractMesh[]>;
  118287. /**
  118288. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118289. * @param mesh defines the mesh to attach to
  118290. */
  118291. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118292. /**
  118293. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118294. * @param renderingGroupId The rendering group id corresponding to its index
  118295. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118296. */
  118297. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118298. /**
  118299. * Clean all associated resources
  118300. */
  118301. dispose(): void;
  118302. /**
  118303. * Converts the reflection probe information to a readable string for debug purpose.
  118304. * @param fullDetails Supports for multiple levels of logging within scene loading
  118305. * @returns the human readable reflection probe info
  118306. */
  118307. toString(fullDetails?: boolean): string;
  118308. /**
  118309. * Get the class name of the relfection probe.
  118310. * @returns "ReflectionProbe"
  118311. */
  118312. getClassName(): string;
  118313. /**
  118314. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118315. * @returns The JSON representation of the texture
  118316. */
  118317. serialize(): any;
  118318. /**
  118319. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118320. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118321. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118322. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118323. * @returns The parsed reflection probe if successful
  118324. */
  118325. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118326. }
  118327. }
  118328. declare module BABYLON {
  118329. /** @hidden */
  118330. export var _BabylonLoaderRegistered: boolean;
  118331. }
  118332. declare module BABYLON {
  118333. /**
  118334. * The Physically based simple base material of BJS.
  118335. *
  118336. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118337. * It is used as the base class for both the specGloss and metalRough conventions.
  118338. */
  118339. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118340. /**
  118341. * Number of Simultaneous lights allowed on the material.
  118342. */
  118343. maxSimultaneousLights: number;
  118344. /**
  118345. * If sets to true, disables all the lights affecting the material.
  118346. */
  118347. disableLighting: boolean;
  118348. /**
  118349. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118350. */
  118351. environmentTexture: BaseTexture;
  118352. /**
  118353. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118354. */
  118355. invertNormalMapX: boolean;
  118356. /**
  118357. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118358. */
  118359. invertNormalMapY: boolean;
  118360. /**
  118361. * Normal map used in the model.
  118362. */
  118363. normalTexture: BaseTexture;
  118364. /**
  118365. * Emissivie color used to self-illuminate the model.
  118366. */
  118367. emissiveColor: Color3;
  118368. /**
  118369. * Emissivie texture used to self-illuminate the model.
  118370. */
  118371. emissiveTexture: BaseTexture;
  118372. /**
  118373. * Occlusion Channel Strenght.
  118374. */
  118375. occlusionStrength: number;
  118376. /**
  118377. * Occlusion Texture of the material (adding extra occlusion effects).
  118378. */
  118379. occlusionTexture: BaseTexture;
  118380. /**
  118381. * Defines the alpha limits in alpha test mode.
  118382. */
  118383. alphaCutOff: number;
  118384. /**
  118385. * Gets the current double sided mode.
  118386. */
  118387. /**
  118388. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118389. */
  118390. doubleSided: boolean;
  118391. /**
  118392. * Stores the pre-calculated light information of a mesh in a texture.
  118393. */
  118394. lightmapTexture: BaseTexture;
  118395. /**
  118396. * If true, the light map contains occlusion information instead of lighting info.
  118397. */
  118398. useLightmapAsShadowmap: boolean;
  118399. /**
  118400. * Instantiates a new PBRMaterial instance.
  118401. *
  118402. * @param name The material name
  118403. * @param scene The scene the material will be use in.
  118404. */
  118405. constructor(name: string, scene: Scene);
  118406. getClassName(): string;
  118407. }
  118408. }
  118409. declare module BABYLON {
  118410. /**
  118411. * The PBR material of BJS following the metal roughness convention.
  118412. *
  118413. * This fits to the PBR convention in the GLTF definition:
  118414. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118415. */
  118416. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118417. /**
  118418. * The base color has two different interpretations depending on the value of metalness.
  118419. * When the material is a metal, the base color is the specific measured reflectance value
  118420. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118421. * of the material.
  118422. */
  118423. baseColor: Color3;
  118424. /**
  118425. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118426. * well as opacity information in the alpha channel.
  118427. */
  118428. baseTexture: BaseTexture;
  118429. /**
  118430. * Specifies the metallic scalar value of the material.
  118431. * Can also be used to scale the metalness values of the metallic texture.
  118432. */
  118433. metallic: number;
  118434. /**
  118435. * Specifies the roughness scalar value of the material.
  118436. * Can also be used to scale the roughness values of the metallic texture.
  118437. */
  118438. roughness: number;
  118439. /**
  118440. * Texture containing both the metallic value in the B channel and the
  118441. * roughness value in the G channel to keep better precision.
  118442. */
  118443. metallicRoughnessTexture: BaseTexture;
  118444. /**
  118445. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118446. *
  118447. * @param name The material name
  118448. * @param scene The scene the material will be use in.
  118449. */
  118450. constructor(name: string, scene: Scene);
  118451. /**
  118452. * Return the currrent class name of the material.
  118453. */
  118454. getClassName(): string;
  118455. /**
  118456. * Makes a duplicate of the current material.
  118457. * @param name - name to use for the new material.
  118458. */
  118459. clone(name: string): PBRMetallicRoughnessMaterial;
  118460. /**
  118461. * Serialize the material to a parsable JSON object.
  118462. */
  118463. serialize(): any;
  118464. /**
  118465. * Parses a JSON object correponding to the serialize function.
  118466. */
  118467. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118468. }
  118469. }
  118470. declare module BABYLON {
  118471. /**
  118472. * The PBR material of BJS following the specular glossiness convention.
  118473. *
  118474. * This fits to the PBR convention in the GLTF definition:
  118475. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118476. */
  118477. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118478. /**
  118479. * Specifies the diffuse color of the material.
  118480. */
  118481. diffuseColor: Color3;
  118482. /**
  118483. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118484. * channel.
  118485. */
  118486. diffuseTexture: BaseTexture;
  118487. /**
  118488. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118489. */
  118490. specularColor: Color3;
  118491. /**
  118492. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118493. */
  118494. glossiness: number;
  118495. /**
  118496. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118497. */
  118498. specularGlossinessTexture: BaseTexture;
  118499. /**
  118500. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118501. *
  118502. * @param name The material name
  118503. * @param scene The scene the material will be use in.
  118504. */
  118505. constructor(name: string, scene: Scene);
  118506. /**
  118507. * Return the currrent class name of the material.
  118508. */
  118509. getClassName(): string;
  118510. /**
  118511. * Makes a duplicate of the current material.
  118512. * @param name - name to use for the new material.
  118513. */
  118514. clone(name: string): PBRSpecularGlossinessMaterial;
  118515. /**
  118516. * Serialize the material to a parsable JSON object.
  118517. */
  118518. serialize(): any;
  118519. /**
  118520. * Parses a JSON object correponding to the serialize function.
  118521. */
  118522. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118523. }
  118524. }
  118525. declare module BABYLON {
  118526. /**
  118527. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118528. * It can help converting any input color in a desired output one. This can then be used to create effects
  118529. * from sepia, black and white to sixties or futuristic rendering...
  118530. *
  118531. * The only supported format is currently 3dl.
  118532. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118533. */
  118534. export class ColorGradingTexture extends BaseTexture {
  118535. /**
  118536. * The current texture matrix. (will always be identity in color grading texture)
  118537. */
  118538. private _textureMatrix;
  118539. /**
  118540. * The texture URL.
  118541. */
  118542. url: string;
  118543. /**
  118544. * Empty line regex stored for GC.
  118545. */
  118546. private static _noneEmptyLineRegex;
  118547. private _engine;
  118548. /**
  118549. * Instantiates a ColorGradingTexture from the following parameters.
  118550. *
  118551. * @param url The location of the color gradind data (currently only supporting 3dl)
  118552. * @param scene The scene the texture will be used in
  118553. */
  118554. constructor(url: string, scene: Scene);
  118555. /**
  118556. * Returns the texture matrix used in most of the material.
  118557. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118558. */
  118559. getTextureMatrix(): Matrix;
  118560. /**
  118561. * Occurs when the file being loaded is a .3dl LUT file.
  118562. */
  118563. private load3dlTexture;
  118564. /**
  118565. * Starts the loading process of the texture.
  118566. */
  118567. private loadTexture;
  118568. /**
  118569. * Clones the color gradind texture.
  118570. */
  118571. clone(): ColorGradingTexture;
  118572. /**
  118573. * Called during delayed load for textures.
  118574. */
  118575. delayLoad(): void;
  118576. /**
  118577. * Parses a color grading texture serialized by Babylon.
  118578. * @param parsedTexture The texture information being parsedTexture
  118579. * @param scene The scene to load the texture in
  118580. * @param rootUrl The root url of the data assets to load
  118581. * @return A color gradind texture
  118582. */
  118583. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118584. /**
  118585. * Serializes the LUT texture to json format.
  118586. */
  118587. serialize(): any;
  118588. }
  118589. }
  118590. declare module BABYLON {
  118591. /**
  118592. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118593. */
  118594. export class EquiRectangularCubeTexture extends BaseTexture {
  118595. /** The six faces of the cube. */
  118596. private static _FacesMapping;
  118597. private _noMipmap;
  118598. private _onLoad;
  118599. private _onError;
  118600. /** The size of the cubemap. */
  118601. private _size;
  118602. /** The buffer of the image. */
  118603. private _buffer;
  118604. /** The width of the input image. */
  118605. private _width;
  118606. /** The height of the input image. */
  118607. private _height;
  118608. /** The URL to the image. */
  118609. url: string;
  118610. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118611. coordinatesMode: number;
  118612. /**
  118613. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118614. * @param url The location of the image
  118615. * @param scene The scene the texture will be used in
  118616. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118617. * @param noMipmap Forces to not generate the mipmap if true
  118618. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118619. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118620. * @param onLoad — defines a callback called when texture is loaded
  118621. * @param onError — defines a callback called if there is an error
  118622. */
  118623. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118624. /**
  118625. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118626. */
  118627. private loadImage;
  118628. /**
  118629. * Convert the image buffer into a cubemap and create a CubeTexture.
  118630. */
  118631. private loadTexture;
  118632. /**
  118633. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118634. * @param buffer The ArrayBuffer that should be converted.
  118635. * @returns The buffer as Float32Array.
  118636. */
  118637. private getFloat32ArrayFromArrayBuffer;
  118638. /**
  118639. * Get the current class name of the texture useful for serialization or dynamic coding.
  118640. * @returns "EquiRectangularCubeTexture"
  118641. */
  118642. getClassName(): string;
  118643. /**
  118644. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118645. * @returns A clone of the current EquiRectangularCubeTexture.
  118646. */
  118647. clone(): EquiRectangularCubeTexture;
  118648. }
  118649. }
  118650. declare module BABYLON {
  118651. /**
  118652. * Based on jsTGALoader - Javascript loader for TGA file
  118653. * By Vincent Thibault
  118654. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118655. */
  118656. export class TGATools {
  118657. private static _TYPE_INDEXED;
  118658. private static _TYPE_RGB;
  118659. private static _TYPE_GREY;
  118660. private static _TYPE_RLE_INDEXED;
  118661. private static _TYPE_RLE_RGB;
  118662. private static _TYPE_RLE_GREY;
  118663. private static _ORIGIN_MASK;
  118664. private static _ORIGIN_SHIFT;
  118665. private static _ORIGIN_BL;
  118666. private static _ORIGIN_BR;
  118667. private static _ORIGIN_UL;
  118668. private static _ORIGIN_UR;
  118669. /**
  118670. * Gets the header of a TGA file
  118671. * @param data defines the TGA data
  118672. * @returns the header
  118673. */
  118674. static GetTGAHeader(data: Uint8Array): any;
  118675. /**
  118676. * Uploads TGA content to a Babylon Texture
  118677. * @hidden
  118678. */
  118679. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118680. /** @hidden */
  118681. 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;
  118682. /** @hidden */
  118683. 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;
  118684. /** @hidden */
  118685. 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;
  118686. /** @hidden */
  118687. 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;
  118688. /** @hidden */
  118689. 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;
  118690. /** @hidden */
  118691. 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;
  118692. }
  118693. }
  118694. declare module BABYLON {
  118695. /**
  118696. * Implementation of the TGA Texture Loader.
  118697. * @hidden
  118698. */
  118699. export class _TGATextureLoader implements IInternalTextureLoader {
  118700. /**
  118701. * Defines wether the loader supports cascade loading the different faces.
  118702. */
  118703. readonly supportCascades: boolean;
  118704. /**
  118705. * This returns if the loader support the current file information.
  118706. * @param extension defines the file extension of the file being loaded
  118707. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118708. * @param fallback defines the fallback internal texture if any
  118709. * @param isBase64 defines whether the texture is encoded as a base64
  118710. * @param isBuffer defines whether the texture data are stored as a buffer
  118711. * @returns true if the loader can load the specified file
  118712. */
  118713. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118714. /**
  118715. * Transform the url before loading if required.
  118716. * @param rootUrl the url of the texture
  118717. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118718. * @returns the transformed texture
  118719. */
  118720. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118721. /**
  118722. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118723. * @param rootUrl the url of the texture
  118724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118725. * @returns the fallback texture
  118726. */
  118727. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118728. /**
  118729. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118730. * @param data contains the texture data
  118731. * @param texture defines the BabylonJS internal texture
  118732. * @param createPolynomials will be true if polynomials have been requested
  118733. * @param onLoad defines the callback to trigger once the texture is ready
  118734. * @param onError defines the callback to trigger in case of error
  118735. */
  118736. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118737. /**
  118738. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118739. * @param data contains the texture data
  118740. * @param texture defines the BabylonJS internal texture
  118741. * @param callback defines the method to call once ready to upload
  118742. */
  118743. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118744. }
  118745. }
  118746. declare module BABYLON {
  118747. /**
  118748. * Info about the .basis files
  118749. */
  118750. class BasisFileInfo {
  118751. /**
  118752. * If the file has alpha
  118753. */
  118754. hasAlpha: boolean;
  118755. /**
  118756. * Info about each image of the basis file
  118757. */
  118758. images: Array<{
  118759. levels: Array<{
  118760. width: number;
  118761. height: number;
  118762. transcodedPixels: ArrayBufferView;
  118763. }>;
  118764. }>;
  118765. }
  118766. /**
  118767. * Result of transcoding a basis file
  118768. */
  118769. class TranscodeResult {
  118770. /**
  118771. * Info about the .basis file
  118772. */
  118773. fileInfo: BasisFileInfo;
  118774. /**
  118775. * Format to use when loading the file
  118776. */
  118777. format: number;
  118778. }
  118779. /**
  118780. * Configuration options for the Basis transcoder
  118781. */
  118782. export class BasisTranscodeConfiguration {
  118783. /**
  118784. * Supported compression formats used to determine the supported output format of the transcoder
  118785. */
  118786. supportedCompressionFormats?: {
  118787. /**
  118788. * etc1 compression format
  118789. */
  118790. etc1?: boolean;
  118791. /**
  118792. * s3tc compression format
  118793. */
  118794. s3tc?: boolean;
  118795. /**
  118796. * pvrtc compression format
  118797. */
  118798. pvrtc?: boolean;
  118799. /**
  118800. * etc2 compression format
  118801. */
  118802. etc2?: boolean;
  118803. };
  118804. /**
  118805. * If mipmap levels should be loaded for transcoded images (Default: true)
  118806. */
  118807. loadMipmapLevels?: boolean;
  118808. /**
  118809. * Index of a single image to load (Default: all images)
  118810. */
  118811. loadSingleImage?: number;
  118812. }
  118813. /**
  118814. * Used to load .Basis files
  118815. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118816. */
  118817. export class BasisTools {
  118818. private static _IgnoreSupportedFormats;
  118819. /**
  118820. * URL to use when loading the basis transcoder
  118821. */
  118822. static JSModuleURL: string;
  118823. /**
  118824. * URL to use when loading the wasm module for the transcoder
  118825. */
  118826. static WasmModuleURL: string;
  118827. /**
  118828. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118829. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118830. * @returns internal format corresponding to the Basis format
  118831. */
  118832. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118833. private static _WorkerPromise;
  118834. private static _Worker;
  118835. private static _actionId;
  118836. private static _CreateWorkerAsync;
  118837. /**
  118838. * Transcodes a loaded image file to compressed pixel data
  118839. * @param imageData image data to transcode
  118840. * @param config configuration options for the transcoding
  118841. * @returns a promise resulting in the transcoded image
  118842. */
  118843. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118844. /**
  118845. * Loads a texture from the transcode result
  118846. * @param texture texture load to
  118847. * @param transcodeResult the result of transcoding the basis file to load from
  118848. */
  118849. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  118850. }
  118851. }
  118852. declare module BABYLON {
  118853. /**
  118854. * Loader for .basis file format
  118855. */
  118856. export class _BasisTextureLoader implements IInternalTextureLoader {
  118857. /**
  118858. * Defines whether the loader supports cascade loading the different faces.
  118859. */
  118860. readonly supportCascades: boolean;
  118861. /**
  118862. * This returns if the loader support the current file information.
  118863. * @param extension defines the file extension of the file being loaded
  118864. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118865. * @param fallback defines the fallback internal texture if any
  118866. * @param isBase64 defines whether the texture is encoded as a base64
  118867. * @param isBuffer defines whether the texture data are stored as a buffer
  118868. * @returns true if the loader can load the specified file
  118869. */
  118870. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118871. /**
  118872. * Transform the url before loading if required.
  118873. * @param rootUrl the url of the texture
  118874. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118875. * @returns the transformed texture
  118876. */
  118877. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118878. /**
  118879. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118880. * @param rootUrl the url of the texture
  118881. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118882. * @returns the fallback texture
  118883. */
  118884. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118885. /**
  118886. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  118887. * @param data contains the texture data
  118888. * @param texture defines the BabylonJS internal texture
  118889. * @param createPolynomials will be true if polynomials have been requested
  118890. * @param onLoad defines the callback to trigger once the texture is ready
  118891. * @param onError defines the callback to trigger in case of error
  118892. */
  118893. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118894. /**
  118895. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118896. * @param data contains the texture data
  118897. * @param texture defines the BabylonJS internal texture
  118898. * @param callback defines the method to call once ready to upload
  118899. */
  118900. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118901. }
  118902. }
  118903. declare module BABYLON {
  118904. /**
  118905. * 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.
  118906. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118907. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118908. */
  118909. export class CustomProceduralTexture extends ProceduralTexture {
  118910. private _animate;
  118911. private _time;
  118912. private _config;
  118913. private _texturePath;
  118914. /**
  118915. * Instantiates a new Custom Procedural Texture.
  118916. * 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.
  118917. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  118918. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  118919. * @param name Define the name of the texture
  118920. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  118921. * @param size Define the size of the texture to create
  118922. * @param scene Define the scene the texture belongs to
  118923. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  118924. * @param generateMipMaps Define if the texture should creates mip maps or not
  118925. */
  118926. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118927. private _loadJson;
  118928. /**
  118929. * Is the texture ready to be used ? (rendered at least once)
  118930. * @returns true if ready, otherwise, false.
  118931. */
  118932. isReady(): boolean;
  118933. /**
  118934. * Render the texture to its associated render target.
  118935. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  118936. */
  118937. render(useCameraPostProcess?: boolean): void;
  118938. /**
  118939. * Update the list of dependant textures samplers in the shader.
  118940. */
  118941. updateTextures(): void;
  118942. /**
  118943. * Update the uniform values of the procedural texture in the shader.
  118944. */
  118945. updateShaderUniforms(): void;
  118946. /**
  118947. * Define if the texture animates or not.
  118948. */
  118949. animate: boolean;
  118950. }
  118951. }
  118952. declare module BABYLON {
  118953. /** @hidden */
  118954. export var noisePixelShader: {
  118955. name: string;
  118956. shader: string;
  118957. };
  118958. }
  118959. declare module BABYLON {
  118960. /**
  118961. * Class used to generate noise procedural textures
  118962. */
  118963. export class NoiseProceduralTexture extends ProceduralTexture {
  118964. private _time;
  118965. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  118966. brightness: number;
  118967. /** Defines the number of octaves to process */
  118968. octaves: number;
  118969. /** Defines the level of persistence (0.8 by default) */
  118970. persistence: number;
  118971. /** Gets or sets animation speed factor (default is 1) */
  118972. animationSpeedFactor: number;
  118973. /**
  118974. * Creates a new NoiseProceduralTexture
  118975. * @param name defines the name fo the texture
  118976. * @param size defines the size of the texture (default is 256)
  118977. * @param scene defines the hosting scene
  118978. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  118979. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  118980. */
  118981. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  118982. private _updateShaderUniforms;
  118983. protected _getDefines(): string;
  118984. /** Generate the current state of the procedural texture */
  118985. render(useCameraPostProcess?: boolean): void;
  118986. /**
  118987. * Serializes this noise procedural texture
  118988. * @returns a serialized noise procedural texture object
  118989. */
  118990. serialize(): any;
  118991. /**
  118992. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  118993. * @param parsedTexture defines parsed texture data
  118994. * @param scene defines the current scene
  118995. * @param rootUrl defines the root URL containing noise procedural texture information
  118996. * @returns a parsed NoiseProceduralTexture
  118997. */
  118998. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  118999. }
  119000. }
  119001. declare module BABYLON {
  119002. /**
  119003. * Raw cube texture where the raw buffers are passed in
  119004. */
  119005. export class RawCubeTexture extends CubeTexture {
  119006. /**
  119007. * Creates a cube texture where the raw buffers are passed in.
  119008. * @param scene defines the scene the texture is attached to
  119009. * @param data defines the array of data to use to create each face
  119010. * @param size defines the size of the textures
  119011. * @param format defines the format of the data
  119012. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119013. * @param generateMipMaps defines if the engine should generate the mip levels
  119014. * @param invertY defines if data must be stored with Y axis inverted
  119015. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119016. * @param compression defines the compression used (null by default)
  119017. */
  119018. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119019. /**
  119020. * Updates the raw cube texture.
  119021. * @param data defines the data to store
  119022. * @param format defines the data format
  119023. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119024. * @param invertY defines if data must be stored with Y axis inverted
  119025. * @param compression defines the compression used (null by default)
  119026. * @param level defines which level of the texture to update
  119027. */
  119028. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119029. /**
  119030. * Updates a raw cube texture with RGBD encoded data.
  119031. * @param data defines the array of data [mipmap][face] to use to create each face
  119032. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119033. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119034. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119035. * @returns a promsie that resolves when the operation is complete
  119036. */
  119037. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119038. /**
  119039. * Clones the raw cube texture.
  119040. * @return a new cube texture
  119041. */
  119042. clone(): CubeTexture;
  119043. /** @hidden */
  119044. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119045. }
  119046. }
  119047. declare module BABYLON {
  119048. /**
  119049. * Class used to store 3D textures containing user data
  119050. */
  119051. export class RawTexture3D extends Texture {
  119052. /** Gets or sets the texture format to use */
  119053. format: number;
  119054. private _engine;
  119055. /**
  119056. * Create a new RawTexture3D
  119057. * @param data defines the data of the texture
  119058. * @param width defines the width of the texture
  119059. * @param height defines the height of the texture
  119060. * @param depth defines the depth of the texture
  119061. * @param format defines the texture format to use
  119062. * @param scene defines the hosting scene
  119063. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119064. * @param invertY defines if texture must be stored with Y axis inverted
  119065. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119066. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119067. */
  119068. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119069. /** Gets or sets the texture format to use */
  119070. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119071. /**
  119072. * Update the texture with new data
  119073. * @param data defines the data to store in the texture
  119074. */
  119075. update(data: ArrayBufferView): void;
  119076. }
  119077. }
  119078. declare module BABYLON {
  119079. /**
  119080. * Creates a refraction texture used by refraction channel of the standard material.
  119081. * It is like a mirror but to see through a material.
  119082. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119083. */
  119084. export class RefractionTexture extends RenderTargetTexture {
  119085. /**
  119086. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119087. * 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.
  119088. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119089. */
  119090. refractionPlane: Plane;
  119091. /**
  119092. * Define how deep under the surface we should see.
  119093. */
  119094. depth: number;
  119095. /**
  119096. * Creates a refraction texture used by refraction channel of the standard material.
  119097. * It is like a mirror but to see through a material.
  119098. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119099. * @param name Define the texture name
  119100. * @param size Define the size of the underlying texture
  119101. * @param scene Define the scene the refraction belongs to
  119102. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119103. */
  119104. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119105. /**
  119106. * Clone the refraction texture.
  119107. * @returns the cloned texture
  119108. */
  119109. clone(): RefractionTexture;
  119110. /**
  119111. * Serialize the texture to a JSON representation you could use in Parse later on
  119112. * @returns the serialized JSON representation
  119113. */
  119114. serialize(): any;
  119115. }
  119116. }
  119117. declare module BABYLON {
  119118. /**
  119119. * Defines the options related to the creation of an HtmlElementTexture
  119120. */
  119121. export interface IHtmlElementTextureOptions {
  119122. /**
  119123. * Defines wether mip maps should be created or not.
  119124. */
  119125. generateMipMaps?: boolean;
  119126. /**
  119127. * Defines the sampling mode of the texture.
  119128. */
  119129. samplingMode?: number;
  119130. /**
  119131. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119132. */
  119133. engine: Nullable<Engine>;
  119134. /**
  119135. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119136. */
  119137. scene: Nullable<Scene>;
  119138. }
  119139. /**
  119140. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119141. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119142. * is automatically managed.
  119143. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119144. * in your application.
  119145. *
  119146. * As the update is not automatic, you need to call them manually.
  119147. */
  119148. export class HtmlElementTexture extends BaseTexture {
  119149. /**
  119150. * The texture URL.
  119151. */
  119152. element: HTMLVideoElement | HTMLCanvasElement;
  119153. private static readonly DefaultOptions;
  119154. private _textureMatrix;
  119155. private _engine;
  119156. private _isVideo;
  119157. private _generateMipMaps;
  119158. private _samplingMode;
  119159. /**
  119160. * Instantiates a HtmlElementTexture from the following parameters.
  119161. *
  119162. * @param name Defines the name of the texture
  119163. * @param element Defines the video or canvas the texture is filled with
  119164. * @param options Defines the other none mandatory texture creation options
  119165. */
  119166. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119167. private _createInternalTexture;
  119168. /**
  119169. * Returns the texture matrix used in most of the material.
  119170. */
  119171. getTextureMatrix(): Matrix;
  119172. /**
  119173. * Updates the content of the texture.
  119174. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119175. */
  119176. update(invertY?: Nullable<boolean>): void;
  119177. }
  119178. }
  119179. declare module BABYLON {
  119180. /**
  119181. * Enum used to define the target of a block
  119182. */
  119183. export enum NodeMaterialBlockTargets {
  119184. /** Vertex shader */
  119185. Vertex = 1,
  119186. /** Fragment shader */
  119187. Fragment = 2,
  119188. /** Neutral */
  119189. Neutral = 4,
  119190. /** Vertex and Fragment */
  119191. VertexAndFragment = 3
  119192. }
  119193. }
  119194. declare module BABYLON {
  119195. /**
  119196. * Defines the kind of connection point for node based material
  119197. */
  119198. export enum NodeMaterialBlockConnectionPointTypes {
  119199. /** Float */
  119200. Float = 1,
  119201. /** Int */
  119202. Int = 2,
  119203. /** Vector2 */
  119204. Vector2 = 4,
  119205. /** Vector3 */
  119206. Vector3 = 8,
  119207. /** Vector4 */
  119208. Vector4 = 16,
  119209. /** Color3 */
  119210. Color3 = 32,
  119211. /** Color4 */
  119212. Color4 = 64,
  119213. /** Matrix */
  119214. Matrix = 128,
  119215. /** Detect type based on connection */
  119216. AutoDetect = 1024,
  119217. /** Output type that will be defined by input type */
  119218. BasedOnInput = 2048
  119219. }
  119220. }
  119221. declare module BABYLON {
  119222. /**
  119223. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119224. */
  119225. export enum NodeMaterialBlockConnectionPointMode {
  119226. /** Value is an uniform */
  119227. Uniform = 0,
  119228. /** Value is a mesh attribute */
  119229. Attribute = 1,
  119230. /** Value is a varying between vertex and fragment shaders */
  119231. Varying = 2,
  119232. /** Mode is undefined */
  119233. Undefined = 3
  119234. }
  119235. }
  119236. declare module BABYLON {
  119237. /**
  119238. * Enum used to define system values e.g. values automatically provided by the system
  119239. */
  119240. export enum NodeMaterialSystemValues {
  119241. /** World */
  119242. World = 1,
  119243. /** View */
  119244. View = 2,
  119245. /** Projection */
  119246. Projection = 3,
  119247. /** ViewProjection */
  119248. ViewProjection = 4,
  119249. /** WorldView */
  119250. WorldView = 5,
  119251. /** WorldViewProjection */
  119252. WorldViewProjection = 6,
  119253. /** CameraPosition */
  119254. CameraPosition = 7,
  119255. /** Fog Color */
  119256. FogColor = 8,
  119257. /** Delta time */
  119258. DeltaTime = 9
  119259. }
  119260. }
  119261. declare module BABYLON {
  119262. /**
  119263. * Root class for all node material optimizers
  119264. */
  119265. export class NodeMaterialOptimizer {
  119266. /**
  119267. * Function used to optimize a NodeMaterial graph
  119268. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119269. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119270. */
  119271. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119272. }
  119273. }
  119274. declare module BABYLON {
  119275. /**
  119276. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119277. */
  119278. export class TransformBlock extends NodeMaterialBlock {
  119279. /**
  119280. * Defines the value to use to complement W value to transform it to a Vector4
  119281. */
  119282. complementW: number;
  119283. /**
  119284. * Defines the value to use to complement z value to transform it to a Vector4
  119285. */
  119286. complementZ: number;
  119287. /**
  119288. * Creates a new TransformBlock
  119289. * @param name defines the block name
  119290. */
  119291. constructor(name: string);
  119292. /**
  119293. * Gets the current class name
  119294. * @returns the class name
  119295. */
  119296. getClassName(): string;
  119297. /**
  119298. * Gets the vector input
  119299. */
  119300. readonly vector: NodeMaterialConnectionPoint;
  119301. /**
  119302. * Gets the output component
  119303. */
  119304. readonly output: NodeMaterialConnectionPoint;
  119305. /**
  119306. * Gets the matrix transform input
  119307. */
  119308. readonly transform: NodeMaterialConnectionPoint;
  119309. protected _buildBlock(state: NodeMaterialBuildState): this;
  119310. serialize(): any;
  119311. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119312. protected _dumpPropertiesCode(): string;
  119313. }
  119314. }
  119315. declare module BABYLON {
  119316. /**
  119317. * Block used to output the vertex position
  119318. */
  119319. export class VertexOutputBlock extends NodeMaterialBlock {
  119320. /**
  119321. * Creates a new VertexOutputBlock
  119322. * @param name defines the block name
  119323. */
  119324. constructor(name: string);
  119325. /**
  119326. * Gets the current class name
  119327. * @returns the class name
  119328. */
  119329. getClassName(): string;
  119330. /**
  119331. * Gets the vector input component
  119332. */
  119333. readonly vector: NodeMaterialConnectionPoint;
  119334. protected _buildBlock(state: NodeMaterialBuildState): this;
  119335. }
  119336. }
  119337. declare module BABYLON {
  119338. /**
  119339. * Block used to output the final color
  119340. */
  119341. export class FragmentOutputBlock extends NodeMaterialBlock {
  119342. /**
  119343. * Create a new FragmentOutputBlock
  119344. * @param name defines the block name
  119345. */
  119346. constructor(name: string);
  119347. /**
  119348. * Gets the current class name
  119349. * @returns the class name
  119350. */
  119351. getClassName(): string;
  119352. /**
  119353. * Gets the rgba input component
  119354. */
  119355. readonly rgba: NodeMaterialConnectionPoint;
  119356. /**
  119357. * Gets the rgb input component
  119358. */
  119359. readonly rgb: NodeMaterialConnectionPoint;
  119360. /**
  119361. * Gets the a input component
  119362. */
  119363. readonly a: NodeMaterialConnectionPoint;
  119364. protected _buildBlock(state: NodeMaterialBuildState): this;
  119365. }
  119366. }
  119367. declare module BABYLON {
  119368. /**
  119369. * Block used to read a reflection texture from a sampler
  119370. */
  119371. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119372. private _define3DName;
  119373. private _defineCubicName;
  119374. private _defineExplicitName;
  119375. private _defineProjectionName;
  119376. private _defineLocalCubicName;
  119377. private _defineSphericalName;
  119378. private _definePlanarName;
  119379. private _defineEquirectangularName;
  119380. private _defineMirroredEquirectangularFixedName;
  119381. private _defineEquirectangularFixedName;
  119382. private _defineSkyboxName;
  119383. private _cubeSamplerName;
  119384. private _2DSamplerName;
  119385. private _positionUVWName;
  119386. private _directionWName;
  119387. private _reflectionCoordsName;
  119388. private _reflection2DCoordsName;
  119389. private _reflectionColorName;
  119390. private _reflectionMatrixName;
  119391. /**
  119392. * Gets or sets the texture associated with the node
  119393. */
  119394. texture: Nullable<BaseTexture>;
  119395. /**
  119396. * Create a new TextureBlock
  119397. * @param name defines the block name
  119398. */
  119399. constructor(name: string);
  119400. /**
  119401. * Gets the current class name
  119402. * @returns the class name
  119403. */
  119404. getClassName(): string;
  119405. /**
  119406. * Gets the world position input component
  119407. */
  119408. readonly position: NodeMaterialConnectionPoint;
  119409. /**
  119410. * Gets the world position input component
  119411. */
  119412. readonly worldPosition: NodeMaterialConnectionPoint;
  119413. /**
  119414. * Gets the world normal input component
  119415. */
  119416. readonly worldNormal: NodeMaterialConnectionPoint;
  119417. /**
  119418. * Gets the world input component
  119419. */
  119420. readonly world: NodeMaterialConnectionPoint;
  119421. /**
  119422. * Gets the camera (or eye) position component
  119423. */
  119424. readonly cameraPosition: NodeMaterialConnectionPoint;
  119425. /**
  119426. * Gets the view input component
  119427. */
  119428. readonly view: NodeMaterialConnectionPoint;
  119429. /**
  119430. * Gets the rgb output component
  119431. */
  119432. readonly rgb: NodeMaterialConnectionPoint;
  119433. /**
  119434. * Gets the r output component
  119435. */
  119436. readonly r: NodeMaterialConnectionPoint;
  119437. /**
  119438. * Gets the g output component
  119439. */
  119440. readonly g: NodeMaterialConnectionPoint;
  119441. /**
  119442. * Gets the b output component
  119443. */
  119444. readonly b: NodeMaterialConnectionPoint;
  119445. autoConfigure(material: NodeMaterial): void;
  119446. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119447. isReady(): boolean;
  119448. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119449. private _injectVertexCode;
  119450. private _writeOutput;
  119451. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119452. serialize(): any;
  119453. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119454. }
  119455. }
  119456. declare module BABYLON {
  119457. /**
  119458. * Interface used to configure the node material editor
  119459. */
  119460. export interface INodeMaterialEditorOptions {
  119461. /** Define the URl to load node editor script */
  119462. editorURL?: string;
  119463. }
  119464. /** @hidden */
  119465. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119466. /** BONES */
  119467. NUM_BONE_INFLUENCERS: number;
  119468. BonesPerMesh: number;
  119469. BONETEXTURE: boolean;
  119470. /** MORPH TARGETS */
  119471. MORPHTARGETS: boolean;
  119472. MORPHTARGETS_NORMAL: boolean;
  119473. MORPHTARGETS_TANGENT: boolean;
  119474. MORPHTARGETS_UV: boolean;
  119475. NUM_MORPH_INFLUENCERS: number;
  119476. /** IMAGE PROCESSING */
  119477. IMAGEPROCESSING: boolean;
  119478. VIGNETTE: boolean;
  119479. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119480. VIGNETTEBLENDMODEOPAQUE: boolean;
  119481. TONEMAPPING: boolean;
  119482. TONEMAPPING_ACES: boolean;
  119483. CONTRAST: boolean;
  119484. EXPOSURE: boolean;
  119485. COLORCURVES: boolean;
  119486. COLORGRADING: boolean;
  119487. COLORGRADING3D: boolean;
  119488. SAMPLER3DGREENDEPTH: boolean;
  119489. SAMPLER3DBGRMAP: boolean;
  119490. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119491. /** MISC. */
  119492. BUMPDIRECTUV: number;
  119493. constructor();
  119494. setValue(name: string, value: boolean): void;
  119495. }
  119496. /**
  119497. * Class used to configure NodeMaterial
  119498. */
  119499. export interface INodeMaterialOptions {
  119500. /**
  119501. * Defines if blocks should emit comments
  119502. */
  119503. emitComments: boolean;
  119504. }
  119505. /**
  119506. * Class used to create a node based material built by assembling shader blocks
  119507. */
  119508. export class NodeMaterial extends PushMaterial {
  119509. private static _BuildIdGenerator;
  119510. private _options;
  119511. private _vertexCompilationState;
  119512. private _fragmentCompilationState;
  119513. private _sharedData;
  119514. private _buildId;
  119515. private _buildWasSuccessful;
  119516. private _cachedWorldViewMatrix;
  119517. private _cachedWorldViewProjectionMatrix;
  119518. private _optimizers;
  119519. private _animationFrame;
  119520. /** Define the URl to load node editor script */
  119521. static EditorURL: string;
  119522. private BJSNODEMATERIALEDITOR;
  119523. /** Get the inspector from bundle or global */
  119524. private _getGlobalNodeMaterialEditor;
  119525. /**
  119526. * 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)
  119527. */
  119528. ignoreAlpha: boolean;
  119529. /**
  119530. * Defines the maximum number of lights that can be used in the material
  119531. */
  119532. maxSimultaneousLights: number;
  119533. /**
  119534. * Observable raised when the material is built
  119535. */
  119536. onBuildObservable: Observable<NodeMaterial>;
  119537. /**
  119538. * Gets or sets the root nodes of the material vertex shader
  119539. */
  119540. _vertexOutputNodes: NodeMaterialBlock[];
  119541. /**
  119542. * Gets or sets the root nodes of the material fragment (pixel) shader
  119543. */
  119544. _fragmentOutputNodes: NodeMaterialBlock[];
  119545. /** Gets or sets options to control the node material overall behavior */
  119546. options: INodeMaterialOptions;
  119547. /**
  119548. * Default configuration related to image processing available in the standard Material.
  119549. */
  119550. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119551. /**
  119552. * Gets the image processing configuration used either in this material.
  119553. */
  119554. /**
  119555. * Sets the Default image processing configuration used either in the this material.
  119556. *
  119557. * If sets to null, the scene one is in use.
  119558. */
  119559. imageProcessingConfiguration: ImageProcessingConfiguration;
  119560. /**
  119561. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119562. */
  119563. attachedBlocks: NodeMaterialBlock[];
  119564. /**
  119565. * Create a new node based material
  119566. * @param name defines the material name
  119567. * @param scene defines the hosting scene
  119568. * @param options defines creation option
  119569. */
  119570. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119571. /**
  119572. * Gets the current class name of the material e.g. "NodeMaterial"
  119573. * @returns the class name
  119574. */
  119575. getClassName(): string;
  119576. /**
  119577. * Keep track of the image processing observer to allow dispose and replace.
  119578. */
  119579. private _imageProcessingObserver;
  119580. /**
  119581. * Attaches a new image processing configuration to the Standard Material.
  119582. * @param configuration
  119583. */
  119584. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119585. /**
  119586. * Get a block by its name
  119587. * @param name defines the name of the block to retrieve
  119588. * @returns the required block or null if not found
  119589. */
  119590. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119591. /**
  119592. * Get a block by its name
  119593. * @param predicate defines the predicate used to find the good candidate
  119594. * @returns the required block or null if not found
  119595. */
  119596. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119597. /**
  119598. * Get an input block by its name
  119599. * @param predicate defines the predicate used to find the good candidate
  119600. * @returns the required input block or null if not found
  119601. */
  119602. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119603. /**
  119604. * Gets the list of input blocks attached to this material
  119605. * @returns an array of InputBlocks
  119606. */
  119607. getInputBlocks(): InputBlock[];
  119608. /**
  119609. * Adds a new optimizer to the list of optimizers
  119610. * @param optimizer defines the optimizers to add
  119611. * @returns the current material
  119612. */
  119613. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119614. /**
  119615. * Remove an optimizer from the list of optimizers
  119616. * @param optimizer defines the optimizers to remove
  119617. * @returns the current material
  119618. */
  119619. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119620. /**
  119621. * Add a new block to the list of output nodes
  119622. * @param node defines the node to add
  119623. * @returns the current material
  119624. */
  119625. addOutputNode(node: NodeMaterialBlock): this;
  119626. /**
  119627. * Remove a block from the list of root nodes
  119628. * @param node defines the node to remove
  119629. * @returns the current material
  119630. */
  119631. removeOutputNode(node: NodeMaterialBlock): this;
  119632. private _addVertexOutputNode;
  119633. private _removeVertexOutputNode;
  119634. private _addFragmentOutputNode;
  119635. private _removeFragmentOutputNode;
  119636. /**
  119637. * Specifies if the material will require alpha blending
  119638. * @returns a boolean specifying if alpha blending is needed
  119639. */
  119640. needAlphaBlending(): boolean;
  119641. /**
  119642. * Specifies if this material should be rendered in alpha test mode
  119643. * @returns a boolean specifying if an alpha test is needed.
  119644. */
  119645. needAlphaTesting(): boolean;
  119646. private _initializeBlock;
  119647. private _resetDualBlocks;
  119648. /**
  119649. * Build the material and generates the inner effect
  119650. * @param verbose defines if the build should log activity
  119651. */
  119652. build(verbose?: boolean): void;
  119653. /**
  119654. * Runs an otpimization phase to try to improve the shader code
  119655. */
  119656. optimize(): void;
  119657. private _prepareDefinesForAttributes;
  119658. /**
  119659. * Get if the submesh is ready to be used and all its information available.
  119660. * Child classes can use it to update shaders
  119661. * @param mesh defines the mesh to check
  119662. * @param subMesh defines which submesh to check
  119663. * @param useInstances specifies that instances should be used
  119664. * @returns a boolean indicating that the submesh is ready or not
  119665. */
  119666. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119667. /**
  119668. * Get a string representing the shaders built by the current node graph
  119669. */
  119670. readonly compiledShaders: string;
  119671. /**
  119672. * Binds the world matrix to the material
  119673. * @param world defines the world transformation matrix
  119674. */
  119675. bindOnlyWorldMatrix(world: Matrix): void;
  119676. /**
  119677. * Binds the submesh to this material by preparing the effect and shader to draw
  119678. * @param world defines the world transformation matrix
  119679. * @param mesh defines the mesh containing the submesh
  119680. * @param subMesh defines the submesh to bind the material to
  119681. */
  119682. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119683. /**
  119684. * Gets the active textures from the material
  119685. * @returns an array of textures
  119686. */
  119687. getActiveTextures(): BaseTexture[];
  119688. /**
  119689. * Gets the list of texture blocks
  119690. * @returns an array of texture blocks
  119691. */
  119692. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119693. /**
  119694. * Specifies if the material uses a texture
  119695. * @param texture defines the texture to check against the material
  119696. * @returns a boolean specifying if the material uses the texture
  119697. */
  119698. hasTexture(texture: BaseTexture): boolean;
  119699. /**
  119700. * Disposes the material
  119701. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119702. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119703. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119704. */
  119705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119706. /** Creates the node editor window. */
  119707. private _createNodeEditor;
  119708. /**
  119709. * Launch the node material editor
  119710. * @param config Define the configuration of the editor
  119711. * @return a promise fulfilled when the node editor is visible
  119712. */
  119713. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119714. /**
  119715. * Clear the current material
  119716. */
  119717. clear(): void;
  119718. /**
  119719. * Clear the current material and set it to a default state
  119720. */
  119721. setToDefault(): void;
  119722. /**
  119723. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119724. * @param url defines the url to load from
  119725. * @returns a promise that will fullfil when the material is fully loaded
  119726. */
  119727. loadAsync(url: string): Promise<unknown>;
  119728. private _gatherBlocks;
  119729. /**
  119730. * Generate a string containing the code declaration required to create an equivalent of this material
  119731. * @returns a string
  119732. */
  119733. generateCode(): string;
  119734. /**
  119735. * Serializes this material in a JSON representation
  119736. * @returns the serialized material object
  119737. */
  119738. serialize(): any;
  119739. private _restoreConnections;
  119740. /**
  119741. * Clear the current graph and load a new one from a serialization object
  119742. * @param source defines the JSON representation of the material
  119743. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119744. */
  119745. loadFromSerialization(source: any, rootUrl?: string): void;
  119746. /**
  119747. * Creates a node material from parsed material data
  119748. * @param source defines the JSON representation of the material
  119749. * @param scene defines the hosting scene
  119750. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119751. * @returns a new node material
  119752. */
  119753. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119754. /**
  119755. * Creates a new node material set to default basic configuration
  119756. * @param name defines the name of the material
  119757. * @param scene defines the hosting scene
  119758. * @returns a new NodeMaterial
  119759. */
  119760. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119761. }
  119762. }
  119763. declare module BABYLON {
  119764. /**
  119765. * Block used to read a texture from a sampler
  119766. */
  119767. export class TextureBlock extends NodeMaterialBlock {
  119768. private _defineName;
  119769. private _linearDefineName;
  119770. private _samplerName;
  119771. private _transformedUVName;
  119772. private _textureTransformName;
  119773. private _textureInfoName;
  119774. private _mainUVName;
  119775. private _mainUVDefineName;
  119776. /**
  119777. * Gets or sets the texture associated with the node
  119778. */
  119779. texture: Nullable<Texture>;
  119780. /**
  119781. * Create a new TextureBlock
  119782. * @param name defines the block name
  119783. */
  119784. constructor(name: string);
  119785. /**
  119786. * Gets the current class name
  119787. * @returns the class name
  119788. */
  119789. getClassName(): string;
  119790. /**
  119791. * Gets the uv input component
  119792. */
  119793. readonly uv: NodeMaterialConnectionPoint;
  119794. /**
  119795. * Gets the rgba output component
  119796. */
  119797. readonly rgba: NodeMaterialConnectionPoint;
  119798. /**
  119799. * Gets the rgb output component
  119800. */
  119801. readonly rgb: NodeMaterialConnectionPoint;
  119802. /**
  119803. * Gets the r output component
  119804. */
  119805. readonly r: NodeMaterialConnectionPoint;
  119806. /**
  119807. * Gets the g output component
  119808. */
  119809. readonly g: NodeMaterialConnectionPoint;
  119810. /**
  119811. * Gets the b output component
  119812. */
  119813. readonly b: NodeMaterialConnectionPoint;
  119814. /**
  119815. * Gets the a output component
  119816. */
  119817. readonly a: NodeMaterialConnectionPoint;
  119818. readonly target: NodeMaterialBlockTargets;
  119819. autoConfigure(material: NodeMaterial): void;
  119820. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119821. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119822. isReady(): boolean;
  119823. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119824. private readonly _isMixed;
  119825. private _injectVertexCode;
  119826. private _writeOutput;
  119827. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119828. protected _dumpPropertiesCode(): string;
  119829. serialize(): any;
  119830. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119831. }
  119832. }
  119833. declare module BABYLON {
  119834. /**
  119835. * Class used to store shared data between 2 NodeMaterialBuildState
  119836. */
  119837. export class NodeMaterialBuildStateSharedData {
  119838. /**
  119839. * Gets the list of emitted varyings
  119840. */
  119841. temps: string[];
  119842. /**
  119843. * Gets the list of emitted varyings
  119844. */
  119845. varyings: string[];
  119846. /**
  119847. * Gets the varying declaration string
  119848. */
  119849. varyingDeclaration: string;
  119850. /**
  119851. * Input blocks
  119852. */
  119853. inputBlocks: InputBlock[];
  119854. /**
  119855. * Input blocks
  119856. */
  119857. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  119858. /**
  119859. * Bindable blocks (Blocks that need to set data to the effect)
  119860. */
  119861. bindableBlocks: NodeMaterialBlock[];
  119862. /**
  119863. * List of blocks that can provide a compilation fallback
  119864. */
  119865. blocksWithFallbacks: NodeMaterialBlock[];
  119866. /**
  119867. * List of blocks that can provide a define update
  119868. */
  119869. blocksWithDefines: NodeMaterialBlock[];
  119870. /**
  119871. * List of blocks that can provide a repeatable content
  119872. */
  119873. repeatableContentBlocks: NodeMaterialBlock[];
  119874. /**
  119875. * List of blocks that can provide a dynamic list of uniforms
  119876. */
  119877. dynamicUniformBlocks: NodeMaterialBlock[];
  119878. /**
  119879. * List of blocks that can block the isReady function for the material
  119880. */
  119881. blockingBlocks: NodeMaterialBlock[];
  119882. /**
  119883. * Gets the list of animated inputs
  119884. */
  119885. animatedInputs: InputBlock[];
  119886. /**
  119887. * Build Id used to avoid multiple recompilations
  119888. */
  119889. buildId: number;
  119890. /** List of emitted variables */
  119891. variableNames: {
  119892. [key: string]: number;
  119893. };
  119894. /** List of emitted defines */
  119895. defineNames: {
  119896. [key: string]: number;
  119897. };
  119898. /** Should emit comments? */
  119899. emitComments: boolean;
  119900. /** Emit build activity */
  119901. verbose: boolean;
  119902. /** Gets or sets the hosting scene */
  119903. scene: Scene;
  119904. /**
  119905. * Gets the compilation hints emitted at compilation time
  119906. */
  119907. hints: {
  119908. needWorldViewMatrix: boolean;
  119909. needWorldViewProjectionMatrix: boolean;
  119910. needAlphaBlending: boolean;
  119911. needAlphaTesting: boolean;
  119912. };
  119913. /**
  119914. * List of compilation checks
  119915. */
  119916. checks: {
  119917. emitVertex: boolean;
  119918. emitFragment: boolean;
  119919. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  119920. };
  119921. /** Creates a new shared data */
  119922. constructor();
  119923. /**
  119924. * Emits console errors and exceptions if there is a failing check
  119925. */
  119926. emitErrors(): void;
  119927. }
  119928. }
  119929. declare module BABYLON {
  119930. /**
  119931. * Class used to store node based material build state
  119932. */
  119933. export class NodeMaterialBuildState {
  119934. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  119935. supportUniformBuffers: boolean;
  119936. /**
  119937. * Gets the list of emitted attributes
  119938. */
  119939. attributes: string[];
  119940. /**
  119941. * Gets the list of emitted uniforms
  119942. */
  119943. uniforms: string[];
  119944. /**
  119945. * Gets the list of emitted constants
  119946. */
  119947. constants: string[];
  119948. /**
  119949. * Gets the list of emitted uniform buffers
  119950. */
  119951. uniformBuffers: string[];
  119952. /**
  119953. * Gets the list of emitted samplers
  119954. */
  119955. samplers: string[];
  119956. /**
  119957. * Gets the list of emitted functions
  119958. */
  119959. functions: {
  119960. [key: string]: string;
  119961. };
  119962. /**
  119963. * Gets the list of emitted extensions
  119964. */
  119965. extensions: {
  119966. [key: string]: string;
  119967. };
  119968. /**
  119969. * Gets the target of the compilation state
  119970. */
  119971. target: NodeMaterialBlockTargets;
  119972. /**
  119973. * Gets the list of emitted counters
  119974. */
  119975. counters: {
  119976. [key: string]: number;
  119977. };
  119978. /**
  119979. * Shared data between multiple NodeMaterialBuildState instances
  119980. */
  119981. sharedData: NodeMaterialBuildStateSharedData;
  119982. /** @hidden */
  119983. _vertexState: NodeMaterialBuildState;
  119984. /** @hidden */
  119985. _attributeDeclaration: string;
  119986. /** @hidden */
  119987. _uniformDeclaration: string;
  119988. /** @hidden */
  119989. _constantDeclaration: string;
  119990. /** @hidden */
  119991. _samplerDeclaration: string;
  119992. /** @hidden */
  119993. _varyingTransfer: string;
  119994. private _repeatableContentAnchorIndex;
  119995. /** @hidden */
  119996. _builtCompilationString: string;
  119997. /**
  119998. * Gets the emitted compilation strings
  119999. */
  120000. compilationString: string;
  120001. /**
  120002. * Finalize the compilation strings
  120003. * @param state defines the current compilation state
  120004. */
  120005. finalize(state: NodeMaterialBuildState): void;
  120006. /** @hidden */
  120007. readonly _repeatableContentAnchor: string;
  120008. /** @hidden */
  120009. _getFreeVariableName(prefix: string): string;
  120010. /** @hidden */
  120011. _getFreeDefineName(prefix: string): string;
  120012. /** @hidden */
  120013. _excludeVariableName(name: string): void;
  120014. /** @hidden */
  120015. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120016. /** @hidden */
  120017. _emitExtension(name: string, extension: string): void;
  120018. /** @hidden */
  120019. _emitFunction(name: string, code: string, comments: string): void;
  120020. /** @hidden */
  120021. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120022. replaceStrings?: {
  120023. search: RegExp;
  120024. replace: string;
  120025. }[];
  120026. repeatKey?: string;
  120027. }): string;
  120028. /** @hidden */
  120029. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120030. repeatKey?: string;
  120031. removeAttributes?: boolean;
  120032. removeUniforms?: boolean;
  120033. removeVaryings?: boolean;
  120034. removeIfDef?: boolean;
  120035. replaceStrings?: {
  120036. search: RegExp;
  120037. replace: string;
  120038. }[];
  120039. }, storeKey?: string): void;
  120040. /** @hidden */
  120041. _registerTempVariable(name: string): boolean;
  120042. /** @hidden */
  120043. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120044. /** @hidden */
  120045. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120046. /** @hidden */
  120047. _emitFloat(value: number): string;
  120048. }
  120049. }
  120050. declare module BABYLON {
  120051. /**
  120052. * Defines a block that can be used inside a node based material
  120053. */
  120054. export class NodeMaterialBlock {
  120055. private _buildId;
  120056. private _buildTarget;
  120057. private _target;
  120058. private _isFinalMerger;
  120059. private _isInput;
  120060. /** @hidden */
  120061. _codeVariableName: string;
  120062. /** @hidden */
  120063. _inputs: NodeMaterialConnectionPoint[];
  120064. /** @hidden */
  120065. _outputs: NodeMaterialConnectionPoint[];
  120066. /** @hidden */
  120067. _preparationId: number;
  120068. /**
  120069. * Gets or sets the name of the block
  120070. */
  120071. name: string;
  120072. /**
  120073. * Gets or sets the unique id of the node
  120074. */
  120075. uniqueId: number;
  120076. /**
  120077. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120078. */
  120079. readonly isFinalMerger: boolean;
  120080. /**
  120081. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120082. */
  120083. readonly isInput: boolean;
  120084. /**
  120085. * Gets or sets the build Id
  120086. */
  120087. buildId: number;
  120088. /**
  120089. * Gets or sets the target of the block
  120090. */
  120091. target: NodeMaterialBlockTargets;
  120092. /**
  120093. * Gets the list of input points
  120094. */
  120095. readonly inputs: NodeMaterialConnectionPoint[];
  120096. /** Gets the list of output points */
  120097. readonly outputs: NodeMaterialConnectionPoint[];
  120098. /**
  120099. * Find an input by its name
  120100. * @param name defines the name of the input to look for
  120101. * @returns the input or null if not found
  120102. */
  120103. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120104. /**
  120105. * Find an output by its name
  120106. * @param name defines the name of the outputto look for
  120107. * @returns the output or null if not found
  120108. */
  120109. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120110. /**
  120111. * Creates a new NodeMaterialBlock
  120112. * @param name defines the block name
  120113. * @param target defines the target of that block (Vertex by default)
  120114. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120115. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120116. */
  120117. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120118. /**
  120119. * Initialize the block and prepare the context for build
  120120. * @param state defines the state that will be used for the build
  120121. */
  120122. initialize(state: NodeMaterialBuildState): void;
  120123. /**
  120124. * Bind data to effect. Will only be called for blocks with isBindable === true
  120125. * @param effect defines the effect to bind data to
  120126. * @param nodeMaterial defines the hosting NodeMaterial
  120127. * @param mesh defines the mesh that will be rendered
  120128. */
  120129. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120130. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120131. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120132. protected _writeFloat(value: number): string;
  120133. /**
  120134. * Gets the current class name e.g. "NodeMaterialBlock"
  120135. * @returns the class name
  120136. */
  120137. getClassName(): string;
  120138. /**
  120139. * Register a new input. Must be called inside a block constructor
  120140. * @param name defines the connection point name
  120141. * @param type defines the connection point type
  120142. * @param isOptional defines a boolean indicating that this input can be omitted
  120143. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120144. * @returns the current block
  120145. */
  120146. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120147. /**
  120148. * Register a new output. Must be called inside a block constructor
  120149. * @param name defines the connection point name
  120150. * @param type defines the connection point type
  120151. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120152. * @returns the current block
  120153. */
  120154. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120155. /**
  120156. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120157. * @param forOutput defines an optional connection point to check compatibility with
  120158. * @returns the first available input or null
  120159. */
  120160. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120161. /**
  120162. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120163. * @param forBlock defines an optional block to check compatibility with
  120164. * @returns the first available input or null
  120165. */
  120166. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120167. /**
  120168. * Gets the sibling of the given output
  120169. * @param current defines the current output
  120170. * @returns the next output in the list or null
  120171. */
  120172. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120173. /**
  120174. * Connect current block with another block
  120175. * @param other defines the block to connect with
  120176. * @param options define the various options to help pick the right connections
  120177. * @returns the current block
  120178. */
  120179. connectTo(other: NodeMaterialBlock, options?: {
  120180. input?: string;
  120181. output?: string;
  120182. outputSwizzle?: string;
  120183. }): this | undefined;
  120184. protected _buildBlock(state: NodeMaterialBuildState): void;
  120185. /**
  120186. * Add uniforms, samplers and uniform buffers at compilation time
  120187. * @param state defines the state to update
  120188. * @param nodeMaterial defines the node material requesting the update
  120189. * @param defines defines the material defines to update
  120190. */
  120191. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120192. /**
  120193. * Add potential fallbacks if shader compilation fails
  120194. * @param mesh defines the mesh to be rendered
  120195. * @param fallbacks defines the current prioritized list of fallbacks
  120196. */
  120197. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120198. /**
  120199. * Initialize defines for shader compilation
  120200. * @param mesh defines the mesh to be rendered
  120201. * @param nodeMaterial defines the node material requesting the update
  120202. * @param defines defines the material defines to update
  120203. * @param useInstances specifies that instances should be used
  120204. */
  120205. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120206. /**
  120207. * Update defines for shader compilation
  120208. * @param mesh defines the mesh to be rendered
  120209. * @param nodeMaterial defines the node material requesting the update
  120210. * @param defines defines the material defines to update
  120211. * @param useInstances specifies that instances should be used
  120212. */
  120213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120214. /**
  120215. * Lets the block try to connect some inputs automatically
  120216. * @param material defines the hosting NodeMaterial
  120217. */
  120218. autoConfigure(material: NodeMaterial): void;
  120219. /**
  120220. * Function called when a block is declared as repeatable content generator
  120221. * @param vertexShaderState defines the current compilation state for the vertex shader
  120222. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120223. * @param mesh defines the mesh to be rendered
  120224. * @param defines defines the material defines to update
  120225. */
  120226. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120227. /**
  120228. * Checks if the block is ready
  120229. * @param mesh defines the mesh to be rendered
  120230. * @param nodeMaterial defines the node material requesting the update
  120231. * @param defines defines the material defines to update
  120232. * @param useInstances specifies that instances should be used
  120233. * @returns true if the block is ready
  120234. */
  120235. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120236. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120237. private _processBuild;
  120238. /**
  120239. * Compile the current node and generate the shader code
  120240. * @param state defines the current compilation state (uniforms, samplers, current string)
  120241. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120242. * @returns true if already built
  120243. */
  120244. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120245. protected _inputRename(name: string): string;
  120246. protected _outputRename(name: string): string;
  120247. protected _dumpPropertiesCode(): string;
  120248. /** @hidden */
  120249. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120250. /**
  120251. * Clone the current block to a new identical block
  120252. * @param scene defines the hosting scene
  120253. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120254. * @returns a copy of the current block
  120255. */
  120256. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120257. /**
  120258. * Serializes this block in a JSON representation
  120259. * @returns the serialized block object
  120260. */
  120261. serialize(): any;
  120262. /** @hidden */
  120263. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120264. }
  120265. }
  120266. declare module BABYLON {
  120267. /**
  120268. * Enum defining the type of animations supported by InputBlock
  120269. */
  120270. export enum AnimatedInputBlockTypes {
  120271. /** No animation */
  120272. None = 0,
  120273. /** Time based animation. Will only work for floats */
  120274. Time = 1
  120275. }
  120276. }
  120277. declare module BABYLON {
  120278. /**
  120279. * Block used to expose an input value
  120280. */
  120281. export class InputBlock extends NodeMaterialBlock {
  120282. private _mode;
  120283. private _associatedVariableName;
  120284. private _storedValue;
  120285. private _valueCallback;
  120286. private _type;
  120287. private _animationType;
  120288. /** Gets or set a value used to limit the range of float values */
  120289. min: number;
  120290. /** Gets or set a value used to limit the range of float values */
  120291. max: number;
  120292. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120293. matrixMode: number;
  120294. /** @hidden */
  120295. _systemValue: Nullable<NodeMaterialSystemValues>;
  120296. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120297. visibleInInspector: boolean;
  120298. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120299. isConstant: boolean;
  120300. /**
  120301. * Gets or sets the connection point type (default is float)
  120302. */
  120303. readonly type: NodeMaterialBlockConnectionPointTypes;
  120304. /**
  120305. * Creates a new InputBlock
  120306. * @param name defines the block name
  120307. * @param target defines the target of that block (Vertex by default)
  120308. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120309. */
  120310. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120311. /**
  120312. * Gets the output component
  120313. */
  120314. readonly output: NodeMaterialConnectionPoint;
  120315. /**
  120316. * Set the source of this connection point to a vertex attribute
  120317. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120318. * @returns the current connection point
  120319. */
  120320. setAsAttribute(attributeName?: string): InputBlock;
  120321. /**
  120322. * Set the source of this connection point to a system value
  120323. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120324. * @returns the current connection point
  120325. */
  120326. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120327. /**
  120328. * Gets or sets the value of that point.
  120329. * Please note that this value will be ignored if valueCallback is defined
  120330. */
  120331. value: any;
  120332. /**
  120333. * Gets or sets a callback used to get the value of that point.
  120334. * Please note that setting this value will force the connection point to ignore the value property
  120335. */
  120336. valueCallback: () => any;
  120337. /**
  120338. * Gets or sets the associated variable name in the shader
  120339. */
  120340. associatedVariableName: string;
  120341. /** Gets or sets the type of animation applied to the input */
  120342. animationType: AnimatedInputBlockTypes;
  120343. /**
  120344. * Gets a boolean indicating that this connection point not defined yet
  120345. */
  120346. readonly isUndefined: boolean;
  120347. /**
  120348. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120349. * In this case the connection point name must be the name of the uniform to use.
  120350. * Can only be set on inputs
  120351. */
  120352. isUniform: boolean;
  120353. /**
  120354. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120355. * In this case the connection point name must be the name of the attribute to use
  120356. * Can only be set on inputs
  120357. */
  120358. isAttribute: boolean;
  120359. /**
  120360. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120361. * Can only be set on exit points
  120362. */
  120363. isVarying: boolean;
  120364. /**
  120365. * Gets a boolean indicating that the current connection point is a system value
  120366. */
  120367. readonly isSystemValue: boolean;
  120368. /**
  120369. * Gets or sets the current well known value or null if not defined as a system value
  120370. */
  120371. systemValue: Nullable<NodeMaterialSystemValues>;
  120372. /**
  120373. * Gets the current class name
  120374. * @returns the class name
  120375. */
  120376. getClassName(): string;
  120377. /**
  120378. * Animate the input if animationType !== None
  120379. * @param scene defines the rendering scene
  120380. */
  120381. animate(scene: Scene): void;
  120382. private _emitDefine;
  120383. initialize(state: NodeMaterialBuildState): void;
  120384. /**
  120385. * Set the input block to its default value (based on its type)
  120386. */
  120387. setDefaultValue(): void;
  120388. private _emitConstant;
  120389. private _emit;
  120390. /** @hidden */
  120391. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120392. /** @hidden */
  120393. _transmit(effect: Effect, scene: Scene): void;
  120394. protected _buildBlock(state: NodeMaterialBuildState): void;
  120395. protected _dumpPropertiesCode(): string;
  120396. serialize(): any;
  120397. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120398. }
  120399. }
  120400. declare module BABYLON {
  120401. /**
  120402. * Defines a connection point for a block
  120403. */
  120404. export class NodeMaterialConnectionPoint {
  120405. /** @hidden */
  120406. _ownerBlock: NodeMaterialBlock;
  120407. /** @hidden */
  120408. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120409. private _endpoints;
  120410. private _associatedVariableName;
  120411. /** @hidden */
  120412. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120413. /** @hidden */
  120414. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120415. private _type;
  120416. /** @hidden */
  120417. _enforceAssociatedVariableName: boolean;
  120418. /**
  120419. * Gets or sets the additional types supported by this connection point
  120420. */
  120421. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120422. /**
  120423. * Gets or sets the additional types excluded by this connection point
  120424. */
  120425. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120426. /**
  120427. * Gets or sets the associated variable name in the shader
  120428. */
  120429. associatedVariableName: string;
  120430. /**
  120431. * Gets or sets the connection point type (default is float)
  120432. */
  120433. type: NodeMaterialBlockConnectionPointTypes;
  120434. /**
  120435. * Gets or sets the connection point name
  120436. */
  120437. name: string;
  120438. /**
  120439. * Gets or sets a boolean indicating that this connection point can be omitted
  120440. */
  120441. isOptional: boolean;
  120442. /**
  120443. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120444. */
  120445. define: string;
  120446. /** Gets or sets the target of that connection point */
  120447. target: NodeMaterialBlockTargets;
  120448. /**
  120449. * Gets a boolean indicating that the current point is connected
  120450. */
  120451. readonly isConnected: boolean;
  120452. /**
  120453. * Gets a boolean indicating that the current point is connected to an input block
  120454. */
  120455. readonly isConnectedToInputBlock: boolean;
  120456. /**
  120457. * Gets a the connected input block (if any)
  120458. */
  120459. readonly connectInputBlock: Nullable<InputBlock>;
  120460. /** Get the other side of the connection (if any) */
  120461. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120462. /** Get the block that owns this connection point */
  120463. readonly ownerBlock: NodeMaterialBlock;
  120464. /** Get the block connected on the other side of this connection (if any) */
  120465. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120466. /** Get the block connected on the endpoints of this connection (if any) */
  120467. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120468. /** Gets the list of connected endpoints */
  120469. readonly endpoints: NodeMaterialConnectionPoint[];
  120470. /** Gets a boolean indicating if that output point is connected to at least one input */
  120471. readonly hasEndpoints: boolean;
  120472. /**
  120473. * Creates a new connection point
  120474. * @param name defines the connection point name
  120475. * @param ownerBlock defines the block hosting this connection point
  120476. */
  120477. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120478. /**
  120479. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120480. * @returns the class name
  120481. */
  120482. getClassName(): string;
  120483. /**
  120484. * Gets an boolean indicating if the current point can be connected to another point
  120485. * @param connectionPoint defines the other connection point
  120486. * @returns true if the connection is possible
  120487. */
  120488. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120489. /**
  120490. * Connect this point to another connection point
  120491. * @param connectionPoint defines the other connection point
  120492. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120493. * @returns the current connection point
  120494. */
  120495. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120496. /**
  120497. * Disconnect this point from one of his endpoint
  120498. * @param endpoint defines the other connection point
  120499. * @returns the current connection point
  120500. */
  120501. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120502. /**
  120503. * Serializes this point in a JSON representation
  120504. * @returns the serialized point object
  120505. */
  120506. serialize(): any;
  120507. }
  120508. }
  120509. declare module BABYLON {
  120510. /**
  120511. * Block used to add support for vertex skinning (bones)
  120512. */
  120513. export class BonesBlock extends NodeMaterialBlock {
  120514. /**
  120515. * Creates a new BonesBlock
  120516. * @param name defines the block name
  120517. */
  120518. constructor(name: string);
  120519. /**
  120520. * Initialize the block and prepare the context for build
  120521. * @param state defines the state that will be used for the build
  120522. */
  120523. initialize(state: NodeMaterialBuildState): void;
  120524. /**
  120525. * Gets the current class name
  120526. * @returns the class name
  120527. */
  120528. getClassName(): string;
  120529. /**
  120530. * Gets the matrix indices input component
  120531. */
  120532. readonly matricesIndices: NodeMaterialConnectionPoint;
  120533. /**
  120534. * Gets the matrix weights input component
  120535. */
  120536. readonly matricesWeights: NodeMaterialConnectionPoint;
  120537. /**
  120538. * Gets the extra matrix indices input component
  120539. */
  120540. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120541. /**
  120542. * Gets the extra matrix weights input component
  120543. */
  120544. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120545. /**
  120546. * Gets the world input component
  120547. */
  120548. readonly world: NodeMaterialConnectionPoint;
  120549. /**
  120550. * Gets the output component
  120551. */
  120552. readonly output: NodeMaterialConnectionPoint;
  120553. autoConfigure(material: NodeMaterial): void;
  120554. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120555. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120556. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120557. protected _buildBlock(state: NodeMaterialBuildState): this;
  120558. }
  120559. }
  120560. declare module BABYLON {
  120561. /**
  120562. * Block used to add support for instances
  120563. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120564. */
  120565. export class InstancesBlock extends NodeMaterialBlock {
  120566. /**
  120567. * Creates a new InstancesBlock
  120568. * @param name defines the block name
  120569. */
  120570. constructor(name: string);
  120571. /**
  120572. * Gets the current class name
  120573. * @returns the class name
  120574. */
  120575. getClassName(): string;
  120576. /**
  120577. * Gets the first world row input component
  120578. */
  120579. readonly world0: NodeMaterialConnectionPoint;
  120580. /**
  120581. * Gets the second world row input component
  120582. */
  120583. readonly world1: NodeMaterialConnectionPoint;
  120584. /**
  120585. * Gets the third world row input component
  120586. */
  120587. readonly world2: NodeMaterialConnectionPoint;
  120588. /**
  120589. * Gets the forth world row input component
  120590. */
  120591. readonly world3: NodeMaterialConnectionPoint;
  120592. /**
  120593. * Gets the world input component
  120594. */
  120595. readonly world: NodeMaterialConnectionPoint;
  120596. /**
  120597. * Gets the output component
  120598. */
  120599. readonly output: NodeMaterialConnectionPoint;
  120600. autoConfigure(material: NodeMaterial): void;
  120601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120602. protected _buildBlock(state: NodeMaterialBuildState): this;
  120603. }
  120604. }
  120605. declare module BABYLON {
  120606. /**
  120607. * Block used to add morph targets support to vertex shader
  120608. */
  120609. export class MorphTargetsBlock extends NodeMaterialBlock {
  120610. private _repeatableContentAnchor;
  120611. private _repeatebleContentGenerated;
  120612. /**
  120613. * Create a new MorphTargetsBlock
  120614. * @param name defines the block name
  120615. */
  120616. constructor(name: string);
  120617. /**
  120618. * Gets the current class name
  120619. * @returns the class name
  120620. */
  120621. getClassName(): string;
  120622. /**
  120623. * Gets the position input component
  120624. */
  120625. readonly position: NodeMaterialConnectionPoint;
  120626. /**
  120627. * Gets the normal input component
  120628. */
  120629. readonly normal: NodeMaterialConnectionPoint;
  120630. /**
  120631. * Gets the tangent input component
  120632. */
  120633. readonly tangent: NodeMaterialConnectionPoint;
  120634. /**
  120635. * Gets the tangent input component
  120636. */
  120637. readonly uv: NodeMaterialConnectionPoint;
  120638. /**
  120639. * Gets the position output component
  120640. */
  120641. readonly positionOutput: NodeMaterialConnectionPoint;
  120642. /**
  120643. * Gets the normal output component
  120644. */
  120645. readonly normalOutput: NodeMaterialConnectionPoint;
  120646. /**
  120647. * Gets the tangent output component
  120648. */
  120649. readonly tangentOutput: NodeMaterialConnectionPoint;
  120650. /**
  120651. * Gets the tangent output component
  120652. */
  120653. readonly uvOutput: NodeMaterialConnectionPoint;
  120654. initialize(state: NodeMaterialBuildState): void;
  120655. autoConfigure(material: NodeMaterial): void;
  120656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120657. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120658. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120659. protected _buildBlock(state: NodeMaterialBuildState): this;
  120660. }
  120661. }
  120662. declare module BABYLON {
  120663. /**
  120664. * Block used to get data information from a light
  120665. */
  120666. export class LightInformationBlock extends NodeMaterialBlock {
  120667. private _lightDataUniformName;
  120668. private _lightColorUniformName;
  120669. private _lightTypeDefineName;
  120670. /**
  120671. * Gets or sets the light associated with this block
  120672. */
  120673. light: Nullable<Light>;
  120674. /**
  120675. * Creates a new LightInformationBlock
  120676. * @param name defines the block name
  120677. */
  120678. constructor(name: string);
  120679. /**
  120680. * Gets the current class name
  120681. * @returns the class name
  120682. */
  120683. getClassName(): string;
  120684. /**
  120685. * Gets the world position input component
  120686. */
  120687. readonly worldPosition: NodeMaterialConnectionPoint;
  120688. /**
  120689. * Gets the direction output component
  120690. */
  120691. readonly direction: NodeMaterialConnectionPoint;
  120692. /**
  120693. * Gets the direction output component
  120694. */
  120695. readonly color: NodeMaterialConnectionPoint;
  120696. /**
  120697. * Gets the direction output component
  120698. */
  120699. readonly intensity: NodeMaterialConnectionPoint;
  120700. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120701. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120702. protected _buildBlock(state: NodeMaterialBuildState): this;
  120703. serialize(): any;
  120704. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120705. }
  120706. }
  120707. declare module BABYLON {
  120708. /**
  120709. * Block used to add image processing support to fragment shader
  120710. */
  120711. export class ImageProcessingBlock extends NodeMaterialBlock {
  120712. /**
  120713. * Create a new ImageProcessingBlock
  120714. * @param name defines the block name
  120715. */
  120716. constructor(name: string);
  120717. /**
  120718. * Gets the current class name
  120719. * @returns the class name
  120720. */
  120721. getClassName(): string;
  120722. /**
  120723. * Gets the color input component
  120724. */
  120725. readonly color: NodeMaterialConnectionPoint;
  120726. /**
  120727. * Gets the output component
  120728. */
  120729. readonly output: NodeMaterialConnectionPoint;
  120730. /**
  120731. * Initialize the block and prepare the context for build
  120732. * @param state defines the state that will be used for the build
  120733. */
  120734. initialize(state: NodeMaterialBuildState): void;
  120735. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120738. protected _buildBlock(state: NodeMaterialBuildState): this;
  120739. }
  120740. }
  120741. declare module BABYLON {
  120742. /**
  120743. * Block used to pertub normals based on a normal map
  120744. */
  120745. export class PerturbNormalBlock extends NodeMaterialBlock {
  120746. private _tangentSpaceParameterName;
  120747. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120748. invertX: boolean;
  120749. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120750. invertY: boolean;
  120751. /**
  120752. * Create a new PerturbNormalBlock
  120753. * @param name defines the block name
  120754. */
  120755. constructor(name: string);
  120756. /**
  120757. * Gets the current class name
  120758. * @returns the class name
  120759. */
  120760. getClassName(): string;
  120761. /**
  120762. * Gets the world position input component
  120763. */
  120764. readonly worldPosition: NodeMaterialConnectionPoint;
  120765. /**
  120766. * Gets the world normal input component
  120767. */
  120768. readonly worldNormal: NodeMaterialConnectionPoint;
  120769. /**
  120770. * Gets the uv input component
  120771. */
  120772. readonly uv: NodeMaterialConnectionPoint;
  120773. /**
  120774. * Gets the normal map color input component
  120775. */
  120776. readonly normalMapColor: NodeMaterialConnectionPoint;
  120777. /**
  120778. * Gets the strength input component
  120779. */
  120780. readonly strength: NodeMaterialConnectionPoint;
  120781. /**
  120782. * Gets the output component
  120783. */
  120784. readonly output: NodeMaterialConnectionPoint;
  120785. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120786. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120787. autoConfigure(material: NodeMaterial): void;
  120788. protected _buildBlock(state: NodeMaterialBuildState): this;
  120789. protected _dumpPropertiesCode(): string;
  120790. serialize(): any;
  120791. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120792. }
  120793. }
  120794. declare module BABYLON {
  120795. /**
  120796. * Block used to discard a pixel if a value is smaller than a cutoff
  120797. */
  120798. export class DiscardBlock extends NodeMaterialBlock {
  120799. /**
  120800. * Create a new DiscardBlock
  120801. * @param name defines the block name
  120802. */
  120803. constructor(name: string);
  120804. /**
  120805. * Gets the current class name
  120806. * @returns the class name
  120807. */
  120808. getClassName(): string;
  120809. /**
  120810. * Gets the color input component
  120811. */
  120812. readonly value: NodeMaterialConnectionPoint;
  120813. /**
  120814. * Gets the cutoff input component
  120815. */
  120816. readonly cutoff: NodeMaterialConnectionPoint;
  120817. protected _buildBlock(state: NodeMaterialBuildState): this;
  120818. }
  120819. }
  120820. declare module BABYLON {
  120821. /**
  120822. * Block used to add support for scene fog
  120823. */
  120824. export class FogBlock extends NodeMaterialBlock {
  120825. private _fogDistanceName;
  120826. private _fogParameters;
  120827. /**
  120828. * Create a new FogBlock
  120829. * @param name defines the block name
  120830. */
  120831. constructor(name: string);
  120832. /**
  120833. * Gets the current class name
  120834. * @returns the class name
  120835. */
  120836. getClassName(): string;
  120837. /**
  120838. * Gets the world position input component
  120839. */
  120840. readonly worldPosition: NodeMaterialConnectionPoint;
  120841. /**
  120842. * Gets the view input component
  120843. */
  120844. readonly view: NodeMaterialConnectionPoint;
  120845. /**
  120846. * Gets the color input component
  120847. */
  120848. readonly input: NodeMaterialConnectionPoint;
  120849. /**
  120850. * Gets the fog color input component
  120851. */
  120852. readonly fogColor: NodeMaterialConnectionPoint;
  120853. /**
  120854. * Gets the output component
  120855. */
  120856. readonly output: NodeMaterialConnectionPoint;
  120857. autoConfigure(material: NodeMaterial): void;
  120858. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120859. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120860. protected _buildBlock(state: NodeMaterialBuildState): this;
  120861. }
  120862. }
  120863. declare module BABYLON {
  120864. /**
  120865. * Block used to add light in the fragment shader
  120866. */
  120867. export class LightBlock extends NodeMaterialBlock {
  120868. private _lightId;
  120869. /**
  120870. * Gets or sets the light associated with this block
  120871. */
  120872. light: Nullable<Light>;
  120873. /**
  120874. * Create a new LightBlock
  120875. * @param name defines the block name
  120876. */
  120877. constructor(name: string);
  120878. /**
  120879. * Gets the current class name
  120880. * @returns the class name
  120881. */
  120882. getClassName(): string;
  120883. /**
  120884. * Gets the world position input component
  120885. */
  120886. readonly worldPosition: NodeMaterialConnectionPoint;
  120887. /**
  120888. * Gets the world normal input component
  120889. */
  120890. readonly worldNormal: NodeMaterialConnectionPoint;
  120891. /**
  120892. * Gets the camera (or eye) position component
  120893. */
  120894. readonly cameraPosition: NodeMaterialConnectionPoint;
  120895. /**
  120896. * Gets the glossiness component
  120897. */
  120898. readonly glossiness: NodeMaterialConnectionPoint;
  120899. /**
  120900. * Gets the glossinness power component
  120901. */
  120902. readonly glossPower: NodeMaterialConnectionPoint;
  120903. /**
  120904. * Gets the diffuse color component
  120905. */
  120906. readonly diffuseColor: NodeMaterialConnectionPoint;
  120907. /**
  120908. * Gets the specular color component
  120909. */
  120910. readonly specularColor: NodeMaterialConnectionPoint;
  120911. /**
  120912. * Gets the diffuse output component
  120913. */
  120914. readonly diffuseOutput: NodeMaterialConnectionPoint;
  120915. /**
  120916. * Gets the specular output component
  120917. */
  120918. readonly specularOutput: NodeMaterialConnectionPoint;
  120919. autoConfigure(material: NodeMaterial): void;
  120920. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120921. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120922. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120923. private _injectVertexCode;
  120924. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120925. serialize(): any;
  120926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120927. }
  120928. }
  120929. declare module BABYLON {
  120930. /**
  120931. * Block used to multiply 2 values
  120932. */
  120933. export class MultiplyBlock extends NodeMaterialBlock {
  120934. /**
  120935. * Creates a new MultiplyBlock
  120936. * @param name defines the block name
  120937. */
  120938. constructor(name: string);
  120939. /**
  120940. * Gets the current class name
  120941. * @returns the class name
  120942. */
  120943. getClassName(): string;
  120944. /**
  120945. * Gets the left operand input component
  120946. */
  120947. readonly left: NodeMaterialConnectionPoint;
  120948. /**
  120949. * Gets the right operand input component
  120950. */
  120951. readonly right: NodeMaterialConnectionPoint;
  120952. /**
  120953. * Gets the output component
  120954. */
  120955. readonly output: NodeMaterialConnectionPoint;
  120956. protected _buildBlock(state: NodeMaterialBuildState): this;
  120957. }
  120958. }
  120959. declare module BABYLON {
  120960. /**
  120961. * Block used to add 2 vectors
  120962. */
  120963. export class AddBlock extends NodeMaterialBlock {
  120964. /**
  120965. * Creates a new AddBlock
  120966. * @param name defines the block name
  120967. */
  120968. constructor(name: string);
  120969. /**
  120970. * Gets the current class name
  120971. * @returns the class name
  120972. */
  120973. getClassName(): string;
  120974. /**
  120975. * Gets the left operand input component
  120976. */
  120977. readonly left: NodeMaterialConnectionPoint;
  120978. /**
  120979. * Gets the right operand input component
  120980. */
  120981. readonly right: NodeMaterialConnectionPoint;
  120982. /**
  120983. * Gets the output component
  120984. */
  120985. readonly output: NodeMaterialConnectionPoint;
  120986. protected _buildBlock(state: NodeMaterialBuildState): this;
  120987. }
  120988. }
  120989. declare module BABYLON {
  120990. /**
  120991. * Block used to scale a vector by a float
  120992. */
  120993. export class ScaleBlock extends NodeMaterialBlock {
  120994. /**
  120995. * Creates a new ScaleBlock
  120996. * @param name defines the block name
  120997. */
  120998. constructor(name: string);
  120999. /**
  121000. * Gets the current class name
  121001. * @returns the class name
  121002. */
  121003. getClassName(): string;
  121004. /**
  121005. * Gets the input component
  121006. */
  121007. readonly input: NodeMaterialConnectionPoint;
  121008. /**
  121009. * Gets the factor input component
  121010. */
  121011. readonly factor: NodeMaterialConnectionPoint;
  121012. /**
  121013. * Gets the output component
  121014. */
  121015. readonly output: NodeMaterialConnectionPoint;
  121016. protected _buildBlock(state: NodeMaterialBuildState): this;
  121017. }
  121018. }
  121019. declare module BABYLON {
  121020. /**
  121021. * Block used to clamp a float
  121022. */
  121023. export class ClampBlock extends NodeMaterialBlock {
  121024. /** Gets or sets the minimum range */
  121025. minimum: number;
  121026. /** Gets or sets the maximum range */
  121027. maximum: number;
  121028. /**
  121029. * Creates a new ClampBlock
  121030. * @param name defines the block name
  121031. */
  121032. constructor(name: string);
  121033. /**
  121034. * Gets the current class name
  121035. * @returns the class name
  121036. */
  121037. getClassName(): string;
  121038. /**
  121039. * Gets the value input component
  121040. */
  121041. readonly value: NodeMaterialConnectionPoint;
  121042. /**
  121043. * Gets the output component
  121044. */
  121045. readonly output: NodeMaterialConnectionPoint;
  121046. protected _buildBlock(state: NodeMaterialBuildState): this;
  121047. protected _dumpPropertiesCode(): string;
  121048. serialize(): any;
  121049. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121050. }
  121051. }
  121052. declare module BABYLON {
  121053. /**
  121054. * Block used to apply a cross product between 2 vectors
  121055. */
  121056. export class CrossBlock extends NodeMaterialBlock {
  121057. /**
  121058. * Creates a new CrossBlock
  121059. * @param name defines the block name
  121060. */
  121061. constructor(name: string);
  121062. /**
  121063. * Gets the current class name
  121064. * @returns the class name
  121065. */
  121066. getClassName(): string;
  121067. /**
  121068. * Gets the left operand input component
  121069. */
  121070. readonly left: NodeMaterialConnectionPoint;
  121071. /**
  121072. * Gets the right operand input component
  121073. */
  121074. readonly right: NodeMaterialConnectionPoint;
  121075. /**
  121076. * Gets the output component
  121077. */
  121078. readonly output: NodeMaterialConnectionPoint;
  121079. protected _buildBlock(state: NodeMaterialBuildState): this;
  121080. }
  121081. }
  121082. declare module BABYLON {
  121083. /**
  121084. * Block used to apply a dot product between 2 vectors
  121085. */
  121086. export class DotBlock extends NodeMaterialBlock {
  121087. /**
  121088. * Creates a new DotBlock
  121089. * @param name defines the block name
  121090. */
  121091. constructor(name: string);
  121092. /**
  121093. * Gets the current class name
  121094. * @returns the class name
  121095. */
  121096. getClassName(): string;
  121097. /**
  121098. * Gets the left operand input component
  121099. */
  121100. readonly left: NodeMaterialConnectionPoint;
  121101. /**
  121102. * Gets the right operand input component
  121103. */
  121104. readonly right: NodeMaterialConnectionPoint;
  121105. /**
  121106. * Gets the output component
  121107. */
  121108. readonly output: NodeMaterialConnectionPoint;
  121109. protected _buildBlock(state: NodeMaterialBuildState): this;
  121110. }
  121111. }
  121112. declare module BABYLON {
  121113. /**
  121114. * Block used to remap a float from a range to a new one
  121115. */
  121116. export class RemapBlock extends NodeMaterialBlock {
  121117. /**
  121118. * Gets or sets the source range
  121119. */
  121120. sourceRange: Vector2;
  121121. /**
  121122. * Gets or sets the target range
  121123. */
  121124. targetRange: Vector2;
  121125. /**
  121126. * Creates a new RemapBlock
  121127. * @param name defines the block name
  121128. */
  121129. constructor(name: string);
  121130. /**
  121131. * Gets the current class name
  121132. * @returns the class name
  121133. */
  121134. getClassName(): string;
  121135. /**
  121136. * Gets the input component
  121137. */
  121138. readonly input: NodeMaterialConnectionPoint;
  121139. /**
  121140. * Gets the source min input component
  121141. */
  121142. readonly sourceMin: NodeMaterialConnectionPoint;
  121143. /**
  121144. * Gets the source max input component
  121145. */
  121146. readonly sourceMax: NodeMaterialConnectionPoint;
  121147. /**
  121148. * Gets the target min input component
  121149. */
  121150. readonly targetMin: NodeMaterialConnectionPoint;
  121151. /**
  121152. * Gets the target max input component
  121153. */
  121154. readonly targetMax: NodeMaterialConnectionPoint;
  121155. /**
  121156. * Gets the output component
  121157. */
  121158. readonly output: NodeMaterialConnectionPoint;
  121159. protected _buildBlock(state: NodeMaterialBuildState): this;
  121160. protected _dumpPropertiesCode(): string;
  121161. serialize(): any;
  121162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121163. }
  121164. }
  121165. declare module BABYLON {
  121166. /**
  121167. * Block used to normalize a vector
  121168. */
  121169. export class NormalizeBlock extends NodeMaterialBlock {
  121170. /**
  121171. * Creates a new NormalizeBlock
  121172. * @param name defines the block name
  121173. */
  121174. constructor(name: string);
  121175. /**
  121176. * Gets the current class name
  121177. * @returns the class name
  121178. */
  121179. getClassName(): string;
  121180. /**
  121181. * Gets the input component
  121182. */
  121183. readonly input: NodeMaterialConnectionPoint;
  121184. /**
  121185. * Gets the output component
  121186. */
  121187. readonly output: NodeMaterialConnectionPoint;
  121188. protected _buildBlock(state: NodeMaterialBuildState): this;
  121189. }
  121190. }
  121191. declare module BABYLON {
  121192. /**
  121193. * Operations supported by the Trigonometry block
  121194. */
  121195. export enum TrigonometryBlockOperations {
  121196. /** Cos */
  121197. Cos = 0,
  121198. /** Sin */
  121199. Sin = 1,
  121200. /** Abs */
  121201. Abs = 2,
  121202. /** Exp */
  121203. Exp = 3,
  121204. /** Exp2 */
  121205. Exp2 = 4,
  121206. /** Round */
  121207. Round = 5,
  121208. /** Floor */
  121209. Floor = 6,
  121210. /** Ceiling */
  121211. Ceiling = 7,
  121212. /** Square root */
  121213. Sqrt = 8,
  121214. /** Log */
  121215. Log = 9,
  121216. /** Tangent */
  121217. Tan = 10,
  121218. /** Arc tangent */
  121219. ArcTan = 11,
  121220. /** Arc cosinus */
  121221. ArcCos = 12,
  121222. /** Arc sinus */
  121223. ArcSin = 13,
  121224. /** Fraction */
  121225. Fract = 14,
  121226. /** Sign */
  121227. Sign = 15,
  121228. /** To radians (from degrees) */
  121229. Radians = 16,
  121230. /** To degrees (from radians) */
  121231. Degrees = 17
  121232. }
  121233. /**
  121234. * Block used to apply trigonometry operation to floats
  121235. */
  121236. export class TrigonometryBlock extends NodeMaterialBlock {
  121237. /**
  121238. * Gets or sets the operation applied by the block
  121239. */
  121240. operation: TrigonometryBlockOperations;
  121241. /**
  121242. * Creates a new TrigonometryBlock
  121243. * @param name defines the block name
  121244. */
  121245. constructor(name: string);
  121246. /**
  121247. * Gets the current class name
  121248. * @returns the class name
  121249. */
  121250. getClassName(): string;
  121251. /**
  121252. * Gets the input component
  121253. */
  121254. readonly input: NodeMaterialConnectionPoint;
  121255. /**
  121256. * Gets the output component
  121257. */
  121258. readonly output: NodeMaterialConnectionPoint;
  121259. protected _buildBlock(state: NodeMaterialBuildState): this;
  121260. serialize(): any;
  121261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121262. }
  121263. }
  121264. declare module BABYLON {
  121265. /**
  121266. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121267. */
  121268. export class ColorMergerBlock extends NodeMaterialBlock {
  121269. /**
  121270. * Create a new ColorMergerBlock
  121271. * @param name defines the block name
  121272. */
  121273. constructor(name: string);
  121274. /**
  121275. * Gets the current class name
  121276. * @returns the class name
  121277. */
  121278. getClassName(): string;
  121279. /**
  121280. * Gets the r component (input)
  121281. */
  121282. readonly r: NodeMaterialConnectionPoint;
  121283. /**
  121284. * Gets the g component (input)
  121285. */
  121286. readonly g: NodeMaterialConnectionPoint;
  121287. /**
  121288. * Gets the b component (input)
  121289. */
  121290. readonly b: NodeMaterialConnectionPoint;
  121291. /**
  121292. * Gets the a component (input)
  121293. */
  121294. readonly a: NodeMaterialConnectionPoint;
  121295. /**
  121296. * Gets the rgba component (output)
  121297. */
  121298. readonly rgba: NodeMaterialConnectionPoint;
  121299. /**
  121300. * Gets the rgb component (output)
  121301. */
  121302. readonly rgb: NodeMaterialConnectionPoint;
  121303. protected _buildBlock(state: NodeMaterialBuildState): this;
  121304. }
  121305. }
  121306. declare module BABYLON {
  121307. /**
  121308. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121309. */
  121310. export class VectorMergerBlock extends NodeMaterialBlock {
  121311. /**
  121312. * Create a new VectorMergerBlock
  121313. * @param name defines the block name
  121314. */
  121315. constructor(name: string);
  121316. /**
  121317. * Gets the current class name
  121318. * @returns the class name
  121319. */
  121320. getClassName(): string;
  121321. /**
  121322. * Gets the x component (input)
  121323. */
  121324. readonly x: NodeMaterialConnectionPoint;
  121325. /**
  121326. * Gets the y component (input)
  121327. */
  121328. readonly y: NodeMaterialConnectionPoint;
  121329. /**
  121330. * Gets the z component (input)
  121331. */
  121332. readonly z: NodeMaterialConnectionPoint;
  121333. /**
  121334. * Gets the w component (input)
  121335. */
  121336. readonly w: NodeMaterialConnectionPoint;
  121337. /**
  121338. * Gets the xyzw component (output)
  121339. */
  121340. readonly xyzw: NodeMaterialConnectionPoint;
  121341. /**
  121342. * Gets the xyz component (output)
  121343. */
  121344. readonly xyz: NodeMaterialConnectionPoint;
  121345. /**
  121346. * Gets the xy component (output)
  121347. */
  121348. readonly xy: NodeMaterialConnectionPoint;
  121349. protected _buildBlock(state: NodeMaterialBuildState): this;
  121350. }
  121351. }
  121352. declare module BABYLON {
  121353. /**
  121354. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121355. */
  121356. export class ColorSplitterBlock extends NodeMaterialBlock {
  121357. /**
  121358. * Create a new ColorSplitterBlock
  121359. * @param name defines the block name
  121360. */
  121361. constructor(name: string);
  121362. /**
  121363. * Gets the current class name
  121364. * @returns the class name
  121365. */
  121366. getClassName(): string;
  121367. /**
  121368. * Gets the rgba component (input)
  121369. */
  121370. readonly rgba: NodeMaterialConnectionPoint;
  121371. /**
  121372. * Gets the rgb component (input)
  121373. */
  121374. readonly rgbIn: NodeMaterialConnectionPoint;
  121375. /**
  121376. * Gets the rgb component (output)
  121377. */
  121378. readonly rgbOut: NodeMaterialConnectionPoint;
  121379. /**
  121380. * Gets the r component (output)
  121381. */
  121382. readonly r: NodeMaterialConnectionPoint;
  121383. /**
  121384. * Gets the g component (output)
  121385. */
  121386. readonly g: NodeMaterialConnectionPoint;
  121387. /**
  121388. * Gets the b component (output)
  121389. */
  121390. readonly b: NodeMaterialConnectionPoint;
  121391. /**
  121392. * Gets the a component (output)
  121393. */
  121394. readonly a: NodeMaterialConnectionPoint;
  121395. protected _inputRename(name: string): string;
  121396. protected _outputRename(name: string): string;
  121397. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121398. }
  121399. }
  121400. declare module BABYLON {
  121401. /**
  121402. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121403. */
  121404. export class VectorSplitterBlock extends NodeMaterialBlock {
  121405. /**
  121406. * Create a new VectorSplitterBlock
  121407. * @param name defines the block name
  121408. */
  121409. constructor(name: string);
  121410. /**
  121411. * Gets the current class name
  121412. * @returns the class name
  121413. */
  121414. getClassName(): string;
  121415. /**
  121416. * Gets the xyzw component (input)
  121417. */
  121418. readonly xyzw: NodeMaterialConnectionPoint;
  121419. /**
  121420. * Gets the xyz component (input)
  121421. */
  121422. readonly xyzIn: NodeMaterialConnectionPoint;
  121423. /**
  121424. * Gets the xy component (input)
  121425. */
  121426. readonly xyIn: NodeMaterialConnectionPoint;
  121427. /**
  121428. * Gets the xyz component (output)
  121429. */
  121430. readonly xyzOut: NodeMaterialConnectionPoint;
  121431. /**
  121432. * Gets the xy component (output)
  121433. */
  121434. readonly xyOut: NodeMaterialConnectionPoint;
  121435. /**
  121436. * Gets the x component (output)
  121437. */
  121438. readonly x: NodeMaterialConnectionPoint;
  121439. /**
  121440. * Gets the y component (output)
  121441. */
  121442. readonly y: NodeMaterialConnectionPoint;
  121443. /**
  121444. * Gets the z component (output)
  121445. */
  121446. readonly z: NodeMaterialConnectionPoint;
  121447. /**
  121448. * Gets the w component (output)
  121449. */
  121450. readonly w: NodeMaterialConnectionPoint;
  121451. protected _inputRename(name: string): string;
  121452. protected _outputRename(name: string): string;
  121453. protected _buildBlock(state: NodeMaterialBuildState): this;
  121454. }
  121455. }
  121456. declare module BABYLON {
  121457. /**
  121458. * Block used to lerp 2 values
  121459. */
  121460. export class LerpBlock extends NodeMaterialBlock {
  121461. /**
  121462. * Creates a new LerpBlock
  121463. * @param name defines the block name
  121464. */
  121465. constructor(name: string);
  121466. /**
  121467. * Gets the current class name
  121468. * @returns the class name
  121469. */
  121470. getClassName(): string;
  121471. /**
  121472. * Gets the left operand input component
  121473. */
  121474. readonly left: NodeMaterialConnectionPoint;
  121475. /**
  121476. * Gets the right operand input component
  121477. */
  121478. readonly right: NodeMaterialConnectionPoint;
  121479. /**
  121480. * Gets the gradient operand input component
  121481. */
  121482. readonly gradient: NodeMaterialConnectionPoint;
  121483. /**
  121484. * Gets the output component
  121485. */
  121486. readonly output: NodeMaterialConnectionPoint;
  121487. protected _buildBlock(state: NodeMaterialBuildState): this;
  121488. }
  121489. }
  121490. declare module BABYLON {
  121491. /**
  121492. * Block used to divide 2 vectors
  121493. */
  121494. export class DivideBlock extends NodeMaterialBlock {
  121495. /**
  121496. * Creates a new DivideBlock
  121497. * @param name defines the block name
  121498. */
  121499. constructor(name: string);
  121500. /**
  121501. * Gets the current class name
  121502. * @returns the class name
  121503. */
  121504. getClassName(): string;
  121505. /**
  121506. * Gets the left operand input component
  121507. */
  121508. readonly left: NodeMaterialConnectionPoint;
  121509. /**
  121510. * Gets the right operand input component
  121511. */
  121512. readonly right: NodeMaterialConnectionPoint;
  121513. /**
  121514. * Gets the output component
  121515. */
  121516. readonly output: NodeMaterialConnectionPoint;
  121517. protected _buildBlock(state: NodeMaterialBuildState): this;
  121518. }
  121519. }
  121520. declare module BABYLON {
  121521. /**
  121522. * Block used to subtract 2 vectors
  121523. */
  121524. export class SubtractBlock extends NodeMaterialBlock {
  121525. /**
  121526. * Creates a new SubtractBlock
  121527. * @param name defines the block name
  121528. */
  121529. constructor(name: string);
  121530. /**
  121531. * Gets the current class name
  121532. * @returns the class name
  121533. */
  121534. getClassName(): string;
  121535. /**
  121536. * Gets the left operand input component
  121537. */
  121538. readonly left: NodeMaterialConnectionPoint;
  121539. /**
  121540. * Gets the right operand input component
  121541. */
  121542. readonly right: NodeMaterialConnectionPoint;
  121543. /**
  121544. * Gets the output component
  121545. */
  121546. readonly output: NodeMaterialConnectionPoint;
  121547. protected _buildBlock(state: NodeMaterialBuildState): this;
  121548. }
  121549. }
  121550. declare module BABYLON {
  121551. /**
  121552. * Block used to step a value
  121553. */
  121554. export class StepBlock extends NodeMaterialBlock {
  121555. /**
  121556. * Creates a new StepBlock
  121557. * @param name defines the block name
  121558. */
  121559. constructor(name: string);
  121560. /**
  121561. * Gets the current class name
  121562. * @returns the class name
  121563. */
  121564. getClassName(): string;
  121565. /**
  121566. * Gets the value operand input component
  121567. */
  121568. readonly value: NodeMaterialConnectionPoint;
  121569. /**
  121570. * Gets the edge operand input component
  121571. */
  121572. readonly edge: NodeMaterialConnectionPoint;
  121573. /**
  121574. * Gets the output component
  121575. */
  121576. readonly output: NodeMaterialConnectionPoint;
  121577. protected _buildBlock(state: NodeMaterialBuildState): this;
  121578. }
  121579. }
  121580. declare module BABYLON {
  121581. /**
  121582. * Block used to get the opposite (1 - x) of a value
  121583. */
  121584. export class OneMinusBlock extends NodeMaterialBlock {
  121585. /**
  121586. * Creates a new OneMinusBlock
  121587. * @param name defines the block name
  121588. */
  121589. constructor(name: string);
  121590. /**
  121591. * Gets the current class name
  121592. * @returns the class name
  121593. */
  121594. getClassName(): string;
  121595. /**
  121596. * Gets the input component
  121597. */
  121598. readonly input: NodeMaterialConnectionPoint;
  121599. /**
  121600. * Gets the output component
  121601. */
  121602. readonly output: NodeMaterialConnectionPoint;
  121603. protected _buildBlock(state: NodeMaterialBuildState): this;
  121604. }
  121605. }
  121606. declare module BABYLON {
  121607. /**
  121608. * Block used to get the view direction
  121609. */
  121610. export class ViewDirectionBlock extends NodeMaterialBlock {
  121611. /**
  121612. * Creates a new ViewDirectionBlock
  121613. * @param name defines the block name
  121614. */
  121615. constructor(name: string);
  121616. /**
  121617. * Gets the current class name
  121618. * @returns the class name
  121619. */
  121620. getClassName(): string;
  121621. /**
  121622. * Gets the world position component
  121623. */
  121624. readonly worldPosition: NodeMaterialConnectionPoint;
  121625. /**
  121626. * Gets the camera position component
  121627. */
  121628. readonly cameraPosition: NodeMaterialConnectionPoint;
  121629. /**
  121630. * Gets the output component
  121631. */
  121632. readonly output: NodeMaterialConnectionPoint;
  121633. autoConfigure(material: NodeMaterial): void;
  121634. protected _buildBlock(state: NodeMaterialBuildState): this;
  121635. }
  121636. }
  121637. declare module BABYLON {
  121638. /**
  121639. * Block used to compute fresnel value
  121640. */
  121641. export class FresnelBlock extends NodeMaterialBlock {
  121642. /**
  121643. * Create a new FresnelBlock
  121644. * @param name defines the block name
  121645. */
  121646. constructor(name: string);
  121647. /**
  121648. * Gets the current class name
  121649. * @returns the class name
  121650. */
  121651. getClassName(): string;
  121652. /**
  121653. * Gets the world normal input component
  121654. */
  121655. readonly worldNormal: NodeMaterialConnectionPoint;
  121656. /**
  121657. * Gets the view direction input component
  121658. */
  121659. readonly viewDirection: NodeMaterialConnectionPoint;
  121660. /**
  121661. * Gets the bias input component
  121662. */
  121663. readonly bias: NodeMaterialConnectionPoint;
  121664. /**
  121665. * Gets the camera (or eye) position component
  121666. */
  121667. readonly power: NodeMaterialConnectionPoint;
  121668. /**
  121669. * Gets the fresnel output component
  121670. */
  121671. readonly fresnel: NodeMaterialConnectionPoint;
  121672. autoConfigure(material: NodeMaterial): void;
  121673. protected _buildBlock(state: NodeMaterialBuildState): this;
  121674. }
  121675. }
  121676. declare module BABYLON {
  121677. /**
  121678. * Block used to get the max of 2 values
  121679. */
  121680. export class MaxBlock extends NodeMaterialBlock {
  121681. /**
  121682. * Creates a new MaxBlock
  121683. * @param name defines the block name
  121684. */
  121685. constructor(name: string);
  121686. /**
  121687. * Gets the current class name
  121688. * @returns the class name
  121689. */
  121690. getClassName(): string;
  121691. /**
  121692. * Gets the left operand input component
  121693. */
  121694. readonly left: NodeMaterialConnectionPoint;
  121695. /**
  121696. * Gets the right operand input component
  121697. */
  121698. readonly right: NodeMaterialConnectionPoint;
  121699. /**
  121700. * Gets the output component
  121701. */
  121702. readonly output: NodeMaterialConnectionPoint;
  121703. protected _buildBlock(state: NodeMaterialBuildState): this;
  121704. }
  121705. }
  121706. declare module BABYLON {
  121707. /**
  121708. * Block used to get the min of 2 values
  121709. */
  121710. export class MinBlock extends NodeMaterialBlock {
  121711. /**
  121712. * Creates a new MinBlock
  121713. * @param name defines the block name
  121714. */
  121715. constructor(name: string);
  121716. /**
  121717. * Gets the current class name
  121718. * @returns the class name
  121719. */
  121720. getClassName(): string;
  121721. /**
  121722. * Gets the left operand input component
  121723. */
  121724. readonly left: NodeMaterialConnectionPoint;
  121725. /**
  121726. * Gets the right operand input component
  121727. */
  121728. readonly right: NodeMaterialConnectionPoint;
  121729. /**
  121730. * Gets the output component
  121731. */
  121732. readonly output: NodeMaterialConnectionPoint;
  121733. protected _buildBlock(state: NodeMaterialBuildState): this;
  121734. }
  121735. }
  121736. declare module BABYLON {
  121737. /**
  121738. * Block used to get the distance between 2 values
  121739. */
  121740. export class DistanceBlock extends NodeMaterialBlock {
  121741. /**
  121742. * Creates a new DistanceBlock
  121743. * @param name defines the block name
  121744. */
  121745. constructor(name: string);
  121746. /**
  121747. * Gets the current class name
  121748. * @returns the class name
  121749. */
  121750. getClassName(): string;
  121751. /**
  121752. * Gets the left operand input component
  121753. */
  121754. readonly left: NodeMaterialConnectionPoint;
  121755. /**
  121756. * Gets the right operand input component
  121757. */
  121758. readonly right: NodeMaterialConnectionPoint;
  121759. /**
  121760. * Gets the output component
  121761. */
  121762. readonly output: NodeMaterialConnectionPoint;
  121763. protected _buildBlock(state: NodeMaterialBuildState): this;
  121764. }
  121765. }
  121766. declare module BABYLON {
  121767. /**
  121768. * Block used to get the length of a vector
  121769. */
  121770. export class LengthBlock extends NodeMaterialBlock {
  121771. /**
  121772. * Creates a new LengthBlock
  121773. * @param name defines the block name
  121774. */
  121775. constructor(name: string);
  121776. /**
  121777. * Gets the current class name
  121778. * @returns the class name
  121779. */
  121780. getClassName(): string;
  121781. /**
  121782. * Gets the value input component
  121783. */
  121784. readonly value: NodeMaterialConnectionPoint;
  121785. /**
  121786. * Gets the output component
  121787. */
  121788. readonly output: NodeMaterialConnectionPoint;
  121789. protected _buildBlock(state: NodeMaterialBuildState): this;
  121790. }
  121791. }
  121792. declare module BABYLON {
  121793. /**
  121794. * Block used to get negative version of a value (i.e. x * -1)
  121795. */
  121796. export class NegateBlock extends NodeMaterialBlock {
  121797. /**
  121798. * Creates a new NegateBlock
  121799. * @param name defines the block name
  121800. */
  121801. constructor(name: string);
  121802. /**
  121803. * Gets the current class name
  121804. * @returns the class name
  121805. */
  121806. getClassName(): string;
  121807. /**
  121808. * Gets the value input component
  121809. */
  121810. readonly value: NodeMaterialConnectionPoint;
  121811. /**
  121812. * Gets the output component
  121813. */
  121814. readonly output: NodeMaterialConnectionPoint;
  121815. protected _buildBlock(state: NodeMaterialBuildState): this;
  121816. }
  121817. }
  121818. declare module BABYLON {
  121819. /**
  121820. * Block used to get the value of the first parameter raised to the power of the second
  121821. */
  121822. export class PowBlock extends NodeMaterialBlock {
  121823. /**
  121824. * Creates a new PowBlock
  121825. * @param name defines the block name
  121826. */
  121827. constructor(name: string);
  121828. /**
  121829. * Gets the current class name
  121830. * @returns the class name
  121831. */
  121832. getClassName(): string;
  121833. /**
  121834. * Gets the value operand input component
  121835. */
  121836. readonly value: NodeMaterialConnectionPoint;
  121837. /**
  121838. * Gets the power operand input component
  121839. */
  121840. readonly power: NodeMaterialConnectionPoint;
  121841. /**
  121842. * Gets the output component
  121843. */
  121844. readonly output: NodeMaterialConnectionPoint;
  121845. protected _buildBlock(state: NodeMaterialBuildState): this;
  121846. }
  121847. }
  121848. declare module BABYLON {
  121849. /**
  121850. * Block used to get a random number
  121851. */
  121852. export class RandomNumberBlock extends NodeMaterialBlock {
  121853. /**
  121854. * Creates a new RandomNumberBlock
  121855. * @param name defines the block name
  121856. */
  121857. constructor(name: string);
  121858. /**
  121859. * Gets the current class name
  121860. * @returns the class name
  121861. */
  121862. getClassName(): string;
  121863. /**
  121864. * Gets the seed input component
  121865. */
  121866. readonly seed: NodeMaterialConnectionPoint;
  121867. /**
  121868. * Gets the output component
  121869. */
  121870. readonly output: NodeMaterialConnectionPoint;
  121871. protected _buildBlock(state: NodeMaterialBuildState): this;
  121872. }
  121873. }
  121874. declare module BABYLON {
  121875. /**
  121876. * Block used to compute arc tangent of 2 values
  121877. */
  121878. export class ArcTan2Block extends NodeMaterialBlock {
  121879. /**
  121880. * Creates a new ArcTan2Block
  121881. * @param name defines the block name
  121882. */
  121883. constructor(name: string);
  121884. /**
  121885. * Gets the current class name
  121886. * @returns the class name
  121887. */
  121888. getClassName(): string;
  121889. /**
  121890. * Gets the x operand input component
  121891. */
  121892. readonly x: NodeMaterialConnectionPoint;
  121893. /**
  121894. * Gets the y operand input component
  121895. */
  121896. readonly y: NodeMaterialConnectionPoint;
  121897. /**
  121898. * Gets the output component
  121899. */
  121900. readonly output: NodeMaterialConnectionPoint;
  121901. protected _buildBlock(state: NodeMaterialBuildState): this;
  121902. }
  121903. }
  121904. declare module BABYLON {
  121905. /**
  121906. * Block used to smooth step a value
  121907. */
  121908. export class SmoothStepBlock extends NodeMaterialBlock {
  121909. /**
  121910. * Creates a new SmoothStepBlock
  121911. * @param name defines the block name
  121912. */
  121913. constructor(name: string);
  121914. /**
  121915. * Gets the current class name
  121916. * @returns the class name
  121917. */
  121918. getClassName(): string;
  121919. /**
  121920. * Gets the value operand input component
  121921. */
  121922. readonly value: NodeMaterialConnectionPoint;
  121923. /**
  121924. * Gets the first edge operand input component
  121925. */
  121926. readonly edge0: NodeMaterialConnectionPoint;
  121927. /**
  121928. * Gets the second edge operand input component
  121929. */
  121930. readonly edge1: NodeMaterialConnectionPoint;
  121931. /**
  121932. * Gets the output component
  121933. */
  121934. readonly output: NodeMaterialConnectionPoint;
  121935. protected _buildBlock(state: NodeMaterialBuildState): this;
  121936. }
  121937. }
  121938. declare module BABYLON {
  121939. /**
  121940. * Block used to get the reciprocal (1 / x) of a value
  121941. */
  121942. export class ReciprocalBlock extends NodeMaterialBlock {
  121943. /**
  121944. * Creates a new ReciprocalBlock
  121945. * @param name defines the block name
  121946. */
  121947. constructor(name: string);
  121948. /**
  121949. * Gets the current class name
  121950. * @returns the class name
  121951. */
  121952. getClassName(): string;
  121953. /**
  121954. * Gets the input component
  121955. */
  121956. readonly input: NodeMaterialConnectionPoint;
  121957. /**
  121958. * Gets the output component
  121959. */
  121960. readonly output: NodeMaterialConnectionPoint;
  121961. protected _buildBlock(state: NodeMaterialBuildState): this;
  121962. }
  121963. }
  121964. declare module BABYLON {
  121965. /**
  121966. * Block used to replace a color by another one
  121967. */
  121968. export class ReplaceColorBlock extends NodeMaterialBlock {
  121969. /**
  121970. * Creates a new ReplaceColorBlock
  121971. * @param name defines the block name
  121972. */
  121973. constructor(name: string);
  121974. /**
  121975. * Gets the current class name
  121976. * @returns the class name
  121977. */
  121978. getClassName(): string;
  121979. /**
  121980. * Gets the value input component
  121981. */
  121982. readonly value: NodeMaterialConnectionPoint;
  121983. /**
  121984. * Gets the reference input component
  121985. */
  121986. readonly reference: NodeMaterialConnectionPoint;
  121987. /**
  121988. * Gets the distance input component
  121989. */
  121990. readonly distance: NodeMaterialConnectionPoint;
  121991. /**
  121992. * Gets the replacement input component
  121993. */
  121994. readonly replacement: NodeMaterialConnectionPoint;
  121995. /**
  121996. * Gets the output component
  121997. */
  121998. readonly output: NodeMaterialConnectionPoint;
  121999. protected _buildBlock(state: NodeMaterialBuildState): this;
  122000. }
  122001. }
  122002. declare module BABYLON {
  122003. /**
  122004. * Block used to posterize a value
  122005. * @see https://en.wikipedia.org/wiki/Posterization
  122006. */
  122007. export class PosterizeBlock extends NodeMaterialBlock {
  122008. /**
  122009. * Creates a new PosterizeBlock
  122010. * @param name defines the block name
  122011. */
  122012. constructor(name: string);
  122013. /**
  122014. * Gets the current class name
  122015. * @returns the class name
  122016. */
  122017. getClassName(): string;
  122018. /**
  122019. * Gets the value input component
  122020. */
  122021. readonly value: NodeMaterialConnectionPoint;
  122022. /**
  122023. * Gets the steps input component
  122024. */
  122025. readonly steps: NodeMaterialConnectionPoint;
  122026. /**
  122027. * Gets the output component
  122028. */
  122029. readonly output: NodeMaterialConnectionPoint;
  122030. protected _buildBlock(state: NodeMaterialBuildState): this;
  122031. }
  122032. }
  122033. declare module BABYLON {
  122034. /**
  122035. * Operations supported by the Wave block
  122036. */
  122037. export enum WaveBlockKind {
  122038. /** SawTooth */
  122039. SawTooth = 0,
  122040. /** Square */
  122041. Square = 1,
  122042. /** Triangle */
  122043. Triangle = 2
  122044. }
  122045. /**
  122046. * Block used to apply wave operation to floats
  122047. */
  122048. export class WaveBlock extends NodeMaterialBlock {
  122049. /**
  122050. * Gets or sets the kibnd of wave to be applied by the block
  122051. */
  122052. kind: WaveBlockKind;
  122053. /**
  122054. * Creates a new WaveBlock
  122055. * @param name defines the block name
  122056. */
  122057. constructor(name: string);
  122058. /**
  122059. * Gets the current class name
  122060. * @returns the class name
  122061. */
  122062. getClassName(): string;
  122063. /**
  122064. * Gets the input component
  122065. */
  122066. readonly input: NodeMaterialConnectionPoint;
  122067. /**
  122068. * Gets the output component
  122069. */
  122070. readonly output: NodeMaterialConnectionPoint;
  122071. protected _buildBlock(state: NodeMaterialBuildState): this;
  122072. serialize(): any;
  122073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122074. }
  122075. }
  122076. declare module BABYLON {
  122077. /**
  122078. * Class used to store a color step for the GradientBlock
  122079. */
  122080. export class GradientBlockColorStep {
  122081. /**
  122082. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122083. */
  122084. step: number;
  122085. /**
  122086. * Gets or sets the color associated with this step
  122087. */
  122088. color: Color3;
  122089. /**
  122090. * Creates a new GradientBlockColorStep
  122091. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122092. * @param color defines the color associated with this step
  122093. */
  122094. constructor(
  122095. /**
  122096. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122097. */
  122098. step: number,
  122099. /**
  122100. * Gets or sets the color associated with this step
  122101. */
  122102. color: Color3);
  122103. }
  122104. /**
  122105. * Block used to return a color from a gradient based on an input value between 0 and 1
  122106. */
  122107. export class GradientBlock extends NodeMaterialBlock {
  122108. /**
  122109. * Gets or sets the list of color steps
  122110. */
  122111. colorSteps: GradientBlockColorStep[];
  122112. /**
  122113. * Creates a new GradientBlock
  122114. * @param name defines the block name
  122115. */
  122116. constructor(name: string);
  122117. /**
  122118. * Gets the current class name
  122119. * @returns the class name
  122120. */
  122121. getClassName(): string;
  122122. /**
  122123. * Gets the gradient input component
  122124. */
  122125. readonly gradient: NodeMaterialConnectionPoint;
  122126. /**
  122127. * Gets the output component
  122128. */
  122129. readonly output: NodeMaterialConnectionPoint;
  122130. private _writeColorConstant;
  122131. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122132. serialize(): any;
  122133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122134. protected _dumpPropertiesCode(): string;
  122135. }
  122136. }
  122137. declare module BABYLON {
  122138. /**
  122139. * Effect Render Options
  122140. */
  122141. export interface IEffectRendererOptions {
  122142. /**
  122143. * Defines the vertices positions.
  122144. */
  122145. positions?: number[];
  122146. /**
  122147. * Defines the indices.
  122148. */
  122149. indices?: number[];
  122150. }
  122151. /**
  122152. * Helper class to render one or more effects
  122153. */
  122154. export class EffectRenderer {
  122155. private engine;
  122156. private static _DefaultOptions;
  122157. private _vertexBuffers;
  122158. private _indexBuffer;
  122159. private _ringBufferIndex;
  122160. private _ringScreenBuffer;
  122161. private _fullscreenViewport;
  122162. private _getNextFrameBuffer;
  122163. /**
  122164. * Creates an effect renderer
  122165. * @param engine the engine to use for rendering
  122166. * @param options defines the options of the effect renderer
  122167. */
  122168. constructor(engine: Engine, options?: IEffectRendererOptions);
  122169. /**
  122170. * Sets the current viewport in normalized coordinates 0-1
  122171. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122172. */
  122173. setViewport(viewport?: Viewport): void;
  122174. /**
  122175. * Binds the embedded attributes buffer to the effect.
  122176. * @param effect Defines the effect to bind the attributes for
  122177. */
  122178. bindBuffers(effect: Effect): void;
  122179. /**
  122180. * Sets the current effect wrapper to use during draw.
  122181. * The effect needs to be ready before calling this api.
  122182. * This also sets the default full screen position attribute.
  122183. * @param effectWrapper Defines the effect to draw with
  122184. */
  122185. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122186. /**
  122187. * Draws a full screen quad.
  122188. */
  122189. draw(): void;
  122190. /**
  122191. * renders one or more effects to a specified texture
  122192. * @param effectWrappers list of effects to renderer
  122193. * @param outputTexture texture to draw to, if null it will render to the screen
  122194. */
  122195. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122196. /**
  122197. * Disposes of the effect renderer
  122198. */
  122199. dispose(): void;
  122200. }
  122201. /**
  122202. * Options to create an EffectWrapper
  122203. */
  122204. interface EffectWrapperCreationOptions {
  122205. /**
  122206. * Engine to use to create the effect
  122207. */
  122208. engine: Engine;
  122209. /**
  122210. * Fragment shader for the effect
  122211. */
  122212. fragmentShader: string;
  122213. /**
  122214. * Vertex shader for the effect
  122215. */
  122216. vertexShader?: string;
  122217. /**
  122218. * Attributes to use in the shader
  122219. */
  122220. attributeNames?: Array<string>;
  122221. /**
  122222. * Uniforms to use in the shader
  122223. */
  122224. uniformNames?: Array<string>;
  122225. /**
  122226. * Texture sampler names to use in the shader
  122227. */
  122228. samplerNames?: Array<string>;
  122229. /**
  122230. * The friendly name of the effect displayed in Spector.
  122231. */
  122232. name?: string;
  122233. }
  122234. /**
  122235. * Wraps an effect to be used for rendering
  122236. */
  122237. export class EffectWrapper {
  122238. /**
  122239. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122240. */
  122241. onApplyObservable: Observable<{}>;
  122242. /**
  122243. * The underlying effect
  122244. */
  122245. effect: Effect;
  122246. /**
  122247. * Creates an effect to be renderer
  122248. * @param creationOptions options to create the effect
  122249. */
  122250. constructor(creationOptions: EffectWrapperCreationOptions);
  122251. /**
  122252. * Disposes of the effect wrapper
  122253. */
  122254. dispose(): void;
  122255. }
  122256. }
  122257. declare module BABYLON {
  122258. /**
  122259. * Helper class to push actions to a pool of workers.
  122260. */
  122261. export class WorkerPool implements IDisposable {
  122262. private _workerInfos;
  122263. private _pendingActions;
  122264. /**
  122265. * Constructor
  122266. * @param workers Array of workers to use for actions
  122267. */
  122268. constructor(workers: Array<Worker>);
  122269. /**
  122270. * Terminates all workers and clears any pending actions.
  122271. */
  122272. dispose(): void;
  122273. /**
  122274. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122275. * pended until a worker has completed its action.
  122276. * @param action The action to perform. Call onComplete when the action is complete.
  122277. */
  122278. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122279. private _execute;
  122280. }
  122281. }
  122282. declare module BABYLON {
  122283. /**
  122284. * Configuration for Draco compression
  122285. */
  122286. export interface IDracoCompressionConfiguration {
  122287. /**
  122288. * Configuration for the decoder.
  122289. */
  122290. decoder: {
  122291. /**
  122292. * The url to the WebAssembly module.
  122293. */
  122294. wasmUrl?: string;
  122295. /**
  122296. * The url to the WebAssembly binary.
  122297. */
  122298. wasmBinaryUrl?: string;
  122299. /**
  122300. * The url to the fallback JavaScript module.
  122301. */
  122302. fallbackUrl?: string;
  122303. };
  122304. }
  122305. /**
  122306. * Draco compression (https://google.github.io/draco/)
  122307. *
  122308. * This class wraps the Draco module.
  122309. *
  122310. * **Encoder**
  122311. *
  122312. * The encoder is not currently implemented.
  122313. *
  122314. * **Decoder**
  122315. *
  122316. * 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.
  122317. *
  122318. * To update the configuration, use the following code:
  122319. * ```javascript
  122320. * DracoCompression.Configuration = {
  122321. * decoder: {
  122322. * wasmUrl: "<url to the WebAssembly library>",
  122323. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122324. * fallbackUrl: "<url to the fallback JavaScript library>",
  122325. * }
  122326. * };
  122327. * ```
  122328. *
  122329. * 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.
  122330. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122331. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122332. *
  122333. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122334. * ```javascript
  122335. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122336. * ```
  122337. *
  122338. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122339. */
  122340. export class DracoCompression implements IDisposable {
  122341. private _workerPoolPromise?;
  122342. private _decoderModulePromise?;
  122343. /**
  122344. * The configuration. Defaults to the following urls:
  122345. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122346. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122347. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122348. */
  122349. static Configuration: IDracoCompressionConfiguration;
  122350. /**
  122351. * Returns true if the decoder configuration is available.
  122352. */
  122353. static readonly DecoderAvailable: boolean;
  122354. /**
  122355. * Default number of workers to create when creating the draco compression object.
  122356. */
  122357. static DefaultNumWorkers: number;
  122358. private static GetDefaultNumWorkers;
  122359. private static _Default;
  122360. /**
  122361. * Default instance for the draco compression object.
  122362. */
  122363. static readonly Default: DracoCompression;
  122364. /**
  122365. * Constructor
  122366. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122367. */
  122368. constructor(numWorkers?: number);
  122369. /**
  122370. * Stop all async operations and release resources.
  122371. */
  122372. dispose(): void;
  122373. /**
  122374. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122375. * @returns a promise that resolves when ready
  122376. */
  122377. whenReadyAsync(): Promise<void>;
  122378. /**
  122379. * Decode Draco compressed mesh data to vertex data.
  122380. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122381. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122382. * @returns A promise that resolves with the decoded vertex data
  122383. */
  122384. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122385. [kind: string]: number;
  122386. }): Promise<VertexData>;
  122387. }
  122388. }
  122389. declare module BABYLON {
  122390. /**
  122391. * Class for building Constructive Solid Geometry
  122392. */
  122393. export class CSG {
  122394. private polygons;
  122395. /**
  122396. * The world matrix
  122397. */
  122398. matrix: Matrix;
  122399. /**
  122400. * Stores the position
  122401. */
  122402. position: Vector3;
  122403. /**
  122404. * Stores the rotation
  122405. */
  122406. rotation: Vector3;
  122407. /**
  122408. * Stores the rotation quaternion
  122409. */
  122410. rotationQuaternion: Nullable<Quaternion>;
  122411. /**
  122412. * Stores the scaling vector
  122413. */
  122414. scaling: Vector3;
  122415. /**
  122416. * Convert the Mesh to CSG
  122417. * @param mesh The Mesh to convert to CSG
  122418. * @returns A new CSG from the Mesh
  122419. */
  122420. static FromMesh(mesh: Mesh): CSG;
  122421. /**
  122422. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122423. * @param polygons Polygons used to construct a CSG solid
  122424. */
  122425. private static FromPolygons;
  122426. /**
  122427. * Clones, or makes a deep copy, of the CSG
  122428. * @returns A new CSG
  122429. */
  122430. clone(): CSG;
  122431. /**
  122432. * Unions this CSG with another CSG
  122433. * @param csg The CSG to union against this CSG
  122434. * @returns The unioned CSG
  122435. */
  122436. union(csg: CSG): CSG;
  122437. /**
  122438. * Unions this CSG with another CSG in place
  122439. * @param csg The CSG to union against this CSG
  122440. */
  122441. unionInPlace(csg: CSG): void;
  122442. /**
  122443. * Subtracts this CSG with another CSG
  122444. * @param csg The CSG to subtract against this CSG
  122445. * @returns A new CSG
  122446. */
  122447. subtract(csg: CSG): CSG;
  122448. /**
  122449. * Subtracts this CSG with another CSG in place
  122450. * @param csg The CSG to subtact against this CSG
  122451. */
  122452. subtractInPlace(csg: CSG): void;
  122453. /**
  122454. * Intersect this CSG with another CSG
  122455. * @param csg The CSG to intersect against this CSG
  122456. * @returns A new CSG
  122457. */
  122458. intersect(csg: CSG): CSG;
  122459. /**
  122460. * Intersects this CSG with another CSG in place
  122461. * @param csg The CSG to intersect against this CSG
  122462. */
  122463. intersectInPlace(csg: CSG): void;
  122464. /**
  122465. * Return a new CSG solid with solid and empty space switched. This solid is
  122466. * not modified.
  122467. * @returns A new CSG solid with solid and empty space switched
  122468. */
  122469. inverse(): CSG;
  122470. /**
  122471. * Inverses the CSG in place
  122472. */
  122473. inverseInPlace(): void;
  122474. /**
  122475. * This is used to keep meshes transformations so they can be restored
  122476. * when we build back a Babylon Mesh
  122477. * NB : All CSG operations are performed in world coordinates
  122478. * @param csg The CSG to copy the transform attributes from
  122479. * @returns This CSG
  122480. */
  122481. copyTransformAttributes(csg: CSG): CSG;
  122482. /**
  122483. * Build Raw mesh from CSG
  122484. * Coordinates here are in world space
  122485. * @param name The name of the mesh geometry
  122486. * @param scene The Scene
  122487. * @param keepSubMeshes Specifies if the submeshes should be kept
  122488. * @returns A new Mesh
  122489. */
  122490. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122491. /**
  122492. * Build Mesh from CSG taking material and transforms into account
  122493. * @param name The name of the Mesh
  122494. * @param material The material of the Mesh
  122495. * @param scene The Scene
  122496. * @param keepSubMeshes Specifies if submeshes should be kept
  122497. * @returns The new Mesh
  122498. */
  122499. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122500. }
  122501. }
  122502. declare module BABYLON {
  122503. /**
  122504. * Class used to create a trail following a mesh
  122505. */
  122506. export class TrailMesh extends Mesh {
  122507. private _generator;
  122508. private _autoStart;
  122509. private _running;
  122510. private _diameter;
  122511. private _length;
  122512. private _sectionPolygonPointsCount;
  122513. private _sectionVectors;
  122514. private _sectionNormalVectors;
  122515. private _beforeRenderObserver;
  122516. /**
  122517. * @constructor
  122518. * @param name The value used by scene.getMeshByName() to do a lookup.
  122519. * @param generator The mesh to generate a trail.
  122520. * @param scene The scene to add this mesh to.
  122521. * @param diameter Diameter of trailing mesh. Default is 1.
  122522. * @param length Length of trailing mesh. Default is 60.
  122523. * @param autoStart Automatically start trailing mesh. Default true.
  122524. */
  122525. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122526. /**
  122527. * "TrailMesh"
  122528. * @returns "TrailMesh"
  122529. */
  122530. getClassName(): string;
  122531. private _createMesh;
  122532. /**
  122533. * Start trailing mesh.
  122534. */
  122535. start(): void;
  122536. /**
  122537. * Stop trailing mesh.
  122538. */
  122539. stop(): void;
  122540. /**
  122541. * Update trailing mesh geometry.
  122542. */
  122543. update(): void;
  122544. /**
  122545. * Returns a new TrailMesh object.
  122546. * @param name is a string, the name given to the new mesh
  122547. * @param newGenerator use new generator object for cloned trail mesh
  122548. * @returns a new mesh
  122549. */
  122550. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122551. /**
  122552. * Serializes this trail mesh
  122553. * @param serializationObject object to write serialization to
  122554. */
  122555. serialize(serializationObject: any): void;
  122556. /**
  122557. * Parses a serialized trail mesh
  122558. * @param parsedMesh the serialized mesh
  122559. * @param scene the scene to create the trail mesh in
  122560. * @returns the created trail mesh
  122561. */
  122562. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122563. }
  122564. }
  122565. declare module BABYLON {
  122566. /**
  122567. * Class containing static functions to help procedurally build meshes
  122568. */
  122569. export class TiledBoxBuilder {
  122570. /**
  122571. * Creates a box mesh
  122572. * 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)
  122573. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122577. * @param name defines the name of the mesh
  122578. * @param options defines the options used to create the mesh
  122579. * @param scene defines the hosting scene
  122580. * @returns the box mesh
  122581. */
  122582. static CreateTiledBox(name: string, options: {
  122583. pattern?: number;
  122584. width?: number;
  122585. height?: number;
  122586. depth?: number;
  122587. tileSize?: number;
  122588. tileWidth?: number;
  122589. tileHeight?: number;
  122590. alignHorizontal?: number;
  122591. alignVertical?: number;
  122592. faceUV?: Vector4[];
  122593. faceColors?: Color4[];
  122594. sideOrientation?: number;
  122595. updatable?: boolean;
  122596. }, scene?: Nullable<Scene>): Mesh;
  122597. }
  122598. }
  122599. declare module BABYLON {
  122600. /**
  122601. * Class containing static functions to help procedurally build meshes
  122602. */
  122603. export class TorusKnotBuilder {
  122604. /**
  122605. * Creates a torus knot mesh
  122606. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122607. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122608. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122609. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122611. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122613. * @param name defines the name of the mesh
  122614. * @param options defines the options used to create the mesh
  122615. * @param scene defines the hosting scene
  122616. * @returns the torus knot mesh
  122617. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122618. */
  122619. static CreateTorusKnot(name: string, options: {
  122620. radius?: number;
  122621. tube?: number;
  122622. radialSegments?: number;
  122623. tubularSegments?: number;
  122624. p?: number;
  122625. q?: number;
  122626. updatable?: boolean;
  122627. sideOrientation?: number;
  122628. frontUVs?: Vector4;
  122629. backUVs?: Vector4;
  122630. }, scene: any): Mesh;
  122631. }
  122632. }
  122633. declare module BABYLON {
  122634. /**
  122635. * Polygon
  122636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122637. */
  122638. export class Polygon {
  122639. /**
  122640. * Creates a rectangle
  122641. * @param xmin bottom X coord
  122642. * @param ymin bottom Y coord
  122643. * @param xmax top X coord
  122644. * @param ymax top Y coord
  122645. * @returns points that make the resulting rectation
  122646. */
  122647. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122648. /**
  122649. * Creates a circle
  122650. * @param radius radius of circle
  122651. * @param cx scale in x
  122652. * @param cy scale in y
  122653. * @param numberOfSides number of sides that make up the circle
  122654. * @returns points that make the resulting circle
  122655. */
  122656. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122657. /**
  122658. * Creates a polygon from input string
  122659. * @param input Input polygon data
  122660. * @returns the parsed points
  122661. */
  122662. static Parse(input: string): Vector2[];
  122663. /**
  122664. * Starts building a polygon from x and y coordinates
  122665. * @param x x coordinate
  122666. * @param y y coordinate
  122667. * @returns the started path2
  122668. */
  122669. static StartingAt(x: number, y: number): Path2;
  122670. }
  122671. /**
  122672. * Builds a polygon
  122673. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122674. */
  122675. export class PolygonMeshBuilder {
  122676. private _points;
  122677. private _outlinepoints;
  122678. private _holes;
  122679. private _name;
  122680. private _scene;
  122681. private _epoints;
  122682. private _eholes;
  122683. private _addToepoint;
  122684. /**
  122685. * Babylon reference to the earcut plugin.
  122686. */
  122687. bjsEarcut: any;
  122688. /**
  122689. * Creates a PolygonMeshBuilder
  122690. * @param name name of the builder
  122691. * @param contours Path of the polygon
  122692. * @param scene scene to add to when creating the mesh
  122693. * @param earcutInjection can be used to inject your own earcut reference
  122694. */
  122695. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122696. /**
  122697. * Adds a whole within the polygon
  122698. * @param hole Array of points defining the hole
  122699. * @returns this
  122700. */
  122701. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122702. /**
  122703. * Creates the polygon
  122704. * @param updatable If the mesh should be updatable
  122705. * @param depth The depth of the mesh created
  122706. * @returns the created mesh
  122707. */
  122708. build(updatable?: boolean, depth?: number): Mesh;
  122709. /**
  122710. * Creates the polygon
  122711. * @param depth The depth of the mesh created
  122712. * @returns the created VertexData
  122713. */
  122714. buildVertexData(depth?: number): VertexData;
  122715. /**
  122716. * Adds a side to the polygon
  122717. * @param positions points that make the polygon
  122718. * @param normals normals of the polygon
  122719. * @param uvs uvs of the polygon
  122720. * @param indices indices of the polygon
  122721. * @param bounds bounds of the polygon
  122722. * @param points points of the polygon
  122723. * @param depth depth of the polygon
  122724. * @param flip flip of the polygon
  122725. */
  122726. private addSide;
  122727. }
  122728. }
  122729. declare module BABYLON {
  122730. /**
  122731. * Class containing static functions to help procedurally build meshes
  122732. */
  122733. export class PolygonBuilder {
  122734. /**
  122735. * Creates a polygon mesh
  122736. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122737. * * 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
  122738. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122740. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122741. * * Remember you can only change the shape positions, not their number when updating a polygon
  122742. * @param name defines the name of the mesh
  122743. * @param options defines the options used to create the mesh
  122744. * @param scene defines the hosting scene
  122745. * @param earcutInjection can be used to inject your own earcut reference
  122746. * @returns the polygon mesh
  122747. */
  122748. static CreatePolygon(name: string, options: {
  122749. shape: Vector3[];
  122750. holes?: Vector3[][];
  122751. depth?: number;
  122752. faceUV?: Vector4[];
  122753. faceColors?: Color4[];
  122754. updatable?: boolean;
  122755. sideOrientation?: number;
  122756. frontUVs?: Vector4;
  122757. backUVs?: Vector4;
  122758. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122759. /**
  122760. * Creates an extruded polygon mesh, with depth in the Y direction.
  122761. * * 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)
  122762. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122763. * @param name defines the name of the mesh
  122764. * @param options defines the options used to create the mesh
  122765. * @param scene defines the hosting scene
  122766. * @param earcutInjection can be used to inject your own earcut reference
  122767. * @returns the polygon mesh
  122768. */
  122769. static ExtrudePolygon(name: string, options: {
  122770. shape: Vector3[];
  122771. holes?: Vector3[][];
  122772. depth?: number;
  122773. faceUV?: Vector4[];
  122774. faceColors?: Color4[];
  122775. updatable?: boolean;
  122776. sideOrientation?: number;
  122777. frontUVs?: Vector4;
  122778. backUVs?: Vector4;
  122779. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122780. }
  122781. }
  122782. declare module BABYLON {
  122783. /**
  122784. * Class containing static functions to help procedurally build meshes
  122785. */
  122786. export class LatheBuilder {
  122787. /**
  122788. * Creates lathe mesh.
  122789. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122790. * * 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
  122791. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122792. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122793. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122794. * * 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
  122795. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122796. * * 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
  122797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122799. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122801. * @param name defines the name of the mesh
  122802. * @param options defines the options used to create the mesh
  122803. * @param scene defines the hosting scene
  122804. * @returns the lathe mesh
  122805. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122806. */
  122807. static CreateLathe(name: string, options: {
  122808. shape: Vector3[];
  122809. radius?: number;
  122810. tessellation?: number;
  122811. clip?: number;
  122812. arc?: number;
  122813. closed?: boolean;
  122814. updatable?: boolean;
  122815. sideOrientation?: number;
  122816. frontUVs?: Vector4;
  122817. backUVs?: Vector4;
  122818. cap?: number;
  122819. invertUV?: boolean;
  122820. }, scene?: Nullable<Scene>): Mesh;
  122821. }
  122822. }
  122823. declare module BABYLON {
  122824. /**
  122825. * Class containing static functions to help procedurally build meshes
  122826. */
  122827. export class TiledPlaneBuilder {
  122828. /**
  122829. * Creates a tiled plane mesh
  122830. * * The parameter `pattern` will, depending on value, do nothing or
  122831. * * * flip (reflect about central vertical) alternate tiles across and up
  122832. * * * flip every tile on alternate rows
  122833. * * * rotate (180 degs) alternate tiles across and up
  122834. * * * rotate every tile on alternate rows
  122835. * * * flip and rotate alternate tiles across and up
  122836. * * * flip and rotate every tile on alternate rows
  122837. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  122838. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  122839. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122840. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122841. * * 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)
  122842. * * 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)
  122843. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122844. * @param name defines the name of the mesh
  122845. * @param options defines the options used to create the mesh
  122846. * @param scene defines the hosting scene
  122847. * @returns the box mesh
  122848. */
  122849. static CreateTiledPlane(name: string, options: {
  122850. pattern?: number;
  122851. tileSize?: number;
  122852. tileWidth?: number;
  122853. tileHeight?: number;
  122854. size?: number;
  122855. width?: number;
  122856. height?: number;
  122857. alignHorizontal?: number;
  122858. alignVertical?: number;
  122859. sideOrientation?: number;
  122860. frontUVs?: Vector4;
  122861. backUVs?: Vector4;
  122862. updatable?: boolean;
  122863. }, scene?: Nullable<Scene>): Mesh;
  122864. }
  122865. }
  122866. declare module BABYLON {
  122867. /**
  122868. * Class containing static functions to help procedurally build meshes
  122869. */
  122870. export class TubeBuilder {
  122871. /**
  122872. * Creates a tube mesh.
  122873. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  122874. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  122875. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  122876. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  122877. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  122878. * * 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)
  122879. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  122880. * * 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
  122881. * * 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
  122882. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122883. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122884. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122885. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122886. * @param name defines the name of the mesh
  122887. * @param options defines the options used to create the mesh
  122888. * @param scene defines the hosting scene
  122889. * @returns the tube mesh
  122890. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122891. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122892. */
  122893. static CreateTube(name: string, options: {
  122894. path: Vector3[];
  122895. radius?: number;
  122896. tessellation?: number;
  122897. radiusFunction?: {
  122898. (i: number, distance: number): number;
  122899. };
  122900. cap?: number;
  122901. arc?: number;
  122902. updatable?: boolean;
  122903. sideOrientation?: number;
  122904. frontUVs?: Vector4;
  122905. backUVs?: Vector4;
  122906. instance?: Mesh;
  122907. invertUV?: boolean;
  122908. }, scene?: Nullable<Scene>): Mesh;
  122909. }
  122910. }
  122911. declare module BABYLON {
  122912. /**
  122913. * Class containing static functions to help procedurally build meshes
  122914. */
  122915. export class IcoSphereBuilder {
  122916. /**
  122917. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  122918. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  122919. * * 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`)
  122920. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  122921. * * 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
  122922. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122923. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122924. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122925. * @param name defines the name of the mesh
  122926. * @param options defines the options used to create the mesh
  122927. * @param scene defines the hosting scene
  122928. * @returns the icosahedron mesh
  122929. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  122930. */
  122931. static CreateIcoSphere(name: string, options: {
  122932. radius?: number;
  122933. radiusX?: number;
  122934. radiusY?: number;
  122935. radiusZ?: number;
  122936. flat?: boolean;
  122937. subdivisions?: number;
  122938. sideOrientation?: number;
  122939. frontUVs?: Vector4;
  122940. backUVs?: Vector4;
  122941. updatable?: boolean;
  122942. }, scene?: Nullable<Scene>): Mesh;
  122943. }
  122944. }
  122945. declare module BABYLON {
  122946. /**
  122947. * Class containing static functions to help procedurally build meshes
  122948. */
  122949. export class DecalBuilder {
  122950. /**
  122951. * Creates a decal mesh.
  122952. * 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
  122953. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122954. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122955. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122956. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122957. * @param name defines the name of the mesh
  122958. * @param sourceMesh defines the mesh where the decal must be applied
  122959. * @param options defines the options used to create the mesh
  122960. * @param scene defines the hosting scene
  122961. * @returns the decal mesh
  122962. * @see https://doc.babylonjs.com/how_to/decals
  122963. */
  122964. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122965. position?: Vector3;
  122966. normal?: Vector3;
  122967. size?: Vector3;
  122968. angle?: number;
  122969. }): Mesh;
  122970. }
  122971. }
  122972. declare module BABYLON {
  122973. /**
  122974. * Class containing static functions to help procedurally build meshes
  122975. */
  122976. export class MeshBuilder {
  122977. /**
  122978. * Creates a box mesh
  122979. * * The parameter `size` sets the size (float) of each box side (default 1)
  122980. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  122981. * * 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)
  122982. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122986. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122987. * @param name defines the name of the mesh
  122988. * @param options defines the options used to create the mesh
  122989. * @param scene defines the hosting scene
  122990. * @returns the box mesh
  122991. */
  122992. static CreateBox(name: string, options: {
  122993. size?: number;
  122994. width?: number;
  122995. height?: number;
  122996. depth?: number;
  122997. faceUV?: Vector4[];
  122998. faceColors?: Color4[];
  122999. sideOrientation?: number;
  123000. frontUVs?: Vector4;
  123001. backUVs?: Vector4;
  123002. updatable?: boolean;
  123003. }, scene?: Nullable<Scene>): Mesh;
  123004. /**
  123005. * Creates a tiled box mesh
  123006. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123008. * @param name defines the name of the mesh
  123009. * @param options defines the options used to create the mesh
  123010. * @param scene defines the hosting scene
  123011. * @returns the tiled box mesh
  123012. */
  123013. static CreateTiledBox(name: string, options: {
  123014. pattern?: number;
  123015. size?: number;
  123016. width?: number;
  123017. height?: number;
  123018. depth: number;
  123019. tileSize?: number;
  123020. tileWidth?: number;
  123021. tileHeight?: number;
  123022. faceUV?: Vector4[];
  123023. faceColors?: Color4[];
  123024. alignHorizontal?: number;
  123025. alignVertical?: number;
  123026. sideOrientation?: number;
  123027. updatable?: boolean;
  123028. }, scene?: Nullable<Scene>): Mesh;
  123029. /**
  123030. * Creates a sphere mesh
  123031. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123032. * * 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`)
  123033. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123034. * * 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
  123035. * * 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)
  123036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123039. * @param name defines the name of the mesh
  123040. * @param options defines the options used to create the mesh
  123041. * @param scene defines the hosting scene
  123042. * @returns the sphere mesh
  123043. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123044. */
  123045. static CreateSphere(name: string, options: {
  123046. segments?: number;
  123047. diameter?: number;
  123048. diameterX?: number;
  123049. diameterY?: number;
  123050. diameterZ?: number;
  123051. arc?: number;
  123052. slice?: number;
  123053. sideOrientation?: number;
  123054. frontUVs?: Vector4;
  123055. backUVs?: Vector4;
  123056. updatable?: boolean;
  123057. }, scene?: Nullable<Scene>): Mesh;
  123058. /**
  123059. * Creates a plane polygonal mesh. By default, this is a disc
  123060. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123061. * * 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
  123062. * * 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
  123063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123066. * @param name defines the name of the mesh
  123067. * @param options defines the options used to create the mesh
  123068. * @param scene defines the hosting scene
  123069. * @returns the plane polygonal mesh
  123070. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123071. */
  123072. static CreateDisc(name: string, options: {
  123073. radius?: number;
  123074. tessellation?: number;
  123075. arc?: number;
  123076. updatable?: boolean;
  123077. sideOrientation?: number;
  123078. frontUVs?: Vector4;
  123079. backUVs?: Vector4;
  123080. }, scene?: Nullable<Scene>): Mesh;
  123081. /**
  123082. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123083. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123084. * * 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`)
  123085. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123086. * * 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
  123087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123090. * @param name defines the name of the mesh
  123091. * @param options defines the options used to create the mesh
  123092. * @param scene defines the hosting scene
  123093. * @returns the icosahedron mesh
  123094. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123095. */
  123096. static CreateIcoSphere(name: string, options: {
  123097. radius?: number;
  123098. radiusX?: number;
  123099. radiusY?: number;
  123100. radiusZ?: number;
  123101. flat?: boolean;
  123102. subdivisions?: number;
  123103. sideOrientation?: number;
  123104. frontUVs?: Vector4;
  123105. backUVs?: Vector4;
  123106. updatable?: boolean;
  123107. }, scene?: Nullable<Scene>): Mesh;
  123108. /**
  123109. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123110. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123111. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123112. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123113. * * 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
  123114. * * 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
  123115. * * 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
  123116. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123117. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123118. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123119. * * 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
  123120. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123121. * * 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
  123122. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123124. * @param name defines the name of the mesh
  123125. * @param options defines the options used to create the mesh
  123126. * @param scene defines the hosting scene
  123127. * @returns the ribbon mesh
  123128. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123129. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123130. */
  123131. static CreateRibbon(name: string, options: {
  123132. pathArray: Vector3[][];
  123133. closeArray?: boolean;
  123134. closePath?: boolean;
  123135. offset?: number;
  123136. updatable?: boolean;
  123137. sideOrientation?: number;
  123138. frontUVs?: Vector4;
  123139. backUVs?: Vector4;
  123140. instance?: Mesh;
  123141. invertUV?: boolean;
  123142. uvs?: Vector2[];
  123143. colors?: Color4[];
  123144. }, scene?: Nullable<Scene>): Mesh;
  123145. /**
  123146. * Creates a cylinder or a cone mesh
  123147. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123148. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123149. * * 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.
  123150. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123151. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123152. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123153. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123154. * * 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).
  123155. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123156. * * 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).
  123157. * * 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
  123158. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123159. * * 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
  123160. * * 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.
  123161. * * If `enclose` is false, a ring surface is one element.
  123162. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123163. * * 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
  123164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123167. * @param name defines the name of the mesh
  123168. * @param options defines the options used to create the mesh
  123169. * @param scene defines the hosting scene
  123170. * @returns the cylinder mesh
  123171. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123172. */
  123173. static CreateCylinder(name: string, options: {
  123174. height?: number;
  123175. diameterTop?: number;
  123176. diameterBottom?: number;
  123177. diameter?: number;
  123178. tessellation?: number;
  123179. subdivisions?: number;
  123180. arc?: number;
  123181. faceColors?: Color4[];
  123182. faceUV?: Vector4[];
  123183. updatable?: boolean;
  123184. hasRings?: boolean;
  123185. enclose?: boolean;
  123186. cap?: number;
  123187. sideOrientation?: number;
  123188. frontUVs?: Vector4;
  123189. backUVs?: Vector4;
  123190. }, scene?: Nullable<Scene>): Mesh;
  123191. /**
  123192. * Creates a torus mesh
  123193. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123194. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123195. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123197. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123199. * @param name defines the name of the mesh
  123200. * @param options defines the options used to create the mesh
  123201. * @param scene defines the hosting scene
  123202. * @returns the torus mesh
  123203. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123204. */
  123205. static CreateTorus(name: string, options: {
  123206. diameter?: number;
  123207. thickness?: number;
  123208. tessellation?: number;
  123209. updatable?: boolean;
  123210. sideOrientation?: number;
  123211. frontUVs?: Vector4;
  123212. backUVs?: Vector4;
  123213. }, scene?: Nullable<Scene>): Mesh;
  123214. /**
  123215. * Creates a torus knot mesh
  123216. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123217. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123218. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123219. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123223. * @param name defines the name of the mesh
  123224. * @param options defines the options used to create the mesh
  123225. * @param scene defines the hosting scene
  123226. * @returns the torus knot mesh
  123227. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123228. */
  123229. static CreateTorusKnot(name: string, options: {
  123230. radius?: number;
  123231. tube?: number;
  123232. radialSegments?: number;
  123233. tubularSegments?: number;
  123234. p?: number;
  123235. q?: number;
  123236. updatable?: boolean;
  123237. sideOrientation?: number;
  123238. frontUVs?: Vector4;
  123239. backUVs?: Vector4;
  123240. }, scene?: Nullable<Scene>): Mesh;
  123241. /**
  123242. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123243. * * 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
  123244. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123245. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123246. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123247. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123248. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123249. * * 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
  123250. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123251. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123253. * @param name defines the name of the new line system
  123254. * @param options defines the options used to create the line system
  123255. * @param scene defines the hosting scene
  123256. * @returns a new line system mesh
  123257. */
  123258. static CreateLineSystem(name: string, options: {
  123259. lines: Vector3[][];
  123260. updatable?: boolean;
  123261. instance?: Nullable<LinesMesh>;
  123262. colors?: Nullable<Color4[][]>;
  123263. useVertexAlpha?: boolean;
  123264. }, scene: Nullable<Scene>): LinesMesh;
  123265. /**
  123266. * Creates a line mesh
  123267. * 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
  123268. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123269. * * The parameter `points` is an array successive Vector3
  123270. * * 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
  123271. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123272. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123273. * * When updating an instance, remember that only point positions can change, not the number of points
  123274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123275. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123276. * @param name defines the name of the new line system
  123277. * @param options defines the options used to create the line system
  123278. * @param scene defines the hosting scene
  123279. * @returns a new line mesh
  123280. */
  123281. static CreateLines(name: string, options: {
  123282. points: Vector3[];
  123283. updatable?: boolean;
  123284. instance?: Nullable<LinesMesh>;
  123285. colors?: Color4[];
  123286. useVertexAlpha?: boolean;
  123287. }, scene?: Nullable<Scene>): LinesMesh;
  123288. /**
  123289. * Creates a dashed line mesh
  123290. * * 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
  123291. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123292. * * The parameter `points` is an array successive Vector3
  123293. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123294. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123295. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123296. * * 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
  123297. * * When updating an instance, remember that only point positions can change, not the number of points
  123298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123299. * @param name defines the name of the mesh
  123300. * @param options defines the options used to create the mesh
  123301. * @param scene defines the hosting scene
  123302. * @returns the dashed line mesh
  123303. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123304. */
  123305. static CreateDashedLines(name: string, options: {
  123306. points: Vector3[];
  123307. dashSize?: number;
  123308. gapSize?: number;
  123309. dashNb?: number;
  123310. updatable?: boolean;
  123311. instance?: LinesMesh;
  123312. }, scene?: Nullable<Scene>): LinesMesh;
  123313. /**
  123314. * 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.
  123315. * * 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.
  123316. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123317. * * 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.
  123318. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123319. * * 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
  123320. * * 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
  123321. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123323. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123324. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123326. * @param name defines the name of the mesh
  123327. * @param options defines the options used to create the mesh
  123328. * @param scene defines the hosting scene
  123329. * @returns the extruded shape mesh
  123330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123332. */
  123333. static ExtrudeShape(name: string, options: {
  123334. shape: Vector3[];
  123335. path: Vector3[];
  123336. scale?: number;
  123337. rotation?: number;
  123338. cap?: number;
  123339. updatable?: boolean;
  123340. sideOrientation?: number;
  123341. frontUVs?: Vector4;
  123342. backUVs?: Vector4;
  123343. instance?: Mesh;
  123344. invertUV?: boolean;
  123345. }, scene?: Nullable<Scene>): Mesh;
  123346. /**
  123347. * Creates an custom extruded shape mesh.
  123348. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123349. * * 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.
  123350. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123351. * * 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
  123352. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123353. * * 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
  123354. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123355. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123356. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123357. * * 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
  123358. * * 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
  123359. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123362. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123364. * @param name defines the name of the mesh
  123365. * @param options defines the options used to create the mesh
  123366. * @param scene defines the hosting scene
  123367. * @returns the custom extruded shape mesh
  123368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123369. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123371. */
  123372. static ExtrudeShapeCustom(name: string, options: {
  123373. shape: Vector3[];
  123374. path: Vector3[];
  123375. scaleFunction?: any;
  123376. rotationFunction?: any;
  123377. ribbonCloseArray?: boolean;
  123378. ribbonClosePath?: boolean;
  123379. cap?: number;
  123380. updatable?: boolean;
  123381. sideOrientation?: number;
  123382. frontUVs?: Vector4;
  123383. backUVs?: Vector4;
  123384. instance?: Mesh;
  123385. invertUV?: boolean;
  123386. }, scene?: Nullable<Scene>): Mesh;
  123387. /**
  123388. * Creates lathe mesh.
  123389. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123390. * * 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
  123391. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123392. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123393. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123394. * * 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
  123395. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123396. * * 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
  123397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123401. * @param name defines the name of the mesh
  123402. * @param options defines the options used to create the mesh
  123403. * @param scene defines the hosting scene
  123404. * @returns the lathe mesh
  123405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123406. */
  123407. static CreateLathe(name: string, options: {
  123408. shape: Vector3[];
  123409. radius?: number;
  123410. tessellation?: number;
  123411. clip?: number;
  123412. arc?: number;
  123413. closed?: boolean;
  123414. updatable?: boolean;
  123415. sideOrientation?: number;
  123416. frontUVs?: Vector4;
  123417. backUVs?: Vector4;
  123418. cap?: number;
  123419. invertUV?: boolean;
  123420. }, scene?: Nullable<Scene>): Mesh;
  123421. /**
  123422. * Creates a tiled plane mesh
  123423. * * You can set a limited pattern arrangement with the tiles
  123424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123425. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123427. * @param name defines the name of the mesh
  123428. * @param options defines the options used to create the mesh
  123429. * @param scene defines the hosting scene
  123430. * @returns the plane mesh
  123431. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123432. */
  123433. static CreateTiledPlane(name: string, options: {
  123434. pattern?: number;
  123435. tileSize?: number;
  123436. tileWidth?: number;
  123437. tileHeight?: number;
  123438. size?: number;
  123439. width?: number;
  123440. height?: number;
  123441. alignHorizontal?: number;
  123442. alignVertical?: number;
  123443. sideOrientation?: number;
  123444. frontUVs?: Vector4;
  123445. backUVs?: Vector4;
  123446. updatable?: boolean;
  123447. }, scene?: Nullable<Scene>): Mesh;
  123448. /**
  123449. * Creates a plane mesh
  123450. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123451. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123452. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123456. * @param name defines the name of the mesh
  123457. * @param options defines the options used to create the mesh
  123458. * @param scene defines the hosting scene
  123459. * @returns the plane mesh
  123460. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123461. */
  123462. static CreatePlane(name: string, options: {
  123463. size?: number;
  123464. width?: number;
  123465. height?: number;
  123466. sideOrientation?: number;
  123467. frontUVs?: Vector4;
  123468. backUVs?: Vector4;
  123469. updatable?: boolean;
  123470. sourcePlane?: Plane;
  123471. }, scene?: Nullable<Scene>): Mesh;
  123472. /**
  123473. * Creates a ground mesh
  123474. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123475. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123477. * @param name defines the name of the mesh
  123478. * @param options defines the options used to create the mesh
  123479. * @param scene defines the hosting scene
  123480. * @returns the ground mesh
  123481. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123482. */
  123483. static CreateGround(name: string, options: {
  123484. width?: number;
  123485. height?: number;
  123486. subdivisions?: number;
  123487. subdivisionsX?: number;
  123488. subdivisionsY?: number;
  123489. updatable?: boolean;
  123490. }, scene?: Nullable<Scene>): Mesh;
  123491. /**
  123492. * Creates a tiled ground mesh
  123493. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123494. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123495. * * 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
  123496. * * 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
  123497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123498. * @param name defines the name of the mesh
  123499. * @param options defines the options used to create the mesh
  123500. * @param scene defines the hosting scene
  123501. * @returns the tiled ground mesh
  123502. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123503. */
  123504. static CreateTiledGround(name: string, options: {
  123505. xmin: number;
  123506. zmin: number;
  123507. xmax: number;
  123508. zmax: number;
  123509. subdivisions?: {
  123510. w: number;
  123511. h: number;
  123512. };
  123513. precision?: {
  123514. w: number;
  123515. h: number;
  123516. };
  123517. updatable?: boolean;
  123518. }, scene?: Nullable<Scene>): Mesh;
  123519. /**
  123520. * Creates a ground mesh from a height map
  123521. * * The parameter `url` sets the URL of the height map image resource.
  123522. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123523. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123524. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123525. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123526. * * 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.
  123527. * * 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).
  123528. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123530. * @param name defines the name of the mesh
  123531. * @param url defines the url to the height map
  123532. * @param options defines the options used to create the mesh
  123533. * @param scene defines the hosting scene
  123534. * @returns the ground mesh
  123535. * @see https://doc.babylonjs.com/babylon101/height_map
  123536. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123537. */
  123538. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123539. width?: number;
  123540. height?: number;
  123541. subdivisions?: number;
  123542. minHeight?: number;
  123543. maxHeight?: number;
  123544. colorFilter?: Color3;
  123545. alphaFilter?: number;
  123546. updatable?: boolean;
  123547. onReady?: (mesh: GroundMesh) => void;
  123548. }, scene?: Nullable<Scene>): GroundMesh;
  123549. /**
  123550. * Creates a polygon mesh
  123551. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123552. * * 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
  123553. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123555. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123556. * * Remember you can only change the shape positions, not their number when updating a polygon
  123557. * @param name defines the name of the mesh
  123558. * @param options defines the options used to create the mesh
  123559. * @param scene defines the hosting scene
  123560. * @param earcutInjection can be used to inject your own earcut reference
  123561. * @returns the polygon mesh
  123562. */
  123563. static CreatePolygon(name: string, options: {
  123564. shape: Vector3[];
  123565. holes?: Vector3[][];
  123566. depth?: number;
  123567. faceUV?: Vector4[];
  123568. faceColors?: Color4[];
  123569. updatable?: boolean;
  123570. sideOrientation?: number;
  123571. frontUVs?: Vector4;
  123572. backUVs?: Vector4;
  123573. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123574. /**
  123575. * Creates an extruded polygon mesh, with depth in the Y direction.
  123576. * * 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)
  123577. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123578. * @param name defines the name of the mesh
  123579. * @param options defines the options used to create the mesh
  123580. * @param scene defines the hosting scene
  123581. * @param earcutInjection can be used to inject your own earcut reference
  123582. * @returns the polygon mesh
  123583. */
  123584. static ExtrudePolygon(name: string, options: {
  123585. shape: Vector3[];
  123586. holes?: Vector3[][];
  123587. depth?: number;
  123588. faceUV?: Vector4[];
  123589. faceColors?: Color4[];
  123590. updatable?: boolean;
  123591. sideOrientation?: number;
  123592. frontUVs?: Vector4;
  123593. backUVs?: Vector4;
  123594. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123595. /**
  123596. * Creates a tube mesh.
  123597. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123598. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123599. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123600. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123601. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123602. * * 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)
  123603. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123604. * * 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
  123605. * * 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
  123606. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123607. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123608. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123610. * @param name defines the name of the mesh
  123611. * @param options defines the options used to create the mesh
  123612. * @param scene defines the hosting scene
  123613. * @returns the tube mesh
  123614. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123615. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123616. */
  123617. static CreateTube(name: string, options: {
  123618. path: Vector3[];
  123619. radius?: number;
  123620. tessellation?: number;
  123621. radiusFunction?: {
  123622. (i: number, distance: number): number;
  123623. };
  123624. cap?: number;
  123625. arc?: number;
  123626. updatable?: boolean;
  123627. sideOrientation?: number;
  123628. frontUVs?: Vector4;
  123629. backUVs?: Vector4;
  123630. instance?: Mesh;
  123631. invertUV?: boolean;
  123632. }, scene?: Nullable<Scene>): Mesh;
  123633. /**
  123634. * Creates a polyhedron mesh
  123635. * * 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
  123636. * * The parameter `size` (positive float, default 1) sets the polygon size
  123637. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123638. * * 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`
  123639. * * 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
  123640. * * 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)`)
  123641. * * 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
  123642. * * 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
  123643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123644. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123646. * @param name defines the name of the mesh
  123647. * @param options defines the options used to create the mesh
  123648. * @param scene defines the hosting scene
  123649. * @returns the polyhedron mesh
  123650. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123651. */
  123652. static CreatePolyhedron(name: string, options: {
  123653. type?: number;
  123654. size?: number;
  123655. sizeX?: number;
  123656. sizeY?: number;
  123657. sizeZ?: number;
  123658. custom?: any;
  123659. faceUV?: Vector4[];
  123660. faceColors?: Color4[];
  123661. flat?: boolean;
  123662. updatable?: boolean;
  123663. sideOrientation?: number;
  123664. frontUVs?: Vector4;
  123665. backUVs?: Vector4;
  123666. }, scene?: Nullable<Scene>): Mesh;
  123667. /**
  123668. * Creates a decal mesh.
  123669. * 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
  123670. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123671. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123672. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123673. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123674. * @param name defines the name of the mesh
  123675. * @param sourceMesh defines the mesh where the decal must be applied
  123676. * @param options defines the options used to create the mesh
  123677. * @param scene defines the hosting scene
  123678. * @returns the decal mesh
  123679. * @see https://doc.babylonjs.com/how_to/decals
  123680. */
  123681. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123682. position?: Vector3;
  123683. normal?: Vector3;
  123684. size?: Vector3;
  123685. angle?: number;
  123686. }): Mesh;
  123687. }
  123688. }
  123689. declare module BABYLON {
  123690. /**
  123691. * A simplifier interface for future simplification implementations
  123692. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123693. */
  123694. export interface ISimplifier {
  123695. /**
  123696. * Simplification of a given mesh according to the given settings.
  123697. * Since this requires computation, it is assumed that the function runs async.
  123698. * @param settings The settings of the simplification, including quality and distance
  123699. * @param successCallback A callback that will be called after the mesh was simplified.
  123700. * @param errorCallback in case of an error, this callback will be called. optional.
  123701. */
  123702. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123703. }
  123704. /**
  123705. * Expected simplification settings.
  123706. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123707. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123708. */
  123709. export interface ISimplificationSettings {
  123710. /**
  123711. * Gets or sets the expected quality
  123712. */
  123713. quality: number;
  123714. /**
  123715. * Gets or sets the distance when this optimized version should be used
  123716. */
  123717. distance: number;
  123718. /**
  123719. * Gets an already optimized mesh
  123720. */
  123721. optimizeMesh?: boolean;
  123722. }
  123723. /**
  123724. * Class used to specify simplification options
  123725. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123726. */
  123727. export class SimplificationSettings implements ISimplificationSettings {
  123728. /** expected quality */
  123729. quality: number;
  123730. /** distance when this optimized version should be used */
  123731. distance: number;
  123732. /** already optimized mesh */
  123733. optimizeMesh?: boolean | undefined;
  123734. /**
  123735. * Creates a SimplificationSettings
  123736. * @param quality expected quality
  123737. * @param distance distance when this optimized version should be used
  123738. * @param optimizeMesh already optimized mesh
  123739. */
  123740. constructor(
  123741. /** expected quality */
  123742. quality: number,
  123743. /** distance when this optimized version should be used */
  123744. distance: number,
  123745. /** already optimized mesh */
  123746. optimizeMesh?: boolean | undefined);
  123747. }
  123748. /**
  123749. * Interface used to define a simplification task
  123750. */
  123751. export interface ISimplificationTask {
  123752. /**
  123753. * Array of settings
  123754. */
  123755. settings: Array<ISimplificationSettings>;
  123756. /**
  123757. * Simplification type
  123758. */
  123759. simplificationType: SimplificationType;
  123760. /**
  123761. * Mesh to simplify
  123762. */
  123763. mesh: Mesh;
  123764. /**
  123765. * Callback called on success
  123766. */
  123767. successCallback?: () => void;
  123768. /**
  123769. * Defines if parallel processing can be used
  123770. */
  123771. parallelProcessing: boolean;
  123772. }
  123773. /**
  123774. * Queue used to order the simplification tasks
  123775. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123776. */
  123777. export class SimplificationQueue {
  123778. private _simplificationArray;
  123779. /**
  123780. * Gets a boolean indicating that the process is still running
  123781. */
  123782. running: boolean;
  123783. /**
  123784. * Creates a new queue
  123785. */
  123786. constructor();
  123787. /**
  123788. * Adds a new simplification task
  123789. * @param task defines a task to add
  123790. */
  123791. addTask(task: ISimplificationTask): void;
  123792. /**
  123793. * Execute next task
  123794. */
  123795. executeNext(): void;
  123796. /**
  123797. * Execute a simplification task
  123798. * @param task defines the task to run
  123799. */
  123800. runSimplification(task: ISimplificationTask): void;
  123801. private getSimplifier;
  123802. }
  123803. /**
  123804. * The implemented types of simplification
  123805. * At the moment only Quadratic Error Decimation is implemented
  123806. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123807. */
  123808. export enum SimplificationType {
  123809. /** Quadratic error decimation */
  123810. QUADRATIC = 0
  123811. }
  123812. }
  123813. declare module BABYLON {
  123814. interface Scene {
  123815. /** @hidden (Backing field) */
  123816. _simplificationQueue: SimplificationQueue;
  123817. /**
  123818. * Gets or sets the simplification queue attached to the scene
  123819. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123820. */
  123821. simplificationQueue: SimplificationQueue;
  123822. }
  123823. interface Mesh {
  123824. /**
  123825. * Simplify the mesh according to the given array of settings.
  123826. * Function will return immediately and will simplify async
  123827. * @param settings a collection of simplification settings
  123828. * @param parallelProcessing should all levels calculate parallel or one after the other
  123829. * @param simplificationType the type of simplification to run
  123830. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  123831. * @returns the current mesh
  123832. */
  123833. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  123834. }
  123835. /**
  123836. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  123837. * created in a scene
  123838. */
  123839. export class SimplicationQueueSceneComponent implements ISceneComponent {
  123840. /**
  123841. * The component name helpfull to identify the component in the list of scene components.
  123842. */
  123843. readonly name: string;
  123844. /**
  123845. * The scene the component belongs to.
  123846. */
  123847. scene: Scene;
  123848. /**
  123849. * Creates a new instance of the component for the given scene
  123850. * @param scene Defines the scene to register the component in
  123851. */
  123852. constructor(scene: Scene);
  123853. /**
  123854. * Registers the component in a given scene
  123855. */
  123856. register(): void;
  123857. /**
  123858. * Rebuilds the elements related to this component in case of
  123859. * context lost for instance.
  123860. */
  123861. rebuild(): void;
  123862. /**
  123863. * Disposes the component and the associated ressources
  123864. */
  123865. dispose(): void;
  123866. private _beforeCameraUpdate;
  123867. }
  123868. }
  123869. declare module BABYLON {
  123870. /**
  123871. * Navigation plugin interface to add navigation constrained by a navigation mesh
  123872. */
  123873. export interface INavigationEnginePlugin {
  123874. /**
  123875. * plugin name
  123876. */
  123877. name: string;
  123878. /**
  123879. * Creates a navigation mesh
  123880. * @param meshes array of all the geometry used to compute the navigatio mesh
  123881. * @param parameters bunch of parameters used to filter geometry
  123882. */
  123883. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  123884. /**
  123885. * Create a navigation mesh debug mesh
  123886. * @param scene is where the mesh will be added
  123887. * @returns debug display mesh
  123888. */
  123889. createDebugNavMesh(scene: Scene): Mesh;
  123890. /**
  123891. * Get a navigation mesh constrained position, closest to the parameter position
  123892. * @param position world position
  123893. * @returns the closest point to position constrained by the navigation mesh
  123894. */
  123895. getClosestPoint(position: Vector3): Vector3;
  123896. /**
  123897. * Get a navigation mesh constrained position, within a particular radius
  123898. * @param position world position
  123899. * @param maxRadius the maximum distance to the constrained world position
  123900. * @returns the closest point to position constrained by the navigation mesh
  123901. */
  123902. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  123903. /**
  123904. * Compute the final position from a segment made of destination-position
  123905. * @param position world position
  123906. * @param destination world position
  123907. * @returns the resulting point along the navmesh
  123908. */
  123909. moveAlong(position: Vector3, destination: Vector3): Vector3;
  123910. /**
  123911. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  123912. * @param start world position
  123913. * @param end world position
  123914. * @returns array containing world position composing the path
  123915. */
  123916. computePath(start: Vector3, end: Vector3): Vector3[];
  123917. /**
  123918. * If this plugin is supported
  123919. * @returns true if plugin is supported
  123920. */
  123921. isSupported(): boolean;
  123922. /**
  123923. * Create a new Crowd so you can add agents
  123924. * @param maxAgents the maximum agent count in the crowd
  123925. * @param maxAgentRadius the maximum radius an agent can have
  123926. * @param scene to attach the crowd to
  123927. * @returns the crowd you can add agents to
  123928. */
  123929. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  123930. /**
  123931. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123932. * The queries will try to find a solution within those bounds
  123933. * default is (1,1,1)
  123934. * @param extent x,y,z value that define the extent around the queries point of reference
  123935. */
  123936. setDefaultQueryExtent(extent: Vector3): void;
  123937. /**
  123938. * Get the Bounding box extent specified by setDefaultQueryExtent
  123939. * @returns the box extent values
  123940. */
  123941. getDefaultQueryExtent(): Vector3;
  123942. /**
  123943. * Release all resources
  123944. */
  123945. dispose(): void;
  123946. }
  123947. /**
  123948. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  123949. */
  123950. export interface ICrowd {
  123951. /**
  123952. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  123953. * You can attach anything to that node. The node position is updated in the scene update tick.
  123954. * @param pos world position that will be constrained by the navigation mesh
  123955. * @param parameters agent parameters
  123956. * @param transform hooked to the agent that will be update by the scene
  123957. * @returns agent index
  123958. */
  123959. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  123960. /**
  123961. * Returns the agent position in world space
  123962. * @param index agent index returned by addAgent
  123963. * @returns world space position
  123964. */
  123965. getAgentPosition(index: number): Vector3;
  123966. /**
  123967. * Gets the agent velocity in world space
  123968. * @param index agent index returned by addAgent
  123969. * @returns world space velocity
  123970. */
  123971. getAgentVelocity(index: number): Vector3;
  123972. /**
  123973. * remove a particular agent previously created
  123974. * @param index agent index returned by addAgent
  123975. */
  123976. removeAgent(index: number): void;
  123977. /**
  123978. * get the list of all agents attached to this crowd
  123979. * @returns list of agent indices
  123980. */
  123981. getAgents(): number[];
  123982. /**
  123983. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  123984. * @param deltaTime in seconds
  123985. */
  123986. update(deltaTime: number): void;
  123987. /**
  123988. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  123989. * @param index agent index returned by addAgent
  123990. * @param destination targeted world position
  123991. */
  123992. agentGoto(index: number, destination: Vector3): void;
  123993. /**
  123994. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  123995. * The queries will try to find a solution within those bounds
  123996. * default is (1,1,1)
  123997. * @param extent x,y,z value that define the extent around the queries point of reference
  123998. */
  123999. setDefaultQueryExtent(extent: Vector3): void;
  124000. /**
  124001. * Get the Bounding box extent specified by setDefaultQueryExtent
  124002. * @returns the box extent values
  124003. */
  124004. getDefaultQueryExtent(): Vector3;
  124005. /**
  124006. * Release all resources
  124007. */
  124008. dispose(): void;
  124009. }
  124010. /**
  124011. * Configures an agent
  124012. */
  124013. export interface IAgentParameters {
  124014. /**
  124015. * Agent radius. [Limit: >= 0]
  124016. */
  124017. radius: number;
  124018. /**
  124019. * Agent height. [Limit: > 0]
  124020. */
  124021. height: number;
  124022. /**
  124023. * Maximum allowed acceleration. [Limit: >= 0]
  124024. */
  124025. maxAcceleration: number;
  124026. /**
  124027. * Maximum allowed speed. [Limit: >= 0]
  124028. */
  124029. maxSpeed: number;
  124030. /**
  124031. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124032. */
  124033. collisionQueryRange: number;
  124034. /**
  124035. * The path visibility optimization range. [Limit: > 0]
  124036. */
  124037. pathOptimizationRange: number;
  124038. /**
  124039. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124040. */
  124041. separationWeight: number;
  124042. }
  124043. /**
  124044. * Configures the navigation mesh creation
  124045. */
  124046. export interface INavMeshParameters {
  124047. /**
  124048. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124049. */
  124050. cs: number;
  124051. /**
  124052. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124053. */
  124054. ch: number;
  124055. /**
  124056. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124057. */
  124058. walkableSlopeAngle: number;
  124059. /**
  124060. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124061. * be considered walkable. [Limit: >= 3] [Units: vx]
  124062. */
  124063. walkableHeight: number;
  124064. /**
  124065. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124066. */
  124067. walkableClimb: number;
  124068. /**
  124069. * The distance to erode/shrink the walkable area of the heightfield away from
  124070. * obstructions. [Limit: >=0] [Units: vx]
  124071. */
  124072. walkableRadius: number;
  124073. /**
  124074. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124075. */
  124076. maxEdgeLen: number;
  124077. /**
  124078. * The maximum distance a simplfied contour's border edges should deviate
  124079. * the original raw contour. [Limit: >=0] [Units: vx]
  124080. */
  124081. maxSimplificationError: number;
  124082. /**
  124083. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124084. */
  124085. minRegionArea: number;
  124086. /**
  124087. * Any regions with a span count smaller than this value will, if possible,
  124088. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124089. */
  124090. mergeRegionArea: number;
  124091. /**
  124092. * The maximum number of vertices allowed for polygons generated during the
  124093. * contour to polygon conversion process. [Limit: >= 3]
  124094. */
  124095. maxVertsPerPoly: number;
  124096. /**
  124097. * Sets the sampling distance to use when generating the detail mesh.
  124098. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124099. */
  124100. detailSampleDist: number;
  124101. /**
  124102. * The maximum distance the detail mesh surface should deviate from heightfield
  124103. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124104. */
  124105. detailSampleMaxError: number;
  124106. }
  124107. }
  124108. declare module BABYLON {
  124109. /**
  124110. * RecastJS navigation plugin
  124111. */
  124112. export class RecastJSPlugin implements INavigationEnginePlugin {
  124113. /**
  124114. * Reference to the Recast library
  124115. */
  124116. bjsRECAST: any;
  124117. /**
  124118. * plugin name
  124119. */
  124120. name: string;
  124121. /**
  124122. * the first navmesh created. We might extend this to support multiple navmeshes
  124123. */
  124124. navMesh: any;
  124125. /**
  124126. * Initializes the recastJS plugin
  124127. * @param recastInjection can be used to inject your own recast reference
  124128. */
  124129. constructor(recastInjection?: any);
  124130. /**
  124131. * Creates a navigation mesh
  124132. * @param meshes array of all the geometry used to compute the navigatio mesh
  124133. * @param parameters bunch of parameters used to filter geometry
  124134. */
  124135. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124136. /**
  124137. * Create a navigation mesh debug mesh
  124138. * @param scene is where the mesh will be added
  124139. * @returns debug display mesh
  124140. */
  124141. createDebugNavMesh(scene: Scene): Mesh;
  124142. /**
  124143. * Get a navigation mesh constrained position, closest to the parameter position
  124144. * @param position world position
  124145. * @returns the closest point to position constrained by the navigation mesh
  124146. */
  124147. getClosestPoint(position: Vector3): Vector3;
  124148. /**
  124149. * Get a navigation mesh constrained position, within a particular radius
  124150. * @param position world position
  124151. * @param maxRadius the maximum distance to the constrained world position
  124152. * @returns the closest point to position constrained by the navigation mesh
  124153. */
  124154. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124155. /**
  124156. * Compute the final position from a segment made of destination-position
  124157. * @param position world position
  124158. * @param destination world position
  124159. * @returns the resulting point along the navmesh
  124160. */
  124161. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124162. /**
  124163. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124164. * @param start world position
  124165. * @param end world position
  124166. * @returns array containing world position composing the path
  124167. */
  124168. computePath(start: Vector3, end: Vector3): Vector3[];
  124169. /**
  124170. * Create a new Crowd so you can add agents
  124171. * @param maxAgents the maximum agent count in the crowd
  124172. * @param maxAgentRadius the maximum radius an agent can have
  124173. * @param scene to attach the crowd to
  124174. * @returns the crowd you can add agents to
  124175. */
  124176. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124177. /**
  124178. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124179. * The queries will try to find a solution within those bounds
  124180. * default is (1,1,1)
  124181. * @param extent x,y,z value that define the extent around the queries point of reference
  124182. */
  124183. setDefaultQueryExtent(extent: Vector3): void;
  124184. /**
  124185. * Get the Bounding box extent specified by setDefaultQueryExtent
  124186. * @returns the box extent values
  124187. */
  124188. getDefaultQueryExtent(): Vector3;
  124189. /**
  124190. * Disposes
  124191. */
  124192. dispose(): void;
  124193. /**
  124194. * If this plugin is supported
  124195. * @returns true if plugin is supported
  124196. */
  124197. isSupported(): boolean;
  124198. }
  124199. /**
  124200. * Recast detour crowd implementation
  124201. */
  124202. export class RecastJSCrowd implements ICrowd {
  124203. /**
  124204. * Recast/detour plugin
  124205. */
  124206. bjsRECASTPlugin: RecastJSPlugin;
  124207. /**
  124208. * Link to the detour crowd
  124209. */
  124210. recastCrowd: any;
  124211. /**
  124212. * One transform per agent
  124213. */
  124214. transforms: TransformNode[];
  124215. /**
  124216. * All agents created
  124217. */
  124218. agents: number[];
  124219. /**
  124220. * Link to the scene is kept to unregister the crowd from the scene
  124221. */
  124222. private _scene;
  124223. /**
  124224. * Observer for crowd updates
  124225. */
  124226. private _onBeforeAnimationsObserver;
  124227. /**
  124228. * Constructor
  124229. * @param plugin recastJS plugin
  124230. * @param maxAgents the maximum agent count in the crowd
  124231. * @param maxAgentRadius the maximum radius an agent can have
  124232. * @param scene to attach the crowd to
  124233. * @returns the crowd you can add agents to
  124234. */
  124235. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124236. /**
  124237. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124238. * You can attach anything to that node. The node position is updated in the scene update tick.
  124239. * @param pos world position that will be constrained by the navigation mesh
  124240. * @param parameters agent parameters
  124241. * @param transform hooked to the agent that will be update by the scene
  124242. * @returns agent index
  124243. */
  124244. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124245. /**
  124246. * Returns the agent position in world space
  124247. * @param index agent index returned by addAgent
  124248. * @returns world space position
  124249. */
  124250. getAgentPosition(index: number): Vector3;
  124251. /**
  124252. * Returns the agent velocity in world space
  124253. * @param index agent index returned by addAgent
  124254. * @returns world space velocity
  124255. */
  124256. getAgentVelocity(index: number): Vector3;
  124257. /**
  124258. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124259. * @param index agent index returned by addAgent
  124260. * @param destination targeted world position
  124261. */
  124262. agentGoto(index: number, destination: Vector3): void;
  124263. /**
  124264. * remove a particular agent previously created
  124265. * @param index agent index returned by addAgent
  124266. */
  124267. removeAgent(index: number): void;
  124268. /**
  124269. * get the list of all agents attached to this crowd
  124270. * @returns list of agent indices
  124271. */
  124272. getAgents(): number[];
  124273. /**
  124274. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124275. * @param deltaTime in seconds
  124276. */
  124277. update(deltaTime: number): void;
  124278. /**
  124279. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124280. * The queries will try to find a solution within those bounds
  124281. * default is (1,1,1)
  124282. * @param extent x,y,z value that define the extent around the queries point of reference
  124283. */
  124284. setDefaultQueryExtent(extent: Vector3): void;
  124285. /**
  124286. * Get the Bounding box extent specified by setDefaultQueryExtent
  124287. * @returns the box extent values
  124288. */
  124289. getDefaultQueryExtent(): Vector3;
  124290. /**
  124291. * Release all resources
  124292. */
  124293. dispose(): void;
  124294. }
  124295. }
  124296. declare module BABYLON {
  124297. /**
  124298. * Class used to enable access to IndexedDB
  124299. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124300. */
  124301. export class Database implements IOfflineProvider {
  124302. private _callbackManifestChecked;
  124303. private _currentSceneUrl;
  124304. private _db;
  124305. private _enableSceneOffline;
  124306. private _enableTexturesOffline;
  124307. private _manifestVersionFound;
  124308. private _mustUpdateRessources;
  124309. private _hasReachedQuota;
  124310. private _isSupported;
  124311. private _idbFactory;
  124312. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124313. private static IsUASupportingBlobStorage;
  124314. /**
  124315. * Gets a boolean indicating if Database storate is enabled (off by default)
  124316. */
  124317. static IDBStorageEnabled: boolean;
  124318. /**
  124319. * Gets a boolean indicating if scene must be saved in the database
  124320. */
  124321. readonly enableSceneOffline: boolean;
  124322. /**
  124323. * Gets a boolean indicating if textures must be saved in the database
  124324. */
  124325. readonly enableTexturesOffline: boolean;
  124326. /**
  124327. * Creates a new Database
  124328. * @param urlToScene defines the url to load the scene
  124329. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124330. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124331. */
  124332. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124333. private static _ParseURL;
  124334. private static _ReturnFullUrlLocation;
  124335. private _checkManifestFile;
  124336. /**
  124337. * Open the database and make it available
  124338. * @param successCallback defines the callback to call on success
  124339. * @param errorCallback defines the callback to call on error
  124340. */
  124341. open(successCallback: () => void, errorCallback: () => void): void;
  124342. /**
  124343. * Loads an image from the database
  124344. * @param url defines the url to load from
  124345. * @param image defines the target DOM image
  124346. */
  124347. loadImage(url: string, image: HTMLImageElement): void;
  124348. private _loadImageFromDBAsync;
  124349. private _saveImageIntoDBAsync;
  124350. private _checkVersionFromDB;
  124351. private _loadVersionFromDBAsync;
  124352. private _saveVersionIntoDBAsync;
  124353. /**
  124354. * Loads a file from database
  124355. * @param url defines the URL to load from
  124356. * @param sceneLoaded defines a callback to call on success
  124357. * @param progressCallBack defines a callback to call when progress changed
  124358. * @param errorCallback defines a callback to call on error
  124359. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124360. */
  124361. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124362. private _loadFileAsync;
  124363. private _saveFileAsync;
  124364. /**
  124365. * Validates if xhr data is correct
  124366. * @param xhr defines the request to validate
  124367. * @param dataType defines the expected data type
  124368. * @returns true if data is correct
  124369. */
  124370. private static _ValidateXHRData;
  124371. }
  124372. }
  124373. declare module BABYLON {
  124374. /** @hidden */
  124375. export var gpuUpdateParticlesPixelShader: {
  124376. name: string;
  124377. shader: string;
  124378. };
  124379. }
  124380. declare module BABYLON {
  124381. /** @hidden */
  124382. export var gpuUpdateParticlesVertexShader: {
  124383. name: string;
  124384. shader: string;
  124385. };
  124386. }
  124387. declare module BABYLON {
  124388. /** @hidden */
  124389. export var clipPlaneFragmentDeclaration2: {
  124390. name: string;
  124391. shader: string;
  124392. };
  124393. }
  124394. declare module BABYLON {
  124395. /** @hidden */
  124396. export var gpuRenderParticlesPixelShader: {
  124397. name: string;
  124398. shader: string;
  124399. };
  124400. }
  124401. declare module BABYLON {
  124402. /** @hidden */
  124403. export var clipPlaneVertexDeclaration2: {
  124404. name: string;
  124405. shader: string;
  124406. };
  124407. }
  124408. declare module BABYLON {
  124409. /** @hidden */
  124410. export var gpuRenderParticlesVertexShader: {
  124411. name: string;
  124412. shader: string;
  124413. };
  124414. }
  124415. declare module BABYLON {
  124416. /**
  124417. * This represents a GPU particle system in Babylon
  124418. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124419. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124420. */
  124421. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124422. /**
  124423. * The layer mask we are rendering the particles through.
  124424. */
  124425. layerMask: number;
  124426. private _capacity;
  124427. private _activeCount;
  124428. private _currentActiveCount;
  124429. private _accumulatedCount;
  124430. private _renderEffect;
  124431. private _updateEffect;
  124432. private _buffer0;
  124433. private _buffer1;
  124434. private _spriteBuffer;
  124435. private _updateVAO;
  124436. private _renderVAO;
  124437. private _targetIndex;
  124438. private _sourceBuffer;
  124439. private _targetBuffer;
  124440. private _engine;
  124441. private _currentRenderId;
  124442. private _started;
  124443. private _stopped;
  124444. private _timeDelta;
  124445. private _randomTexture;
  124446. private _randomTexture2;
  124447. private _attributesStrideSize;
  124448. private _updateEffectOptions;
  124449. private _randomTextureSize;
  124450. private _actualFrame;
  124451. private readonly _rawTextureWidth;
  124452. /**
  124453. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124454. */
  124455. static readonly IsSupported: boolean;
  124456. /**
  124457. * An event triggered when the system is disposed.
  124458. */
  124459. onDisposeObservable: Observable<GPUParticleSystem>;
  124460. /**
  124461. * Gets the maximum number of particles active at the same time.
  124462. * @returns The max number of active particles.
  124463. */
  124464. getCapacity(): number;
  124465. /**
  124466. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124467. * to override the particles.
  124468. */
  124469. forceDepthWrite: boolean;
  124470. /**
  124471. * Gets or set the number of active particles
  124472. */
  124473. activeParticleCount: number;
  124474. private _preWarmDone;
  124475. /**
  124476. * Is this system ready to be used/rendered
  124477. * @return true if the system is ready
  124478. */
  124479. isReady(): boolean;
  124480. /**
  124481. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124482. * @returns True if it has been started, otherwise false.
  124483. */
  124484. isStarted(): boolean;
  124485. /**
  124486. * Starts the particle system and begins to emit
  124487. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124488. */
  124489. start(delay?: number): void;
  124490. /**
  124491. * Stops the particle system.
  124492. */
  124493. stop(): void;
  124494. /**
  124495. * Remove all active particles
  124496. */
  124497. reset(): void;
  124498. /**
  124499. * Returns the string "GPUParticleSystem"
  124500. * @returns a string containing the class name
  124501. */
  124502. getClassName(): string;
  124503. private _colorGradientsTexture;
  124504. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124505. /**
  124506. * Adds a new color gradient
  124507. * @param gradient defines the gradient to use (between 0 and 1)
  124508. * @param color1 defines the color to affect to the specified gradient
  124509. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124510. * @returns the current particle system
  124511. */
  124512. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124513. /**
  124514. * Remove a specific color gradient
  124515. * @param gradient defines the gradient to remove
  124516. * @returns the current particle system
  124517. */
  124518. removeColorGradient(gradient: number): GPUParticleSystem;
  124519. private _angularSpeedGradientsTexture;
  124520. private _sizeGradientsTexture;
  124521. private _velocityGradientsTexture;
  124522. private _limitVelocityGradientsTexture;
  124523. private _dragGradientsTexture;
  124524. private _addFactorGradient;
  124525. /**
  124526. * Adds a new size gradient
  124527. * @param gradient defines the gradient to use (between 0 and 1)
  124528. * @param factor defines the size factor to affect to the specified gradient
  124529. * @returns the current particle system
  124530. */
  124531. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124532. /**
  124533. * Remove a specific size gradient
  124534. * @param gradient defines the gradient to remove
  124535. * @returns the current particle system
  124536. */
  124537. removeSizeGradient(gradient: number): GPUParticleSystem;
  124538. /**
  124539. * Adds a new angular speed gradient
  124540. * @param gradient defines the gradient to use (between 0 and 1)
  124541. * @param factor defines the angular speed to affect to the specified gradient
  124542. * @returns the current particle system
  124543. */
  124544. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124545. /**
  124546. * Remove a specific angular speed gradient
  124547. * @param gradient defines the gradient to remove
  124548. * @returns the current particle system
  124549. */
  124550. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124551. /**
  124552. * Adds a new velocity gradient
  124553. * @param gradient defines the gradient to use (between 0 and 1)
  124554. * @param factor defines the velocity to affect to the specified gradient
  124555. * @returns the current particle system
  124556. */
  124557. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124558. /**
  124559. * Remove a specific velocity gradient
  124560. * @param gradient defines the gradient to remove
  124561. * @returns the current particle system
  124562. */
  124563. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124564. /**
  124565. * Adds a new limit velocity gradient
  124566. * @param gradient defines the gradient to use (between 0 and 1)
  124567. * @param factor defines the limit velocity value to affect to the specified gradient
  124568. * @returns the current particle system
  124569. */
  124570. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124571. /**
  124572. * Remove a specific limit velocity gradient
  124573. * @param gradient defines the gradient to remove
  124574. * @returns the current particle system
  124575. */
  124576. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124577. /**
  124578. * Adds a new drag gradient
  124579. * @param gradient defines the gradient to use (between 0 and 1)
  124580. * @param factor defines the drag value to affect to the specified gradient
  124581. * @returns the current particle system
  124582. */
  124583. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124584. /**
  124585. * Remove a specific drag gradient
  124586. * @param gradient defines the gradient to remove
  124587. * @returns the current particle system
  124588. */
  124589. removeDragGradient(gradient: number): GPUParticleSystem;
  124590. /**
  124591. * Not supported by GPUParticleSystem
  124592. * @param gradient defines the gradient to use (between 0 and 1)
  124593. * @param factor defines the emit rate value to affect to the specified gradient
  124594. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124595. * @returns the current particle system
  124596. */
  124597. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124598. /**
  124599. * Not supported by GPUParticleSystem
  124600. * @param gradient defines the gradient to remove
  124601. * @returns the current particle system
  124602. */
  124603. removeEmitRateGradient(gradient: number): IParticleSystem;
  124604. /**
  124605. * Not supported by GPUParticleSystem
  124606. * @param gradient defines the gradient to use (between 0 and 1)
  124607. * @param factor defines the start size value to affect to the specified gradient
  124608. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124609. * @returns the current particle system
  124610. */
  124611. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124612. /**
  124613. * Not supported by GPUParticleSystem
  124614. * @param gradient defines the gradient to remove
  124615. * @returns the current particle system
  124616. */
  124617. removeStartSizeGradient(gradient: number): IParticleSystem;
  124618. /**
  124619. * Not supported by GPUParticleSystem
  124620. * @param gradient defines the gradient to use (between 0 and 1)
  124621. * @param min defines the color remap minimal range
  124622. * @param max defines the color remap maximal range
  124623. * @returns the current particle system
  124624. */
  124625. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124626. /**
  124627. * Not supported by GPUParticleSystem
  124628. * @param gradient defines the gradient to remove
  124629. * @returns the current particle system
  124630. */
  124631. removeColorRemapGradient(): IParticleSystem;
  124632. /**
  124633. * Not supported by GPUParticleSystem
  124634. * @param gradient defines the gradient to use (between 0 and 1)
  124635. * @param min defines the alpha remap minimal range
  124636. * @param max defines the alpha remap maximal range
  124637. * @returns the current particle system
  124638. */
  124639. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124640. /**
  124641. * Not supported by GPUParticleSystem
  124642. * @param gradient defines the gradient to remove
  124643. * @returns the current particle system
  124644. */
  124645. removeAlphaRemapGradient(): IParticleSystem;
  124646. /**
  124647. * Not supported by GPUParticleSystem
  124648. * @param gradient defines the gradient to use (between 0 and 1)
  124649. * @param color defines the color to affect to the specified gradient
  124650. * @returns the current particle system
  124651. */
  124652. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124653. /**
  124654. * Not supported by GPUParticleSystem
  124655. * @param gradient defines the gradient to remove
  124656. * @returns the current particle system
  124657. */
  124658. removeRampGradient(): IParticleSystem;
  124659. /**
  124660. * Not supported by GPUParticleSystem
  124661. * @returns the list of ramp gradients
  124662. */
  124663. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124664. /**
  124665. * Not supported by GPUParticleSystem
  124666. * Gets or sets a boolean indicating that ramp gradients must be used
  124667. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124668. */
  124669. useRampGradients: boolean;
  124670. /**
  124671. * Not supported by GPUParticleSystem
  124672. * @param gradient defines the gradient to use (between 0 and 1)
  124673. * @param factor defines the life time factor to affect to the specified gradient
  124674. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124675. * @returns the current particle system
  124676. */
  124677. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124678. /**
  124679. * Not supported by GPUParticleSystem
  124680. * @param gradient defines the gradient to remove
  124681. * @returns the current particle system
  124682. */
  124683. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124684. /**
  124685. * Instantiates a GPU particle system.
  124686. * 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.
  124687. * @param name The name of the particle system
  124688. * @param options The options used to create the system
  124689. * @param scene The scene the particle system belongs to
  124690. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124691. */
  124692. constructor(name: string, options: Partial<{
  124693. capacity: number;
  124694. randomTextureSize: number;
  124695. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124696. protected _reset(): void;
  124697. private _createUpdateVAO;
  124698. private _createRenderVAO;
  124699. private _initialize;
  124700. /** @hidden */
  124701. _recreateUpdateEffect(): void;
  124702. /** @hidden */
  124703. _recreateRenderEffect(): void;
  124704. /**
  124705. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124706. * @param preWarm defines if we are in the pre-warmimg phase
  124707. */
  124708. animate(preWarm?: boolean): void;
  124709. private _createFactorGradientTexture;
  124710. private _createSizeGradientTexture;
  124711. private _createAngularSpeedGradientTexture;
  124712. private _createVelocityGradientTexture;
  124713. private _createLimitVelocityGradientTexture;
  124714. private _createDragGradientTexture;
  124715. private _createColorGradientTexture;
  124716. /**
  124717. * Renders the particle system in its current state
  124718. * @param preWarm defines if the system should only update the particles but not render them
  124719. * @returns the current number of particles
  124720. */
  124721. render(preWarm?: boolean): number;
  124722. /**
  124723. * Rebuilds the particle system
  124724. */
  124725. rebuild(): void;
  124726. private _releaseBuffers;
  124727. private _releaseVAOs;
  124728. /**
  124729. * Disposes the particle system and free the associated resources
  124730. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124731. */
  124732. dispose(disposeTexture?: boolean): void;
  124733. /**
  124734. * Clones the particle system.
  124735. * @param name The name of the cloned object
  124736. * @param newEmitter The new emitter to use
  124737. * @returns the cloned particle system
  124738. */
  124739. clone(name: string, newEmitter: any): GPUParticleSystem;
  124740. /**
  124741. * Serializes the particle system to a JSON object.
  124742. * @returns the JSON object
  124743. */
  124744. serialize(): any;
  124745. /**
  124746. * Parses a JSON object to create a GPU particle system.
  124747. * @param parsedParticleSystem The JSON object to parse
  124748. * @param scene The scene to create the particle system in
  124749. * @param rootUrl The root url to use to load external dependencies like texture
  124750. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124751. * @returns the parsed GPU particle system
  124752. */
  124753. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124754. }
  124755. }
  124756. declare module BABYLON {
  124757. /**
  124758. * Represents a set of particle systems working together to create a specific effect
  124759. */
  124760. export class ParticleSystemSet implements IDisposable {
  124761. private _emitterCreationOptions;
  124762. private _emitterNode;
  124763. /**
  124764. * Gets the particle system list
  124765. */
  124766. systems: IParticleSystem[];
  124767. /**
  124768. * Gets the emitter node used with this set
  124769. */
  124770. readonly emitterNode: Nullable<TransformNode>;
  124771. /**
  124772. * Creates a new emitter mesh as a sphere
  124773. * @param options defines the options used to create the sphere
  124774. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124775. * @param scene defines the hosting scene
  124776. */
  124777. setEmitterAsSphere(options: {
  124778. diameter: number;
  124779. segments: number;
  124780. color: Color3;
  124781. }, renderingGroupId: number, scene: Scene): void;
  124782. /**
  124783. * Starts all particle systems of the set
  124784. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124785. */
  124786. start(emitter?: AbstractMesh): void;
  124787. /**
  124788. * Release all associated resources
  124789. */
  124790. dispose(): void;
  124791. /**
  124792. * Serialize the set into a JSON compatible object
  124793. * @returns a JSON compatible representation of the set
  124794. */
  124795. serialize(): any;
  124796. /**
  124797. * Parse a new ParticleSystemSet from a serialized source
  124798. * @param data defines a JSON compatible representation of the set
  124799. * @param scene defines the hosting scene
  124800. * @param gpu defines if we want GPU particles or CPU particles
  124801. * @returns a new ParticleSystemSet
  124802. */
  124803. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124804. }
  124805. }
  124806. declare module BABYLON {
  124807. /**
  124808. * This class is made for on one-liner static method to help creating particle system set.
  124809. */
  124810. export class ParticleHelper {
  124811. /**
  124812. * Gets or sets base Assets URL
  124813. */
  124814. static BaseAssetsUrl: string;
  124815. /**
  124816. * Create a default particle system that you can tweak
  124817. * @param emitter defines the emitter to use
  124818. * @param capacity defines the system capacity (default is 500 particles)
  124819. * @param scene defines the hosting scene
  124820. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  124821. * @returns the new Particle system
  124822. */
  124823. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  124824. /**
  124825. * This is the main static method (one-liner) of this helper to create different particle systems
  124826. * @param type This string represents the type to the particle system to create
  124827. * @param scene The scene where the particle system should live
  124828. * @param gpu If the system will use gpu
  124829. * @returns the ParticleSystemSet created
  124830. */
  124831. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  124832. /**
  124833. * Static function used to export a particle system to a ParticleSystemSet variable.
  124834. * Please note that the emitter shape is not exported
  124835. * @param systems defines the particle systems to export
  124836. * @returns the created particle system set
  124837. */
  124838. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  124839. }
  124840. }
  124841. declare module BABYLON {
  124842. interface Engine {
  124843. /**
  124844. * Create an effect to use with particle systems.
  124845. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  124846. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  124847. * @param uniformsNames defines a list of attribute names
  124848. * @param samplers defines an array of string used to represent textures
  124849. * @param defines defines the string containing the defines to use to compile the shaders
  124850. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  124851. * @param onCompiled defines a function to call when the effect creation is successful
  124852. * @param onError defines a function to call when the effect creation has failed
  124853. * @returns the new Effect
  124854. */
  124855. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  124856. }
  124857. interface Mesh {
  124858. /**
  124859. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  124860. * @returns an array of IParticleSystem
  124861. */
  124862. getEmittedParticleSystems(): IParticleSystem[];
  124863. /**
  124864. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  124865. * @returns an array of IParticleSystem
  124866. */
  124867. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  124868. }
  124869. /**
  124870. * @hidden
  124871. */
  124872. export var _IDoNeedToBeInTheBuild: number;
  124873. }
  124874. declare module BABYLON {
  124875. interface Scene {
  124876. /** @hidden (Backing field) */
  124877. _physicsEngine: Nullable<IPhysicsEngine>;
  124878. /**
  124879. * Gets the current physics engine
  124880. * @returns a IPhysicsEngine or null if none attached
  124881. */
  124882. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  124883. /**
  124884. * Enables physics to the current scene
  124885. * @param gravity defines the scene's gravity for the physics engine
  124886. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  124887. * @return a boolean indicating if the physics engine was initialized
  124888. */
  124889. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  124890. /**
  124891. * Disables and disposes the physics engine associated with the scene
  124892. */
  124893. disablePhysicsEngine(): void;
  124894. /**
  124895. * Gets a boolean indicating if there is an active physics engine
  124896. * @returns a boolean indicating if there is an active physics engine
  124897. */
  124898. isPhysicsEnabled(): boolean;
  124899. /**
  124900. * Deletes a physics compound impostor
  124901. * @param compound defines the compound to delete
  124902. */
  124903. deleteCompoundImpostor(compound: any): void;
  124904. /**
  124905. * An event triggered when physic simulation is about to be run
  124906. */
  124907. onBeforePhysicsObservable: Observable<Scene>;
  124908. /**
  124909. * An event triggered when physic simulation has been done
  124910. */
  124911. onAfterPhysicsObservable: Observable<Scene>;
  124912. }
  124913. interface AbstractMesh {
  124914. /** @hidden */
  124915. _physicsImpostor: Nullable<PhysicsImpostor>;
  124916. /**
  124917. * Gets or sets impostor used for physic simulation
  124918. * @see http://doc.babylonjs.com/features/physics_engine
  124919. */
  124920. physicsImpostor: Nullable<PhysicsImpostor>;
  124921. /**
  124922. * Gets the current physics impostor
  124923. * @see http://doc.babylonjs.com/features/physics_engine
  124924. * @returns a physics impostor or null
  124925. */
  124926. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  124927. /** Apply a physic impulse to the mesh
  124928. * @param force defines the force to apply
  124929. * @param contactPoint defines where to apply the force
  124930. * @returns the current mesh
  124931. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  124932. */
  124933. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  124934. /**
  124935. * Creates a physic joint between two meshes
  124936. * @param otherMesh defines the other mesh to use
  124937. * @param pivot1 defines the pivot to use on this mesh
  124938. * @param pivot2 defines the pivot to use on the other mesh
  124939. * @param options defines additional options (can be plugin dependent)
  124940. * @returns the current mesh
  124941. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  124942. */
  124943. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  124944. /** @hidden */
  124945. _disposePhysicsObserver: Nullable<Observer<Node>>;
  124946. }
  124947. /**
  124948. * Defines the physics engine scene component responsible to manage a physics engine
  124949. */
  124950. export class PhysicsEngineSceneComponent implements ISceneComponent {
  124951. /**
  124952. * The component name helpful to identify the component in the list of scene components.
  124953. */
  124954. readonly name: string;
  124955. /**
  124956. * The scene the component belongs to.
  124957. */
  124958. scene: Scene;
  124959. /**
  124960. * Creates a new instance of the component for the given scene
  124961. * @param scene Defines the scene to register the component in
  124962. */
  124963. constructor(scene: Scene);
  124964. /**
  124965. * Registers the component in a given scene
  124966. */
  124967. register(): void;
  124968. /**
  124969. * Rebuilds the elements related to this component in case of
  124970. * context lost for instance.
  124971. */
  124972. rebuild(): void;
  124973. /**
  124974. * Disposes the component and the associated ressources
  124975. */
  124976. dispose(): void;
  124977. }
  124978. }
  124979. declare module BABYLON {
  124980. /**
  124981. * A helper for physics simulations
  124982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  124983. */
  124984. export class PhysicsHelper {
  124985. private _scene;
  124986. private _physicsEngine;
  124987. /**
  124988. * Initializes the Physics helper
  124989. * @param scene Babylon.js scene
  124990. */
  124991. constructor(scene: Scene);
  124992. /**
  124993. * Applies a radial explosion impulse
  124994. * @param origin the origin of the explosion
  124995. * @param radiusOrEventOptions the radius or the options of radial explosion
  124996. * @param strength the explosion strength
  124997. * @param falloff possible options: Constant & Linear. Defaults to Constant
  124998. * @returns A physics radial explosion event, or null
  124999. */
  125000. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125001. /**
  125002. * Applies a radial explosion force
  125003. * @param origin the origin of the explosion
  125004. * @param radiusOrEventOptions the radius or the options of radial explosion
  125005. * @param strength the explosion strength
  125006. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125007. * @returns A physics radial explosion event, or null
  125008. */
  125009. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125010. /**
  125011. * Creates a gravitational field
  125012. * @param origin the origin of the explosion
  125013. * @param radiusOrEventOptions the radius or the options of radial explosion
  125014. * @param strength the explosion strength
  125015. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125016. * @returns A physics gravitational field event, or null
  125017. */
  125018. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125019. /**
  125020. * Creates a physics updraft event
  125021. * @param origin the origin of the updraft
  125022. * @param radiusOrEventOptions the radius or the options of the updraft
  125023. * @param strength the strength of the updraft
  125024. * @param height the height of the updraft
  125025. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125026. * @returns A physics updraft event, or null
  125027. */
  125028. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125029. /**
  125030. * Creates a physics vortex event
  125031. * @param origin the of the vortex
  125032. * @param radiusOrEventOptions the radius or the options of the vortex
  125033. * @param strength the strength of the vortex
  125034. * @param height the height of the vortex
  125035. * @returns a Physics vortex event, or null
  125036. * A physics vortex event or null
  125037. */
  125038. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125039. }
  125040. /**
  125041. * Represents a physics radial explosion event
  125042. */
  125043. class PhysicsRadialExplosionEvent {
  125044. private _scene;
  125045. private _options;
  125046. private _sphere;
  125047. private _dataFetched;
  125048. /**
  125049. * Initializes a radial explosioin event
  125050. * @param _scene BabylonJS scene
  125051. * @param _options The options for the vortex event
  125052. */
  125053. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125054. /**
  125055. * Returns the data related to the radial explosion event (sphere).
  125056. * @returns The radial explosion event data
  125057. */
  125058. getData(): PhysicsRadialExplosionEventData;
  125059. /**
  125060. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125061. * @param impostor A physics imposter
  125062. * @param origin the origin of the explosion
  125063. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125064. */
  125065. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125066. /**
  125067. * Triggers affecterd impostors callbacks
  125068. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125069. */
  125070. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125071. /**
  125072. * Disposes the sphere.
  125073. * @param force Specifies if the sphere should be disposed by force
  125074. */
  125075. dispose(force?: boolean): void;
  125076. /*** Helpers ***/
  125077. private _prepareSphere;
  125078. private _intersectsWithSphere;
  125079. }
  125080. /**
  125081. * Represents a gravitational field event
  125082. */
  125083. class PhysicsGravitationalFieldEvent {
  125084. private _physicsHelper;
  125085. private _scene;
  125086. private _origin;
  125087. private _options;
  125088. private _tickCallback;
  125089. private _sphere;
  125090. private _dataFetched;
  125091. /**
  125092. * Initializes the physics gravitational field event
  125093. * @param _physicsHelper A physics helper
  125094. * @param _scene BabylonJS scene
  125095. * @param _origin The origin position of the gravitational field event
  125096. * @param _options The options for the vortex event
  125097. */
  125098. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125099. /**
  125100. * Returns the data related to the gravitational field event (sphere).
  125101. * @returns A gravitational field event
  125102. */
  125103. getData(): PhysicsGravitationalFieldEventData;
  125104. /**
  125105. * Enables the gravitational field.
  125106. */
  125107. enable(): void;
  125108. /**
  125109. * Disables the gravitational field.
  125110. */
  125111. disable(): void;
  125112. /**
  125113. * Disposes the sphere.
  125114. * @param force The force to dispose from the gravitational field event
  125115. */
  125116. dispose(force?: boolean): void;
  125117. private _tick;
  125118. }
  125119. /**
  125120. * Represents a physics updraft event
  125121. */
  125122. class PhysicsUpdraftEvent {
  125123. private _scene;
  125124. private _origin;
  125125. private _options;
  125126. private _physicsEngine;
  125127. private _originTop;
  125128. private _originDirection;
  125129. private _tickCallback;
  125130. private _cylinder;
  125131. private _cylinderPosition;
  125132. private _dataFetched;
  125133. /**
  125134. * Initializes the physics updraft event
  125135. * @param _scene BabylonJS scene
  125136. * @param _origin The origin position of the updraft
  125137. * @param _options The options for the updraft event
  125138. */
  125139. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125140. /**
  125141. * Returns the data related to the updraft event (cylinder).
  125142. * @returns A physics updraft event
  125143. */
  125144. getData(): PhysicsUpdraftEventData;
  125145. /**
  125146. * Enables the updraft.
  125147. */
  125148. enable(): void;
  125149. /**
  125150. * Disables the updraft.
  125151. */
  125152. disable(): void;
  125153. /**
  125154. * Disposes the cylinder.
  125155. * @param force Specifies if the updraft should be disposed by force
  125156. */
  125157. dispose(force?: boolean): void;
  125158. private getImpostorHitData;
  125159. private _tick;
  125160. /*** Helpers ***/
  125161. private _prepareCylinder;
  125162. private _intersectsWithCylinder;
  125163. }
  125164. /**
  125165. * Represents a physics vortex event
  125166. */
  125167. class PhysicsVortexEvent {
  125168. private _scene;
  125169. private _origin;
  125170. private _options;
  125171. private _physicsEngine;
  125172. private _originTop;
  125173. private _tickCallback;
  125174. private _cylinder;
  125175. private _cylinderPosition;
  125176. private _dataFetched;
  125177. /**
  125178. * Initializes the physics vortex event
  125179. * @param _scene The BabylonJS scene
  125180. * @param _origin The origin position of the vortex
  125181. * @param _options The options for the vortex event
  125182. */
  125183. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125184. /**
  125185. * Returns the data related to the vortex event (cylinder).
  125186. * @returns The physics vortex event data
  125187. */
  125188. getData(): PhysicsVortexEventData;
  125189. /**
  125190. * Enables the vortex.
  125191. */
  125192. enable(): void;
  125193. /**
  125194. * Disables the cortex.
  125195. */
  125196. disable(): void;
  125197. /**
  125198. * Disposes the sphere.
  125199. * @param force
  125200. */
  125201. dispose(force?: boolean): void;
  125202. private getImpostorHitData;
  125203. private _tick;
  125204. /*** Helpers ***/
  125205. private _prepareCylinder;
  125206. private _intersectsWithCylinder;
  125207. }
  125208. /**
  125209. * Options fot the radial explosion event
  125210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125211. */
  125212. export class PhysicsRadialExplosionEventOptions {
  125213. /**
  125214. * The radius of the sphere for the radial explosion.
  125215. */
  125216. radius: number;
  125217. /**
  125218. * The strenth of the explosion.
  125219. */
  125220. strength: number;
  125221. /**
  125222. * The strenght of the force in correspondence to the distance of the affected object
  125223. */
  125224. falloff: PhysicsRadialImpulseFalloff;
  125225. /**
  125226. * Sphere options for the radial explosion.
  125227. */
  125228. sphere: {
  125229. segments: number;
  125230. diameter: number;
  125231. };
  125232. /**
  125233. * Sphere options for the radial explosion.
  125234. */
  125235. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125236. }
  125237. /**
  125238. * Options fot the updraft event
  125239. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125240. */
  125241. export class PhysicsUpdraftEventOptions {
  125242. /**
  125243. * The radius of the cylinder for the vortex
  125244. */
  125245. radius: number;
  125246. /**
  125247. * The strenth of the updraft.
  125248. */
  125249. strength: number;
  125250. /**
  125251. * The height of the cylinder for the updraft.
  125252. */
  125253. height: number;
  125254. /**
  125255. * The mode for the the updraft.
  125256. */
  125257. updraftMode: PhysicsUpdraftMode;
  125258. }
  125259. /**
  125260. * Options fot the vortex event
  125261. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125262. */
  125263. export class PhysicsVortexEventOptions {
  125264. /**
  125265. * The radius of the cylinder for the vortex
  125266. */
  125267. radius: number;
  125268. /**
  125269. * The strenth of the vortex.
  125270. */
  125271. strength: number;
  125272. /**
  125273. * The height of the cylinder for the vortex.
  125274. */
  125275. height: number;
  125276. /**
  125277. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125278. */
  125279. centripetalForceThreshold: number;
  125280. /**
  125281. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125282. */
  125283. centripetalForceMultiplier: number;
  125284. /**
  125285. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125286. */
  125287. centrifugalForceMultiplier: number;
  125288. /**
  125289. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125290. */
  125291. updraftForceMultiplier: number;
  125292. }
  125293. /**
  125294. * The strenght of the force in correspondence to the distance of the affected object
  125295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125296. */
  125297. export enum PhysicsRadialImpulseFalloff {
  125298. /** Defines that impulse is constant in strength across it's whole radius */
  125299. Constant = 0,
  125300. /** Defines that impulse gets weaker if it's further from the origin */
  125301. Linear = 1
  125302. }
  125303. /**
  125304. * The strength of the force in correspondence to the distance of the affected object
  125305. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125306. */
  125307. export enum PhysicsUpdraftMode {
  125308. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125309. Center = 0,
  125310. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125311. Perpendicular = 1
  125312. }
  125313. /**
  125314. * Interface for a physics hit data
  125315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125316. */
  125317. export interface PhysicsHitData {
  125318. /**
  125319. * The force applied at the contact point
  125320. */
  125321. force: Vector3;
  125322. /**
  125323. * The contact point
  125324. */
  125325. contactPoint: Vector3;
  125326. /**
  125327. * The distance from the origin to the contact point
  125328. */
  125329. distanceFromOrigin: number;
  125330. }
  125331. /**
  125332. * Interface for radial explosion event data
  125333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125334. */
  125335. export interface PhysicsRadialExplosionEventData {
  125336. /**
  125337. * A sphere used for the radial explosion event
  125338. */
  125339. sphere: Mesh;
  125340. }
  125341. /**
  125342. * Interface for gravitational field event data
  125343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125344. */
  125345. export interface PhysicsGravitationalFieldEventData {
  125346. /**
  125347. * A sphere mesh used for the gravitational field event
  125348. */
  125349. sphere: Mesh;
  125350. }
  125351. /**
  125352. * Interface for updraft event data
  125353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125354. */
  125355. export interface PhysicsUpdraftEventData {
  125356. /**
  125357. * A cylinder used for the updraft event
  125358. */
  125359. cylinder: Mesh;
  125360. }
  125361. /**
  125362. * Interface for vortex event data
  125363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125364. */
  125365. export interface PhysicsVortexEventData {
  125366. /**
  125367. * A cylinder used for the vortex event
  125368. */
  125369. cylinder: Mesh;
  125370. }
  125371. /**
  125372. * Interface for an affected physics impostor
  125373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125374. */
  125375. export interface PhysicsAffectedImpostorWithData {
  125376. /**
  125377. * The impostor affected by the effect
  125378. */
  125379. impostor: PhysicsImpostor;
  125380. /**
  125381. * The data about the hit/horce from the explosion
  125382. */
  125383. hitData: PhysicsHitData;
  125384. }
  125385. }
  125386. declare module BABYLON {
  125387. /** @hidden */
  125388. export var blackAndWhitePixelShader: {
  125389. name: string;
  125390. shader: string;
  125391. };
  125392. }
  125393. declare module BABYLON {
  125394. /**
  125395. * Post process used to render in black and white
  125396. */
  125397. export class BlackAndWhitePostProcess extends PostProcess {
  125398. /**
  125399. * Linear about to convert he result to black and white (default: 1)
  125400. */
  125401. degree: number;
  125402. /**
  125403. * Creates a black and white post process
  125404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125405. * @param name The name of the effect.
  125406. * @param options The required width/height ratio to downsize to before computing the render pass.
  125407. * @param camera The camera to apply the render pass to.
  125408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125409. * @param engine The engine which the post process will be applied. (default: current engine)
  125410. * @param reusable If the post process can be reused on the same frame. (default: false)
  125411. */
  125412. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125413. }
  125414. }
  125415. declare module BABYLON {
  125416. /**
  125417. * This represents a set of one or more post processes in Babylon.
  125418. * A post process can be used to apply a shader to a texture after it is rendered.
  125419. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125420. */
  125421. export class PostProcessRenderEffect {
  125422. private _postProcesses;
  125423. private _getPostProcesses;
  125424. private _singleInstance;
  125425. private _cameras;
  125426. private _indicesForCamera;
  125427. /**
  125428. * Name of the effect
  125429. * @hidden
  125430. */
  125431. _name: string;
  125432. /**
  125433. * Instantiates a post process render effect.
  125434. * A post process can be used to apply a shader to a texture after it is rendered.
  125435. * @param engine The engine the effect is tied to
  125436. * @param name The name of the effect
  125437. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125438. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125439. */
  125440. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125441. /**
  125442. * Checks if all the post processes in the effect are supported.
  125443. */
  125444. readonly isSupported: boolean;
  125445. /**
  125446. * Updates the current state of the effect
  125447. * @hidden
  125448. */
  125449. _update(): void;
  125450. /**
  125451. * Attaches the effect on cameras
  125452. * @param cameras The camera to attach to.
  125453. * @hidden
  125454. */
  125455. _attachCameras(cameras: Camera): void;
  125456. /**
  125457. * Attaches the effect on cameras
  125458. * @param cameras The camera to attach to.
  125459. * @hidden
  125460. */
  125461. _attachCameras(cameras: Camera[]): void;
  125462. /**
  125463. * Detaches the effect on cameras
  125464. * @param cameras The camera to detatch from.
  125465. * @hidden
  125466. */
  125467. _detachCameras(cameras: Camera): void;
  125468. /**
  125469. * Detatches the effect on cameras
  125470. * @param cameras The camera to detatch from.
  125471. * @hidden
  125472. */
  125473. _detachCameras(cameras: Camera[]): void;
  125474. /**
  125475. * Enables the effect on given cameras
  125476. * @param cameras The camera to enable.
  125477. * @hidden
  125478. */
  125479. _enable(cameras: Camera): void;
  125480. /**
  125481. * Enables the effect on given cameras
  125482. * @param cameras The camera to enable.
  125483. * @hidden
  125484. */
  125485. _enable(cameras: Nullable<Camera[]>): void;
  125486. /**
  125487. * Disables the effect on the given cameras
  125488. * @param cameras The camera to disable.
  125489. * @hidden
  125490. */
  125491. _disable(cameras: Camera): void;
  125492. /**
  125493. * Disables the effect on the given cameras
  125494. * @param cameras The camera to disable.
  125495. * @hidden
  125496. */
  125497. _disable(cameras: Nullable<Camera[]>): void;
  125498. /**
  125499. * Gets a list of the post processes contained in the effect.
  125500. * @param camera The camera to get the post processes on.
  125501. * @returns The list of the post processes in the effect.
  125502. */
  125503. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125504. }
  125505. }
  125506. declare module BABYLON {
  125507. /** @hidden */
  125508. export var extractHighlightsPixelShader: {
  125509. name: string;
  125510. shader: string;
  125511. };
  125512. }
  125513. declare module BABYLON {
  125514. /**
  125515. * 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.
  125516. */
  125517. export class ExtractHighlightsPostProcess extends PostProcess {
  125518. /**
  125519. * The luminance threshold, pixels below this value will be set to black.
  125520. */
  125521. threshold: number;
  125522. /** @hidden */
  125523. _exposure: number;
  125524. /**
  125525. * Post process which has the input texture to be used when performing highlight extraction
  125526. * @hidden
  125527. */
  125528. _inputPostProcess: Nullable<PostProcess>;
  125529. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125530. }
  125531. }
  125532. declare module BABYLON {
  125533. /** @hidden */
  125534. export var bloomMergePixelShader: {
  125535. name: string;
  125536. shader: string;
  125537. };
  125538. }
  125539. declare module BABYLON {
  125540. /**
  125541. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125542. */
  125543. export class BloomMergePostProcess extends PostProcess {
  125544. /** Weight of the bloom to be added to the original input. */
  125545. weight: number;
  125546. /**
  125547. * Creates a new instance of @see BloomMergePostProcess
  125548. * @param name The name of the effect.
  125549. * @param originalFromInput Post process which's input will be used for the merge.
  125550. * @param blurred Blurred highlights post process which's output will be used.
  125551. * @param weight Weight of the bloom to be added to the original input.
  125552. * @param options The required width/height ratio to downsize to before computing the render pass.
  125553. * @param camera The camera to apply the render pass to.
  125554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125555. * @param engine The engine which the post process will be applied. (default: current engine)
  125556. * @param reusable If the post process can be reused on the same frame. (default: false)
  125557. * @param textureType Type of textures used when performing the post process. (default: 0)
  125558. * @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)
  125559. */
  125560. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125561. /** Weight of the bloom to be added to the original input. */
  125562. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125563. }
  125564. }
  125565. declare module BABYLON {
  125566. /**
  125567. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125568. */
  125569. export class BloomEffect extends PostProcessRenderEffect {
  125570. private bloomScale;
  125571. /**
  125572. * @hidden Internal
  125573. */
  125574. _effects: Array<PostProcess>;
  125575. /**
  125576. * @hidden Internal
  125577. */
  125578. _downscale: ExtractHighlightsPostProcess;
  125579. private _blurX;
  125580. private _blurY;
  125581. private _merge;
  125582. /**
  125583. * The luminance threshold to find bright areas of the image to bloom.
  125584. */
  125585. threshold: number;
  125586. /**
  125587. * The strength of the bloom.
  125588. */
  125589. weight: number;
  125590. /**
  125591. * Specifies the size of the bloom blur kernel, relative to the final output size
  125592. */
  125593. kernel: number;
  125594. /**
  125595. * Creates a new instance of @see BloomEffect
  125596. * @param scene The scene the effect belongs to.
  125597. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125598. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125599. * @param bloomWeight The the strength of bloom.
  125600. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125601. * @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)
  125602. */
  125603. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125604. /**
  125605. * Disposes each of the internal effects for a given camera.
  125606. * @param camera The camera to dispose the effect on.
  125607. */
  125608. disposeEffects(camera: Camera): void;
  125609. /**
  125610. * @hidden Internal
  125611. */
  125612. _updateEffects(): void;
  125613. /**
  125614. * Internal
  125615. * @returns if all the contained post processes are ready.
  125616. * @hidden
  125617. */
  125618. _isReady(): boolean;
  125619. }
  125620. }
  125621. declare module BABYLON {
  125622. /** @hidden */
  125623. export var chromaticAberrationPixelShader: {
  125624. name: string;
  125625. shader: string;
  125626. };
  125627. }
  125628. declare module BABYLON {
  125629. /**
  125630. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125631. */
  125632. export class ChromaticAberrationPostProcess extends PostProcess {
  125633. /**
  125634. * The amount of seperation of rgb channels (default: 30)
  125635. */
  125636. aberrationAmount: number;
  125637. /**
  125638. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125639. */
  125640. radialIntensity: number;
  125641. /**
  125642. * 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))
  125643. */
  125644. direction: Vector2;
  125645. /**
  125646. * 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))
  125647. */
  125648. centerPosition: Vector2;
  125649. /**
  125650. * Creates a new instance ChromaticAberrationPostProcess
  125651. * @param name The name of the effect.
  125652. * @param screenWidth The width of the screen to apply the effect on.
  125653. * @param screenHeight The height of the screen to apply the effect on.
  125654. * @param options The required width/height ratio to downsize to before computing the render pass.
  125655. * @param camera The camera to apply the render pass to.
  125656. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125657. * @param engine The engine which the post process will be applied. (default: current engine)
  125658. * @param reusable If the post process can be reused on the same frame. (default: false)
  125659. * @param textureType Type of textures used when performing the post process. (default: 0)
  125660. * @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)
  125661. */
  125662. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125663. }
  125664. }
  125665. declare module BABYLON {
  125666. /** @hidden */
  125667. export var circleOfConfusionPixelShader: {
  125668. name: string;
  125669. shader: string;
  125670. };
  125671. }
  125672. declare module BABYLON {
  125673. /**
  125674. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125675. */
  125676. export class CircleOfConfusionPostProcess extends PostProcess {
  125677. /**
  125678. * 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.
  125679. */
  125680. lensSize: number;
  125681. /**
  125682. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125683. */
  125684. fStop: number;
  125685. /**
  125686. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125687. */
  125688. focusDistance: number;
  125689. /**
  125690. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125691. */
  125692. focalLength: number;
  125693. private _depthTexture;
  125694. /**
  125695. * Creates a new instance CircleOfConfusionPostProcess
  125696. * @param name The name of the effect.
  125697. * @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.
  125698. * @param options The required width/height ratio to downsize to before computing the render pass.
  125699. * @param camera The camera to apply the render pass to.
  125700. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125701. * @param engine The engine which the post process will be applied. (default: current engine)
  125702. * @param reusable If the post process can be reused on the same frame. (default: false)
  125703. * @param textureType Type of textures used when performing the post process. (default: 0)
  125704. * @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)
  125705. */
  125706. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125707. /**
  125708. * 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.
  125709. */
  125710. depthTexture: RenderTargetTexture;
  125711. }
  125712. }
  125713. declare module BABYLON {
  125714. /** @hidden */
  125715. export var colorCorrectionPixelShader: {
  125716. name: string;
  125717. shader: string;
  125718. };
  125719. }
  125720. declare module BABYLON {
  125721. /**
  125722. *
  125723. * This post-process allows the modification of rendered colors by using
  125724. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125725. *
  125726. * The object needs to be provided an url to a texture containing the color
  125727. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125728. * Use an image editing software to tweak the LUT to match your needs.
  125729. *
  125730. * For an example of a color LUT, see here:
  125731. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125732. * For explanations on color grading, see here:
  125733. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125734. *
  125735. */
  125736. export class ColorCorrectionPostProcess extends PostProcess {
  125737. private _colorTableTexture;
  125738. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125739. }
  125740. }
  125741. declare module BABYLON {
  125742. /** @hidden */
  125743. export var convolutionPixelShader: {
  125744. name: string;
  125745. shader: string;
  125746. };
  125747. }
  125748. declare module BABYLON {
  125749. /**
  125750. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125751. * input texture to perform effects such as edge detection or sharpening
  125752. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125753. */
  125754. export class ConvolutionPostProcess extends PostProcess {
  125755. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125756. kernel: number[];
  125757. /**
  125758. * Creates a new instance ConvolutionPostProcess
  125759. * @param name The name of the effect.
  125760. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125761. * @param options The required width/height ratio to downsize to before computing the render pass.
  125762. * @param camera The camera to apply the render pass to.
  125763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125764. * @param engine The engine which the post process will be applied. (default: current engine)
  125765. * @param reusable If the post process can be reused on the same frame. (default: false)
  125766. * @param textureType Type of textures used when performing the post process. (default: 0)
  125767. */
  125768. constructor(name: string,
  125769. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125770. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125771. /**
  125772. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125773. */
  125774. static EdgeDetect0Kernel: number[];
  125775. /**
  125776. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125777. */
  125778. static EdgeDetect1Kernel: number[];
  125779. /**
  125780. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125781. */
  125782. static EdgeDetect2Kernel: number[];
  125783. /**
  125784. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125785. */
  125786. static SharpenKernel: number[];
  125787. /**
  125788. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125789. */
  125790. static EmbossKernel: number[];
  125791. /**
  125792. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125793. */
  125794. static GaussianKernel: number[];
  125795. }
  125796. }
  125797. declare module BABYLON {
  125798. /**
  125799. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125800. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125801. * based on samples that have a large difference in distance than the center pixel.
  125802. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125803. */
  125804. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125805. direction: Vector2;
  125806. /**
  125807. * Creates a new instance CircleOfConfusionPostProcess
  125808. * @param name The name of the effect.
  125809. * @param scene The scene the effect belongs to.
  125810. * @param direction The direction the blur should be applied.
  125811. * @param kernel The size of the kernel used to blur.
  125812. * @param options The required width/height ratio to downsize to before computing the render pass.
  125813. * @param camera The camera to apply the render pass to.
  125814. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125815. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125816. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125817. * @param engine The engine which the post process will be applied. (default: current engine)
  125818. * @param reusable If the post process can be reused on the same frame. (default: false)
  125819. * @param textureType Type of textures used when performing the post process. (default: 0)
  125820. * @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)
  125821. */
  125822. 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);
  125823. }
  125824. }
  125825. declare module BABYLON {
  125826. /** @hidden */
  125827. export var depthOfFieldMergePixelShader: {
  125828. name: string;
  125829. shader: string;
  125830. };
  125831. }
  125832. declare module BABYLON {
  125833. /**
  125834. * Options to be set when merging outputs from the default pipeline.
  125835. */
  125836. export class DepthOfFieldMergePostProcessOptions {
  125837. /**
  125838. * The original image to merge on top of
  125839. */
  125840. originalFromInput: PostProcess;
  125841. /**
  125842. * Parameters to perform the merge of the depth of field effect
  125843. */
  125844. depthOfField?: {
  125845. circleOfConfusion: PostProcess;
  125846. blurSteps: Array<PostProcess>;
  125847. };
  125848. /**
  125849. * Parameters to perform the merge of bloom effect
  125850. */
  125851. bloom?: {
  125852. blurred: PostProcess;
  125853. weight: number;
  125854. };
  125855. }
  125856. /**
  125857. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125858. */
  125859. export class DepthOfFieldMergePostProcess extends PostProcess {
  125860. private blurSteps;
  125861. /**
  125862. * Creates a new instance of DepthOfFieldMergePostProcess
  125863. * @param name The name of the effect.
  125864. * @param originalFromInput Post process which's input will be used for the merge.
  125865. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  125866. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  125867. * @param options The required width/height ratio to downsize to before computing the render pass.
  125868. * @param camera The camera to apply the render pass to.
  125869. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125870. * @param engine The engine which the post process will be applied. (default: current engine)
  125871. * @param reusable If the post process can be reused on the same frame. (default: false)
  125872. * @param textureType Type of textures used when performing the post process. (default: 0)
  125873. * @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)
  125874. */
  125875. 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);
  125876. /**
  125877. * Updates the effect with the current post process compile time values and recompiles the shader.
  125878. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  125879. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  125880. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  125881. * @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
  125882. * @param onCompiled Called when the shader has been compiled.
  125883. * @param onError Called if there is an error when compiling a shader.
  125884. */
  125885. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  125886. }
  125887. }
  125888. declare module BABYLON {
  125889. /**
  125890. * Specifies the level of max blur that should be applied when using the depth of field effect
  125891. */
  125892. export enum DepthOfFieldEffectBlurLevel {
  125893. /**
  125894. * Subtle blur
  125895. */
  125896. Low = 0,
  125897. /**
  125898. * Medium blur
  125899. */
  125900. Medium = 1,
  125901. /**
  125902. * Large blur
  125903. */
  125904. High = 2
  125905. }
  125906. /**
  125907. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  125908. */
  125909. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  125910. private _circleOfConfusion;
  125911. /**
  125912. * @hidden Internal, blurs from high to low
  125913. */
  125914. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  125915. private _depthOfFieldBlurY;
  125916. private _dofMerge;
  125917. /**
  125918. * @hidden Internal post processes in depth of field effect
  125919. */
  125920. _effects: Array<PostProcess>;
  125921. /**
  125922. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  125923. */
  125924. focalLength: number;
  125925. /**
  125926. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125927. */
  125928. fStop: number;
  125929. /**
  125930. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125931. */
  125932. focusDistance: number;
  125933. /**
  125934. * 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.
  125935. */
  125936. lensSize: number;
  125937. /**
  125938. * Creates a new instance DepthOfFieldEffect
  125939. * @param scene The scene the effect belongs to.
  125940. * @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.
  125941. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125942. * @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)
  125943. */
  125944. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  125945. /**
  125946. * Get the current class name of the current effet
  125947. * @returns "DepthOfFieldEffect"
  125948. */
  125949. getClassName(): string;
  125950. /**
  125951. * 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.
  125952. */
  125953. depthTexture: RenderTargetTexture;
  125954. /**
  125955. * Disposes each of the internal effects for a given camera.
  125956. * @param camera The camera to dispose the effect on.
  125957. */
  125958. disposeEffects(camera: Camera): void;
  125959. /**
  125960. * @hidden Internal
  125961. */
  125962. _updateEffects(): void;
  125963. /**
  125964. * Internal
  125965. * @returns if all the contained post processes are ready.
  125966. * @hidden
  125967. */
  125968. _isReady(): boolean;
  125969. }
  125970. }
  125971. declare module BABYLON {
  125972. /** @hidden */
  125973. export var displayPassPixelShader: {
  125974. name: string;
  125975. shader: string;
  125976. };
  125977. }
  125978. declare module BABYLON {
  125979. /**
  125980. * DisplayPassPostProcess which produces an output the same as it's input
  125981. */
  125982. export class DisplayPassPostProcess extends PostProcess {
  125983. /**
  125984. * Creates the DisplayPassPostProcess
  125985. * @param name The name of the effect.
  125986. * @param options The required width/height ratio to downsize to before computing the render pass.
  125987. * @param camera The camera to apply the render pass to.
  125988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125989. * @param engine The engine which the post process will be applied. (default: current engine)
  125990. * @param reusable If the post process can be reused on the same frame. (default: false)
  125991. */
  125992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125993. }
  125994. }
  125995. declare module BABYLON {
  125996. /** @hidden */
  125997. export var filterPixelShader: {
  125998. name: string;
  125999. shader: string;
  126000. };
  126001. }
  126002. declare module BABYLON {
  126003. /**
  126004. * Applies a kernel filter to the image
  126005. */
  126006. export class FilterPostProcess extends PostProcess {
  126007. /** The matrix to be applied to the image */
  126008. kernelMatrix: Matrix;
  126009. /**
  126010. *
  126011. * @param name The name of the effect.
  126012. * @param kernelMatrix The matrix to be applied to the image
  126013. * @param options The required width/height ratio to downsize to before computing the render pass.
  126014. * @param camera The camera to apply the render pass to.
  126015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126016. * @param engine The engine which the post process will be applied. (default: current engine)
  126017. * @param reusable If the post process can be reused on the same frame. (default: false)
  126018. */
  126019. constructor(name: string,
  126020. /** The matrix to be applied to the image */
  126021. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126022. }
  126023. }
  126024. declare module BABYLON {
  126025. /** @hidden */
  126026. export var fxaaPixelShader: {
  126027. name: string;
  126028. shader: string;
  126029. };
  126030. }
  126031. declare module BABYLON {
  126032. /** @hidden */
  126033. export var fxaaVertexShader: {
  126034. name: string;
  126035. shader: string;
  126036. };
  126037. }
  126038. declare module BABYLON {
  126039. /**
  126040. * Fxaa post process
  126041. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126042. */
  126043. export class FxaaPostProcess extends PostProcess {
  126044. /** @hidden */
  126045. texelWidth: number;
  126046. /** @hidden */
  126047. texelHeight: number;
  126048. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126049. private _getDefines;
  126050. }
  126051. }
  126052. declare module BABYLON {
  126053. /** @hidden */
  126054. export var grainPixelShader: {
  126055. name: string;
  126056. shader: string;
  126057. };
  126058. }
  126059. declare module BABYLON {
  126060. /**
  126061. * The GrainPostProcess adds noise to the image at mid luminance levels
  126062. */
  126063. export class GrainPostProcess extends PostProcess {
  126064. /**
  126065. * The intensity of the grain added (default: 30)
  126066. */
  126067. intensity: number;
  126068. /**
  126069. * If the grain should be randomized on every frame
  126070. */
  126071. animated: boolean;
  126072. /**
  126073. * Creates a new instance of @see GrainPostProcess
  126074. * @param name The name of the effect.
  126075. * @param options The required width/height ratio to downsize to before computing the render pass.
  126076. * @param camera The camera to apply the render pass to.
  126077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126078. * @param engine The engine which the post process will be applied. (default: current engine)
  126079. * @param reusable If the post process can be reused on the same frame. (default: false)
  126080. * @param textureType Type of textures used when performing the post process. (default: 0)
  126081. * @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)
  126082. */
  126083. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126084. }
  126085. }
  126086. declare module BABYLON {
  126087. /** @hidden */
  126088. export var highlightsPixelShader: {
  126089. name: string;
  126090. shader: string;
  126091. };
  126092. }
  126093. declare module BABYLON {
  126094. /**
  126095. * Extracts highlights from the image
  126096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126097. */
  126098. export class HighlightsPostProcess extends PostProcess {
  126099. /**
  126100. * Extracts highlights from the image
  126101. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126102. * @param name The name of the effect.
  126103. * @param options The required width/height ratio to downsize to before computing the render pass.
  126104. * @param camera The camera to apply the render pass to.
  126105. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126106. * @param engine The engine which the post process will be applied. (default: current engine)
  126107. * @param reusable If the post process can be reused on the same frame. (default: false)
  126108. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126109. */
  126110. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126111. }
  126112. }
  126113. declare module BABYLON {
  126114. /** @hidden */
  126115. export var mrtFragmentDeclaration: {
  126116. name: string;
  126117. shader: string;
  126118. };
  126119. }
  126120. declare module BABYLON {
  126121. /** @hidden */
  126122. export var geometryPixelShader: {
  126123. name: string;
  126124. shader: string;
  126125. };
  126126. }
  126127. declare module BABYLON {
  126128. /** @hidden */
  126129. export var geometryVertexShader: {
  126130. name: string;
  126131. shader: string;
  126132. };
  126133. }
  126134. declare module BABYLON {
  126135. /** @hidden */
  126136. interface ISavedTransformationMatrix {
  126137. world: Matrix;
  126138. viewProjection: Matrix;
  126139. }
  126140. /**
  126141. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126142. */
  126143. export class GeometryBufferRenderer {
  126144. /**
  126145. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126146. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126147. */
  126148. static readonly POSITION_TEXTURE_TYPE: number;
  126149. /**
  126150. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126151. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126152. */
  126153. static readonly VELOCITY_TEXTURE_TYPE: number;
  126154. /**
  126155. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126156. * in order to compute objects velocities when enableVelocity is set to "true"
  126157. * @hidden
  126158. */
  126159. _previousTransformationMatrices: {
  126160. [index: number]: ISavedTransformationMatrix;
  126161. };
  126162. /**
  126163. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126164. * in order to compute objects velocities when enableVelocity is set to "true"
  126165. * @hidden
  126166. */
  126167. _previousBonesTransformationMatrices: {
  126168. [index: number]: Float32Array;
  126169. };
  126170. /**
  126171. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126172. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126173. */
  126174. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126175. private _scene;
  126176. private _multiRenderTarget;
  126177. private _ratio;
  126178. private _enablePosition;
  126179. private _enableVelocity;
  126180. private _positionIndex;
  126181. private _velocityIndex;
  126182. protected _effect: Effect;
  126183. protected _cachedDefines: string;
  126184. /**
  126185. * Set the render list (meshes to be rendered) used in the G buffer.
  126186. */
  126187. renderList: Mesh[];
  126188. /**
  126189. * Gets wether or not G buffer are supported by the running hardware.
  126190. * This requires draw buffer supports
  126191. */
  126192. readonly isSupported: boolean;
  126193. /**
  126194. * Returns the index of the given texture type in the G-Buffer textures array
  126195. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126196. * @returns the index of the given texture type in the G-Buffer textures array
  126197. */
  126198. getTextureIndex(textureType: number): number;
  126199. /**
  126200. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126201. */
  126202. /**
  126203. * Sets whether or not objects positions are enabled for the G buffer.
  126204. */
  126205. enablePosition: boolean;
  126206. /**
  126207. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126208. */
  126209. /**
  126210. * Sets wether or not objects velocities are enabled for the G buffer.
  126211. */
  126212. enableVelocity: boolean;
  126213. /**
  126214. * Gets the scene associated with the buffer.
  126215. */
  126216. readonly scene: Scene;
  126217. /**
  126218. * Gets the ratio used by the buffer during its creation.
  126219. * How big is the buffer related to the main canvas.
  126220. */
  126221. readonly ratio: number;
  126222. /** @hidden */
  126223. static _SceneComponentInitialization: (scene: Scene) => void;
  126224. /**
  126225. * Creates a new G Buffer for the scene
  126226. * @param scene The scene the buffer belongs to
  126227. * @param ratio How big is the buffer related to the main canvas.
  126228. */
  126229. constructor(scene: Scene, ratio?: number);
  126230. /**
  126231. * Checks wether everything is ready to render a submesh to the G buffer.
  126232. * @param subMesh the submesh to check readiness for
  126233. * @param useInstances is the mesh drawn using instance or not
  126234. * @returns true if ready otherwise false
  126235. */
  126236. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126237. /**
  126238. * Gets the current underlying G Buffer.
  126239. * @returns the buffer
  126240. */
  126241. getGBuffer(): MultiRenderTarget;
  126242. /**
  126243. * Gets the number of samples used to render the buffer (anti aliasing).
  126244. */
  126245. /**
  126246. * Sets the number of samples used to render the buffer (anti aliasing).
  126247. */
  126248. samples: number;
  126249. /**
  126250. * Disposes the renderer and frees up associated resources.
  126251. */
  126252. dispose(): void;
  126253. protected _createRenderTargets(): void;
  126254. private _copyBonesTransformationMatrices;
  126255. }
  126256. }
  126257. declare module BABYLON {
  126258. interface Scene {
  126259. /** @hidden (Backing field) */
  126260. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126261. /**
  126262. * Gets or Sets the current geometry buffer associated to the scene.
  126263. */
  126264. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126265. /**
  126266. * Enables a GeometryBufferRender and associates it with the scene
  126267. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126268. * @returns the GeometryBufferRenderer
  126269. */
  126270. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126271. /**
  126272. * Disables the GeometryBufferRender associated with the scene
  126273. */
  126274. disableGeometryBufferRenderer(): void;
  126275. }
  126276. /**
  126277. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126278. * in several rendering techniques.
  126279. */
  126280. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126281. /**
  126282. * The component name helpful to identify the component in the list of scene components.
  126283. */
  126284. readonly name: string;
  126285. /**
  126286. * The scene the component belongs to.
  126287. */
  126288. scene: Scene;
  126289. /**
  126290. * Creates a new instance of the component for the given scene
  126291. * @param scene Defines the scene to register the component in
  126292. */
  126293. constructor(scene: Scene);
  126294. /**
  126295. * Registers the component in a given scene
  126296. */
  126297. register(): void;
  126298. /**
  126299. * Rebuilds the elements related to this component in case of
  126300. * context lost for instance.
  126301. */
  126302. rebuild(): void;
  126303. /**
  126304. * Disposes the component and the associated ressources
  126305. */
  126306. dispose(): void;
  126307. private _gatherRenderTargets;
  126308. }
  126309. }
  126310. declare module BABYLON {
  126311. /** @hidden */
  126312. export var motionBlurPixelShader: {
  126313. name: string;
  126314. shader: string;
  126315. };
  126316. }
  126317. declare module BABYLON {
  126318. /**
  126319. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126320. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126321. * As an example, all you have to do is to create the post-process:
  126322. * var mb = new BABYLON.MotionBlurPostProcess(
  126323. * 'mb', // The name of the effect.
  126324. * scene, // The scene containing the objects to blur according to their velocity.
  126325. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126326. * camera // The camera to apply the render pass to.
  126327. * );
  126328. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126329. */
  126330. export class MotionBlurPostProcess extends PostProcess {
  126331. /**
  126332. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126333. */
  126334. motionStrength: number;
  126335. /**
  126336. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126337. */
  126338. /**
  126339. * Sets the number of iterations to be used for motion blur quality
  126340. */
  126341. motionBlurSamples: number;
  126342. private _motionBlurSamples;
  126343. private _geometryBufferRenderer;
  126344. /**
  126345. * Creates a new instance MotionBlurPostProcess
  126346. * @param name The name of the effect.
  126347. * @param scene The scene containing the objects to blur according to their velocity.
  126348. * @param options The required width/height ratio to downsize to before computing the render pass.
  126349. * @param camera The camera to apply the render pass to.
  126350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126351. * @param engine The engine which the post process will be applied. (default: current engine)
  126352. * @param reusable If the post process can be reused on the same frame. (default: false)
  126353. * @param textureType Type of textures used when performing the post process. (default: 0)
  126354. * @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)
  126355. */
  126356. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126357. /**
  126358. * Excludes the given skinned mesh from computing bones velocities.
  126359. * 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.
  126360. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126361. */
  126362. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126363. /**
  126364. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126365. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126366. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126367. */
  126368. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126369. /**
  126370. * Disposes the post process.
  126371. * @param camera The camera to dispose the post process on.
  126372. */
  126373. dispose(camera?: Camera): void;
  126374. }
  126375. }
  126376. declare module BABYLON {
  126377. /** @hidden */
  126378. export var refractionPixelShader: {
  126379. name: string;
  126380. shader: string;
  126381. };
  126382. }
  126383. declare module BABYLON {
  126384. /**
  126385. * Post process which applies a refractin texture
  126386. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126387. */
  126388. export class RefractionPostProcess extends PostProcess {
  126389. /** the base color of the refraction (used to taint the rendering) */
  126390. color: Color3;
  126391. /** simulated refraction depth */
  126392. depth: number;
  126393. /** the coefficient of the base color (0 to remove base color tainting) */
  126394. colorLevel: number;
  126395. private _refTexture;
  126396. private _ownRefractionTexture;
  126397. /**
  126398. * Gets or sets the refraction texture
  126399. * Please note that you are responsible for disposing the texture if you set it manually
  126400. */
  126401. refractionTexture: Texture;
  126402. /**
  126403. * Initializes the RefractionPostProcess
  126404. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126405. * @param name The name of the effect.
  126406. * @param refractionTextureUrl Url of the refraction texture to use
  126407. * @param color the base color of the refraction (used to taint the rendering)
  126408. * @param depth simulated refraction depth
  126409. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126410. * @param camera The camera to apply the render pass to.
  126411. * @param options The required width/height ratio to downsize to before computing the render pass.
  126412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126413. * @param engine The engine which the post process will be applied. (default: current engine)
  126414. * @param reusable If the post process can be reused on the same frame. (default: false)
  126415. */
  126416. constructor(name: string, refractionTextureUrl: string,
  126417. /** the base color of the refraction (used to taint the rendering) */
  126418. color: Color3,
  126419. /** simulated refraction depth */
  126420. depth: number,
  126421. /** the coefficient of the base color (0 to remove base color tainting) */
  126422. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126423. /**
  126424. * Disposes of the post process
  126425. * @param camera Camera to dispose post process on
  126426. */
  126427. dispose(camera: Camera): void;
  126428. }
  126429. }
  126430. declare module BABYLON {
  126431. /** @hidden */
  126432. export var sharpenPixelShader: {
  126433. name: string;
  126434. shader: string;
  126435. };
  126436. }
  126437. declare module BABYLON {
  126438. /**
  126439. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126440. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126441. */
  126442. export class SharpenPostProcess extends PostProcess {
  126443. /**
  126444. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126445. */
  126446. colorAmount: number;
  126447. /**
  126448. * How much sharpness should be applied (default: 0.3)
  126449. */
  126450. edgeAmount: number;
  126451. /**
  126452. * Creates a new instance ConvolutionPostProcess
  126453. * @param name The name of the effect.
  126454. * @param options The required width/height ratio to downsize to before computing the render pass.
  126455. * @param camera The camera to apply the render pass to.
  126456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126457. * @param engine The engine which the post process will be applied. (default: current engine)
  126458. * @param reusable If the post process can be reused on the same frame. (default: false)
  126459. * @param textureType Type of textures used when performing the post process. (default: 0)
  126460. * @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)
  126461. */
  126462. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126463. }
  126464. }
  126465. declare module BABYLON {
  126466. /**
  126467. * PostProcessRenderPipeline
  126468. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126469. */
  126470. export class PostProcessRenderPipeline {
  126471. private engine;
  126472. private _renderEffects;
  126473. private _renderEffectsForIsolatedPass;
  126474. /**
  126475. * List of inspectable custom properties (used by the Inspector)
  126476. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126477. */
  126478. inspectableCustomProperties: IInspectable[];
  126479. /**
  126480. * @hidden
  126481. */
  126482. protected _cameras: Camera[];
  126483. /** @hidden */
  126484. _name: string;
  126485. /**
  126486. * Gets pipeline name
  126487. */
  126488. readonly name: string;
  126489. /**
  126490. * Initializes a PostProcessRenderPipeline
  126491. * @param engine engine to add the pipeline to
  126492. * @param name name of the pipeline
  126493. */
  126494. constructor(engine: Engine, name: string);
  126495. /**
  126496. * Gets the class name
  126497. * @returns "PostProcessRenderPipeline"
  126498. */
  126499. getClassName(): string;
  126500. /**
  126501. * If all the render effects in the pipeline are supported
  126502. */
  126503. readonly isSupported: boolean;
  126504. /**
  126505. * Adds an effect to the pipeline
  126506. * @param renderEffect the effect to add
  126507. */
  126508. addEffect(renderEffect: PostProcessRenderEffect): void;
  126509. /** @hidden */
  126510. _rebuild(): void;
  126511. /** @hidden */
  126512. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126513. /** @hidden */
  126514. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126515. /** @hidden */
  126516. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126517. /** @hidden */
  126518. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126519. /** @hidden */
  126520. _attachCameras(cameras: Camera, unique: boolean): void;
  126521. /** @hidden */
  126522. _attachCameras(cameras: Camera[], unique: boolean): void;
  126523. /** @hidden */
  126524. _detachCameras(cameras: Camera): void;
  126525. /** @hidden */
  126526. _detachCameras(cameras: Nullable<Camera[]>): void;
  126527. /** @hidden */
  126528. _update(): void;
  126529. /** @hidden */
  126530. _reset(): void;
  126531. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126532. /**
  126533. * Disposes of the pipeline
  126534. */
  126535. dispose(): void;
  126536. }
  126537. }
  126538. declare module BABYLON {
  126539. /**
  126540. * PostProcessRenderPipelineManager class
  126541. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126542. */
  126543. export class PostProcessRenderPipelineManager {
  126544. private _renderPipelines;
  126545. /**
  126546. * Initializes a PostProcessRenderPipelineManager
  126547. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126548. */
  126549. constructor();
  126550. /**
  126551. * Gets the list of supported render pipelines
  126552. */
  126553. readonly supportedPipelines: PostProcessRenderPipeline[];
  126554. /**
  126555. * Adds a pipeline to the manager
  126556. * @param renderPipeline The pipeline to add
  126557. */
  126558. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126559. /**
  126560. * Attaches a camera to the pipeline
  126561. * @param renderPipelineName The name of the pipeline to attach to
  126562. * @param cameras the camera to attach
  126563. * @param unique if the camera can be attached multiple times to the pipeline
  126564. */
  126565. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126566. /**
  126567. * Detaches a camera from the pipeline
  126568. * @param renderPipelineName The name of the pipeline to detach from
  126569. * @param cameras the camera to detach
  126570. */
  126571. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126572. /**
  126573. * Enables an effect by name on a pipeline
  126574. * @param renderPipelineName the name of the pipeline to enable the effect in
  126575. * @param renderEffectName the name of the effect to enable
  126576. * @param cameras the cameras that the effect should be enabled on
  126577. */
  126578. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126579. /**
  126580. * Disables an effect by name on a pipeline
  126581. * @param renderPipelineName the name of the pipeline to disable the effect in
  126582. * @param renderEffectName the name of the effect to disable
  126583. * @param cameras the cameras that the effect should be disabled on
  126584. */
  126585. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126586. /**
  126587. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126588. */
  126589. update(): void;
  126590. /** @hidden */
  126591. _rebuild(): void;
  126592. /**
  126593. * Disposes of the manager and pipelines
  126594. */
  126595. dispose(): void;
  126596. }
  126597. }
  126598. declare module BABYLON {
  126599. interface Scene {
  126600. /** @hidden (Backing field) */
  126601. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126602. /**
  126603. * Gets the postprocess render pipeline manager
  126604. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126605. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126606. */
  126607. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126608. }
  126609. /**
  126610. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126611. */
  126612. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126613. /**
  126614. * The component name helpfull to identify the component in the list of scene components.
  126615. */
  126616. readonly name: string;
  126617. /**
  126618. * The scene the component belongs to.
  126619. */
  126620. scene: Scene;
  126621. /**
  126622. * Creates a new instance of the component for the given scene
  126623. * @param scene Defines the scene to register the component in
  126624. */
  126625. constructor(scene: Scene);
  126626. /**
  126627. * Registers the component in a given scene
  126628. */
  126629. register(): void;
  126630. /**
  126631. * Rebuilds the elements related to this component in case of
  126632. * context lost for instance.
  126633. */
  126634. rebuild(): void;
  126635. /**
  126636. * Disposes the component and the associated ressources
  126637. */
  126638. dispose(): void;
  126639. private _gatherRenderTargets;
  126640. }
  126641. }
  126642. declare module BABYLON {
  126643. /**
  126644. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126645. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126646. */
  126647. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126648. private _scene;
  126649. private _camerasToBeAttached;
  126650. /**
  126651. * ID of the sharpen post process,
  126652. */
  126653. private readonly SharpenPostProcessId;
  126654. /**
  126655. * @ignore
  126656. * ID of the image processing post process;
  126657. */
  126658. readonly ImageProcessingPostProcessId: string;
  126659. /**
  126660. * @ignore
  126661. * ID of the Fast Approximate Anti-Aliasing post process;
  126662. */
  126663. readonly FxaaPostProcessId: string;
  126664. /**
  126665. * ID of the chromatic aberration post process,
  126666. */
  126667. private readonly ChromaticAberrationPostProcessId;
  126668. /**
  126669. * ID of the grain post process
  126670. */
  126671. private readonly GrainPostProcessId;
  126672. /**
  126673. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126674. */
  126675. sharpen: SharpenPostProcess;
  126676. private _sharpenEffect;
  126677. private bloom;
  126678. /**
  126679. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126680. */
  126681. depthOfField: DepthOfFieldEffect;
  126682. /**
  126683. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126684. */
  126685. fxaa: FxaaPostProcess;
  126686. /**
  126687. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126688. */
  126689. imageProcessing: ImageProcessingPostProcess;
  126690. /**
  126691. * Chromatic aberration post process which will shift rgb colors in the image
  126692. */
  126693. chromaticAberration: ChromaticAberrationPostProcess;
  126694. private _chromaticAberrationEffect;
  126695. /**
  126696. * Grain post process which add noise to the image
  126697. */
  126698. grain: GrainPostProcess;
  126699. private _grainEffect;
  126700. /**
  126701. * Glow post process which adds a glow to emissive areas of the image
  126702. */
  126703. private _glowLayer;
  126704. /**
  126705. * Animations which can be used to tweak settings over a period of time
  126706. */
  126707. animations: Animation[];
  126708. private _imageProcessingConfigurationObserver;
  126709. private _sharpenEnabled;
  126710. private _bloomEnabled;
  126711. private _depthOfFieldEnabled;
  126712. private _depthOfFieldBlurLevel;
  126713. private _fxaaEnabled;
  126714. private _imageProcessingEnabled;
  126715. private _defaultPipelineTextureType;
  126716. private _bloomScale;
  126717. private _chromaticAberrationEnabled;
  126718. private _grainEnabled;
  126719. private _buildAllowed;
  126720. /**
  126721. * Gets active scene
  126722. */
  126723. readonly scene: Scene;
  126724. /**
  126725. * Enable or disable the sharpen process from the pipeline
  126726. */
  126727. sharpenEnabled: boolean;
  126728. private _resizeObserver;
  126729. private _hardwareScaleLevel;
  126730. private _bloomKernel;
  126731. /**
  126732. * Specifies the size of the bloom blur kernel, relative to the final output size
  126733. */
  126734. bloomKernel: number;
  126735. /**
  126736. * Specifies the weight of the bloom in the final rendering
  126737. */
  126738. private _bloomWeight;
  126739. /**
  126740. * Specifies the luma threshold for the area that will be blurred by the bloom
  126741. */
  126742. private _bloomThreshold;
  126743. private _hdr;
  126744. /**
  126745. * The strength of the bloom.
  126746. */
  126747. bloomWeight: number;
  126748. /**
  126749. * The strength of the bloom.
  126750. */
  126751. bloomThreshold: number;
  126752. /**
  126753. * The scale of the bloom, lower value will provide better performance.
  126754. */
  126755. bloomScale: number;
  126756. /**
  126757. * Enable or disable the bloom from the pipeline
  126758. */
  126759. bloomEnabled: boolean;
  126760. private _rebuildBloom;
  126761. /**
  126762. * If the depth of field is enabled.
  126763. */
  126764. depthOfFieldEnabled: boolean;
  126765. /**
  126766. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126767. */
  126768. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126769. /**
  126770. * If the anti aliasing is enabled.
  126771. */
  126772. fxaaEnabled: boolean;
  126773. private _samples;
  126774. /**
  126775. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126776. */
  126777. samples: number;
  126778. /**
  126779. * If image processing is enabled.
  126780. */
  126781. imageProcessingEnabled: boolean;
  126782. /**
  126783. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126784. */
  126785. glowLayerEnabled: boolean;
  126786. /**
  126787. * Gets the glow layer (or null if not defined)
  126788. */
  126789. readonly glowLayer: Nullable<GlowLayer>;
  126790. /**
  126791. * Enable or disable the chromaticAberration process from the pipeline
  126792. */
  126793. chromaticAberrationEnabled: boolean;
  126794. /**
  126795. * Enable or disable the grain process from the pipeline
  126796. */
  126797. grainEnabled: boolean;
  126798. /**
  126799. * @constructor
  126800. * @param name - The rendering pipeline name (default: "")
  126801. * @param hdr - If high dynamic range textures should be used (default: true)
  126802. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126803. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126804. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126805. */
  126806. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126807. /**
  126808. * Get the class name
  126809. * @returns "DefaultRenderingPipeline"
  126810. */
  126811. getClassName(): string;
  126812. /**
  126813. * Force the compilation of the entire pipeline.
  126814. */
  126815. prepare(): void;
  126816. private _hasCleared;
  126817. private _prevPostProcess;
  126818. private _prevPrevPostProcess;
  126819. private _setAutoClearAndTextureSharing;
  126820. private _depthOfFieldSceneObserver;
  126821. private _buildPipeline;
  126822. private _disposePostProcesses;
  126823. /**
  126824. * Adds a camera to the pipeline
  126825. * @param camera the camera to be added
  126826. */
  126827. addCamera(camera: Camera): void;
  126828. /**
  126829. * Removes a camera from the pipeline
  126830. * @param camera the camera to remove
  126831. */
  126832. removeCamera(camera: Camera): void;
  126833. /**
  126834. * Dispose of the pipeline and stop all post processes
  126835. */
  126836. dispose(): void;
  126837. /**
  126838. * Serialize the rendering pipeline (Used when exporting)
  126839. * @returns the serialized object
  126840. */
  126841. serialize(): any;
  126842. /**
  126843. * Parse the serialized pipeline
  126844. * @param source Source pipeline.
  126845. * @param scene The scene to load the pipeline to.
  126846. * @param rootUrl The URL of the serialized pipeline.
  126847. * @returns An instantiated pipeline from the serialized object.
  126848. */
  126849. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  126850. }
  126851. }
  126852. declare module BABYLON {
  126853. /** @hidden */
  126854. export var lensHighlightsPixelShader: {
  126855. name: string;
  126856. shader: string;
  126857. };
  126858. }
  126859. declare module BABYLON {
  126860. /** @hidden */
  126861. export var depthOfFieldPixelShader: {
  126862. name: string;
  126863. shader: string;
  126864. };
  126865. }
  126866. declare module BABYLON {
  126867. /**
  126868. * BABYLON.JS Chromatic Aberration GLSL Shader
  126869. * Author: Olivier Guyot
  126870. * Separates very slightly R, G and B colors on the edges of the screen
  126871. * Inspired by Francois Tarlier & Martins Upitis
  126872. */
  126873. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  126874. /**
  126875. * @ignore
  126876. * The chromatic aberration PostProcess id in the pipeline
  126877. */
  126878. LensChromaticAberrationEffect: string;
  126879. /**
  126880. * @ignore
  126881. * The highlights enhancing PostProcess id in the pipeline
  126882. */
  126883. HighlightsEnhancingEffect: string;
  126884. /**
  126885. * @ignore
  126886. * The depth-of-field PostProcess id in the pipeline
  126887. */
  126888. LensDepthOfFieldEffect: string;
  126889. private _scene;
  126890. private _depthTexture;
  126891. private _grainTexture;
  126892. private _chromaticAberrationPostProcess;
  126893. private _highlightsPostProcess;
  126894. private _depthOfFieldPostProcess;
  126895. private _edgeBlur;
  126896. private _grainAmount;
  126897. private _chromaticAberration;
  126898. private _distortion;
  126899. private _highlightsGain;
  126900. private _highlightsThreshold;
  126901. private _dofDistance;
  126902. private _dofAperture;
  126903. private _dofDarken;
  126904. private _dofPentagon;
  126905. private _blurNoise;
  126906. /**
  126907. * @constructor
  126908. *
  126909. * Effect parameters are as follow:
  126910. * {
  126911. * chromatic_aberration: number; // from 0 to x (1 for realism)
  126912. * edge_blur: number; // from 0 to x (1 for realism)
  126913. * distortion: number; // from 0 to x (1 for realism)
  126914. * grain_amount: number; // from 0 to 1
  126915. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  126916. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  126917. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  126918. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  126919. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  126920. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  126921. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  126922. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  126923. * }
  126924. * Note: if an effect parameter is unset, effect is disabled
  126925. *
  126926. * @param name The rendering pipeline name
  126927. * @param parameters - An object containing all parameters (see above)
  126928. * @param scene The scene linked to this pipeline
  126929. * @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)
  126930. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126931. */
  126932. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  126933. /**
  126934. * Get the class name
  126935. * @returns "LensRenderingPipeline"
  126936. */
  126937. getClassName(): string;
  126938. /**
  126939. * Gets associated scene
  126940. */
  126941. readonly scene: Scene;
  126942. /**
  126943. * Gets or sets the edge blur
  126944. */
  126945. edgeBlur: number;
  126946. /**
  126947. * Gets or sets the grain amount
  126948. */
  126949. grainAmount: number;
  126950. /**
  126951. * Gets or sets the chromatic aberration amount
  126952. */
  126953. chromaticAberration: number;
  126954. /**
  126955. * Gets or sets the depth of field aperture
  126956. */
  126957. dofAperture: number;
  126958. /**
  126959. * Gets or sets the edge distortion
  126960. */
  126961. edgeDistortion: number;
  126962. /**
  126963. * Gets or sets the depth of field distortion
  126964. */
  126965. dofDistortion: number;
  126966. /**
  126967. * Gets or sets the darken out of focus amount
  126968. */
  126969. darkenOutOfFocus: number;
  126970. /**
  126971. * Gets or sets a boolean indicating if blur noise is enabled
  126972. */
  126973. blurNoise: boolean;
  126974. /**
  126975. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  126976. */
  126977. pentagonBokeh: boolean;
  126978. /**
  126979. * Gets or sets the highlight grain amount
  126980. */
  126981. highlightsGain: number;
  126982. /**
  126983. * Gets or sets the highlight threshold
  126984. */
  126985. highlightsThreshold: number;
  126986. /**
  126987. * Sets the amount of blur at the edges
  126988. * @param amount blur amount
  126989. */
  126990. setEdgeBlur(amount: number): void;
  126991. /**
  126992. * Sets edge blur to 0
  126993. */
  126994. disableEdgeBlur(): void;
  126995. /**
  126996. * Sets the amout of grain
  126997. * @param amount Amount of grain
  126998. */
  126999. setGrainAmount(amount: number): void;
  127000. /**
  127001. * Set grain amount to 0
  127002. */
  127003. disableGrain(): void;
  127004. /**
  127005. * Sets the chromatic aberration amount
  127006. * @param amount amount of chromatic aberration
  127007. */
  127008. setChromaticAberration(amount: number): void;
  127009. /**
  127010. * Sets chromatic aberration amount to 0
  127011. */
  127012. disableChromaticAberration(): void;
  127013. /**
  127014. * Sets the EdgeDistortion amount
  127015. * @param amount amount of EdgeDistortion
  127016. */
  127017. setEdgeDistortion(amount: number): void;
  127018. /**
  127019. * Sets edge distortion to 0
  127020. */
  127021. disableEdgeDistortion(): void;
  127022. /**
  127023. * Sets the FocusDistance amount
  127024. * @param amount amount of FocusDistance
  127025. */
  127026. setFocusDistance(amount: number): void;
  127027. /**
  127028. * Disables depth of field
  127029. */
  127030. disableDepthOfField(): void;
  127031. /**
  127032. * Sets the Aperture amount
  127033. * @param amount amount of Aperture
  127034. */
  127035. setAperture(amount: number): void;
  127036. /**
  127037. * Sets the DarkenOutOfFocus amount
  127038. * @param amount amount of DarkenOutOfFocus
  127039. */
  127040. setDarkenOutOfFocus(amount: number): void;
  127041. private _pentagonBokehIsEnabled;
  127042. /**
  127043. * Creates a pentagon bokeh effect
  127044. */
  127045. enablePentagonBokeh(): void;
  127046. /**
  127047. * Disables the pentagon bokeh effect
  127048. */
  127049. disablePentagonBokeh(): void;
  127050. /**
  127051. * Enables noise blur
  127052. */
  127053. enableNoiseBlur(): void;
  127054. /**
  127055. * Disables noise blur
  127056. */
  127057. disableNoiseBlur(): void;
  127058. /**
  127059. * Sets the HighlightsGain amount
  127060. * @param amount amount of HighlightsGain
  127061. */
  127062. setHighlightsGain(amount: number): void;
  127063. /**
  127064. * Sets the HighlightsThreshold amount
  127065. * @param amount amount of HighlightsThreshold
  127066. */
  127067. setHighlightsThreshold(amount: number): void;
  127068. /**
  127069. * Disables highlights
  127070. */
  127071. disableHighlights(): void;
  127072. /**
  127073. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127074. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127075. */
  127076. dispose(disableDepthRender?: boolean): void;
  127077. private _createChromaticAberrationPostProcess;
  127078. private _createHighlightsPostProcess;
  127079. private _createDepthOfFieldPostProcess;
  127080. private _createGrainTexture;
  127081. }
  127082. }
  127083. declare module BABYLON {
  127084. /** @hidden */
  127085. export var ssao2PixelShader: {
  127086. name: string;
  127087. shader: string;
  127088. };
  127089. }
  127090. declare module BABYLON {
  127091. /** @hidden */
  127092. export var ssaoCombinePixelShader: {
  127093. name: string;
  127094. shader: string;
  127095. };
  127096. }
  127097. declare module BABYLON {
  127098. /**
  127099. * Render pipeline to produce ssao effect
  127100. */
  127101. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127102. /**
  127103. * @ignore
  127104. * The PassPostProcess id in the pipeline that contains the original scene color
  127105. */
  127106. SSAOOriginalSceneColorEffect: string;
  127107. /**
  127108. * @ignore
  127109. * The SSAO PostProcess id in the pipeline
  127110. */
  127111. SSAORenderEffect: string;
  127112. /**
  127113. * @ignore
  127114. * The horizontal blur PostProcess id in the pipeline
  127115. */
  127116. SSAOBlurHRenderEffect: string;
  127117. /**
  127118. * @ignore
  127119. * The vertical blur PostProcess id in the pipeline
  127120. */
  127121. SSAOBlurVRenderEffect: string;
  127122. /**
  127123. * @ignore
  127124. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127125. */
  127126. SSAOCombineRenderEffect: string;
  127127. /**
  127128. * The output strength of the SSAO post-process. Default value is 1.0.
  127129. */
  127130. totalStrength: number;
  127131. /**
  127132. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127133. */
  127134. maxZ: number;
  127135. /**
  127136. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127137. */
  127138. minZAspect: number;
  127139. private _samples;
  127140. /**
  127141. * Number of samples used for the SSAO calculations. Default value is 8
  127142. */
  127143. samples: number;
  127144. private _textureSamples;
  127145. /**
  127146. * Number of samples to use for antialiasing
  127147. */
  127148. textureSamples: number;
  127149. /**
  127150. * Ratio object used for SSAO ratio and blur ratio
  127151. */
  127152. private _ratio;
  127153. /**
  127154. * Dynamically generated sphere sampler.
  127155. */
  127156. private _sampleSphere;
  127157. /**
  127158. * Blur filter offsets
  127159. */
  127160. private _samplerOffsets;
  127161. private _expensiveBlur;
  127162. /**
  127163. * If bilateral blur should be used
  127164. */
  127165. expensiveBlur: boolean;
  127166. /**
  127167. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127168. */
  127169. radius: number;
  127170. /**
  127171. * The base color of the SSAO post-process
  127172. * The final result is "base + ssao" between [0, 1]
  127173. */
  127174. base: number;
  127175. /**
  127176. * Support test.
  127177. */
  127178. static readonly IsSupported: boolean;
  127179. private _scene;
  127180. private _depthTexture;
  127181. private _normalTexture;
  127182. private _randomTexture;
  127183. private _originalColorPostProcess;
  127184. private _ssaoPostProcess;
  127185. private _blurHPostProcess;
  127186. private _blurVPostProcess;
  127187. private _ssaoCombinePostProcess;
  127188. private _firstUpdate;
  127189. /**
  127190. * Gets active scene
  127191. */
  127192. readonly scene: Scene;
  127193. /**
  127194. * @constructor
  127195. * @param name The rendering pipeline name
  127196. * @param scene The scene linked to this pipeline
  127197. * @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 }
  127198. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127199. */
  127200. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127201. /**
  127202. * Get the class name
  127203. * @returns "SSAO2RenderingPipeline"
  127204. */
  127205. getClassName(): string;
  127206. /**
  127207. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127208. */
  127209. dispose(disableGeometryBufferRenderer?: boolean): void;
  127210. private _createBlurPostProcess;
  127211. /** @hidden */
  127212. _rebuild(): void;
  127213. private _bits;
  127214. private _radicalInverse_VdC;
  127215. private _hammersley;
  127216. private _hemisphereSample_uniform;
  127217. private _generateHemisphere;
  127218. private _createSSAOPostProcess;
  127219. private _createSSAOCombinePostProcess;
  127220. private _createRandomTexture;
  127221. /**
  127222. * Serialize the rendering pipeline (Used when exporting)
  127223. * @returns the serialized object
  127224. */
  127225. serialize(): any;
  127226. /**
  127227. * Parse the serialized pipeline
  127228. * @param source Source pipeline.
  127229. * @param scene The scene to load the pipeline to.
  127230. * @param rootUrl The URL of the serialized pipeline.
  127231. * @returns An instantiated pipeline from the serialized object.
  127232. */
  127233. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127234. }
  127235. }
  127236. declare module BABYLON {
  127237. /** @hidden */
  127238. export var ssaoPixelShader: {
  127239. name: string;
  127240. shader: string;
  127241. };
  127242. }
  127243. declare module BABYLON {
  127244. /**
  127245. * Render pipeline to produce ssao effect
  127246. */
  127247. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127248. /**
  127249. * @ignore
  127250. * The PassPostProcess id in the pipeline that contains the original scene color
  127251. */
  127252. SSAOOriginalSceneColorEffect: string;
  127253. /**
  127254. * @ignore
  127255. * The SSAO PostProcess id in the pipeline
  127256. */
  127257. SSAORenderEffect: string;
  127258. /**
  127259. * @ignore
  127260. * The horizontal blur PostProcess id in the pipeline
  127261. */
  127262. SSAOBlurHRenderEffect: string;
  127263. /**
  127264. * @ignore
  127265. * The vertical blur PostProcess id in the pipeline
  127266. */
  127267. SSAOBlurVRenderEffect: string;
  127268. /**
  127269. * @ignore
  127270. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127271. */
  127272. SSAOCombineRenderEffect: string;
  127273. /**
  127274. * The output strength of the SSAO post-process. Default value is 1.0.
  127275. */
  127276. totalStrength: number;
  127277. /**
  127278. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127279. */
  127280. radius: number;
  127281. /**
  127282. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127283. * Must not be equal to fallOff and superior to fallOff.
  127284. * Default value is 0.0075
  127285. */
  127286. area: number;
  127287. /**
  127288. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127289. * Must not be equal to area and inferior to area.
  127290. * Default value is 0.000001
  127291. */
  127292. fallOff: number;
  127293. /**
  127294. * The base color of the SSAO post-process
  127295. * The final result is "base + ssao" between [0, 1]
  127296. */
  127297. base: number;
  127298. private _scene;
  127299. private _depthTexture;
  127300. private _randomTexture;
  127301. private _originalColorPostProcess;
  127302. private _ssaoPostProcess;
  127303. private _blurHPostProcess;
  127304. private _blurVPostProcess;
  127305. private _ssaoCombinePostProcess;
  127306. private _firstUpdate;
  127307. /**
  127308. * Gets active scene
  127309. */
  127310. readonly scene: Scene;
  127311. /**
  127312. * @constructor
  127313. * @param name - The rendering pipeline name
  127314. * @param scene - The scene linked to this pipeline
  127315. * @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 }
  127316. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127317. */
  127318. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127319. /**
  127320. * Get the class name
  127321. * @returns "SSAORenderingPipeline"
  127322. */
  127323. getClassName(): string;
  127324. /**
  127325. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127326. */
  127327. dispose(disableDepthRender?: boolean): void;
  127328. private _createBlurPostProcess;
  127329. /** @hidden */
  127330. _rebuild(): void;
  127331. private _createSSAOPostProcess;
  127332. private _createSSAOCombinePostProcess;
  127333. private _createRandomTexture;
  127334. }
  127335. }
  127336. declare module BABYLON {
  127337. /** @hidden */
  127338. export var standardPixelShader: {
  127339. name: string;
  127340. shader: string;
  127341. };
  127342. }
  127343. declare module BABYLON {
  127344. /**
  127345. * Standard rendering pipeline
  127346. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127347. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127348. */
  127349. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127350. /**
  127351. * Public members
  127352. */
  127353. /**
  127354. * Post-process which contains the original scene color before the pipeline applies all the effects
  127355. */
  127356. originalPostProcess: Nullable<PostProcess>;
  127357. /**
  127358. * Post-process used to down scale an image x4
  127359. */
  127360. downSampleX4PostProcess: Nullable<PostProcess>;
  127361. /**
  127362. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127363. */
  127364. brightPassPostProcess: Nullable<PostProcess>;
  127365. /**
  127366. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127367. */
  127368. blurHPostProcesses: PostProcess[];
  127369. /**
  127370. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127371. */
  127372. blurVPostProcesses: PostProcess[];
  127373. /**
  127374. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127375. */
  127376. textureAdderPostProcess: Nullable<PostProcess>;
  127377. /**
  127378. * Post-process used to create volumetric lighting effect
  127379. */
  127380. volumetricLightPostProcess: Nullable<PostProcess>;
  127381. /**
  127382. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127383. */
  127384. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127385. /**
  127386. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127387. */
  127388. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127389. /**
  127390. * Post-process used to merge the volumetric light effect and the real scene color
  127391. */
  127392. volumetricLightMergePostProces: Nullable<PostProcess>;
  127393. /**
  127394. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127395. */
  127396. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127397. /**
  127398. * Base post-process used to calculate the average luminance of the final image for HDR
  127399. */
  127400. luminancePostProcess: Nullable<PostProcess>;
  127401. /**
  127402. * Post-processes used to create down sample post-processes in order to get
  127403. * the average luminance of the final image for HDR
  127404. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127405. */
  127406. luminanceDownSamplePostProcesses: PostProcess[];
  127407. /**
  127408. * Post-process used to create a HDR effect (light adaptation)
  127409. */
  127410. hdrPostProcess: Nullable<PostProcess>;
  127411. /**
  127412. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127413. */
  127414. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127415. /**
  127416. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127417. */
  127418. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127419. /**
  127420. * Post-process used to merge the final HDR post-process and the real scene color
  127421. */
  127422. hdrFinalPostProcess: Nullable<PostProcess>;
  127423. /**
  127424. * Post-process used to create a lens flare effect
  127425. */
  127426. lensFlarePostProcess: Nullable<PostProcess>;
  127427. /**
  127428. * Post-process that merges the result of the lens flare post-process and the real scene color
  127429. */
  127430. lensFlareComposePostProcess: Nullable<PostProcess>;
  127431. /**
  127432. * Post-process used to create a motion blur effect
  127433. */
  127434. motionBlurPostProcess: Nullable<PostProcess>;
  127435. /**
  127436. * Post-process used to create a depth of field effect
  127437. */
  127438. depthOfFieldPostProcess: Nullable<PostProcess>;
  127439. /**
  127440. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127441. */
  127442. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127443. /**
  127444. * Represents the brightness threshold in order to configure the illuminated surfaces
  127445. */
  127446. brightThreshold: number;
  127447. /**
  127448. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127449. */
  127450. blurWidth: number;
  127451. /**
  127452. * Sets if the blur for highlighted surfaces must be only horizontal
  127453. */
  127454. horizontalBlur: boolean;
  127455. /**
  127456. * Gets the overall exposure used by the pipeline
  127457. */
  127458. /**
  127459. * Sets the overall exposure used by the pipeline
  127460. */
  127461. exposure: number;
  127462. /**
  127463. * Texture used typically to simulate "dirty" on camera lens
  127464. */
  127465. lensTexture: Nullable<Texture>;
  127466. /**
  127467. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127468. */
  127469. volumetricLightCoefficient: number;
  127470. /**
  127471. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127472. */
  127473. volumetricLightPower: number;
  127474. /**
  127475. * Used the set the blur intensity to smooth the volumetric lights
  127476. */
  127477. volumetricLightBlurScale: number;
  127478. /**
  127479. * Light (spot or directional) used to generate the volumetric lights rays
  127480. * The source light must have a shadow generate so the pipeline can get its
  127481. * depth map
  127482. */
  127483. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127484. /**
  127485. * For eye adaptation, represents the minimum luminance the eye can see
  127486. */
  127487. hdrMinimumLuminance: number;
  127488. /**
  127489. * For eye adaptation, represents the decrease luminance speed
  127490. */
  127491. hdrDecreaseRate: number;
  127492. /**
  127493. * For eye adaptation, represents the increase luminance speed
  127494. */
  127495. hdrIncreaseRate: number;
  127496. /**
  127497. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127498. */
  127499. /**
  127500. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127501. */
  127502. hdrAutoExposure: boolean;
  127503. /**
  127504. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127505. */
  127506. lensColorTexture: Nullable<Texture>;
  127507. /**
  127508. * The overall strengh for the lens flare effect
  127509. */
  127510. lensFlareStrength: number;
  127511. /**
  127512. * Dispersion coefficient for lens flare ghosts
  127513. */
  127514. lensFlareGhostDispersal: number;
  127515. /**
  127516. * Main lens flare halo width
  127517. */
  127518. lensFlareHaloWidth: number;
  127519. /**
  127520. * Based on the lens distortion effect, defines how much the lens flare result
  127521. * is distorted
  127522. */
  127523. lensFlareDistortionStrength: number;
  127524. /**
  127525. * Configures the blur intensity used for for lens flare (halo)
  127526. */
  127527. lensFlareBlurWidth: number;
  127528. /**
  127529. * Lens star texture must be used to simulate rays on the flares and is available
  127530. * in the documentation
  127531. */
  127532. lensStarTexture: Nullable<Texture>;
  127533. /**
  127534. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127535. * flare effect by taking account of the dirt texture
  127536. */
  127537. lensFlareDirtTexture: Nullable<Texture>;
  127538. /**
  127539. * Represents the focal length for the depth of field effect
  127540. */
  127541. depthOfFieldDistance: number;
  127542. /**
  127543. * Represents the blur intensity for the blurred part of the depth of field effect
  127544. */
  127545. depthOfFieldBlurWidth: number;
  127546. /**
  127547. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127548. */
  127549. /**
  127550. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127551. */
  127552. motionStrength: number;
  127553. /**
  127554. * Gets wether or not the motion blur post-process is object based or screen based.
  127555. */
  127556. /**
  127557. * Sets wether or not the motion blur post-process should be object based or screen based
  127558. */
  127559. objectBasedMotionBlur: boolean;
  127560. /**
  127561. * List of animations for the pipeline (IAnimatable implementation)
  127562. */
  127563. animations: Animation[];
  127564. /**
  127565. * Private members
  127566. */
  127567. private _scene;
  127568. private _currentDepthOfFieldSource;
  127569. private _basePostProcess;
  127570. private _fixedExposure;
  127571. private _currentExposure;
  127572. private _hdrAutoExposure;
  127573. private _hdrCurrentLuminance;
  127574. private _motionStrength;
  127575. private _isObjectBasedMotionBlur;
  127576. private _floatTextureType;
  127577. private _camerasToBeAttached;
  127578. private _ratio;
  127579. private _bloomEnabled;
  127580. private _depthOfFieldEnabled;
  127581. private _vlsEnabled;
  127582. private _lensFlareEnabled;
  127583. private _hdrEnabled;
  127584. private _motionBlurEnabled;
  127585. private _fxaaEnabled;
  127586. private _motionBlurSamples;
  127587. private _volumetricLightStepsCount;
  127588. private _samples;
  127589. /**
  127590. * @ignore
  127591. * Specifies if the bloom pipeline is enabled
  127592. */
  127593. BloomEnabled: boolean;
  127594. /**
  127595. * @ignore
  127596. * Specifies if the depth of field pipeline is enabed
  127597. */
  127598. DepthOfFieldEnabled: boolean;
  127599. /**
  127600. * @ignore
  127601. * Specifies if the lens flare pipeline is enabed
  127602. */
  127603. LensFlareEnabled: boolean;
  127604. /**
  127605. * @ignore
  127606. * Specifies if the HDR pipeline is enabled
  127607. */
  127608. HDREnabled: boolean;
  127609. /**
  127610. * @ignore
  127611. * Specifies if the volumetric lights scattering effect is enabled
  127612. */
  127613. VLSEnabled: boolean;
  127614. /**
  127615. * @ignore
  127616. * Specifies if the motion blur effect is enabled
  127617. */
  127618. MotionBlurEnabled: boolean;
  127619. /**
  127620. * Specifies if anti-aliasing is enabled
  127621. */
  127622. fxaaEnabled: boolean;
  127623. /**
  127624. * Specifies the number of steps used to calculate the volumetric lights
  127625. * Typically in interval [50, 200]
  127626. */
  127627. volumetricLightStepsCount: number;
  127628. /**
  127629. * Specifies the number of samples used for the motion blur effect
  127630. * Typically in interval [16, 64]
  127631. */
  127632. motionBlurSamples: number;
  127633. /**
  127634. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127635. */
  127636. samples: number;
  127637. /**
  127638. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127639. * @constructor
  127640. * @param name The rendering pipeline name
  127641. * @param scene The scene linked to this pipeline
  127642. * @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)
  127643. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127644. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127645. */
  127646. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127647. private _buildPipeline;
  127648. private _createDownSampleX4PostProcess;
  127649. private _createBrightPassPostProcess;
  127650. private _createBlurPostProcesses;
  127651. private _createTextureAdderPostProcess;
  127652. private _createVolumetricLightPostProcess;
  127653. private _createLuminancePostProcesses;
  127654. private _createHdrPostProcess;
  127655. private _createLensFlarePostProcess;
  127656. private _createDepthOfFieldPostProcess;
  127657. private _createMotionBlurPostProcess;
  127658. private _getDepthTexture;
  127659. private _disposePostProcesses;
  127660. /**
  127661. * Dispose of the pipeline and stop all post processes
  127662. */
  127663. dispose(): void;
  127664. /**
  127665. * Serialize the rendering pipeline (Used when exporting)
  127666. * @returns the serialized object
  127667. */
  127668. serialize(): any;
  127669. /**
  127670. * Parse the serialized pipeline
  127671. * @param source Source pipeline.
  127672. * @param scene The scene to load the pipeline to.
  127673. * @param rootUrl The URL of the serialized pipeline.
  127674. * @returns An instantiated pipeline from the serialized object.
  127675. */
  127676. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127677. /**
  127678. * Luminance steps
  127679. */
  127680. static LuminanceSteps: number;
  127681. }
  127682. }
  127683. declare module BABYLON {
  127684. /** @hidden */
  127685. export var tonemapPixelShader: {
  127686. name: string;
  127687. shader: string;
  127688. };
  127689. }
  127690. declare module BABYLON {
  127691. /** Defines operator used for tonemapping */
  127692. export enum TonemappingOperator {
  127693. /** Hable */
  127694. Hable = 0,
  127695. /** Reinhard */
  127696. Reinhard = 1,
  127697. /** HejiDawson */
  127698. HejiDawson = 2,
  127699. /** Photographic */
  127700. Photographic = 3
  127701. }
  127702. /**
  127703. * Defines a post process to apply tone mapping
  127704. */
  127705. export class TonemapPostProcess extends PostProcess {
  127706. private _operator;
  127707. /** Defines the required exposure adjustement */
  127708. exposureAdjustment: number;
  127709. /**
  127710. * Creates a new TonemapPostProcess
  127711. * @param name defines the name of the postprocess
  127712. * @param _operator defines the operator to use
  127713. * @param exposureAdjustment defines the required exposure adjustement
  127714. * @param camera defines the camera to use (can be null)
  127715. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127716. * @param engine defines the hosting engine (can be ignore if camera is set)
  127717. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127718. */
  127719. constructor(name: string, _operator: TonemappingOperator,
  127720. /** Defines the required exposure adjustement */
  127721. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127722. }
  127723. }
  127724. declare module BABYLON {
  127725. /** @hidden */
  127726. export var depthVertexShader: {
  127727. name: string;
  127728. shader: string;
  127729. };
  127730. }
  127731. declare module BABYLON {
  127732. /** @hidden */
  127733. export var volumetricLightScatteringPixelShader: {
  127734. name: string;
  127735. shader: string;
  127736. };
  127737. }
  127738. declare module BABYLON {
  127739. /** @hidden */
  127740. export var volumetricLightScatteringPassVertexShader: {
  127741. name: string;
  127742. shader: string;
  127743. };
  127744. }
  127745. declare module BABYLON {
  127746. /** @hidden */
  127747. export var volumetricLightScatteringPassPixelShader: {
  127748. name: string;
  127749. shader: string;
  127750. };
  127751. }
  127752. declare module BABYLON {
  127753. /**
  127754. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127755. */
  127756. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127757. private _volumetricLightScatteringPass;
  127758. private _volumetricLightScatteringRTT;
  127759. private _viewPort;
  127760. private _screenCoordinates;
  127761. private _cachedDefines;
  127762. /**
  127763. * If not undefined, the mesh position is computed from the attached node position
  127764. */
  127765. attachedNode: {
  127766. position: Vector3;
  127767. };
  127768. /**
  127769. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127770. */
  127771. customMeshPosition: Vector3;
  127772. /**
  127773. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127774. */
  127775. useCustomMeshPosition: boolean;
  127776. /**
  127777. * If the post-process should inverse the light scattering direction
  127778. */
  127779. invert: boolean;
  127780. /**
  127781. * The internal mesh used by the post-process
  127782. */
  127783. mesh: Mesh;
  127784. /**
  127785. * @hidden
  127786. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127787. */
  127788. useDiffuseColor: boolean;
  127789. /**
  127790. * Array containing the excluded meshes not rendered in the internal pass
  127791. */
  127792. excludedMeshes: AbstractMesh[];
  127793. /**
  127794. * Controls the overall intensity of the post-process
  127795. */
  127796. exposure: number;
  127797. /**
  127798. * Dissipates each sample's contribution in range [0, 1]
  127799. */
  127800. decay: number;
  127801. /**
  127802. * Controls the overall intensity of each sample
  127803. */
  127804. weight: number;
  127805. /**
  127806. * Controls the density of each sample
  127807. */
  127808. density: number;
  127809. /**
  127810. * @constructor
  127811. * @param name The post-process name
  127812. * @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)
  127813. * @param camera The camera that the post-process will be attached to
  127814. * @param mesh The mesh used to create the light scattering
  127815. * @param samples The post-process quality, default 100
  127816. * @param samplingModeThe post-process filtering mode
  127817. * @param engine The babylon engine
  127818. * @param reusable If the post-process is reusable
  127819. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127820. */
  127821. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  127822. /**
  127823. * Returns the string "VolumetricLightScatteringPostProcess"
  127824. * @returns "VolumetricLightScatteringPostProcess"
  127825. */
  127826. getClassName(): string;
  127827. private _isReady;
  127828. /**
  127829. * Sets the new light position for light scattering effect
  127830. * @param position The new custom light position
  127831. */
  127832. setCustomMeshPosition(position: Vector3): void;
  127833. /**
  127834. * Returns the light position for light scattering effect
  127835. * @return Vector3 The custom light position
  127836. */
  127837. getCustomMeshPosition(): Vector3;
  127838. /**
  127839. * Disposes the internal assets and detaches the post-process from the camera
  127840. */
  127841. dispose(camera: Camera): void;
  127842. /**
  127843. * Returns the render target texture used by the post-process
  127844. * @return the render target texture used by the post-process
  127845. */
  127846. getPass(): RenderTargetTexture;
  127847. private _meshExcluded;
  127848. private _createPass;
  127849. private _updateMeshScreenCoordinates;
  127850. /**
  127851. * Creates a default mesh for the Volumeric Light Scattering post-process
  127852. * @param name The mesh name
  127853. * @param scene The scene where to create the mesh
  127854. * @return the default mesh
  127855. */
  127856. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  127857. }
  127858. }
  127859. declare module BABYLON {
  127860. interface Scene {
  127861. /** @hidden (Backing field) */
  127862. _boundingBoxRenderer: BoundingBoxRenderer;
  127863. /** @hidden (Backing field) */
  127864. _forceShowBoundingBoxes: boolean;
  127865. /**
  127866. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  127867. */
  127868. forceShowBoundingBoxes: boolean;
  127869. /**
  127870. * Gets the bounding box renderer associated with the scene
  127871. * @returns a BoundingBoxRenderer
  127872. */
  127873. getBoundingBoxRenderer(): BoundingBoxRenderer;
  127874. }
  127875. interface AbstractMesh {
  127876. /** @hidden (Backing field) */
  127877. _showBoundingBox: boolean;
  127878. /**
  127879. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  127880. */
  127881. showBoundingBox: boolean;
  127882. }
  127883. /**
  127884. * Component responsible of rendering the bounding box of the meshes in a scene.
  127885. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  127886. */
  127887. export class BoundingBoxRenderer implements ISceneComponent {
  127888. /**
  127889. * The component name helpfull to identify the component in the list of scene components.
  127890. */
  127891. readonly name: string;
  127892. /**
  127893. * The scene the component belongs to.
  127894. */
  127895. scene: Scene;
  127896. /**
  127897. * Color of the bounding box lines placed in front of an object
  127898. */
  127899. frontColor: Color3;
  127900. /**
  127901. * Color of the bounding box lines placed behind an object
  127902. */
  127903. backColor: Color3;
  127904. /**
  127905. * Defines if the renderer should show the back lines or not
  127906. */
  127907. showBackLines: boolean;
  127908. /**
  127909. * @hidden
  127910. */
  127911. renderList: SmartArray<BoundingBox>;
  127912. private _colorShader;
  127913. private _vertexBuffers;
  127914. private _indexBuffer;
  127915. private _fillIndexBuffer;
  127916. private _fillIndexData;
  127917. /**
  127918. * Instantiates a new bounding box renderer in a scene.
  127919. * @param scene the scene the renderer renders in
  127920. */
  127921. constructor(scene: Scene);
  127922. /**
  127923. * Registers the component in a given scene
  127924. */
  127925. register(): void;
  127926. private _evaluateSubMesh;
  127927. private _activeMesh;
  127928. private _prepareRessources;
  127929. private _createIndexBuffer;
  127930. /**
  127931. * Rebuilds the elements related to this component in case of
  127932. * context lost for instance.
  127933. */
  127934. rebuild(): void;
  127935. /**
  127936. * @hidden
  127937. */
  127938. reset(): void;
  127939. /**
  127940. * Render the bounding boxes of a specific rendering group
  127941. * @param renderingGroupId defines the rendering group to render
  127942. */
  127943. render(renderingGroupId: number): void;
  127944. /**
  127945. * In case of occlusion queries, we can render the occlusion bounding box through this method
  127946. * @param mesh Define the mesh to render the occlusion bounding box for
  127947. */
  127948. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  127949. /**
  127950. * Dispose and release the resources attached to this renderer.
  127951. */
  127952. dispose(): void;
  127953. }
  127954. }
  127955. declare module BABYLON {
  127956. /** @hidden */
  127957. export var depthPixelShader: {
  127958. name: string;
  127959. shader: string;
  127960. };
  127961. }
  127962. declare module BABYLON {
  127963. /**
  127964. * This represents a depth renderer in Babylon.
  127965. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127966. */
  127967. export class DepthRenderer {
  127968. private _scene;
  127969. private _depthMap;
  127970. private _effect;
  127971. private readonly _storeNonLinearDepth;
  127972. private readonly _clearColor;
  127973. /** Get if the depth renderer is using packed depth or not */
  127974. readonly isPacked: boolean;
  127975. private _cachedDefines;
  127976. private _camera;
  127977. /**
  127978. * Specifiess that the depth renderer will only be used within
  127979. * the camera it is created for.
  127980. * This can help forcing its rendering during the camera processing.
  127981. */
  127982. useOnlyInActiveCamera: boolean;
  127983. /** @hidden */
  127984. static _SceneComponentInitialization: (scene: Scene) => void;
  127985. /**
  127986. * Instantiates a depth renderer
  127987. * @param scene The scene the renderer belongs to
  127988. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127989. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127990. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127991. */
  127992. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127993. /**
  127994. * Creates the depth rendering effect and checks if the effect is ready.
  127995. * @param subMesh The submesh to be used to render the depth map of
  127996. * @param useInstances If multiple world instances should be used
  127997. * @returns if the depth renderer is ready to render the depth map
  127998. */
  127999. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128000. /**
  128001. * Gets the texture which the depth map will be written to.
  128002. * @returns The depth map texture
  128003. */
  128004. getDepthMap(): RenderTargetTexture;
  128005. /**
  128006. * Disposes of the depth renderer.
  128007. */
  128008. dispose(): void;
  128009. }
  128010. }
  128011. declare module BABYLON {
  128012. interface Scene {
  128013. /** @hidden (Backing field) */
  128014. _depthRenderer: {
  128015. [id: string]: DepthRenderer;
  128016. };
  128017. /**
  128018. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128019. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128020. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128021. * @returns the created depth renderer
  128022. */
  128023. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128024. /**
  128025. * Disables a depth renderer for a given camera
  128026. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128027. */
  128028. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128029. }
  128030. /**
  128031. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128032. * in several rendering techniques.
  128033. */
  128034. export class DepthRendererSceneComponent implements ISceneComponent {
  128035. /**
  128036. * The component name helpfull to identify the component in the list of scene components.
  128037. */
  128038. readonly name: string;
  128039. /**
  128040. * The scene the component belongs to.
  128041. */
  128042. scene: Scene;
  128043. /**
  128044. * Creates a new instance of the component for the given scene
  128045. * @param scene Defines the scene to register the component in
  128046. */
  128047. constructor(scene: Scene);
  128048. /**
  128049. * Registers the component in a given scene
  128050. */
  128051. register(): void;
  128052. /**
  128053. * Rebuilds the elements related to this component in case of
  128054. * context lost for instance.
  128055. */
  128056. rebuild(): void;
  128057. /**
  128058. * Disposes the component and the associated ressources
  128059. */
  128060. dispose(): void;
  128061. private _gatherRenderTargets;
  128062. private _gatherActiveCameraRenderTargets;
  128063. }
  128064. }
  128065. declare module BABYLON {
  128066. /** @hidden */
  128067. export var outlinePixelShader: {
  128068. name: string;
  128069. shader: string;
  128070. };
  128071. }
  128072. declare module BABYLON {
  128073. /** @hidden */
  128074. export var outlineVertexShader: {
  128075. name: string;
  128076. shader: string;
  128077. };
  128078. }
  128079. declare module BABYLON {
  128080. interface Scene {
  128081. /** @hidden */
  128082. _outlineRenderer: OutlineRenderer;
  128083. /**
  128084. * Gets the outline renderer associated with the scene
  128085. * @returns a OutlineRenderer
  128086. */
  128087. getOutlineRenderer(): OutlineRenderer;
  128088. }
  128089. interface AbstractMesh {
  128090. /** @hidden (Backing field) */
  128091. _renderOutline: boolean;
  128092. /**
  128093. * Gets or sets a boolean indicating if the outline must be rendered as well
  128094. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128095. */
  128096. renderOutline: boolean;
  128097. /** @hidden (Backing field) */
  128098. _renderOverlay: boolean;
  128099. /**
  128100. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128101. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128102. */
  128103. renderOverlay: boolean;
  128104. }
  128105. /**
  128106. * This class is responsible to draw bothe outline/overlay of meshes.
  128107. * It should not be used directly but through the available method on mesh.
  128108. */
  128109. export class OutlineRenderer implements ISceneComponent {
  128110. /**
  128111. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128112. */
  128113. private static _StencilReference;
  128114. /**
  128115. * The name of the component. Each component must have a unique name.
  128116. */
  128117. name: string;
  128118. /**
  128119. * The scene the component belongs to.
  128120. */
  128121. scene: Scene;
  128122. /**
  128123. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128124. */
  128125. zOffset: number;
  128126. private _engine;
  128127. private _effect;
  128128. private _cachedDefines;
  128129. private _savedDepthWrite;
  128130. /**
  128131. * Instantiates a new outline renderer. (There could be only one per scene).
  128132. * @param scene Defines the scene it belongs to
  128133. */
  128134. constructor(scene: Scene);
  128135. /**
  128136. * Register the component to one instance of a scene.
  128137. */
  128138. register(): void;
  128139. /**
  128140. * Rebuilds the elements related to this component in case of
  128141. * context lost for instance.
  128142. */
  128143. rebuild(): void;
  128144. /**
  128145. * Disposes the component and the associated ressources.
  128146. */
  128147. dispose(): void;
  128148. /**
  128149. * Renders the outline in the canvas.
  128150. * @param subMesh Defines the sumesh to render
  128151. * @param batch Defines the batch of meshes in case of instances
  128152. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128153. */
  128154. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128155. /**
  128156. * Returns whether or not the outline renderer is ready for a given submesh.
  128157. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128158. * @param subMesh Defines the submesh to check readyness for
  128159. * @param useInstances Defines wheter wee are trying to render instances or not
  128160. * @returns true if ready otherwise false
  128161. */
  128162. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128163. private _beforeRenderingMesh;
  128164. private _afterRenderingMesh;
  128165. }
  128166. }
  128167. declare module BABYLON {
  128168. /**
  128169. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128170. * @see http://doc.babylonjs.com/babylon101/sprites
  128171. */
  128172. export class SpritePackedManager extends SpriteManager {
  128173. /** defines the packed manager's name */
  128174. name: string;
  128175. /**
  128176. * Creates a new sprite manager from a packed sprite sheet
  128177. * @param name defines the manager's name
  128178. * @param imgUrl defines the sprite sheet url
  128179. * @param capacity defines the maximum allowed number of sprites
  128180. * @param scene defines the hosting scene
  128181. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128182. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128183. * @param samplingMode defines the smapling mode to use with spritesheet
  128184. * @param fromPacked set to true; do not alter
  128185. */
  128186. constructor(
  128187. /** defines the packed manager's name */
  128188. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128189. }
  128190. }
  128191. declare module BABYLON {
  128192. /**
  128193. * Defines the list of states available for a task inside a AssetsManager
  128194. */
  128195. export enum AssetTaskState {
  128196. /**
  128197. * Initialization
  128198. */
  128199. INIT = 0,
  128200. /**
  128201. * Running
  128202. */
  128203. RUNNING = 1,
  128204. /**
  128205. * Done
  128206. */
  128207. DONE = 2,
  128208. /**
  128209. * Error
  128210. */
  128211. ERROR = 3
  128212. }
  128213. /**
  128214. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128215. */
  128216. export abstract class AbstractAssetTask {
  128217. /**
  128218. * Task name
  128219. */ name: string;
  128220. /**
  128221. * Callback called when the task is successful
  128222. */
  128223. onSuccess: (task: any) => void;
  128224. /**
  128225. * Callback called when the task is not successful
  128226. */
  128227. onError: (task: any, message?: string, exception?: any) => void;
  128228. /**
  128229. * Creates a new AssetsManager
  128230. * @param name defines the name of the task
  128231. */
  128232. constructor(
  128233. /**
  128234. * Task name
  128235. */ name: string);
  128236. private _isCompleted;
  128237. private _taskState;
  128238. private _errorObject;
  128239. /**
  128240. * Get if the task is completed
  128241. */
  128242. readonly isCompleted: boolean;
  128243. /**
  128244. * Gets the current state of the task
  128245. */
  128246. readonly taskState: AssetTaskState;
  128247. /**
  128248. * Gets the current error object (if task is in error)
  128249. */
  128250. readonly errorObject: {
  128251. message?: string;
  128252. exception?: any;
  128253. };
  128254. /**
  128255. * Internal only
  128256. * @hidden
  128257. */
  128258. _setErrorObject(message?: string, exception?: any): void;
  128259. /**
  128260. * Execute the current task
  128261. * @param scene defines the scene where you want your assets to be loaded
  128262. * @param onSuccess is a callback called when the task is successfully executed
  128263. * @param onError is a callback called if an error occurs
  128264. */
  128265. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128266. /**
  128267. * Execute the current task
  128268. * @param scene defines the scene where you want your assets to be loaded
  128269. * @param onSuccess is a callback called when the task is successfully executed
  128270. * @param onError is a callback called if an error occurs
  128271. */
  128272. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128273. /**
  128274. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128275. * This can be used with failed tasks that have the reason for failure fixed.
  128276. */
  128277. reset(): void;
  128278. private onErrorCallback;
  128279. private onDoneCallback;
  128280. }
  128281. /**
  128282. * Define the interface used by progress events raised during assets loading
  128283. */
  128284. export interface IAssetsProgressEvent {
  128285. /**
  128286. * Defines the number of remaining tasks to process
  128287. */
  128288. remainingCount: number;
  128289. /**
  128290. * Defines the total number of tasks
  128291. */
  128292. totalCount: number;
  128293. /**
  128294. * Defines the task that was just processed
  128295. */
  128296. task: AbstractAssetTask;
  128297. }
  128298. /**
  128299. * Class used to share progress information about assets loading
  128300. */
  128301. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128302. /**
  128303. * Defines the number of remaining tasks to process
  128304. */
  128305. remainingCount: number;
  128306. /**
  128307. * Defines the total number of tasks
  128308. */
  128309. totalCount: number;
  128310. /**
  128311. * Defines the task that was just processed
  128312. */
  128313. task: AbstractAssetTask;
  128314. /**
  128315. * Creates a AssetsProgressEvent
  128316. * @param remainingCount defines the number of remaining tasks to process
  128317. * @param totalCount defines the total number of tasks
  128318. * @param task defines the task that was just processed
  128319. */
  128320. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128321. }
  128322. /**
  128323. * Define a task used by AssetsManager to load meshes
  128324. */
  128325. export class MeshAssetTask extends AbstractAssetTask {
  128326. /**
  128327. * Defines the name of the task
  128328. */
  128329. name: string;
  128330. /**
  128331. * Defines the list of mesh's names you want to load
  128332. */
  128333. meshesNames: any;
  128334. /**
  128335. * Defines the root url to use as a base to load your meshes and associated resources
  128336. */
  128337. rootUrl: string;
  128338. /**
  128339. * Defines the filename of the scene to load from
  128340. */
  128341. sceneFilename: string;
  128342. /**
  128343. * Gets the list of loaded meshes
  128344. */
  128345. loadedMeshes: Array<AbstractMesh>;
  128346. /**
  128347. * Gets the list of loaded particle systems
  128348. */
  128349. loadedParticleSystems: Array<IParticleSystem>;
  128350. /**
  128351. * Gets the list of loaded skeletons
  128352. */
  128353. loadedSkeletons: Array<Skeleton>;
  128354. /**
  128355. * Gets the list of loaded animation groups
  128356. */
  128357. loadedAnimationGroups: Array<AnimationGroup>;
  128358. /**
  128359. * Callback called when the task is successful
  128360. */
  128361. onSuccess: (task: MeshAssetTask) => void;
  128362. /**
  128363. * Callback called when the task is successful
  128364. */
  128365. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128366. /**
  128367. * Creates a new MeshAssetTask
  128368. * @param name defines the name of the task
  128369. * @param meshesNames defines the list of mesh's names you want to load
  128370. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128371. * @param sceneFilename defines the filename of the scene to load from
  128372. */
  128373. constructor(
  128374. /**
  128375. * Defines the name of the task
  128376. */
  128377. name: string,
  128378. /**
  128379. * Defines the list of mesh's names you want to load
  128380. */
  128381. meshesNames: any,
  128382. /**
  128383. * Defines the root url to use as a base to load your meshes and associated resources
  128384. */
  128385. rootUrl: string,
  128386. /**
  128387. * Defines the filename of the scene to load from
  128388. */
  128389. sceneFilename: string);
  128390. /**
  128391. * Execute the current task
  128392. * @param scene defines the scene where you want your assets to be loaded
  128393. * @param onSuccess is a callback called when the task is successfully executed
  128394. * @param onError is a callback called if an error occurs
  128395. */
  128396. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128397. }
  128398. /**
  128399. * Define a task used by AssetsManager to load text content
  128400. */
  128401. export class TextFileAssetTask extends AbstractAssetTask {
  128402. /**
  128403. * Defines the name of the task
  128404. */
  128405. name: string;
  128406. /**
  128407. * Defines the location of the file to load
  128408. */
  128409. url: string;
  128410. /**
  128411. * Gets the loaded text string
  128412. */
  128413. text: string;
  128414. /**
  128415. * Callback called when the task is successful
  128416. */
  128417. onSuccess: (task: TextFileAssetTask) => void;
  128418. /**
  128419. * Callback called when the task is successful
  128420. */
  128421. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128422. /**
  128423. * Creates a new TextFileAssetTask object
  128424. * @param name defines the name of the task
  128425. * @param url defines the location of the file to load
  128426. */
  128427. constructor(
  128428. /**
  128429. * Defines the name of the task
  128430. */
  128431. name: string,
  128432. /**
  128433. * Defines the location of the file to load
  128434. */
  128435. url: string);
  128436. /**
  128437. * Execute the current task
  128438. * @param scene defines the scene where you want your assets to be loaded
  128439. * @param onSuccess is a callback called when the task is successfully executed
  128440. * @param onError is a callback called if an error occurs
  128441. */
  128442. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128443. }
  128444. /**
  128445. * Define a task used by AssetsManager to load binary data
  128446. */
  128447. export class BinaryFileAssetTask extends AbstractAssetTask {
  128448. /**
  128449. * Defines the name of the task
  128450. */
  128451. name: string;
  128452. /**
  128453. * Defines the location of the file to load
  128454. */
  128455. url: string;
  128456. /**
  128457. * Gets the lodaded data (as an array buffer)
  128458. */
  128459. data: ArrayBuffer;
  128460. /**
  128461. * Callback called when the task is successful
  128462. */
  128463. onSuccess: (task: BinaryFileAssetTask) => void;
  128464. /**
  128465. * Callback called when the task is successful
  128466. */
  128467. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128468. /**
  128469. * Creates a new BinaryFileAssetTask object
  128470. * @param name defines the name of the new task
  128471. * @param url defines the location of the file to load
  128472. */
  128473. constructor(
  128474. /**
  128475. * Defines the name of the task
  128476. */
  128477. name: string,
  128478. /**
  128479. * Defines the location of the file to load
  128480. */
  128481. url: string);
  128482. /**
  128483. * Execute the current task
  128484. * @param scene defines the scene where you want your assets to be loaded
  128485. * @param onSuccess is a callback called when the task is successfully executed
  128486. * @param onError is a callback called if an error occurs
  128487. */
  128488. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128489. }
  128490. /**
  128491. * Define a task used by AssetsManager to load images
  128492. */
  128493. export class ImageAssetTask extends AbstractAssetTask {
  128494. /**
  128495. * Defines the name of the task
  128496. */
  128497. name: string;
  128498. /**
  128499. * Defines the location of the image to load
  128500. */
  128501. url: string;
  128502. /**
  128503. * Gets the loaded images
  128504. */
  128505. image: HTMLImageElement;
  128506. /**
  128507. * Callback called when the task is successful
  128508. */
  128509. onSuccess: (task: ImageAssetTask) => void;
  128510. /**
  128511. * Callback called when the task is successful
  128512. */
  128513. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128514. /**
  128515. * Creates a new ImageAssetTask
  128516. * @param name defines the name of the task
  128517. * @param url defines the location of the image to load
  128518. */
  128519. constructor(
  128520. /**
  128521. * Defines the name of the task
  128522. */
  128523. name: string,
  128524. /**
  128525. * Defines the location of the image to load
  128526. */
  128527. url: string);
  128528. /**
  128529. * Execute the current task
  128530. * @param scene defines the scene where you want your assets to be loaded
  128531. * @param onSuccess is a callback called when the task is successfully executed
  128532. * @param onError is a callback called if an error occurs
  128533. */
  128534. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128535. }
  128536. /**
  128537. * Defines the interface used by texture loading tasks
  128538. */
  128539. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128540. /**
  128541. * Gets the loaded texture
  128542. */
  128543. texture: TEX;
  128544. }
  128545. /**
  128546. * Define a task used by AssetsManager to load 2D textures
  128547. */
  128548. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128549. /**
  128550. * Defines the name of the task
  128551. */
  128552. name: string;
  128553. /**
  128554. * Defines the location of the file to load
  128555. */
  128556. url: string;
  128557. /**
  128558. * Defines if mipmap should not be generated (default is false)
  128559. */
  128560. noMipmap?: boolean | undefined;
  128561. /**
  128562. * Defines if texture must be inverted on Y axis (default is false)
  128563. */
  128564. invertY?: boolean | undefined;
  128565. /**
  128566. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128567. */
  128568. samplingMode: number;
  128569. /**
  128570. * Gets the loaded texture
  128571. */
  128572. texture: Texture;
  128573. /**
  128574. * Callback called when the task is successful
  128575. */
  128576. onSuccess: (task: TextureAssetTask) => void;
  128577. /**
  128578. * Callback called when the task is successful
  128579. */
  128580. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128581. /**
  128582. * Creates a new TextureAssetTask object
  128583. * @param name defines the name of the task
  128584. * @param url defines the location of the file to load
  128585. * @param noMipmap defines if mipmap should not be generated (default is false)
  128586. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128587. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128588. */
  128589. constructor(
  128590. /**
  128591. * Defines the name of the task
  128592. */
  128593. name: string,
  128594. /**
  128595. * Defines the location of the file to load
  128596. */
  128597. url: string,
  128598. /**
  128599. * Defines if mipmap should not be generated (default is false)
  128600. */
  128601. noMipmap?: boolean | undefined,
  128602. /**
  128603. * Defines if texture must be inverted on Y axis (default is false)
  128604. */
  128605. invertY?: boolean | undefined,
  128606. /**
  128607. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128608. */
  128609. samplingMode?: number);
  128610. /**
  128611. * Execute the current task
  128612. * @param scene defines the scene where you want your assets to be loaded
  128613. * @param onSuccess is a callback called when the task is successfully executed
  128614. * @param onError is a callback called if an error occurs
  128615. */
  128616. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128617. }
  128618. /**
  128619. * Define a task used by AssetsManager to load cube textures
  128620. */
  128621. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128622. /**
  128623. * Defines the name of the task
  128624. */
  128625. name: string;
  128626. /**
  128627. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128628. */
  128629. url: string;
  128630. /**
  128631. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128632. */
  128633. extensions?: string[] | undefined;
  128634. /**
  128635. * Defines if mipmaps should not be generated (default is false)
  128636. */
  128637. noMipmap?: boolean | undefined;
  128638. /**
  128639. * Defines the explicit list of files (undefined by default)
  128640. */
  128641. files?: string[] | undefined;
  128642. /**
  128643. * Gets the loaded texture
  128644. */
  128645. texture: CubeTexture;
  128646. /**
  128647. * Callback called when the task is successful
  128648. */
  128649. onSuccess: (task: CubeTextureAssetTask) => void;
  128650. /**
  128651. * Callback called when the task is successful
  128652. */
  128653. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128654. /**
  128655. * Creates a new CubeTextureAssetTask
  128656. * @param name defines the name of the task
  128657. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128658. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128659. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128660. * @param files defines the explicit list of files (undefined by default)
  128661. */
  128662. constructor(
  128663. /**
  128664. * Defines the name of the task
  128665. */
  128666. name: string,
  128667. /**
  128668. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128669. */
  128670. url: string,
  128671. /**
  128672. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128673. */
  128674. extensions?: string[] | undefined,
  128675. /**
  128676. * Defines if mipmaps should not be generated (default is false)
  128677. */
  128678. noMipmap?: boolean | undefined,
  128679. /**
  128680. * Defines the explicit list of files (undefined by default)
  128681. */
  128682. files?: string[] | undefined);
  128683. /**
  128684. * Execute the current task
  128685. * @param scene defines the scene where you want your assets to be loaded
  128686. * @param onSuccess is a callback called when the task is successfully executed
  128687. * @param onError is a callback called if an error occurs
  128688. */
  128689. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128690. }
  128691. /**
  128692. * Define a task used by AssetsManager to load HDR cube textures
  128693. */
  128694. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128695. /**
  128696. * Defines the name of the task
  128697. */
  128698. name: string;
  128699. /**
  128700. * Defines the location of the file to load
  128701. */
  128702. url: string;
  128703. /**
  128704. * Defines the desired size (the more it increases the longer the generation will be)
  128705. */
  128706. size: number;
  128707. /**
  128708. * Defines if mipmaps should not be generated (default is false)
  128709. */
  128710. noMipmap: boolean;
  128711. /**
  128712. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128713. */
  128714. generateHarmonics: boolean;
  128715. /**
  128716. * 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)
  128717. */
  128718. gammaSpace: boolean;
  128719. /**
  128720. * Internal Use Only
  128721. */
  128722. reserved: boolean;
  128723. /**
  128724. * Gets the loaded texture
  128725. */
  128726. texture: HDRCubeTexture;
  128727. /**
  128728. * Callback called when the task is successful
  128729. */
  128730. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128731. /**
  128732. * Callback called when the task is successful
  128733. */
  128734. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128735. /**
  128736. * Creates a new HDRCubeTextureAssetTask object
  128737. * @param name defines the name of the task
  128738. * @param url defines the location of the file to load
  128739. * @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.
  128740. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128741. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128742. * @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)
  128743. * @param reserved Internal use only
  128744. */
  128745. constructor(
  128746. /**
  128747. * Defines the name of the task
  128748. */
  128749. name: string,
  128750. /**
  128751. * Defines the location of the file to load
  128752. */
  128753. url: string,
  128754. /**
  128755. * Defines the desired size (the more it increases the longer the generation will be)
  128756. */
  128757. size: number,
  128758. /**
  128759. * Defines if mipmaps should not be generated (default is false)
  128760. */
  128761. noMipmap?: boolean,
  128762. /**
  128763. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128764. */
  128765. generateHarmonics?: boolean,
  128766. /**
  128767. * 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)
  128768. */
  128769. gammaSpace?: boolean,
  128770. /**
  128771. * Internal Use Only
  128772. */
  128773. reserved?: boolean);
  128774. /**
  128775. * Execute the current task
  128776. * @param scene defines the scene where you want your assets to be loaded
  128777. * @param onSuccess is a callback called when the task is successfully executed
  128778. * @param onError is a callback called if an error occurs
  128779. */
  128780. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128781. }
  128782. /**
  128783. * Define a task used by AssetsManager to load Equirectangular cube textures
  128784. */
  128785. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128786. /**
  128787. * Defines the name of the task
  128788. */
  128789. name: string;
  128790. /**
  128791. * Defines the location of the file to load
  128792. */
  128793. url: string;
  128794. /**
  128795. * Defines the desired size (the more it increases the longer the generation will be)
  128796. */
  128797. size: number;
  128798. /**
  128799. * Defines if mipmaps should not be generated (default is false)
  128800. */
  128801. noMipmap: boolean;
  128802. /**
  128803. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128804. * but the standard material would require them in Gamma space) (default is true)
  128805. */
  128806. gammaSpace: boolean;
  128807. /**
  128808. * Gets the loaded texture
  128809. */
  128810. texture: EquiRectangularCubeTexture;
  128811. /**
  128812. * Callback called when the task is successful
  128813. */
  128814. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  128815. /**
  128816. * Callback called when the task is successful
  128817. */
  128818. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  128819. /**
  128820. * Creates a new EquiRectangularCubeTextureAssetTask object
  128821. * @param name defines the name of the task
  128822. * @param url defines the location of the file to load
  128823. * @param size defines the desired size (the more it increases the longer the generation will be)
  128824. * If the size is omitted this implies you are using a preprocessed cubemap.
  128825. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128826. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  128827. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  128828. * (default is true)
  128829. */
  128830. constructor(
  128831. /**
  128832. * Defines the name of the task
  128833. */
  128834. name: string,
  128835. /**
  128836. * Defines the location of the file to load
  128837. */
  128838. url: string,
  128839. /**
  128840. * Defines the desired size (the more it increases the longer the generation will be)
  128841. */
  128842. size: number,
  128843. /**
  128844. * Defines if mipmaps should not be generated (default is false)
  128845. */
  128846. noMipmap?: boolean,
  128847. /**
  128848. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128849. * but the standard material would require them in Gamma space) (default is true)
  128850. */
  128851. gammaSpace?: boolean);
  128852. /**
  128853. * Execute the current task
  128854. * @param scene defines the scene where you want your assets to be loaded
  128855. * @param onSuccess is a callback called when the task is successfully executed
  128856. * @param onError is a callback called if an error occurs
  128857. */
  128858. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128859. }
  128860. /**
  128861. * This class can be used to easily import assets into a scene
  128862. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  128863. */
  128864. export class AssetsManager {
  128865. private _scene;
  128866. private _isLoading;
  128867. protected _tasks: AbstractAssetTask[];
  128868. protected _waitingTasksCount: number;
  128869. protected _totalTasksCount: number;
  128870. /**
  128871. * Callback called when all tasks are processed
  128872. */
  128873. onFinish: (tasks: AbstractAssetTask[]) => void;
  128874. /**
  128875. * Callback called when a task is successful
  128876. */
  128877. onTaskSuccess: (task: AbstractAssetTask) => void;
  128878. /**
  128879. * Callback called when a task had an error
  128880. */
  128881. onTaskError: (task: AbstractAssetTask) => void;
  128882. /**
  128883. * Callback called when a task is done (whatever the result is)
  128884. */
  128885. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  128886. /**
  128887. * Observable called when all tasks are processed
  128888. */
  128889. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  128890. /**
  128891. * Observable called when a task had an error
  128892. */
  128893. onTaskErrorObservable: Observable<AbstractAssetTask>;
  128894. /**
  128895. * Observable called when all tasks were executed
  128896. */
  128897. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  128898. /**
  128899. * Observable called when a task is done (whatever the result is)
  128900. */
  128901. onProgressObservable: Observable<IAssetsProgressEvent>;
  128902. /**
  128903. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  128904. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  128905. */
  128906. useDefaultLoadingScreen: boolean;
  128907. /**
  128908. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  128909. * when all assets have been downloaded.
  128910. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  128911. */
  128912. autoHideLoadingUI: boolean;
  128913. /**
  128914. * Creates a new AssetsManager
  128915. * @param scene defines the scene to work on
  128916. */
  128917. constructor(scene: Scene);
  128918. /**
  128919. * Add a MeshAssetTask to the list of active tasks
  128920. * @param taskName defines the name of the new task
  128921. * @param meshesNames defines the name of meshes to load
  128922. * @param rootUrl defines the root url to use to locate files
  128923. * @param sceneFilename defines the filename of the scene file
  128924. * @returns a new MeshAssetTask object
  128925. */
  128926. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  128927. /**
  128928. * Add a TextFileAssetTask to the list of active tasks
  128929. * @param taskName defines the name of the new task
  128930. * @param url defines the url of the file to load
  128931. * @returns a new TextFileAssetTask object
  128932. */
  128933. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  128934. /**
  128935. * Add a BinaryFileAssetTask to the list of active tasks
  128936. * @param taskName defines the name of the new task
  128937. * @param url defines the url of the file to load
  128938. * @returns a new BinaryFileAssetTask object
  128939. */
  128940. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  128941. /**
  128942. * Add a ImageAssetTask to the list of active tasks
  128943. * @param taskName defines the name of the new task
  128944. * @param url defines the url of the file to load
  128945. * @returns a new ImageAssetTask object
  128946. */
  128947. addImageTask(taskName: string, url: string): ImageAssetTask;
  128948. /**
  128949. * Add a TextureAssetTask to the list of active tasks
  128950. * @param taskName defines the name of the new task
  128951. * @param url defines the url of the file to load
  128952. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128953. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  128954. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  128955. * @returns a new TextureAssetTask object
  128956. */
  128957. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  128958. /**
  128959. * Add a CubeTextureAssetTask to the list of active tasks
  128960. * @param taskName defines the name of the new task
  128961. * @param url defines the url of the file to load
  128962. * @param extensions defines the extension to use to load the cube map (can be null)
  128963. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128964. * @param files defines the list of files to load (can be null)
  128965. * @returns a new CubeTextureAssetTask object
  128966. */
  128967. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  128968. /**
  128969. *
  128970. * Add a HDRCubeTextureAssetTask to the list of active tasks
  128971. * @param taskName defines the name of the new task
  128972. * @param url defines the url of the file to load
  128973. * @param size defines the size you want for the cubemap (can be null)
  128974. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128975. * @param generateHarmonics defines if you want to automatically generate (true by default)
  128976. * @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)
  128977. * @param reserved Internal use only
  128978. * @returns a new HDRCubeTextureAssetTask object
  128979. */
  128980. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  128981. /**
  128982. *
  128983. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  128984. * @param taskName defines the name of the new task
  128985. * @param url defines the url of the file to load
  128986. * @param size defines the size you want for the cubemap (can be null)
  128987. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  128988. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  128989. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  128990. * @returns a new EquiRectangularCubeTextureAssetTask object
  128991. */
  128992. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  128993. /**
  128994. * Remove a task from the assets manager.
  128995. * @param task the task to remove
  128996. */
  128997. removeTask(task: AbstractAssetTask): void;
  128998. private _decreaseWaitingTasksCount;
  128999. private _runTask;
  129000. /**
  129001. * Reset the AssetsManager and remove all tasks
  129002. * @return the current instance of the AssetsManager
  129003. */
  129004. reset(): AssetsManager;
  129005. /**
  129006. * Start the loading process
  129007. * @return the current instance of the AssetsManager
  129008. */
  129009. load(): AssetsManager;
  129010. /**
  129011. * Start the loading process as an async operation
  129012. * @return a promise returning the list of failed tasks
  129013. */
  129014. loadAsync(): Promise<void>;
  129015. }
  129016. }
  129017. declare module BABYLON {
  129018. /**
  129019. * Wrapper class for promise with external resolve and reject.
  129020. */
  129021. export class Deferred<T> {
  129022. /**
  129023. * The promise associated with this deferred object.
  129024. */
  129025. readonly promise: Promise<T>;
  129026. private _resolve;
  129027. private _reject;
  129028. /**
  129029. * The resolve method of the promise associated with this deferred object.
  129030. */
  129031. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129032. /**
  129033. * The reject method of the promise associated with this deferred object.
  129034. */
  129035. readonly reject: (reason?: any) => void;
  129036. /**
  129037. * Constructor for this deferred object.
  129038. */
  129039. constructor();
  129040. }
  129041. }
  129042. declare module BABYLON {
  129043. /**
  129044. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129045. */
  129046. export class MeshExploder {
  129047. private _centerMesh;
  129048. private _meshes;
  129049. private _meshesOrigins;
  129050. private _toCenterVectors;
  129051. private _scaledDirection;
  129052. private _newPosition;
  129053. private _centerPosition;
  129054. /**
  129055. * Explodes meshes from a center mesh.
  129056. * @param meshes The meshes to explode.
  129057. * @param centerMesh The mesh to be center of explosion.
  129058. */
  129059. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129060. private _setCenterMesh;
  129061. /**
  129062. * Get class name
  129063. * @returns "MeshExploder"
  129064. */
  129065. getClassName(): string;
  129066. /**
  129067. * "Exploded meshes"
  129068. * @returns Array of meshes with the centerMesh at index 0.
  129069. */
  129070. getMeshes(): Array<Mesh>;
  129071. /**
  129072. * Explodes meshes giving a specific direction
  129073. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129074. */
  129075. explode(direction?: number): void;
  129076. }
  129077. }
  129078. declare module BABYLON {
  129079. /**
  129080. * Class used to help managing file picking and drag'n'drop
  129081. */
  129082. export class FilesInput {
  129083. /**
  129084. * List of files ready to be loaded
  129085. */
  129086. static readonly FilesToLoad: {
  129087. [key: string]: File;
  129088. };
  129089. /**
  129090. * Callback called when a file is processed
  129091. */
  129092. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129093. private _engine;
  129094. private _currentScene;
  129095. private _sceneLoadedCallback;
  129096. private _progressCallback;
  129097. private _additionalRenderLoopLogicCallback;
  129098. private _textureLoadingCallback;
  129099. private _startingProcessingFilesCallback;
  129100. private _onReloadCallback;
  129101. private _errorCallback;
  129102. private _elementToMonitor;
  129103. private _sceneFileToLoad;
  129104. private _filesToLoad;
  129105. /**
  129106. * Creates a new FilesInput
  129107. * @param engine defines the rendering engine
  129108. * @param scene defines the hosting scene
  129109. * @param sceneLoadedCallback callback called when scene is loaded
  129110. * @param progressCallback callback called to track progress
  129111. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129112. * @param textureLoadingCallback callback called when a texture is loading
  129113. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129114. * @param onReloadCallback callback called when a reload is requested
  129115. * @param errorCallback callback call if an error occurs
  129116. */
  129117. 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);
  129118. private _dragEnterHandler;
  129119. private _dragOverHandler;
  129120. private _dropHandler;
  129121. /**
  129122. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129123. * @param elementToMonitor defines the DOM element to track
  129124. */
  129125. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129126. /**
  129127. * Release all associated resources
  129128. */
  129129. dispose(): void;
  129130. private renderFunction;
  129131. private drag;
  129132. private drop;
  129133. private _traverseFolder;
  129134. private _processFiles;
  129135. /**
  129136. * Load files from a drop event
  129137. * @param event defines the drop event to use as source
  129138. */
  129139. loadFiles(event: any): void;
  129140. private _processReload;
  129141. /**
  129142. * Reload the current scene from the loaded files
  129143. */
  129144. reload(): void;
  129145. }
  129146. }
  129147. declare module BABYLON {
  129148. /**
  129149. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129150. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129151. */
  129152. export class SceneOptimization {
  129153. /**
  129154. * Defines the priority of this optimization (0 by default which means first in the list)
  129155. */
  129156. priority: number;
  129157. /**
  129158. * Gets a string describing the action executed by the current optimization
  129159. * @returns description string
  129160. */
  129161. getDescription(): string;
  129162. /**
  129163. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129164. * @param scene defines the current scene where to apply this optimization
  129165. * @param optimizer defines the current optimizer
  129166. * @returns true if everything that can be done was applied
  129167. */
  129168. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129169. /**
  129170. * Creates the SceneOptimization object
  129171. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129172. * @param desc defines the description associated with the optimization
  129173. */
  129174. constructor(
  129175. /**
  129176. * Defines the priority of this optimization (0 by default which means first in the list)
  129177. */
  129178. priority?: number);
  129179. }
  129180. /**
  129181. * Defines an optimization used to reduce the size of render target textures
  129182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129183. */
  129184. export class TextureOptimization extends SceneOptimization {
  129185. /**
  129186. * Defines the priority of this optimization (0 by default which means first in the list)
  129187. */
  129188. priority: number;
  129189. /**
  129190. * 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
  129191. */
  129192. maximumSize: number;
  129193. /**
  129194. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129195. */
  129196. step: number;
  129197. /**
  129198. * Gets a string describing the action executed by the current optimization
  129199. * @returns description string
  129200. */
  129201. getDescription(): string;
  129202. /**
  129203. * Creates the TextureOptimization object
  129204. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129205. * @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
  129206. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129207. */
  129208. constructor(
  129209. /**
  129210. * Defines the priority of this optimization (0 by default which means first in the list)
  129211. */
  129212. priority?: number,
  129213. /**
  129214. * 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
  129215. */
  129216. maximumSize?: number,
  129217. /**
  129218. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129219. */
  129220. step?: number);
  129221. /**
  129222. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129223. * @param scene defines the current scene where to apply this optimization
  129224. * @param optimizer defines the current optimizer
  129225. * @returns true if everything that can be done was applied
  129226. */
  129227. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129228. }
  129229. /**
  129230. * Defines an optimization used to increase or decrease the rendering resolution
  129231. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129232. */
  129233. export class HardwareScalingOptimization extends SceneOptimization {
  129234. /**
  129235. * Defines the priority of this optimization (0 by default which means first in the list)
  129236. */
  129237. priority: number;
  129238. /**
  129239. * Defines the maximum scale to use (2 by default)
  129240. */
  129241. maximumScale: number;
  129242. /**
  129243. * Defines the step to use between two passes (0.5 by default)
  129244. */
  129245. step: number;
  129246. private _currentScale;
  129247. private _directionOffset;
  129248. /**
  129249. * Gets a string describing the action executed by the current optimization
  129250. * @return description string
  129251. */
  129252. getDescription(): string;
  129253. /**
  129254. * Creates the HardwareScalingOptimization object
  129255. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129256. * @param maximumScale defines the maximum scale to use (2 by default)
  129257. * @param step defines the step to use between two passes (0.5 by default)
  129258. */
  129259. constructor(
  129260. /**
  129261. * Defines the priority of this optimization (0 by default which means first in the list)
  129262. */
  129263. priority?: number,
  129264. /**
  129265. * Defines the maximum scale to use (2 by default)
  129266. */
  129267. maximumScale?: number,
  129268. /**
  129269. * Defines the step to use between two passes (0.5 by default)
  129270. */
  129271. step?: number);
  129272. /**
  129273. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129274. * @param scene defines the current scene where to apply this optimization
  129275. * @param optimizer defines the current optimizer
  129276. * @returns true if everything that can be done was applied
  129277. */
  129278. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129279. }
  129280. /**
  129281. * Defines an optimization used to remove shadows
  129282. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129283. */
  129284. export class ShadowsOptimization extends SceneOptimization {
  129285. /**
  129286. * Gets a string describing the action executed by the current optimization
  129287. * @return description string
  129288. */
  129289. getDescription(): string;
  129290. /**
  129291. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129292. * @param scene defines the current scene where to apply this optimization
  129293. * @param optimizer defines the current optimizer
  129294. * @returns true if everything that can be done was applied
  129295. */
  129296. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129297. }
  129298. /**
  129299. * Defines an optimization used to turn post-processes off
  129300. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129301. */
  129302. export class PostProcessesOptimization extends SceneOptimization {
  129303. /**
  129304. * Gets a string describing the action executed by the current optimization
  129305. * @return description string
  129306. */
  129307. getDescription(): string;
  129308. /**
  129309. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129310. * @param scene defines the current scene where to apply this optimization
  129311. * @param optimizer defines the current optimizer
  129312. * @returns true if everything that can be done was applied
  129313. */
  129314. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129315. }
  129316. /**
  129317. * Defines an optimization used to turn lens flares off
  129318. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129319. */
  129320. export class LensFlaresOptimization extends SceneOptimization {
  129321. /**
  129322. * Gets a string describing the action executed by the current optimization
  129323. * @return description string
  129324. */
  129325. getDescription(): string;
  129326. /**
  129327. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129328. * @param scene defines the current scene where to apply this optimization
  129329. * @param optimizer defines the current optimizer
  129330. * @returns true if everything that can be done was applied
  129331. */
  129332. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129333. }
  129334. /**
  129335. * Defines an optimization based on user defined callback.
  129336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129337. */
  129338. export class CustomOptimization extends SceneOptimization {
  129339. /**
  129340. * Callback called to apply the custom optimization.
  129341. */
  129342. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129343. /**
  129344. * Callback called to get custom description
  129345. */
  129346. onGetDescription: () => string;
  129347. /**
  129348. * Gets a string describing the action executed by the current optimization
  129349. * @returns description string
  129350. */
  129351. getDescription(): string;
  129352. /**
  129353. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129354. * @param scene defines the current scene where to apply this optimization
  129355. * @param optimizer defines the current optimizer
  129356. * @returns true if everything that can be done was applied
  129357. */
  129358. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129359. }
  129360. /**
  129361. * Defines an optimization used to turn particles off
  129362. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129363. */
  129364. export class ParticlesOptimization extends SceneOptimization {
  129365. /**
  129366. * Gets a string describing the action executed by the current optimization
  129367. * @return description string
  129368. */
  129369. getDescription(): string;
  129370. /**
  129371. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129372. * @param scene defines the current scene where to apply this optimization
  129373. * @param optimizer defines the current optimizer
  129374. * @returns true if everything that can be done was applied
  129375. */
  129376. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129377. }
  129378. /**
  129379. * Defines an optimization used to turn render targets off
  129380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129381. */
  129382. export class RenderTargetsOptimization extends SceneOptimization {
  129383. /**
  129384. * Gets a string describing the action executed by the current optimization
  129385. * @return description string
  129386. */
  129387. getDescription(): string;
  129388. /**
  129389. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129390. * @param scene defines the current scene where to apply this optimization
  129391. * @param optimizer defines the current optimizer
  129392. * @returns true if everything that can be done was applied
  129393. */
  129394. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129395. }
  129396. /**
  129397. * Defines an optimization used to merge meshes with compatible materials
  129398. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129399. */
  129400. export class MergeMeshesOptimization extends SceneOptimization {
  129401. private static _UpdateSelectionTree;
  129402. /**
  129403. * Gets or sets a boolean which defines if optimization octree has to be updated
  129404. */
  129405. /**
  129406. * Gets or sets a boolean which defines if optimization octree has to be updated
  129407. */
  129408. static UpdateSelectionTree: boolean;
  129409. /**
  129410. * Gets a string describing the action executed by the current optimization
  129411. * @return description string
  129412. */
  129413. getDescription(): string;
  129414. private _canBeMerged;
  129415. /**
  129416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129417. * @param scene defines the current scene where to apply this optimization
  129418. * @param optimizer defines the current optimizer
  129419. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129420. * @returns true if everything that can be done was applied
  129421. */
  129422. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129423. }
  129424. /**
  129425. * Defines a list of options used by SceneOptimizer
  129426. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129427. */
  129428. export class SceneOptimizerOptions {
  129429. /**
  129430. * Defines the target frame rate to reach (60 by default)
  129431. */
  129432. targetFrameRate: number;
  129433. /**
  129434. * Defines the interval between two checkes (2000ms by default)
  129435. */
  129436. trackerDuration: number;
  129437. /**
  129438. * Gets the list of optimizations to apply
  129439. */
  129440. optimizations: SceneOptimization[];
  129441. /**
  129442. * Creates a new list of options used by SceneOptimizer
  129443. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129444. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129445. */
  129446. constructor(
  129447. /**
  129448. * Defines the target frame rate to reach (60 by default)
  129449. */
  129450. targetFrameRate?: number,
  129451. /**
  129452. * Defines the interval between two checkes (2000ms by default)
  129453. */
  129454. trackerDuration?: number);
  129455. /**
  129456. * Add a new optimization
  129457. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129458. * @returns the current SceneOptimizerOptions
  129459. */
  129460. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129461. /**
  129462. * Add a new custom optimization
  129463. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129464. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129465. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129466. * @returns the current SceneOptimizerOptions
  129467. */
  129468. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129469. /**
  129470. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129471. * @param targetFrameRate defines the target frame rate (60 by default)
  129472. * @returns a SceneOptimizerOptions object
  129473. */
  129474. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129475. /**
  129476. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129477. * @param targetFrameRate defines the target frame rate (60 by default)
  129478. * @returns a SceneOptimizerOptions object
  129479. */
  129480. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129481. /**
  129482. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129483. * @param targetFrameRate defines the target frame rate (60 by default)
  129484. * @returns a SceneOptimizerOptions object
  129485. */
  129486. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129487. }
  129488. /**
  129489. * Class used to run optimizations in order to reach a target frame rate
  129490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129491. */
  129492. export class SceneOptimizer implements IDisposable {
  129493. private _isRunning;
  129494. private _options;
  129495. private _scene;
  129496. private _currentPriorityLevel;
  129497. private _targetFrameRate;
  129498. private _trackerDuration;
  129499. private _currentFrameRate;
  129500. private _sceneDisposeObserver;
  129501. private _improvementMode;
  129502. /**
  129503. * Defines an observable called when the optimizer reaches the target frame rate
  129504. */
  129505. onSuccessObservable: Observable<SceneOptimizer>;
  129506. /**
  129507. * Defines an observable called when the optimizer enables an optimization
  129508. */
  129509. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129510. /**
  129511. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129512. */
  129513. onFailureObservable: Observable<SceneOptimizer>;
  129514. /**
  129515. * Gets a boolean indicating if the optimizer is in improvement mode
  129516. */
  129517. readonly isInImprovementMode: boolean;
  129518. /**
  129519. * Gets the current priority level (0 at start)
  129520. */
  129521. readonly currentPriorityLevel: number;
  129522. /**
  129523. * Gets the current frame rate checked by the SceneOptimizer
  129524. */
  129525. readonly currentFrameRate: number;
  129526. /**
  129527. * Gets or sets the current target frame rate (60 by default)
  129528. */
  129529. /**
  129530. * Gets or sets the current target frame rate (60 by default)
  129531. */
  129532. targetFrameRate: number;
  129533. /**
  129534. * Gets or sets the current interval between two checks (every 2000ms by default)
  129535. */
  129536. /**
  129537. * Gets or sets the current interval between two checks (every 2000ms by default)
  129538. */
  129539. trackerDuration: number;
  129540. /**
  129541. * Gets the list of active optimizations
  129542. */
  129543. readonly optimizations: SceneOptimization[];
  129544. /**
  129545. * Creates a new SceneOptimizer
  129546. * @param scene defines the scene to work on
  129547. * @param options defines the options to use with the SceneOptimizer
  129548. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129549. * @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)
  129550. */
  129551. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129552. /**
  129553. * Stops the current optimizer
  129554. */
  129555. stop(): void;
  129556. /**
  129557. * Reset the optimizer to initial step (current priority level = 0)
  129558. */
  129559. reset(): void;
  129560. /**
  129561. * Start the optimizer. By default it will try to reach a specific framerate
  129562. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129563. */
  129564. start(): void;
  129565. private _checkCurrentState;
  129566. /**
  129567. * Release all resources
  129568. */
  129569. dispose(): void;
  129570. /**
  129571. * Helper function to create a SceneOptimizer with one single line of code
  129572. * @param scene defines the scene to work on
  129573. * @param options defines the options to use with the SceneOptimizer
  129574. * @param onSuccess defines a callback to call on success
  129575. * @param onFailure defines a callback to call on failure
  129576. * @returns the new SceneOptimizer object
  129577. */
  129578. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129579. }
  129580. }
  129581. declare module BABYLON {
  129582. /**
  129583. * Class used to serialize a scene into a string
  129584. */
  129585. export class SceneSerializer {
  129586. /**
  129587. * Clear cache used by a previous serialization
  129588. */
  129589. static ClearCache(): void;
  129590. /**
  129591. * Serialize a scene into a JSON compatible object
  129592. * @param scene defines the scene to serialize
  129593. * @returns a JSON compatible object
  129594. */
  129595. static Serialize(scene: Scene): any;
  129596. /**
  129597. * Serialize a mesh into a JSON compatible object
  129598. * @param toSerialize defines the mesh to serialize
  129599. * @param withParents defines if parents must be serialized as well
  129600. * @param withChildren defines if children must be serialized as well
  129601. * @returns a JSON compatible object
  129602. */
  129603. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129604. }
  129605. }
  129606. declare module BABYLON {
  129607. /**
  129608. * Class used to host texture specific utilities
  129609. */
  129610. export class TextureTools {
  129611. /**
  129612. * Uses the GPU to create a copy texture rescaled at a given size
  129613. * @param texture Texture to copy from
  129614. * @param width defines the desired width
  129615. * @param height defines the desired height
  129616. * @param useBilinearMode defines if bilinear mode has to be used
  129617. * @return the generated texture
  129618. */
  129619. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129620. }
  129621. }
  129622. declare module BABYLON {
  129623. /**
  129624. * This represents the different options available for the video capture.
  129625. */
  129626. export interface VideoRecorderOptions {
  129627. /** Defines the mime type of the video. */
  129628. mimeType: string;
  129629. /** Defines the FPS the video should be recorded at. */
  129630. fps: number;
  129631. /** Defines the chunk size for the recording data. */
  129632. recordChunckSize: number;
  129633. /** The audio tracks to attach to the recording. */
  129634. audioTracks?: MediaStreamTrack[];
  129635. }
  129636. /**
  129637. * This can help with recording videos from BabylonJS.
  129638. * This is based on the available WebRTC functionalities of the browser.
  129639. *
  129640. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129641. */
  129642. export class VideoRecorder {
  129643. private static readonly _defaultOptions;
  129644. /**
  129645. * Returns whether or not the VideoRecorder is available in your browser.
  129646. * @param engine Defines the Babylon Engine.
  129647. * @returns true if supported otherwise false.
  129648. */
  129649. static IsSupported(engine: Engine): boolean;
  129650. private readonly _options;
  129651. private _canvas;
  129652. private _mediaRecorder;
  129653. private _recordedChunks;
  129654. private _fileName;
  129655. private _resolve;
  129656. private _reject;
  129657. /**
  129658. * True when a recording is already in progress.
  129659. */
  129660. readonly isRecording: boolean;
  129661. /**
  129662. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129663. * @param engine Defines the BabylonJS Engine you wish to record.
  129664. * @param options Defines options that can be used to customize the capture.
  129665. */
  129666. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129667. /**
  129668. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129669. */
  129670. stopRecording(): void;
  129671. /**
  129672. * Starts recording the canvas for a max duration specified in parameters.
  129673. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129674. * If null no automatic download will start and you can rely on the promise to get the data back.
  129675. * @param maxDuration Defines the maximum recording time in seconds.
  129676. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129677. * @return A promise callback at the end of the recording with the video data in Blob.
  129678. */
  129679. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129680. /**
  129681. * Releases internal resources used during the recording.
  129682. */
  129683. dispose(): void;
  129684. private _handleDataAvailable;
  129685. private _handleError;
  129686. private _handleStop;
  129687. }
  129688. }
  129689. declare module BABYLON {
  129690. /**
  129691. * Class containing a set of static utilities functions for screenshots
  129692. */
  129693. export class ScreenshotTools {
  129694. /**
  129695. * Captures a screenshot of the current rendering
  129696. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129697. * @param engine defines the rendering engine
  129698. * @param camera defines the source camera
  129699. * @param size This parameter can be set to a single number or to an object with the
  129700. * following (optional) properties: precision, width, height. If a single number is passed,
  129701. * it will be used for both width and height. If an object is passed, the screenshot size
  129702. * will be derived from the parameters. The precision property is a multiplier allowing
  129703. * rendering at a higher or lower resolution
  129704. * @param successCallback defines the callback receives a single parameter which contains the
  129705. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129706. * src parameter of an <img> to display it
  129707. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129708. * Check your browser for supported MIME types
  129709. */
  129710. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129711. /**
  129712. * Captures a screenshot of the current rendering
  129713. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129714. * @param engine defines the rendering engine
  129715. * @param camera defines the source camera
  129716. * @param size This parameter can be set to a single number or to an object with the
  129717. * following (optional) properties: precision, width, height. If a single number is passed,
  129718. * it will be used for both width and height. If an object is passed, the screenshot size
  129719. * will be derived from the parameters. The precision property is a multiplier allowing
  129720. * rendering at a higher or lower resolution
  129721. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129722. * Check your browser for supported MIME types
  129723. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129724. * to the src parameter of an <img> to display it
  129725. */
  129726. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129727. /**
  129728. * Generates an image screenshot from the specified camera.
  129729. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129730. * @param engine The engine to use for rendering
  129731. * @param camera The camera to use for rendering
  129732. * @param size This parameter can be set to a single number or to an object with the
  129733. * following (optional) properties: precision, width, height. If a single number is passed,
  129734. * it will be used for both width and height. If an object is passed, the screenshot size
  129735. * will be derived from the parameters. The precision property is a multiplier allowing
  129736. * rendering at a higher or lower resolution
  129737. * @param successCallback The callback receives a single parameter which contains the
  129738. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129739. * src parameter of an <img> to display it
  129740. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129741. * Check your browser for supported MIME types
  129742. * @param samples Texture samples (default: 1)
  129743. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129744. * @param fileName A name for for the downloaded file.
  129745. */
  129746. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129747. /**
  129748. * Generates an image screenshot from the specified camera.
  129749. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129750. * @param engine The engine to use for rendering
  129751. * @param camera The camera to use for rendering
  129752. * @param size This parameter can be set to a single number or to an object with the
  129753. * following (optional) properties: precision, width, height. If a single number is passed,
  129754. * it will be used for both width and height. If an object is passed, the screenshot size
  129755. * will be derived from the parameters. The precision property is a multiplier allowing
  129756. * rendering at a higher or lower resolution
  129757. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129758. * Check your browser for supported MIME types
  129759. * @param samples Texture samples (default: 1)
  129760. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129761. * @param fileName A name for for the downloaded file.
  129762. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129763. * to the src parameter of an <img> to display it
  129764. */
  129765. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129766. /**
  129767. * Gets height and width for screenshot size
  129768. * @private
  129769. */
  129770. private static _getScreenshotSize;
  129771. }
  129772. }
  129773. declare module BABYLON {
  129774. /**
  129775. * A cursor which tracks a point on a path
  129776. */
  129777. export class PathCursor {
  129778. private path;
  129779. /**
  129780. * Stores path cursor callbacks for when an onchange event is triggered
  129781. */
  129782. private _onchange;
  129783. /**
  129784. * The value of the path cursor
  129785. */
  129786. value: number;
  129787. /**
  129788. * The animation array of the path cursor
  129789. */
  129790. animations: Animation[];
  129791. /**
  129792. * Initializes the path cursor
  129793. * @param path The path to track
  129794. */
  129795. constructor(path: Path2);
  129796. /**
  129797. * Gets the cursor point on the path
  129798. * @returns A point on the path cursor at the cursor location
  129799. */
  129800. getPoint(): Vector3;
  129801. /**
  129802. * Moves the cursor ahead by the step amount
  129803. * @param step The amount to move the cursor forward
  129804. * @returns This path cursor
  129805. */
  129806. moveAhead(step?: number): PathCursor;
  129807. /**
  129808. * Moves the cursor behind by the step amount
  129809. * @param step The amount to move the cursor back
  129810. * @returns This path cursor
  129811. */
  129812. moveBack(step?: number): PathCursor;
  129813. /**
  129814. * Moves the cursor by the step amount
  129815. * If the step amount is greater than one, an exception is thrown
  129816. * @param step The amount to move the cursor
  129817. * @returns This path cursor
  129818. */
  129819. move(step: number): PathCursor;
  129820. /**
  129821. * Ensures that the value is limited between zero and one
  129822. * @returns This path cursor
  129823. */
  129824. private ensureLimits;
  129825. /**
  129826. * Runs onchange callbacks on change (used by the animation engine)
  129827. * @returns This path cursor
  129828. */
  129829. private raiseOnChange;
  129830. /**
  129831. * Executes a function on change
  129832. * @param f A path cursor onchange callback
  129833. * @returns This path cursor
  129834. */
  129835. onchange(f: (cursor: PathCursor) => void): PathCursor;
  129836. }
  129837. }
  129838. declare module BABYLON {
  129839. /** @hidden */
  129840. export var blurPixelShader: {
  129841. name: string;
  129842. shader: string;
  129843. };
  129844. }
  129845. declare module BABYLON {
  129846. /** @hidden */
  129847. export var pointCloudVertexDeclaration: {
  129848. name: string;
  129849. shader: string;
  129850. };
  129851. }
  129852. // Mixins
  129853. interface Window {
  129854. mozIndexedDB: IDBFactory;
  129855. webkitIndexedDB: IDBFactory;
  129856. msIndexedDB: IDBFactory;
  129857. webkitURL: typeof URL;
  129858. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  129859. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  129860. WebGLRenderingContext: WebGLRenderingContext;
  129861. MSGesture: MSGesture;
  129862. CANNON: any;
  129863. AudioContext: AudioContext;
  129864. webkitAudioContext: AudioContext;
  129865. PointerEvent: any;
  129866. Math: Math;
  129867. Uint8Array: Uint8ArrayConstructor;
  129868. Float32Array: Float32ArrayConstructor;
  129869. mozURL: typeof URL;
  129870. msURL: typeof URL;
  129871. VRFrameData: any; // WebVR, from specs 1.1
  129872. DracoDecoderModule: any;
  129873. setImmediate(handler: (...args: any[]) => void): number;
  129874. }
  129875. interface HTMLCanvasElement {
  129876. requestPointerLock(): void;
  129877. msRequestPointerLock?(): void;
  129878. mozRequestPointerLock?(): void;
  129879. webkitRequestPointerLock?(): void;
  129880. /** Track wether a record is in progress */
  129881. isRecording: boolean;
  129882. /** Capture Stream method defined by some browsers */
  129883. captureStream(fps?: number): MediaStream;
  129884. }
  129885. interface CanvasRenderingContext2D {
  129886. msImageSmoothingEnabled: boolean;
  129887. }
  129888. interface MouseEvent {
  129889. mozMovementX: number;
  129890. mozMovementY: number;
  129891. webkitMovementX: number;
  129892. webkitMovementY: number;
  129893. msMovementX: number;
  129894. msMovementY: number;
  129895. }
  129896. interface Navigator {
  129897. mozGetVRDevices: (any: any) => any;
  129898. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129899. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129900. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  129901. webkitGetGamepads(): Gamepad[];
  129902. msGetGamepads(): Gamepad[];
  129903. webkitGamepads(): Gamepad[];
  129904. }
  129905. interface HTMLVideoElement {
  129906. mozSrcObject: any;
  129907. }
  129908. interface Math {
  129909. fround(x: number): number;
  129910. imul(a: number, b: number): number;
  129911. }
  129912. interface WebGLRenderingContext {
  129913. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  129914. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  129915. vertexAttribDivisor(index: number, divisor: number): void;
  129916. createVertexArray(): any;
  129917. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  129918. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  129919. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  129920. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  129921. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  129922. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  129923. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  129924. // Queries
  129925. createQuery(): WebGLQuery;
  129926. deleteQuery(query: WebGLQuery): void;
  129927. beginQuery(target: number, query: WebGLQuery): void;
  129928. endQuery(target: number): void;
  129929. getQueryParameter(query: WebGLQuery, pname: number): any;
  129930. getQuery(target: number, pname: number): any;
  129931. MAX_SAMPLES: number;
  129932. RGBA8: number;
  129933. READ_FRAMEBUFFER: number;
  129934. DRAW_FRAMEBUFFER: number;
  129935. UNIFORM_BUFFER: number;
  129936. HALF_FLOAT_OES: number;
  129937. RGBA16F: number;
  129938. RGBA32F: number;
  129939. R32F: number;
  129940. RG32F: number;
  129941. RGB32F: number;
  129942. R16F: number;
  129943. RG16F: number;
  129944. RGB16F: number;
  129945. RED: number;
  129946. RG: number;
  129947. R8: number;
  129948. RG8: number;
  129949. UNSIGNED_INT_24_8: number;
  129950. DEPTH24_STENCIL8: number;
  129951. MIN: number;
  129952. MAX: number;
  129953. /* Multiple Render Targets */
  129954. drawBuffers(buffers: number[]): void;
  129955. readBuffer(src: number): void;
  129956. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  129957. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  129958. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  129959. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  129960. // Occlusion Query
  129961. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  129962. ANY_SAMPLES_PASSED: number;
  129963. QUERY_RESULT_AVAILABLE: number;
  129964. QUERY_RESULT: number;
  129965. }
  129966. interface WebGLProgram {
  129967. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  129968. }
  129969. interface EXT_disjoint_timer_query {
  129970. QUERY_COUNTER_BITS_EXT: number;
  129971. TIME_ELAPSED_EXT: number;
  129972. TIMESTAMP_EXT: number;
  129973. GPU_DISJOINT_EXT: number;
  129974. QUERY_RESULT_EXT: number;
  129975. QUERY_RESULT_AVAILABLE_EXT: number;
  129976. queryCounterEXT(query: WebGLQuery, target: number): void;
  129977. createQueryEXT(): WebGLQuery;
  129978. beginQueryEXT(target: number, query: WebGLQuery): void;
  129979. endQueryEXT(target: number): void;
  129980. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  129981. deleteQueryEXT(query: WebGLQuery): void;
  129982. }
  129983. interface WebGLUniformLocation {
  129984. _currentState: any;
  129985. }
  129986. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  129987. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  129988. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  129989. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  129990. interface WebGLRenderingContext {
  129991. readonly RASTERIZER_DISCARD: number;
  129992. readonly DEPTH_COMPONENT24: number;
  129993. readonly TEXTURE_3D: number;
  129994. readonly TEXTURE_2D_ARRAY: number;
  129995. readonly TEXTURE_COMPARE_FUNC: number;
  129996. readonly TEXTURE_COMPARE_MODE: number;
  129997. readonly COMPARE_REF_TO_TEXTURE: number;
  129998. readonly TEXTURE_WRAP_R: number;
  129999. readonly HALF_FLOAT: number;
  130000. readonly RGB8: number;
  130001. readonly RED_INTEGER: number;
  130002. readonly RG_INTEGER: number;
  130003. readonly RGB_INTEGER: number;
  130004. readonly RGBA_INTEGER: number;
  130005. readonly R8_SNORM: number;
  130006. readonly RG8_SNORM: number;
  130007. readonly RGB8_SNORM: number;
  130008. readonly RGBA8_SNORM: number;
  130009. readonly R8I: number;
  130010. readonly RG8I: number;
  130011. readonly RGB8I: number;
  130012. readonly RGBA8I: number;
  130013. readonly R8UI: number;
  130014. readonly RG8UI: number;
  130015. readonly RGB8UI: number;
  130016. readonly RGBA8UI: number;
  130017. readonly R16I: number;
  130018. readonly RG16I: number;
  130019. readonly RGB16I: number;
  130020. readonly RGBA16I: number;
  130021. readonly R16UI: number;
  130022. readonly RG16UI: number;
  130023. readonly RGB16UI: number;
  130024. readonly RGBA16UI: number;
  130025. readonly R32I: number;
  130026. readonly RG32I: number;
  130027. readonly RGB32I: number;
  130028. readonly RGBA32I: number;
  130029. readonly R32UI: number;
  130030. readonly RG32UI: number;
  130031. readonly RGB32UI: number;
  130032. readonly RGBA32UI: number;
  130033. readonly RGB10_A2UI: number;
  130034. readonly R11F_G11F_B10F: number;
  130035. readonly RGB9_E5: number;
  130036. readonly RGB10_A2: number;
  130037. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130038. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130039. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130040. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130041. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130042. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130043. 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;
  130044. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130045. readonly TRANSFORM_FEEDBACK: number;
  130046. readonly INTERLEAVED_ATTRIBS: number;
  130047. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130048. createTransformFeedback(): WebGLTransformFeedback;
  130049. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130050. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130051. beginTransformFeedback(primitiveMode: number): void;
  130052. endTransformFeedback(): void;
  130053. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130054. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130055. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130056. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130057. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130058. }
  130059. interface ImageBitmap {
  130060. readonly width: number;
  130061. readonly height: number;
  130062. close(): void;
  130063. }
  130064. interface WebGLQuery extends WebGLObject {
  130065. }
  130066. declare var WebGLQuery: {
  130067. prototype: WebGLQuery;
  130068. new(): WebGLQuery;
  130069. };
  130070. interface WebGLSampler extends WebGLObject {
  130071. }
  130072. declare var WebGLSampler: {
  130073. prototype: WebGLSampler;
  130074. new(): WebGLSampler;
  130075. };
  130076. interface WebGLSync extends WebGLObject {
  130077. }
  130078. declare var WebGLSync: {
  130079. prototype: WebGLSync;
  130080. new(): WebGLSync;
  130081. };
  130082. interface WebGLTransformFeedback extends WebGLObject {
  130083. }
  130084. declare var WebGLTransformFeedback: {
  130085. prototype: WebGLTransformFeedback;
  130086. new(): WebGLTransformFeedback;
  130087. };
  130088. interface WebGLVertexArrayObject extends WebGLObject {
  130089. }
  130090. declare var WebGLVertexArrayObject: {
  130091. prototype: WebGLVertexArrayObject;
  130092. new(): WebGLVertexArrayObject;
  130093. };
  130094. // Type definitions for WebVR API
  130095. // Project: https://w3c.github.io/webvr/
  130096. // Definitions by: six a <https://github.com/lostfictions>
  130097. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130098. interface VRDisplay extends EventTarget {
  130099. /**
  130100. * Dictionary of capabilities describing the VRDisplay.
  130101. */
  130102. readonly capabilities: VRDisplayCapabilities;
  130103. /**
  130104. * z-depth defining the far plane of the eye view frustum
  130105. * enables mapping of values in the render target depth
  130106. * attachment to scene coordinates. Initially set to 10000.0.
  130107. */
  130108. depthFar: number;
  130109. /**
  130110. * z-depth defining the near plane of the eye view frustum
  130111. * enables mapping of values in the render target depth
  130112. * attachment to scene coordinates. Initially set to 0.01.
  130113. */
  130114. depthNear: number;
  130115. /**
  130116. * An identifier for this distinct VRDisplay. Used as an
  130117. * association point in the Gamepad API.
  130118. */
  130119. readonly displayId: number;
  130120. /**
  130121. * A display name, a user-readable name identifying it.
  130122. */
  130123. readonly displayName: string;
  130124. readonly isConnected: boolean;
  130125. readonly isPresenting: boolean;
  130126. /**
  130127. * If this VRDisplay supports room-scale experiences, the optional
  130128. * stage attribute contains details on the room-scale parameters.
  130129. */
  130130. readonly stageParameters: VRStageParameters | null;
  130131. /**
  130132. * Passing the value returned by `requestAnimationFrame` to
  130133. * `cancelAnimationFrame` will unregister the callback.
  130134. * @param handle Define the hanle of the request to cancel
  130135. */
  130136. cancelAnimationFrame(handle: number): void;
  130137. /**
  130138. * Stops presenting to the VRDisplay.
  130139. * @returns a promise to know when it stopped
  130140. */
  130141. exitPresent(): Promise<void>;
  130142. /**
  130143. * Return the current VREyeParameters for the given eye.
  130144. * @param whichEye Define the eye we want the parameter for
  130145. * @returns the eye parameters
  130146. */
  130147. getEyeParameters(whichEye: string): VREyeParameters;
  130148. /**
  130149. * Populates the passed VRFrameData with the information required to render
  130150. * the current frame.
  130151. * @param frameData Define the data structure to populate
  130152. * @returns true if ok otherwise false
  130153. */
  130154. getFrameData(frameData: VRFrameData): boolean;
  130155. /**
  130156. * Get the layers currently being presented.
  130157. * @returns the list of VR layers
  130158. */
  130159. getLayers(): VRLayer[];
  130160. /**
  130161. * Return a VRPose containing the future predicted pose of the VRDisplay
  130162. * when the current frame will be presented. The value returned will not
  130163. * change until JavaScript has returned control to the browser.
  130164. *
  130165. * The VRPose will contain the position, orientation, velocity,
  130166. * and acceleration of each of these properties.
  130167. * @returns the pose object
  130168. */
  130169. getPose(): VRPose;
  130170. /**
  130171. * Return the current instantaneous pose of the VRDisplay, with no
  130172. * prediction applied.
  130173. * @returns the current instantaneous pose
  130174. */
  130175. getImmediatePose(): VRPose;
  130176. /**
  130177. * The callback passed to `requestAnimationFrame` will be called
  130178. * any time a new frame should be rendered. When the VRDisplay is
  130179. * presenting the callback will be called at the native refresh
  130180. * rate of the HMD. When not presenting this function acts
  130181. * identically to how window.requestAnimationFrame acts. Content should
  130182. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130183. * asynchronously from other displays and at differing refresh rates.
  130184. * @param callback Define the eaction to run next frame
  130185. * @returns the request handle it
  130186. */
  130187. requestAnimationFrame(callback: FrameRequestCallback): number;
  130188. /**
  130189. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130190. * Repeat calls while already presenting will update the VRLayers being displayed.
  130191. * @param layers Define the list of layer to present
  130192. * @returns a promise to know when the request has been fulfilled
  130193. */
  130194. requestPresent(layers: VRLayer[]): Promise<void>;
  130195. /**
  130196. * Reset the pose for this display, treating its current position and
  130197. * orientation as the "origin/zero" values. VRPose.position,
  130198. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130199. * updated when calling resetPose(). This should be called in only
  130200. * sitting-space experiences.
  130201. */
  130202. resetPose(): void;
  130203. /**
  130204. * The VRLayer provided to the VRDisplay will be captured and presented
  130205. * in the HMD. Calling this function has the same effect on the source
  130206. * canvas as any other operation that uses its source image, and canvases
  130207. * created without preserveDrawingBuffer set to true will be cleared.
  130208. * @param pose Define the pose to submit
  130209. */
  130210. submitFrame(pose?: VRPose): void;
  130211. }
  130212. declare var VRDisplay: {
  130213. prototype: VRDisplay;
  130214. new(): VRDisplay;
  130215. };
  130216. interface VRLayer {
  130217. leftBounds?: number[] | Float32Array | null;
  130218. rightBounds?: number[] | Float32Array | null;
  130219. source?: HTMLCanvasElement | null;
  130220. }
  130221. interface VRDisplayCapabilities {
  130222. readonly canPresent: boolean;
  130223. readonly hasExternalDisplay: boolean;
  130224. readonly hasOrientation: boolean;
  130225. readonly hasPosition: boolean;
  130226. readonly maxLayers: number;
  130227. }
  130228. interface VREyeParameters {
  130229. /** @deprecated */
  130230. readonly fieldOfView: VRFieldOfView;
  130231. readonly offset: Float32Array;
  130232. readonly renderHeight: number;
  130233. readonly renderWidth: number;
  130234. }
  130235. interface VRFieldOfView {
  130236. readonly downDegrees: number;
  130237. readonly leftDegrees: number;
  130238. readonly rightDegrees: number;
  130239. readonly upDegrees: number;
  130240. }
  130241. interface VRFrameData {
  130242. readonly leftProjectionMatrix: Float32Array;
  130243. readonly leftViewMatrix: Float32Array;
  130244. readonly pose: VRPose;
  130245. readonly rightProjectionMatrix: Float32Array;
  130246. readonly rightViewMatrix: Float32Array;
  130247. readonly timestamp: number;
  130248. }
  130249. interface VRPose {
  130250. readonly angularAcceleration: Float32Array | null;
  130251. readonly angularVelocity: Float32Array | null;
  130252. readonly linearAcceleration: Float32Array | null;
  130253. readonly linearVelocity: Float32Array | null;
  130254. readonly orientation: Float32Array | null;
  130255. readonly position: Float32Array | null;
  130256. readonly timestamp: number;
  130257. }
  130258. interface VRStageParameters {
  130259. sittingToStandingTransform?: Float32Array;
  130260. sizeX?: number;
  130261. sizeY?: number;
  130262. }
  130263. interface Navigator {
  130264. getVRDisplays(): Promise<VRDisplay[]>;
  130265. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130266. }
  130267. interface Window {
  130268. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130269. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130270. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130271. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130272. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130273. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130274. }
  130275. interface Gamepad {
  130276. readonly displayId: number;
  130277. }
  130278. type XRSessionMode =
  130279. | "inline"
  130280. | "immersive-vr"
  130281. | "immersive-ar";
  130282. type XRReferenceSpaceType =
  130283. | "viewer"
  130284. | "local"
  130285. | "local-floor"
  130286. | "bounded-floor"
  130287. | "unbounded";
  130288. type XREnvironmentBlendMode =
  130289. | "opaque"
  130290. | "additive"
  130291. | "alpha-blend";
  130292. type XRVisibilityState =
  130293. | "visible"
  130294. | "visible-blurred"
  130295. | "hidden";
  130296. type XRHandedness =
  130297. | "none"
  130298. | "left"
  130299. | "right";
  130300. type XRTargetRayMode =
  130301. | "gaze"
  130302. | "tracked-pointer"
  130303. | "screen";
  130304. type XREye =
  130305. | "none"
  130306. | "left"
  130307. | "right";
  130308. interface XRSpace extends EventTarget {
  130309. }
  130310. interface XRRenderState {
  130311. depthNear?: number;
  130312. depthFar?: number;
  130313. inlineVerticalFieldOfView?: number;
  130314. baseLayer?: XRWebGLLayer;
  130315. }
  130316. interface XRInputSource {
  130317. handedness: XRHandedness;
  130318. targetRayMode: XRTargetRayMode;
  130319. targetRaySpace: XRSpace;
  130320. gripSpace: XRSpace | undefined;
  130321. gamepad: Gamepad | undefined;
  130322. profiles: Array<string>;
  130323. }
  130324. interface XRSession {
  130325. addEventListener: Function;
  130326. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130327. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130328. requestAnimationFrame: Function;
  130329. end(): Promise<void>;
  130330. renderState: XRRenderState;
  130331. inputSources: Array<XRInputSource>;
  130332. }
  130333. interface XRReferenceSpace extends XRSpace {
  130334. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130335. onreset: any;
  130336. }
  130337. interface XRFrame {
  130338. session: XRSession;
  130339. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130340. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130341. }
  130342. interface XRViewerPose extends XRPose {
  130343. views: Array<XRView>;
  130344. }
  130345. interface XRPose {
  130346. transform: XRRigidTransform;
  130347. emulatedPosition: boolean;
  130348. }
  130349. declare var XRWebGLLayer: {
  130350. prototype: XRWebGLLayer;
  130351. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130352. };
  130353. interface XRWebGLLayer {
  130354. framebuffer: WebGLFramebuffer;
  130355. framebufferWidth: number;
  130356. framebufferHeight: number;
  130357. getViewport: Function;
  130358. }
  130359. interface XRRigidTransform {
  130360. position: DOMPointReadOnly;
  130361. orientation: DOMPointReadOnly;
  130362. matrix: Float32Array;
  130363. inverse: XRRigidTransform;
  130364. }
  130365. interface XRView {
  130366. eye: XREye;
  130367. projectionMatrix: Float32Array;
  130368. transform: XRRigidTransform;
  130369. }
  130370. interface XRInputSourceChangeEvent {
  130371. session: XRSession;
  130372. removed: Array<XRInputSource>;
  130373. added: Array<XRInputSource>;
  130374. }